mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 11:52:32 +01:00
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 commit4fc4c81e89(cherrypicked fromaa7ef797d6)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user