Core/SmartAI: Delay SMART_ACTION_FORCE_DESPAWN by at least one world tick

- Restore old despawn behavior of SmartAI despawning (without reintroducing the run time logs caused by IsSmart)
- Some SAIs relied on this to function (for example #1249)

Partial reverts commit 4fc4c81e89

(cherrypicked from aa7ef797d6)
This commit is contained in:
ariel-
2017-02-06 19:28:44 -03:00
committed by Shauren
parent 3f7fe6f8a5
commit a29a157e34

View File

@@ -1230,11 +1230,24 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!targets)
break;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
if (Creature* target = (*itr)->ToCreature())
target->DespawnOrUnsummon(e.action.forceDespawn.delay, Seconds(e.action.forceDespawn.respawn));
else if (GameObject* goTarget = (*itr)->ToGameObject())
goTarget->SetRespawnTime(e.action.forceDespawn.delay + 1);
// there should be at least a world update tick before despawn, to avoid breaking linked actions
int32 const respawnDelay = std::max<int32>(e.action.forceDespawn.delay, 1);
for (WorldObject* target : *targets)
{
if (Creature* creatureTarget = target->ToCreature())
{
if (SmartAI* smartAI = CAST_AI(SmartAI, creatureTarget->AI()))
{
smartAI->SetDespawnTime(respawnDelay);
smartAI->StartDespawn();
}
else
creatureTarget->DespawnOrUnsummon(respawnDelay);
}
else if (GameObject* goTarget = target->ToGameObject())
goTarget->SetRespawnTime(respawnDelay);
}
delete targets;
break;