public void EndCombat() { // sequencing matters here - AI might do nasty stuff, so make sure refs are in a consistent state before you hand off! // first, get rid of any threat that still exists... first.GetThreatManager().ClearThreat(second); second.GetThreatManager().ClearThreat(first); // ...then, remove the references from both managers... first.GetCombatManager().PurgeReference(second.GetGUID(), _isPvP); second.GetCombatManager().PurgeReference(first.GetGUID(), _isPvP); // ...update the combat state, which will potentially remove IN_COMBAT... bool needFirstAI = first.GetCombatManager().UpdateOwnerCombatState(); bool needSecondAI = second.GetCombatManager().UpdateOwnerCombatState(); // ...and if that happened, also notify the AI of it... if (needFirstAI) { UnitAI firstAI = first.GetAI(); if (firstAI != null) { firstAI.JustExitedCombat(); } } if (needSecondAI) { UnitAI secondAI = second.GetAI(); if (secondAI != null) { secondAI.JustExitedCombat(); } } }
public void SuppressFor(Unit who) { Suppress(who); if (who.GetCombatManager().UpdateOwnerCombatState()) { UnitAI ai = who.GetAI(); if (ai != null) { ai.JustExitedCombat(); } } }