Core/Spells: Adjust range checks to GameObject targets

(cherry picked from commit 72052aa9a5)
This commit is contained in:
jackpoz
2019-03-03 21:42:07 +01:00
committed by Shauren
parent 71b58c2e62
commit 7a2ef47495

View File

@@ -6494,7 +6494,7 @@ SpellCastResult Spell::CheckRange(bool strict) const
maxRange += std::min(MAX_SPELL_RANGE_TOLERANCE, maxRange*0.1f); // 10% but no more than MAX_SPELL_RANGE_TOLERANCE
// save the original values before squaring them
float origMaxRange = maxRange;
float origMinRange = minRange, origMaxRange = maxRange;
// get square values for sqr distance checks
minRange *= minRange;
@@ -6517,6 +6517,9 @@ SpellCastResult Spell::CheckRange(bool strict) const
if (GameObject* goTarget = m_targets.GetGOTarget())
{
if (origMinRange > 0.0f && goTarget->IsInRange(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), origMinRange))
return SPELL_FAILED_OUT_OF_RANGE;
if (!goTarget->IsInRange(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), origMaxRange))
return SPELL_FAILED_OUT_OF_RANGE;
}