Core/SmartAI: Delay SMART_ACTION_FORCE_DESPAWN by at least one world tick
Port From (https://github.com/TrinityCore/TrinityCore/commit/a29a157e34e603aed5dd813702f16bb3e0ccd3a5)
This commit is contained in:
@@ -1064,19 +1064,28 @@ namespace Game.AI
|
|||||||
if (targets == null)
|
if (targets == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// there should be at least a world update tick before despawn, to avoid breaking linked actions
|
||||||
|
uint respawnDelay = Math.Max(e.Action.forceDespawn.delay, 1u);
|
||||||
|
|
||||||
foreach (var obj in targets)
|
foreach (var obj in targets)
|
||||||
{
|
{
|
||||||
if (obj.IsTypeId(TypeId.Unit))
|
Creature creatureTarget = obj.ToCreature();
|
||||||
|
if (creatureTarget != null)
|
||||||
{
|
{
|
||||||
Creature target = obj.ToCreature();
|
SmartAI smartAI = (SmartAI)creatureTarget.GetAI();
|
||||||
if (target)
|
if (smartAI != null)
|
||||||
target.DespawnOrUnsummon(e.Action.forceDespawn.delay, TimeSpan.FromSeconds(e.Action.forceDespawn.respawn));
|
{
|
||||||
|
smartAI.SetDespawnTime(respawnDelay);
|
||||||
|
smartAI.StartDespawn();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
creatureTarget.DespawnOrUnsummon(respawnDelay);
|
||||||
}
|
}
|
||||||
else if (obj.IsTypeId(TypeId.GameObject))
|
else
|
||||||
{
|
{
|
||||||
GameObject goTarget = obj.ToGameObject();
|
GameObject goTarget = obj.ToGameObject();
|
||||||
if (goTarget)
|
if (goTarget != null)
|
||||||
goTarget.SetRespawnTime((int)e.Action.forceDespawn.delay + 1);
|
goTarget.SetRespawnTime((int)respawnDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user