diff options
author | ariel- <ariel-@users.noreply.github.com> | 2017-02-06 19:28:44 -0300 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2017-02-06 19:28:44 -0300 |
commit | aa7ef797d6c362710a38c12e31db4b8f3b2963e4 (patch) | |
tree | 981d262ea2dd3ce4fdec58b3d65092d471462a41 /src | |
parent | d9c465ed870cd054289384610f4ece4857beb5ed (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
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 8acbc9bea45..a6f84695876 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1066,11 +1066,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); - 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; |