fix(Core/Player): allow attacking target within boundary radius when… (#22500)

Co-authored-by: Kito <kito@vortexirc.com>
This commit is contained in:
Jelle Meeus
2025-07-29 05:38:49 -07:00
committed by GitHub
parent 98eda3684d
commit 40c58123b1
4 changed files with 18 additions and 6 deletions
@@ -181,8 +181,8 @@ void Player::Update(uint32 p_time)
m_swingErrorMsg = 1; m_swingErrorMsg = 1;
} }
} }
// 120 degrees of radiant range // 120 degrees of radiant range, if player is not in boundary radius
else if (!HasInArc(2 * M_PI / 3, victim)) else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * float(M_PI) / 3, victim))
{ {
setAttackTimer(BASE_ATTACK, 100); setAttackTimer(BASE_ATTACK, 100);
if (m_swingErrorMsg != 2) // send single time (client auto repeat) if (m_swingErrorMsg != 2) // send single time (client auto repeat)
@@ -211,8 +211,8 @@ void Player::Update(uint32 p_time)
{ {
if (!IsWithinMeleeRange(victim)) if (!IsWithinMeleeRange(victim))
setAttackTimer(OFF_ATTACK, 100); setAttackTimer(OFF_ATTACK, 100);
else if (!HasInArc(2 * M_PI / 3, victim)) else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * float(M_PI) / 3, victim))
setAttackTimer(OFF_ATTACK, 100); setAttackTimer(BASE_ATTACK, 100);
else else
{ {
// prevent base and off attack in same time, delay attack at // prevent base and off attack in same time, delay attack at
+10
View File
@@ -698,6 +698,16 @@ bool Unit::IsWithinRange(Unit const* obj, float dist) const
return distsq <= dist * dist; return distsq <= dist * dist;
} }
bool Unit::IsWithinBoundaryRadius(const Unit* obj) const
{
if (!obj || !IsInMap(obj) || !InSamePhase(obj))
return false;
float objBoundaryRadius = std::max(obj->GetBoundaryRadius(), MIN_MELEE_REACH);
return IsInDist(obj, objBoundaryRadius);
}
bool Unit::GetRandomContactPoint(Unit const* obj, float& x, float& y, float& z, bool force) const bool Unit::GetRandomContactPoint(Unit const* obj, float& x, float& y, float& z, bool force) const
{ {
float combat_reach = GetCombatReach(); float combat_reach = GetCombatReach();
+2
View File
@@ -818,9 +818,11 @@ public:
bool _IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const; bool _IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const;
// Combat range // Combat range
[[nodiscard]] float GetBoundaryRadius() const { return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS]; }
[[nodiscard]] float GetCombatReach() const override { return m_floatValues[UNIT_FIELD_COMBATREACH]; } [[nodiscard]] float GetCombatReach() const override { return m_floatValues[UNIT_FIELD_COMBATREACH]; }
[[nodiscard]] float GetMeleeReach() const { float reach = m_floatValues[UNIT_FIELD_COMBATREACH]; return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH; } [[nodiscard]] float GetMeleeReach() const { float reach = m_floatValues[UNIT_FIELD_COMBATREACH]; return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH; }
[[nodiscard]] bool IsWithinRange(Unit const* obj, float dist) const; [[nodiscard]] bool IsWithinRange(Unit const* obj, float dist) const;
bool IsWithinBoundaryRadius(const Unit* obj) const;
bool IsWithinCombatRange(Unit const* obj, float dist2compare) const; bool IsWithinCombatRange(Unit const* obj, float dist2compare) const;
bool IsWithinMeleeRange(Unit const* obj, float dist = 0.f) const; bool IsWithinMeleeRange(Unit const* obj, float dist = 0.f) const;
float GetMeleeRange(Unit const* target) const; float GetMeleeRange(Unit const* target) const;
+2 -2
View File
@@ -7126,7 +7126,7 @@ SpellCastResult Spell::CheckRange(bool strict)
return SPELL_FAILED_TOO_CLOSE; return SPELL_FAILED_TOO_CLOSE;
} }
if (m_caster->IsPlayer() && (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast<float>(M_PI), target)) if (m_caster->IsPlayer() && (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast<float>(M_PI), target) && !m_caster->IsWithinBoundaryRadius(target))
return SPELL_FAILED_UNIT_NOT_INFRONT; return SPELL_FAILED_UNIT_NOT_INFRONT;
} }
@@ -9129,7 +9129,7 @@ namespace Acore
} }
else else
{ {
if (!_caster->isInFront(target, _coneAngle)) if (!_caster->IsWithinBoundaryRadius(target->ToUnit()) && !_caster->isInFront(target, _coneAngle))
return false; return false;
} }
return WorldObjectSpellAreaTargetCheck::operator ()(target); return WorldObjectSpellAreaTargetCheck::operator ()(target);