Core/Entities: Kick engagement logic upstairs to Unit (from ThreatManager), since all Units with AI need it (not just those with threat list).

Port From (https://github.com/TrinityCore/TrinityCore/commit/35e55f10899712435102764671241b94a2026599)
This commit is contained in:
hondacrx
2021-12-23 20:00:45 -05:00
parent ff48f2cab9
commit 8694a2ae24
6 changed files with 49 additions and 42 deletions
+16 -4
View File
@@ -1042,9 +1042,9 @@ namespace Game.Entities
&& !GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.NoXpAtKill);
}
public override void AtEnterCombat()
public override void AtEngage(Unit target)
{
base.AtEnterCombat();
base.AtEngage(target);
if (!GetCreatureTemplate().TypeFlags.HasAnyFlag(CreatureTypeFlags.MountedCombatAllowed))
Dismount();
@@ -1055,11 +1055,23 @@ namespace Game.Entities
UpdateSpeed(UnitMoveType.Swim);
UpdateSpeed(UnitMoveType.Flight);
}
MovementGeneratorType movetype = GetMotionMaster().GetCurrentMovementGeneratorType();
if (movetype == MovementGeneratorType.Waypoint || movetype == MovementGeneratorType.Point || (IsAIEnabled() && GetAI().IsEscorted()))
SetHomePosition(GetPosition());
CreatureAI ai = GetAI();
if (ai != null)
ai.JustEngagedWith(target);
CreatureGroup formation = GetFormation();
if (formation != null)
formation.MemberEngagingTarget(this, target);
}
public override void AtExitCombat()
public override void AtDisengage()
{
base.AtExitCombat();
base.AtDisengage();
ClearUnitState(UnitState.AttackPlayer);
if (HasDynamicFlag(UnitDynFlags.Tapped))