コード例 #1
0
ファイル: gnomeregan.cpp プロジェクト: martial69320/cerberus
        void RestoreAll()
        {
            if (GameObject* go = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_GO_CAVE_IN_RIGHT)))
                instance->HandleGameObject(ObjectGuid::Empty, false, go);

            if (GameObject* go = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_GO_CAVE_IN_LEFT)))
                instance->HandleGameObject(ObjectGuid::Empty, false, go);

            if (!GoSummonList.empty())
                for (GuidList::const_iterator itr = GoSummonList.begin(); itr != GoSummonList.end(); ++itr)
                {
                    if (GameObject* go = ObjectAccessor::GetGameObject(*me, *itr))
                        go->RemoveFromWorld();
                }

            if (!SummonList.empty())
                for (GuidList::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
                {
                    if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
                    {
                        if (summon->IsAlive())
                            summon->DisappearAndDie();
                        else
                            summon->RemoveCorpse();
                    }
                }
        }
コード例 #2
0
    void InitSentinelsNear(Unit* pTarget)
    {
        if (!m_lAssistList.empty())
        {
            for (GuidList::const_iterator itr = m_lAssistList.begin(); itr != m_lAssistList.end(); ++itr)
            {
                if (*itr == m_creature->GetObjectGuid())
                    continue;

                if (Creature* pBuddy = m_creature->GetMap()->GetCreature(*itr))
                {
                    if (pBuddy->isAlive())
                        pBuddy->AI()->AttackStart(pTarget);
                }
            }

            return;
        }

        std::list<Creature*> lAssistList;
        GetCreatureListWithEntryInGrid(lAssistList, m_creature, m_creature->GetEntry(), 80.0f);

        for (std::list<Creature*>::iterator iter = lAssistList.begin(); iter != lAssistList.end(); ++iter)
        {
            m_lAssistList.push_back((*iter)->GetObjectGuid());

            if ((*iter)->GetObjectGuid() == m_creature->GetObjectGuid())
                continue;

            (*iter)->AI()->AttackStart(pTarget);
        }

        if (m_lAssistList.size() != MAX_BUDDY)
            script_error_log("npc_anubisath_sentinel for %s found too few/too many buddies, expected %u.", m_creature->GetGuidStr().c_str(), MAX_BUDDY);
    }
コード例 #3
0
ファイル: boss_gothik.cpp プロジェクト: Hammerdrinker/scripts
    void SummonAdds(bool /*bRightSide*/, uint32 uiSummonEntry)
    {
        GuidList* plSummonPosGuids;
        switch (uiSummonEntry)
        {
            case NPC_UNREL_TRAINEE:
                plSummonPosGuids = &m_lTraineeSummonPosGuids;
                break;
            case NPC_UNREL_DEATH_KNIGHT:
                plSummonPosGuids = &m_lDeathKnightSummonPosGuids;
                break;
            case NPC_UNREL_RIDER:
                plSummonPosGuids = &m_lRiderSummonPosGuids;
                break;
            default:
                return;
        }
        if (plSummonPosGuids->empty())
        {
            return;
        }

        for (GuidList::iterator itr = plSummonPosGuids->begin(); itr != plSummonPosGuids->end(); ++itr)
        {
            if (Creature* pPos = m_creature->GetMap()->GetCreature(*itr))
            {
                m_creature->SummonCreature(uiSummonEntry, pPos->GetPositionX(), pPos->GetPositionY(), pPos->GetPositionZ(), pPos->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0);
            }
        }
    }
コード例 #4
0
       void UpdateAI(uint32 uiDiff) override
        {
            ScriptedAI::UpdateAI(uiDiff);

            if (uiTimer <= uiDiff)
            {
                switch (uiPhase)
                {
                    case 1:
                        DoSummonGrandChampion(uiSecondBoss);
                        NextStep(10000, true);
                        break;
                    case 2:
                        DoSummonGrandChampion(uiThirdBoss);
                        NextStep(0, false);
                        break;
                    case 3:
                        if (!Champion1List.empty())
                        {
                            for (GuidList::const_iterator itr = Champion1List.begin(); itr != Champion1List.end(); ++itr)
                                if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
                                    AggroAllPlayers(summon);
                            NextStep(0, false);
                        }
                        break;
                }
            } else uiTimer -= uiDiff;

            if (!UpdateVictim())
                return;
        }
コード例 #5
0
    void SummonedCreatureJustDied(Creature* pSummoned) override
    {
        if (pSummoned->GetEntry() == NPC_GLOB_OF_VISCIDUS)
        {
            // shrink - modify scale
            m_creature->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X, float(-4), true);
            m_creature->UpdateModelData();
            m_creature->SetHealth(m_creature->GetHealth() - (m_creature->GetMaxHealth() * 0.05f));
            m_lGlobesGuidList.remove(pSummoned->GetObjectGuid());

            // suicide if required
            if (m_creature->GetHealthPercent() < 5.0f)
            {
                m_creature->SetVisibility(VISIBILITY_ON);

                if (DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SUICIDE, CAST_TRIGGERED) == CAST_OK)
                    m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false);
            }
            else if (m_lGlobesGuidList.empty())
            {
                m_creature->SetVisibility(VISIBILITY_ON);
                m_creature->SetStandState(UNIT_STAND_STATE_STAND);
                m_uiPhase = PHASE_NORMAL;

                SetCombatMovement(true);
                DoStartMovement(m_creature->getVictim());
            }
        }
    }
コード例 #6
0
    // Activate a random Constellation
    void ActivateRandomConstellation()
    {
        // spawn a new set of constellations if empty
        if (m_lConstellationsGuids.empty())
        {
            DoSpawnConstellations();
            m_uiConstellationTimer = 5000;
            return;
        }

        GuidList::iterator iter = m_lConstellationsGuids.begin();
        advance(iter, urand(0, m_lConstellationsGuids.size() - 1));

        if (Creature* pConstellation = m_creature->GetMap()->GetCreature(*iter))
        {
            // follow second top aggro player
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, uint32(0), SELECT_FLAG_PLAYER))
            {
                pConstellation->GetMotionMaster()->MoveFollow(pTarget, CONTACT_DISTANCE, 0);
                SendAIEvent(AI_EVENT_CUSTOM_A, m_creature, pConstellation);
                ++m_uiActiveConstelations;
            }
        }

        m_lConstellationsGuids.remove(*iter);
    }
コード例 #7
0
ファイル: boss_volkhan.cpp プロジェクト: AwkwardDev/mangos-d3
    void ShatterGolems()
    {
        if (m_lGolemGUIDList.empty())
            return;

        uint8 m_uiBrittleGolemsCount = 0;

        for (GuidList::const_iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
        {
            if (Creature* pTemp = m_creature->GetMap()->GetCreature(*itr))
            {
                // only shatter brittle golems
                if (pTemp->GetEntry() == NPC_BRITTLE_GOLEM)
                {
                    pTemp->CastSpell(pTemp, m_bIsRegularMode ? SPELL_SHATTER : SPELL_SHATTER_H, true);
                    ++m_uiBrittleGolemsCount;
                }
            }
        }

        // If shattered more than 4 golems mark achiev as failed
        if (m_uiBrittleGolemsCount > MAX_ACHIEV_GOLEMS)
        {
            if (m_pInstance)
                m_pInstance->SetData(TYPE_VOLKHAN, SPECIAL);
        }
    }
コード例 #8
0
   Unit* SelectTargetWithinDist()
   {
        ThreatList const& m_threatlist = m_creature->getThreatManager().getThreatList();

        if (m_threatlist.empty())
            return NULL;

        GuidList distPositive;
        for (ThreatList::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
        {
            if (Unit* pTemp = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid()))
            {
                //player within 80 yards
                if ((pTemp->GetTypeId() == TYPEID_PLAYER && !m_creature->IsWithinDist(pTemp, 10.0f) && m_creature->IsWithinDist(pTemp, 80.0f)))
                    distPositive.push_back(pTemp->GetObjectGuid());
            }
        }

        if (!distPositive.empty())
        {
            GuidList::iterator m_uiPlayerGUID = distPositive.begin();
            advance(m_uiPlayerGUID, (rand()%distPositive.size()));

            if (Player* pTemp = m_creature->GetMap()->GetPlayer(*m_uiPlayerGUID))
                return pTemp;
        }
        return NULL;
    }
コード例 #9
0
ファイル: LFGQueue.cpp プロジェクト: samaelsacred/4.3.4
/**
   Checks que main queue to try to form a Lfg group. Returns first match found (if any)

   @param[in]     check List of guids trying to match with other groups
   @param[in]     all List of all other guids in main queue to match against
   @return LfgCompatibility type of compatibility between groups
*/
LfgCompatibility LFGQueue::FindNewGroups(GuidList& check, GuidList& all)
{
    std::string strGuids = ConcatenateGuids(check);
    LfgCompatibility compatibles = GetCompatibles(strGuids);

    TC_LOG_DEBUG("lfg.queue.match.check", "Guids: (%s): %s - all(%s)", strGuids.c_str(), GetCompatibleString(compatibles), ConcatenateGuids(all).c_str());
    if (compatibles == LFG_COMPATIBILITY_PENDING) // Not previously cached, calculate
        compatibles = CheckCompatibility(check);

    if (compatibles == LFG_COMPATIBLES_BAD_STATES && sLFGMgr->AllQueued(check))
    {
        TC_LOG_DEBUG("lfg.queue.match.check", "Guids: (%s) compatibles (cached) changed from bad states to match", strGuids.c_str());
        SetCompatibles(strGuids, LFG_COMPATIBLES_MATCH);
        return LFG_COMPATIBLES_MATCH;
    }

    if (compatibles != LFG_COMPATIBLES_WITH_LESS_PLAYERS)
        return compatibles;

    // Try to match with queued groups
    while (!all.empty())
    {
        check.push_back(all.front());
        all.pop_front();
        LfgCompatibility subcompatibility = FindNewGroups(check, all);
        if (subcompatibility == LFG_COMPATIBLES_MATCH)
            return LFG_COMPATIBLES_MATCH;
        check.pop_back();
    }
    return compatibles;
}
コード例 #10
0
 void GetAIInformation(ChatHandler& reader) override
 {
     if (m_lAssistList.empty())
         reader.PSendSysMessage("Anubisath Sentinel - group not assigned, will be assigned OnAggro");
     if (m_lAssistList.size() == MAX_BUDDY)
         reader.PSendSysMessage("Anubisath Sentinel - proper group found");
     else
         reader.PSendSysMessage("Anubisath Sentinel - not correct number of mobs for group found. Number found %u, should be %u", uint32(m_lAssistList.size()), MAX_BUDDY);
 }
コード例 #11
0
ファイル: felwood.cpp プロジェクト: Maduse/server
 void SummonedCreatureJustDied(Creature* pSummoned) override
 {
     if (pSummoned->GetEntry() == NPC_IRONTREE_STOMPER || pSummoned->GetEntry() == NPC_IRONTREE_WANDERER)
     {
         m_lSummonsGuids.remove(pSummoned->GetObjectGuid());
         if (m_lSummonsGuids.empty())
             dialogueStep = 1;
     }
 }
コード例 #12
0
ファイル: boss_jedoga.cpp プロジェクト: jviljoen82/ScriptDev3
    ObjectGuid SelectRandomVolunteer()
    {
        if (m_lVolunteerGuidList.empty())
            return ObjectGuid();

        GuidList::iterator iter = m_lVolunteerGuidList.begin();
        advance(iter, urand(0, m_lVolunteerGuidList.size() - 1));

        return *iter;
    }
コード例 #13
0
ファイル: boss_thorim.cpp プロジェクト: jviljoen82/ScriptDev3
    // function to return a random arena upper Bunny
    Creature* SelectRandomUpperBunny()
    {
        if (m_lUpperBunniesGuids.empty())
            return NULL;

        GuidList::iterator iter = m_lUpperBunniesGuids.begin();
        advance(iter, urand(0, m_lUpperBunniesGuids.size() - 1));

        return m_creature->GetMap()->GetCreature(*iter);
    }
コード例 #14
0
ファイル: boss_thorim.cpp プロジェクト: jviljoen82/ScriptDev3
    // function to return a random arena bunny for Blizzard spell
    ObjectGuid SelectRandomBunnyGuid()
    {
        if (m_lBunniesGuids.empty())
            return ObjectGuid();

        GuidList::iterator iter = m_lBunniesGuids.begin();
        advance(iter, urand(0, m_lBunniesGuids.size() - 1));

        return *iter;
    }
コード例 #15
0
    ObjectGuid SelectRandomCrowdNpc()
    {
        if (m_lCrowdGuidList.empty())
            return ObjectGuid();

        GuidList::iterator iter = m_lCrowdGuidList.begin();
        advance(iter, urand(0, m_lCrowdGuidList.size() - 1));

        return *iter;
    }
コード例 #16
0
ファイル: felwood.cpp プロジェクト: 520lly/mangos-classic
    void SummonedCreatureJustDied(Creature* pSummoned) override
    {
        if (pSummoned->GetEntry() == NPC_IRONTREE_STOMPER || pSummoned->GetEntry() == NPC_IRONTREE_WANDERER)
        {
            m_lSummonsGuids.remove(pSummoned->GetObjectGuid());

            if (m_lSummonsGuids.empty())
                StartNextDialogueText(SAY_CLEAR_PATH);
        }
    }
コード例 #17
0
ファイル: boss_jeklik.cpp プロジェクト: MantisLord/mangos-tbc
    // Wrapper to despawn the bomb riders on evade / death
    void DoDespawnBombRiders()
    {
        if (m_lBombRiderGuidsList.empty())
            return;

        for (GuidList::const_iterator itr = m_lBombRiderGuidsList.begin(); itr != m_lBombRiderGuidsList.end(); ++itr)
        {
            if (Creature* pRider = m_creature->GetMap()->GetCreature(*itr))
                pRider->ForcedDespawn();
        }
    }
コード例 #18
0
ファイル: halls_of_stone.cpp プロジェクト: mynew/Core
 void DespawnDwarf()
 {
     if (lDwarfGUIDList.empty())
         return;
     for (GuidList::const_iterator itr = lDwarfGUIDList.begin(); itr != lDwarfGUIDList.end(); ++itr)
     {
         Creature* temp = ObjectAccessor::GetCreature(*me, instance ? (*itr) : ObjectGuid::Empty);
         if (temp && temp->IsAlive())
             temp->DespawnOrUnsummon();
     }
     lDwarfGUIDList.clear();
 }
コード例 #19
0
 void DespawnAdds(GuidList& List)
 {
     if (!List.empty())
     {
         for (GuidList::iterator itr = List.begin(); itr != List.end(); ++itr)
         {
             if (Creature* pSummon = m_creature->GetMap()->GetCreature(*itr))
                 pSummon->ForcedDespawn();
         }
         List.clear();
     }
 }
コード例 #20
0
ファイル: halls_of_stone.cpp プロジェクト: mynew/Core
 void UpdateAI(uint32 diff) override
 {
     if (bKaddrakActivated)
     {
         if (uiKaddrakEncounterTimer <= diff)
         {
             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 if (!KaddrakGUIDList.empty())
                     for (GuidList::const_iterator itr = KaddrakGUIDList.begin(); itr != KaddrakGUIDList.end(); ++itr)
                     {
                         if (Creature* pKaddrak = ObjectAccessor::GetCreature(*me, *itr))
                         {
                             if (pKaddrak->IsAlive())
                                 pKaddrak->CastSpell(target, SPELL_GLARE_OF_THE_TRIBUNAL, true);
                         }
                     }
             uiKaddrakEncounterTimer = 1500;
         } else uiKaddrakEncounterTimer -= diff;
     }
     if (bMarnakActivated)
     {
         if (uiMarnakEncounterTimer <= diff)
         {
             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
             {
                 if (Creature* summon = me->SummonCreature(NPC_DARK_MATTER_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 1000))
                 {
                     summon->SetDisplayId(11686);
                     summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                     summon->CastSpell(target, SPELL_DARK_MATTER, true);
                 }
             }
             uiMarnakEncounterTimer = urand(30000, 31000);
         } else uiMarnakEncounterTimer -= diff;
     }
     if (bAbedneumActivated)
     {
         if (uiAbedneumEncounterTimer <= diff)
         {
             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
             {
                 if (Creature* summon = me->SummonCreature(NPC_SEARING_GAZE_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 1000))
                 {
                     summon->SetDisplayId(11686);
                     summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                     summon->CastSpell(target, SPELL_SEARING_GAZE, true);
                 }
             }
             uiAbedneumEncounterTimer = urand(30000, 31000);
         } else uiAbedneumEncounterTimer -= diff;
     }
 }
コード例 #21
0
        bool OnCheck(Player* player, Unit* target) override
        {
            if (!target)
                return false;

            GuidList intenseColdList = ENSURE_AI(boss_keristrasza::boss_keristraszaAI, target->ToCreature()->AI())->intenseColdList;
            if (!intenseColdList.empty())
                for (GuidList::iterator itr = intenseColdList.begin(); itr != intenseColdList.end(); ++itr)
                    if (player->GetGUID() == *itr)
                        return false;

            return true;
        }
コード例 #22
0
 void SendAddsUpStairs(uint32 count)
 {
     //pop a add from list, send him up the stairs...
     for (uint32 addCount = 0; addCount<count && !addsAtBase.empty(); addCount++)
     {
         if (Creature* add = instance->GetCreature(*addsAtBase.begin()))
         {
             add->GetMotionMaster()->MovePath(PATH_ADDS, false);
             movedadds.push_back(add->GetGUID());
         }
         addsAtBase.erase(addsAtBase.begin());
     }
 }
コード例 #23
0
ファイル: boss_volkhan.cpp プロジェクト: AwkwardDev/mangos-d3
    void DespawnGolems()
    {
        if (m_lGolemGUIDList.empty())
            return;

        for (GuidList::const_iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
        {
            if (Creature* pTemp = m_creature->GetMap()->GetCreature(*itr))
            {
                if (pTemp->isAlive())
                    pTemp->ForcedDespawn();
            }
        }
    }
コード例 #24
0
        void DespawnGolem()
        {
            if (m_lGolemGUIDList.empty())
                return;

            for (ObjectGuid guid : m_lGolemGUIDList)
            {
                if (Creature* temp = ObjectAccessor::GetCreature(*me, guid))
                    if (temp->IsAlive())
                        temp->DespawnOrUnsummon();
            }

            m_lGolemGUIDList.clear();
        }
コード例 #25
0
ファイル: boss_thorim.cpp プロジェクト: jviljoen82/ScriptDev3
    // function to return the closest ground Bunny
    Creature* GetClosestLowerBunny(Creature* pSource)
    {
        if (m_lLowerBunniesGuids.empty())
            return NULL;

        std::list<Creature*> lBunnies;
        for (GuidList::const_iterator itr = m_lLowerBunniesGuids.begin(); itr != m_lLowerBunniesGuids.end(); ++itr)
        {
            if (Creature* pBunny = m_creature->GetMap()->GetCreature(*itr))
                lBunnies.push_back(pBunny);
        }

        lBunnies.sort(ObjectDistanceOrder(pSource));
        return lBunnies.front();
    }
コード例 #26
0
    void DoSetupAdds()
    {
        m_uiSetupAddsTimer = 0;

        if (!m_pInstance)
            return;

        GuidList lAddGuids;
        m_pInstance->GetKelidanAddList(lAddGuids);

        // Sort Adds to vector if not already done
        if (!lAddGuids.empty())
        {
            m_vAddGuids.reserve(lAddGuids.size());
            std::list<Creature*> lAdds;
            for (GuidList::const_iterator itr = lAddGuids.begin(); itr != lAddGuids.end(); ++itr)
            {
                if (Creature* pAdd = m_pInstance->instance->GetCreature(*itr))
                    lAdds.push_back(pAdd);
            }
            // Sort them by angle
            lAdds.sort(SortByAngle(m_creature));
            for (std::list<Creature*>::const_iterator itr = lAdds.begin(); itr != lAdds.end(); ++itr)
                m_vAddGuids.push_back((*itr)->GetObjectGuid());
        }

        // Respawn killed adds and reset counter
        m_uiKilledAdds = 0;
        for (GuidVector::const_iterator itr = m_vAddGuids.begin(); itr != m_vAddGuids.end(); ++itr)
        {
            Creature* pAdd = m_pInstance->instance->GetCreature(*itr);
            if (pAdd && !pAdd->isAlive())
                pAdd->Respawn();
        }

        // Cast pentagram
        uint8 s = m_vAddGuids.size();
        for (uint8 i = 0; i < s; ++i)
        {
            Creature* pCaster = m_pInstance->instance->GetCreature(m_vAddGuids[i]);
            Creature* pTarget = m_pInstance->instance->GetCreature(m_vAddGuids[(i + 2) % s]);
            if (pCaster && pTarget)
                pCaster->CastSpell(pTarget, SPELL_CHANNELING, TRIGGERED_NONE);
        }

        m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
        m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
    }
コード例 #27
0
    void SummonedCreatureJustDied(Creature* pSummoned) override
    {
        switch (pSummoned->GetEntry())
        {
            case NPC_INFINITE_ADVERSARY:
            case NPC_INFINITE_AGENT:
            case NPC_INFINITE_HUNTER:
                m_lSummonedGuidsList.remove(pSummoned->GetObjectGuid());

                if (m_lSummonedGuidsList.empty())
                    SetEscortPaused(false);
                break;
            case NPC_LORD_EPOCH:
                m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                break;
        }
    }
コード例 #28
0
ファイル: LFGQueue.cpp プロジェクト: samaelsacred/4.3.4
/**
   Given a list of guids returns the concatenation using | as delimiter

   @param[in]     check list of guids
   @returns Concatenated string
*/
std::string ConcatenateGuids(GuidList const& check)
{
    if (check.empty())
        return "";

    // need the guids in order to avoid duplicates
    GuidSet guids(check.begin(), check.end());

    std::ostringstream o;

    GuidSet::const_iterator it = guids.begin();
    o << it->GetRawValue();
    for (++it; it != guids.end(); ++it)
        o << '|' << it->GetRawValue();

    return o.str();
}
コード例 #29
0
        void ShatterGolem()
        {
            if (m_lGolemGUIDList.empty())
                return;

            for (ObjectGuid guid : m_lGolemGUIDList)
            {
                if (Creature* temp = ObjectAccessor::GetCreature(*me, guid))
                {
                    // Only shatter brittle golems
                    if (temp->IsAlive() && temp->GetEntry() == NPC_BRITTLE_GOLEM)
                    {
                        temp->CastSpell(temp, SPELL_SHATTER, false);
                        GolemsShattered += 1;
                    }
                }
            }
        }
コード例 #30
0
    Player* SelectRandomPlayerForMark()
    {
        Player* pResult = NULL;
        GuidList lPlayers;
        ThreatList const& threatlist = m_creature->getThreatManager().getThreatList();

        if (!threatlist.empty())
        {
            for (ThreatList::const_iterator itr = threatlist.begin();itr != threatlist.end(); ++itr)
            {
                ObjectGuid const& guid = (*itr)->getUnitGuid();
                if (guid.IsPlayer() && guid != m_creature->getVictim()->GetObjectGuid()) // exclude current target
                {
                    // check if player already has the mark
                    if (Player* pPlayer = m_creature->GetMap()->GetPlayer(guid))
                    {
                        if (!pPlayer->HasAura(SPELL_MARK_OF_FALLEN_CHAMPION_DEBUFF))
                            lPlayers.push_back(guid);
                    }
                }
            }
        }

        if (!lPlayers.empty())
        {
            GuidList::iterator i = lPlayers.begin();
            uint32 max = uint32(lPlayers.size() - 1);

            if (max > 0)
                std::advance(i, urand(0, max));

            pResult = m_creature->GetMap()->GetPlayer(*i);
        }

        // last option - current target
        if (!pResult)
        {
            Unit* pVictim = m_creature->getVictim();
            if (pVictim && pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->HasAura(SPELL_MARK_OF_FALLEN_CHAMPION_DEBUFF))
                pResult = (Player*)pVictim;
        }

        return pResult;
    }