Core/Units: add new functionality for units to block or enable combat interactions
Port From (https://github.com/TrinityCore/TrinityCore/commit/2819951dce545438724719836e3a13d3039b8690)
This commit is contained in:
@@ -57,11 +57,8 @@ namespace Game.Combat
|
||||
return false;
|
||||
if (a.HasUnitState(UnitState.InFlight) || b.HasUnitState(UnitState.InFlight))
|
||||
return false;
|
||||
Creature aCreature = a.ToCreature();
|
||||
if (aCreature != null && aCreature.IsCombatDisallowed())
|
||||
return false;
|
||||
Creature bCreature = b.ToCreature();
|
||||
if (bCreature != null && bCreature.IsCombatDisallowed())
|
||||
// ... both units must not be ignoring combat
|
||||
if (a.IsIgnoringCombat() || b.IsIgnoringCombat())
|
||||
return false;
|
||||
if (a.IsFriendlyTo(b) || b.IsFriendlyTo(a))
|
||||
return false;
|
||||
|
||||
@@ -420,6 +420,8 @@ namespace Game.Entities
|
||||
ApplySpellImmune(0, SpellImmunity.Effect, SpellEffectName.AttackMe, true);
|
||||
}
|
||||
|
||||
SetIgnoringCombat(cInfo.FlagsExtra.HasFlag(CreatureFlagsExtra.NoCombat));
|
||||
|
||||
LoadTemplateRoot();
|
||||
InitializeMovementFlags();
|
||||
|
||||
@@ -3096,10 +3098,6 @@ namespace Game.Entities
|
||||
{
|
||||
return GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Guard);
|
||||
}
|
||||
public bool IsCombatDisallowed()
|
||||
{
|
||||
return GetCreatureTemplate().FlagsExtra.HasFlag(CreatureFlagsExtra.NoCombat);
|
||||
}
|
||||
|
||||
public bool CanWalk() { return GetMovementTemplate().IsGroundAllowed(); }
|
||||
public override bool CanSwim() { return GetMovementTemplate().IsSwimAllowed() || IsPet();}
|
||||
|
||||
@@ -1420,7 +1420,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
public bool IsWithinMeleeRange(Unit obj) { return IsWithinMeleeRangeAt(GetPosition(), obj); }
|
||||
|
||||
|
||||
public bool IsWithinMeleeRangeAt(Position pos, Unit obj)
|
||||
{
|
||||
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
|
||||
@@ -1491,5 +1491,15 @@ namespace Game.Entities
|
||||
UpdateAttackTimeField(att);
|
||||
m_attackTimer[(int)att] = (uint)(m_baseAttackSpeed[(int)att] * m_modAttackSpeedPct[(int)att] * remainingTimePct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns if the unit is ignoring any combat interaction
|
||||
/// </summary>
|
||||
public bool IsIgnoringCombat() { return _isIgnoringCombat; }
|
||||
|
||||
/// <summary>
|
||||
/// enables/disables combat interaction of this unit.
|
||||
/// </summary>
|
||||
public void SetIgnoringCombat(bool apply) { _isIgnoringCombat = apply; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace Game.Entities
|
||||
uint[] m_baseAttackSpeed = new uint[(int)WeaponAttackType.Max];
|
||||
internal float[] m_modAttackSpeedPct = new float[(int)WeaponAttackType.Max];
|
||||
protected uint[] m_attackTimer = new uint[(int)WeaponAttackType.Max];
|
||||
bool _isIgnoringCombat;
|
||||
|
||||
// Threat+combat management
|
||||
CombatManager m_combatManager;
|
||||
|
||||
Reference in New Issue
Block a user