*Update melee range calculation. By QAston.
--HG-- branch : trunk
This commit is contained in:
1 parent
d36672cd7e
commit
3a1293ef18
34 files changed
+93
-138
No files matched your search
+17
-8
@@ -420,13 +420,7 @@ void Unit::resetAttackTimer(WeaponAttackType type)
|
||||
m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]);
|
||||
}
|
||||
|
||||
bool Unit::canReachWithAttack(Unit *pVictim) const
|
||||
{
|
||||
assert(pVictim);
|
||||
return IsWithinDistInMap(pVictim, GetCombatReach());
|
||||
}
|
||||
|
||||
bool Unit::IsWithinCombatDist(Unit *obj, float dist2compare) const
|
||||
bool Unit::IsWithinCombatRange(Unit *obj, float dist2compare) const
|
||||
{
|
||||
if (!obj || !IsInMap(obj)) return false;
|
||||
|
||||
@@ -434,13 +428,28 @@ bool Unit::IsWithinCombatDist(Unit *obj, float dist2compare) const
|
||||
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 = GetCombatReach() + obj->GetCombatReach();
|
||||
float maxdist = dist2compare + sizefactor;
|
||||
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
bool Unit::IsWithinMeleeRange(Unit *obj) 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;
|
||||
|
||||
float sizefactor = GetMeleeReach() + obj->GetMeleeReach();
|
||||
float maxdist = MELEE_RANGE + sizefactor;
|
||||
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const
|
||||
{
|
||||
float combat_reach = GetCombatReach();
|
||||
|
||||
Reference in new issue
Block a user