void UpdatePortals() // Here we handle the beams' behavior
    {
        for (int j=0; j<3; ++j) // j = color
            if (Creature *portal = Unit::GetCreature(*me, PortalGUID[j]))
            {
                // the one who's been casted upon before
                Unit *current = Unit::GetUnit(*portal, BeamTarget[j]);
                // temporary store for the best suitable beam reciever
                Unit *pTarget = me;

                if (Map* map = me->GetMap())
                {
                    Map::PlayerList const& players = map->GetPlayers();

                    // get the best suitable target
                    for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
                    {
                        Player* p = i->getSource();
                        if (p && p->isAlive() // alive
                            && (!pTarget || pTarget->GetDistance2d(portal)>p->GetDistance2d(portal)) // closer than current best
                            && !p->HasAura(PlayerDebuff[j],0) // not exhausted
                            && !p->HasAura(PlayerBuff[(j+1)%3],0) // not on another beam
                            && !p->HasAura(PlayerBuff[(j+2)%3],0)
                            && IsBetween(me, p, portal)) // on the beam
                            pTarget = p;
                    }
                }
                // buff the target
                if (pTarget->GetTypeId() == TYPEID_PLAYER)
                    pTarget->AddAura(PlayerBuff[j], pTarget);
                else
                    pTarget->AddAura(NetherBuff[j], pTarget);
                // cast visual beam on the chosen target if switched
                // simple target switching isn't working -> using BeamerGUID to cast (workaround)
                if (!current || pTarget != current)
                {
                    BeamTarget[j] = pTarget->GetGUID();
                    // remove currently beaming portal
                    if (Creature *beamer = Unit::GetCreature(*portal, BeamerGUID[j]))
                    {
                        beamer->CastSpell(pTarget, PortalBeam[j], false);
                        beamer->SetVisibility(VISIBILITY_OFF);
                        beamer->DealDamage(beamer, beamer->GetMaxHealth());
                        beamer->RemoveFromWorld();
                        BeamerGUID[j] = 0;
                    }
                    // create new one and start beaming on the target
                    if (Creature *beamer = portal->SummonCreature(PortalID[j],portal->GetPositionX(),portal->GetPositionY(),portal->GetPositionZ(),portal->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,60000))
                    {
                        beamer->CastSpell(pTarget, PortalBeam[j], false);
                        BeamerGUID[j] = beamer->GetGUID();
                    }
                }
                // aggro target if Red Beam
                if (j == RED_PORTAL && me->getVictim() != pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
                    me->getThreatManager().addThreat(pTarget, 100000.0f+DoGetThreat(me->getVictim()));
            }
    }
Example #2
0
void BattlegroundDS::PostUpdateImpl(uint32 diff)
{
    if (getWaterFallTimer() < diff)
    {
        if (GetBgMap())
            if (isWaterFallActive())
            {
                setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, getWaterFallTimer());
                setWaterFallActive(false);
            }
            else
            {
                setWaterFallTimer(BG_DS_WATERFALL_DURATION);
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, RESPAWN_IMMEDIATELY);
                setWaterFallActive(true);
            }
    }
    else
        setWaterFallTimer(getWaterFallTimer() - diff);

        if (GetStatus() == STATUS_IN_PROGRESS)
        {
                if(m_knockback < diff && m_knockbackCheck)
                {
                        for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end();itr++)
                        {
                                Player * plr = ObjectAccessor::FindPlayer(itr->first);
                                if (plr->GetTeam() == ALLIANCE && plr->GetDistance2d(1214, 765) <= 50 && plr->GetPositionZ() > 10)
                                        KnockBackPlayer(plr, 6.15f, 50.00f, 7.00f);
                                if (plr->GetTeam() == HORDE && plr->GetDistance2d(1369, 817) <= 50 && plr->GetPositionZ() > 10)
                                        KnockBackPlayer(plr, 3.10f, 50.00f, 7.00f);
                                plr->RemoveAurasDueToSpell(48018);
                        }
                        m_knockbackCheck = false;
                 } else m_knockback -= diff;
        }
}
Example #3
0
        void JustDied(Unit* /*killer*/)
        {
            DoScriptText(SAY_DEATH, me);

            if (pInstance)
            {
                AchievementEntry const *achievIntenseCold = GetAchievementStore()->LookupEntry(ACHIEV_INTENSE_COLD);
                if (achievIntenseCold && IsHeroic())
                {
                    for (std::set<uint64>::const_iterator itr = lIntenseColdPlayers.begin(); itr != lIntenseColdPlayers.end(); ++itr)
                    {
                        Player* temp = Unit::GetPlayer(*me, *itr);
                        if (temp && temp->isAlive() && (temp->GetDistance2d(me) < 50))
                            temp->CompletedAchievement(achievIntenseCold);
                    }
                }

                pInstance->SetData(DATA_KERISTRASZA_EVENT, DONE);
            }
        }
Example #4
0
void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/)
{
    sLog->outDebug("WORLD: CMSG_LOOT_MONEY");

    Player* player = GetPlayer();
    uint64 guid = player->GetLootGUID();
    if (!guid)
        return;

    Loot *pLoot = NULL;

    switch (GUID_HIPART(guid))
    {
        case HIGHGUID_GAMEOBJECT:
        {
            GameObject *pGameObject = GetPlayer()->GetMap()->GetGameObject(guid);

            // not check distance for GO in case owned GO (fishing bobber case, for example)
            if (pGameObject && ((pGameObject->GetOwnerGUID() == _player->GetGUID() || pGameObject->IsWithinDistInMap(_player, INTERACTION_DISTANCE))))
                pLoot = &pGameObject->loot;

            break;
        }
        case HIGHGUID_CORPSE:                               // remove insignia ONLY in BG
        {
            Corpse *bones = ObjectAccessor::GetCorpse(*GetPlayer(), guid);

            if (bones && bones->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
                pLoot = &bones->loot;

            break;
        }
        case HIGHGUID_ITEM:
        {
            if (Item *item = GetPlayer()->GetItemByGuid(guid))
                pLoot = &item->loot;
            break;
        }
        case HIGHGUID_UNIT:
        {
            Creature* creature = GetPlayer()->GetMap()->GetCreature(guid);

            bool ok_loot = creature && creature->isAlive() == (player->getClass() == CLASS_ROGUE && creature->lootForPickPocketed);

            if (ok_loot && creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
                pLoot = &creature->loot ;

            break;
        }
        default:
            return;                                         // unlootable type
    }

    if (pLoot)
    {
        if (!IS_ITEM_GUID(guid) && player->GetGroup())      //item can be looted only single player
        {
            Group *group = player->GetGroup();

            std::vector<Player*> playersNear;
            for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
            {
                Player* playerGroup = itr->getSource();
                if (!playerGroup)
                    continue;
                if (player->GetDistance2d(playerGroup) < sWorld->getConfig(CONFIG_GROUP_XP_DISTANCE))
                    playersNear.push_back(playerGroup);
            }

            uint32 money_per_player = uint32((pLoot->gold)/(playersNear.size()));

            for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
            {
                (*i)->ModifyMoney(money_per_player);
                //Offset surely incorrect, but works
                WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4);
                data << uint32(money_per_player);
                (*i)->GetSession()->SendPacket(&data);
            }
        }
        else
            player->ModifyMoney(pLoot->gold);
        pLoot->gold = 0;
        pLoot->NotifyMoneyRemoved();
    }
}
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;


                events.Update(diff);

                if (me->HasAura(SPELL_MAGNETIC_FIELD))
                {
                    if (magnetic_timer <= diff)
                    {
                        //Grip the players
                        Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers();
                        if (!PlayerList.isEmpty())
                        {
                            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                            {
                                Player* plr = i->getSource();
                                if( !plr)
                                    continue;
                                if (plr->GetDistance2d(me) <= 5.f)
                                    plr->GetMotionMaster()->MoveJump(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 25.0f, 10.f);
                            }
                        }
                        magnetic_timer = 1000;
                    }
                    else
                        magnetic_timer -= diff;
                }

                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                    case EVENT_OUTRO_02:
                        if (me->GetInstanceScript())
                            me->GetInstanceScript()->SetData(TYPE_OUTRO_04, 0);
                        break;
                    case EVENT_OUTRO_01:
                        if (me->GetInstanceScript())
                            me->GetInstanceScript()->SetData(TYPE_OUTRO_02, 0);
                        break;
                    case EVENT_LIGHTNING_BOLT:
                        if (!me->HasAura(SPELL_MAGNETIC_FIELD))
                            me->CastSpell(me->getVictim(), SPELL_LIGHTNING_BOLT, false);
                        events.ScheduleEvent(EVENT_LIGHTNING_BOLT, 6000);
                        break;
                    case EVENT_WHIRLING_DERVISH:
                        if (!me->HasAura(SPELL_MAGNETIC_FIELD))
                            me->CastSpell(me, SPELL_WHIRLING_DERVISH, false);
                        events.ScheduleEvent(EVENT_WHIRLING_DERVISH, 10000);
                        break;
                    case EVENT_MAGNETIC_FIELD:
                        {
                            me->CastSpell(me, SPELL_MAGNETIC_FIELD, false);
                            events.ScheduleEvent(EVENT_MAGNETIC_FIELD, 30000);
                        }
                        break;
                    case EVENT_BOSS_RETIRE:
                        if (me->GetInstanceScript())
                            me->GetInstanceScript()->SetData(TYPE_KUAI_ATTACK, 0);
                        break;
                    }
                }

                DoMeleeAttackIfReady();
            }