Core/Spells: Adjust range checks to GameObject targets

This commit is contained in:
jackpoz
2019-03-03 21:24:39 +01:00
committed by Ovahlord
parent d99de4db33
commit 85bf4daf45

View File

@@ -6439,6 +6439,9 @@ SpellCastResult Spell::CheckRange(bool strict) const
if (m_spellInfo->RangeEntry && m_spellInfo->RangeEntry->type != SPELL_RANGE_MELEE && !strict)
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;
// get square values for sqr distance checks
minRange *= minRange;
maxRange *= maxRange;
@@ -6460,10 +6463,7 @@ SpellCastResult Spell::CheckRange(bool strict) const
if (GameObject* goTarget = m_targets.GetGOTarget())
{
if (m_caster->GetExactDistSq(goTarget) > maxRange)
return SPELL_FAILED_OUT_OF_RANGE;
if (minRange > 0.0f && m_caster->GetExactDistSq(goTarget) < minRange)
if (!goTarget->IsInRange(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), origMaxRange))
return SPELL_FAILED_OUT_OF_RANGE;
}