mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[11105] Melee attacks distance
Inspired by patch provided by Feanordev. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
aa4c1be8cf
commit
8e68d1bcaf
13 changed files with 77 additions and 43 deletions
|
|
@ -445,13 +445,23 @@ void Unit::resetAttackTimer(WeaponAttackType type)
|
|||
m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]);
|
||||
}
|
||||
|
||||
bool Unit::canReachWithAttack(Unit *pVictim) const
|
||||
bool Unit::CanReachWithMeleeAttack(Unit* pVictim, float flat_mod /*= 0.0f*/) const
|
||||
{
|
||||
MANGOS_ASSERT(pVictim);
|
||||
float reach = GetFloatValue(UNIT_FIELD_COMBATREACH);
|
||||
if( reach <= 0.0f )
|
||||
reach = 1.0f;
|
||||
return IsWithinDistInMap(pVictim, reach);
|
||||
|
||||
// The measured values show BASE_MELEE_OFFSET in (1.3224, 1.342)
|
||||
float reach = GetFloatValue(UNIT_FIELD_COMBATREACH) + pVictim->GetFloatValue(UNIT_FIELD_COMBATREACH) +
|
||||
BASE_MELEERANGE_OFFSET + flat_mod;
|
||||
|
||||
if (reach < ATTACK_DISTANCE)
|
||||
reach = ATTACK_DISTANCE;
|
||||
|
||||
// This check is not related to bounding radius
|
||||
float dx = GetPositionX() - pVictim->GetPositionX();
|
||||
float dy = GetPositionY() - pVictim->GetPositionY();
|
||||
float dz = GetPositionZ() - pVictim->GetPositionZ();
|
||||
|
||||
return dx*dx + dy*dy + dz*dz < reach*reach;
|
||||
}
|
||||
|
||||
void Unit::RemoveSpellsCausingAura(AuraType auraType)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue