Scripts/Icecrown Citadel: Valithria Dreamwalker encounter will now be ended if there is no player on combat trigger's threat list

This commit is contained in:
Shauren
2011-05-27 17:25:30 +02:00
parent 5851ec3e4f
commit 65fc7f7a28
@@ -535,8 +535,29 @@ class npc_green_dragon_combat_trigger : public CreatureScript
void UpdateAI(uint32 const /*diff*/)
{
UpdateVictim();
std::list<HostileReference*> const& threatList = me->getThreatManager().getThreatList();
if (threatList.empty())
{
EnterEvadeMode();
return;
}
// check evade every second tick
_evadeCheck ^= true;
if (!_evadeCheck)
return;
// check if there is any player on threatlist, if not - evade
for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
if (Unit* target = (*itr)->getTarget())
if (target->GetTypeId() == TYPEID_PLAYER)
return; // found any player, return
EnterEvadeMode();
}
private:
bool _evadeCheck;
};
CreatureAI* GetAI(Creature* creature) const