[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
This commit is contained in:
megamage
2008-10-19 14:42:12 -05:00
parent e7519059c9
commit 672d304a44
5 changed files with 21 additions and 6 deletions

View File

@@ -408,6 +408,21 @@ bool Unit::canReachWithAttack(Unit *pVictim) const
return IsWithinDistInMap(pVictim, reach);
}
bool Unit::IsWithinCombatDist(Unit *obj, float dist2compare) const
{
if (!obj || !IsInMap(obj)) return false;
float dx = GetPositionX() - obj->GetPositionX();
float dy = GetPositionY() - obj->GetPositionY();
float dz = GetPositionZ() - obj->GetPositionZ();
float distsq = dx*dx + dy*dy + dz*dz;
//not sure here, or combatreach + combatreach?
float sizefactor = GetObjectSize() + obj->GetFloatValue(UNIT_FIELD_COMBATREACH);
float maxdist = dist2compare + sizefactor;
return distsq < maxdist * maxdist;
}
void Unit::RemoveSpellsCausingAura(AuraType auraType)
{
if (auraType >= TOTAL_AURAS) return;