diff options
author | Discover- <amort11@hotmail.com> | 2013-12-18 10:06:19 +0100 |
---|---|---|
committer | Discover- <amort11@hotmail.com> | 2013-12-18 10:06:19 +0100 |
commit | e5f7beecf5fabefa13fbe2645cc7d7ca707e46e8 (patch) | |
tree | 8bc72f47cf6e41aeefbb625323f43806cba7e168 /src | |
parent | a0f7fee922e4f568fe24223234461f9824cc7307 (diff) |
Core/SAI: Using SMART_ACTION_FORCE_DESPAWN now despawns the given target_type instead of always the creature itself.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 9b97124de64..a36621f87d5 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1040,18 +1040,24 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_FORCE_DESPAWN: { - if (!IsSmart()) + ObjectList* targets = GetTargets(e, unit); + + if (!targets) break; - // The AI is only updated if the creature is alive - if (me->IsAlive()) + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - CAST_AI(SmartAI, me->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick - CAST_AI(SmartAI, me->AI())->StartDespawn(); + if (!IsCreature(*itr)) + continue; + + if ((*itr)->ToUnit()->IsAlive() && IsSmart((*itr)->ToCreature())) + { + CAST_AI(SmartAI, (*itr)->ToCreature()->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick + CAST_AI(SmartAI, (*itr)->ToCreature()->AI())->StartDespawn(); + } + else + (*itr)->ToCreature()->DespawnOrUnsummon(e.action.forceDespawn.delay); } - // Otherwise we call the despawn directly - else - me->DespawnOrUnsummon(e.action.forceDespawn.delay); break; } |