mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
Entities/GO: Add forceRespawnTimer support to DespawnOrUnsummon. Use it in SAI.
This commit is contained in:
@@ -1032,22 +1032,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_FORCE_DESPAWN:
|
||||
{
|
||||
// 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);
|
||||
Milliseconds despawnDelay(e.action.forceDespawn.delay);
|
||||
if (despawnDelay <= 0ms)
|
||||
despawnDelay = 1ms;
|
||||
|
||||
Seconds forceRespawnTimer(e.action.forceDespawn.forceRespawnTimer);
|
||||
|
||||
for (WorldObject* target : targets)
|
||||
{
|
||||
if (Creature* creature = target->ToCreature())
|
||||
{
|
||||
if (SmartAI* smartAI = CAST_AI(SmartAI, creature->AI()))
|
||||
{
|
||||
smartAI->SetDespawnTime(respawnDelay);
|
||||
smartAI->StartDespawn();
|
||||
}
|
||||
else
|
||||
creature->DespawnOrUnsummon(respawnDelay);
|
||||
}
|
||||
creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
|
||||
else if (GameObject* goTarget = target->ToGameObject())
|
||||
goTarget->DespawnOrUnsummon(Milliseconds(respawnDelay));
|
||||
goTarget->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user