diff options
author | ariel- <ariel-@users.noreply.github.com> | 2017-02-06 19:28:44 -0300 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2019-06-15 18:41:09 +0200 |
commit | a29a157e34e603aed5dd813702f16bb3e0ccd3a5 (patch) | |
tree | 7a54f194ad6b6652c6d79a9e796c00728d1b7627 /src | |
parent | 3f7fe6f8a51f61083b4940eaadddc3b390f8e238 (diff) |
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 4fc4c81e8989febd7e650d749af358548e264e2c
(cherrypicked from aa7ef797d6c362710a38c12e31db4b8f3b2963e4)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index a43d592d745..f5026728012 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -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; |