mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 10:56:38 +01:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user