From 7414041af0d49f256994850cdb98593f9f5cfb09 Mon Sep 17 00:00:00 2001 From: robinsch Date: Tue, 7 Jul 2015 10:20:06 +0200 Subject: SmartAI: Added the possibility to despawn object with action 41 (SMART_ACTION_FORCE_DESPAWN) --- src/server/game/AI/SmartScripts/SmartScript.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 267c038faaf..88cb351060f 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1017,16 +1017,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (!IsCreature(*itr)) - continue; - - if ((*itr)->ToUnit()->IsAlive() && IsSmart((*itr)->ToCreature())) + if (Creature* target = (*itr)->ToCreature()) { - ENSURE_AI(SmartAI, (*itr)->ToCreature()->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick - ENSURE_AI(SmartAI, (*itr)->ToCreature()->AI())->StartDespawn(); + if (target->IsAlive() && IsSmart(target)) + { + ENSURE_AI(SmartAI, target->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick + ENSURE_AI(SmartAI, target->AI())->StartDespawn(); + } + else + target->DespawnOrUnsummon(e.action.forceDespawn.delay); + } + else if (GameObject* goTarget = (*itr)->ToGameObject()) + { + if (IsSmartGO(goTarget)) + goTarget->SetRespawnTime(e.action.forceDespawn.delay + 1); } - else - (*itr)->ToCreature()->DespawnOrUnsummon(e.action.forceDespawn.delay); } delete targets; -- cgit v1.2.3