mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 15:46:24 +00:00
fix(Core/Player): allow attacking target within boundary radius when… (#22500)
Co-authored-by: Kito <kito@vortexirc.com>
This commit is contained in:
@@ -181,8 +181,8 @@ void Player::Update(uint32 p_time)
|
||||
m_swingErrorMsg = 1;
|
||||
}
|
||||
}
|
||||
// 120 degrees of radiant range
|
||||
else if (!HasInArc(2 * M_PI / 3, victim))
|
||||
// 120 degrees of radiant range, if player is not in boundary radius
|
||||
else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * float(M_PI) / 3, victim))
|
||||
{
|
||||
setAttackTimer(BASE_ATTACK, 100);
|
||||
if (m_swingErrorMsg != 2) // send single time (client auto repeat)
|
||||
@@ -211,8 +211,8 @@ void Player::Update(uint32 p_time)
|
||||
{
|
||||
if (!IsWithinMeleeRange(victim))
|
||||
setAttackTimer(OFF_ATTACK, 100);
|
||||
else if (!HasInArc(2 * M_PI / 3, victim))
|
||||
setAttackTimer(OFF_ATTACK, 100);
|
||||
else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * float(M_PI) / 3, victim))
|
||||
setAttackTimer(BASE_ATTACK, 100);
|
||||
else
|
||||
{
|
||||
// prevent base and off attack in same time, delay attack at
|
||||
|
||||
@@ -698,6 +698,16 @@ bool Unit::IsWithinRange(Unit const* obj, float dist) const
|
||||
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
|
||||
{
|
||||
float combat_reach = GetCombatReach();
|
||||
|
||||
@@ -818,9 +818,11 @@ public:
|
||||
bool _IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const;
|
||||
|
||||
// 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 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;
|
||||
bool IsWithinBoundaryRadius(const Unit* obj) const;
|
||||
bool IsWithinCombatRange(Unit const* obj, float dist2compare) const;
|
||||
bool IsWithinMeleeRange(Unit const* obj, float dist = 0.f) const;
|
||||
float GetMeleeRange(Unit const* target) const;
|
||||
|
||||
@@ -7126,7 +7126,7 @@ SpellCastResult Spell::CheckRange(bool strict)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -9129,7 +9129,7 @@ namespace Acore
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_caster->isInFront(target, _coneAngle))
|
||||
if (!_caster->IsWithinBoundaryRadius(target->ToUnit()) && !_caster->isInFront(target, _coneAngle))
|
||||
return false;
|
||||
}
|
||||
return WorldObjectSpellAreaTargetCheck::operator ()(target);
|
||||
|
||||
Reference in New Issue
Block a user