mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-14 20:22:23 -04:00
Merge pull request #15022 from robinsch/GOdespawn
SmartAI: Possibility to despawn object with SMART_ACTION_FORCE_DESPAWN
This commit is contained in:
@@ -1026,16 +1026,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;
|
||||
|
||||
Reference in New Issue
Block a user