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:
@@ -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))
|
||||
|
||||
@@ -57,6 +57,9 @@ namespace Game.Entities
|
||||
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.LeavingCombat);
|
||||
}
|
||||
|
||||
public virtual void AtEngage(Unit target) { m_isEngaged = true; }
|
||||
public virtual void AtDisengage() { m_isEngaged = false; }
|
||||
|
||||
public void CombatStop(bool includingCast = false, bool mutualPvP = true)
|
||||
{
|
||||
if (includingCast && IsNonMeleeSpellCast(false))
|
||||
@@ -144,10 +147,10 @@ namespace Game.Entities
|
||||
|
||||
public bool CanHaveThreatList() { return m_threatManager.CanHaveThreatList(); }
|
||||
|
||||
// For NPCs with threat list: Whether there are any enemies on our threat list
|
||||
// For other units: Whether we're in combat
|
||||
// This value is different from IsInCombat when a projectile spell is midair (combat on launch - threat+aggro on impact)
|
||||
public bool IsEngaged() { return CanHaveThreatList() ? m_threatManager.IsEngaged() : IsInCombat(); }
|
||||
// This value can be different from IsInCombat:
|
||||
// - when a projectile spell is midair against a creature (combat on launch - threat+aggro on impact)
|
||||
// - when the creature has no targets left, but the AI has not yet ceased engaged logic
|
||||
public bool IsEngaged() { return m_isEngaged; }
|
||||
|
||||
public bool IsEngagedBy(Unit who) { return CanHaveThreatList() ? IsThreatenedBy(who) : IsInCombatWith(who); }
|
||||
|
||||
|
||||
@@ -54,6 +54,9 @@ namespace Game.Entities
|
||||
internal float[] m_modAttackSpeedPct = new float[(int)WeaponAttackType.Max];
|
||||
protected uint[] m_attackTimer = new uint[(int)WeaponAttackType.Max];
|
||||
|
||||
// Threat+combat management
|
||||
bool m_isEngaged;
|
||||
|
||||
CombatManager m_combatManager;
|
||||
ThreatManager m_threatManager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user