Core/AI: Add a new LeavingWorld AI hook

(cherry picked from commit c0a7274ff1)
This commit is contained in:
Treeston
2018-06-26 12:15:57 +02:00
committed by Shauren
parent 4923084937
commit 2642fb1a48
2 changed files with 6 additions and 0 deletions

View File

@@ -284,6 +284,9 @@ class TC_GAME_API UnitAI
// Called when the unit leaves combat
virtual void JustExitedCombat() { }
// Called when the unit is about to be removed from the world (despawn, grid unload, corpse disappearing, player logging out etc.)
virtual void LeavingWorld() { }
// Called at any Damage to any victim (before damage apply)
virtual void DamageDealt(Unit* /*victim*/, uint32& /*damage*/, DamageEffectType /*damageType*/) { }

View File

@@ -9064,6 +9064,9 @@ void Unit::RemoveFromWorld()
if (IsInWorld())
{
m_duringRemoveFromWorld = true;
if (IsAIEnabled)
GetAI()->LeavingWorld();
if (IsVehicle())
RemoveVehicleKit(true);