From 672d304a4478afa58d6e094b1bf53ae25b176356 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 19 Oct 2008 14:42:12 -0500 Subject: [svn] Add Unit::IsWithinCombatDist function to check melee range and spell range (now range is related to the attacker's bounding_radius and target's combat_reach, not sure if both should be combat_reach). --HG-- branch : trunk --- src/game/Spell.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/game/Spell.cpp') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f82f2bd29bf..3c44df10cb9 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4337,10 +4337,9 @@ uint8 Spell::CheckRange(bool strict) if(target && target != m_caster) { // distance from target center in checks - float dist = m_caster->GetDistance(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ()); - if(dist > max_range) + if(!m_caster->IsWithinCombatDist(target, max_range)) return SPELL_FAILED_OUT_OF_RANGE; //0x5A; - if(dist < min_range) + if(min_range && m_caster->IsWithinCombatDist(target, min_range)) // skip this check if min_range = 0 return SPELL_FAILED_TOO_CLOSE; if( m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc( M_PI, target ) ) -- cgit v1.2.3