Core/AI: delay all AI()->Respawn() hooks by 1 server tick, this way when creatures are just got created they will successfully find other objects in scripts at spawn time

--HG--
branch : trunk
This commit is contained in:
Rat
2010-11-03 18:33:47 +01:00
parent 4747c5f820
commit c9cf2f059f
2 changed files with 9 additions and 1 deletions
@@ -161,6 +161,7 @@ m_formation(NULL)
m_CombatDistance = 0;//MELEE_RANGE;
ResetLootMode(); // restore default loot mode
TriggerJustRespawned = false;
}
Creature::~Creature()
@@ -437,6 +438,12 @@ void Creature::Update(uint32 diff)
else
m_GlobalCooldown -= diff;
if (IsAIEnabled && TriggerJustRespawned)
{
TriggerJustRespawned = false;
AI()->JustRespawned();
}
switch(m_deathState)
{
case JUST_ALIVED:
@@ -1630,7 +1637,7 @@ void Creature::Respawn(bool force)
//Call AI respawn virtual function
if (IsAIEnabled)
AI()->JustRespawned();
TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
if (poolid)
@@ -732,6 +732,7 @@ class Creature : public Unit, public GridObject<Creature>
//Formation var
CreatureGroup *m_formation;
bool TriggerJustRespawned;
};
class AssistDelayEvent : public BasicEvent