From f954046c4c60c28d24bc3416626c3e5867cbf19b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 2 Jan 2022 12:32:11 -0500 Subject: [PATCH] Core/Combat: Properly unset engagement flag on death. Port From (https://github.com/TrinityCore/TrinityCore/commit/6b1ca0ca128425677043d36a147a019f6d2ac6e6) --- Source/Game/AI/CoreAI/CreatureAI.cs | 6 ++++++ Source/Game/Entities/Creature/Creature.cs | 6 ++++-- Source/Game/Entities/Unit/Unit.Combat.cs | 2 -- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Game/AI/CoreAI/CreatureAI.cs b/Source/Game/AI/CoreAI/CreatureAI.cs index fdd916cc8..2740b4e59 100644 --- a/Source/Game/AI/CoreAI/CreatureAI.cs +++ b/Source/Game/AI/CoreAI/CreatureAI.cs @@ -244,6 +244,12 @@ namespace Game.AI if (!IsEngaged()) return false; + if (!me.IsAlive()) + { + EngagementOver(); + return false; + } + if (!me.HasReactState(ReactStates.Passive)) { Unit victim = me.SelectVictim(); diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index a4b1df281..c86b8cd62 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -502,6 +502,9 @@ namespace Game.Entities if (m_deathState != DeathState.Corpse) break; + if (IsEngaged()) + AIUpdateTick(diff); + if (m_groupLootTimer != 0 && !lootingGroupLowGUID.IsEmpty()) { if (m_groupLootTimer <= diff) @@ -583,7 +586,6 @@ namespace Game.Entities } } - // do not allow the AI to be changed during update AIUpdateTick(diff); if (!IsAlive()) @@ -1087,7 +1089,7 @@ namespace Game.Entities base.AtDisengage(); ClearUnitState(UnitState.AttackPlayer); - if (HasDynamicFlag(UnitDynFlags.Tapped)) + if (IsAlive() && HasDynamicFlag(UnitDynFlags.Tapped)) SetDynamicFlags((UnitDynFlags)GetCreatureTemplate().DynamicFlags); if (IsPet() || IsGuardian()) // update pets' speed for catchup OOC speed diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index 13f020d99..383e058ba 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -858,8 +858,6 @@ namespace Game.Entities if (!creature.IsPet()) { - creature.GetThreatManager().ClearAllThreat(); - // must be after setDeathState which resets dynamic flags if (!creature.loot.IsLooted()) creature.AddDynamicFlag(UnitDynFlags.Lootable);