mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 14:16:31 +00:00
fix(Core/Unit): Add melee leeway for auto attacks (#22566)
This commit is contained in:
@@ -48,6 +48,8 @@
|
||||
#define NOMINAL_MELEE_RANGE 5.0f
|
||||
#define MELEE_RANGE (NOMINAL_MELEE_RANGE - MIN_MELEE_REACH * 2) //center to center for players
|
||||
#define DEFAULT_COLLISION_HEIGHT 2.03128f // Most common value in dbc
|
||||
#define LEEWAY_MIN_MOVE_SPEED 4.97f // NYI
|
||||
#define LEEWAY_BONUS_RANGE 2.66f
|
||||
|
||||
// used for creating values for respawn for example
|
||||
inline uint32 PAIR64_HIPART(uint64 x);
|
||||
|
||||
@@ -674,6 +674,9 @@ bool Unit::IsWithinMeleeRange(Unit const* obj, float dist) const
|
||||
|
||||
float maxdist = dist + GetMeleeRange(obj);
|
||||
|
||||
if ((IsPlayer() || obj->IsPlayer()) && HasLeewayMovement() && obj->HasLeewayMovement())
|
||||
maxdist += LEEWAY_BONUS_RANGE;
|
||||
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
|
||||
@@ -1639,6 +1639,12 @@ public:
|
||||
UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && !GetOwnerGUID();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool HasLeewayMovement() const
|
||||
{
|
||||
return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT | MOVEMENTFLAG_FALLING)
|
||||
&& !IsWalking();
|
||||
}
|
||||
|
||||
void KnockbackFrom(float x, float y, float speedXY, float speedZ);
|
||||
void JumpTo(float speedXY, float speedZ, bool forward = true);
|
||||
void JumpTo(WorldObject* obj, float speedZ);
|
||||
|
||||
@@ -7109,7 +7109,7 @@ SpellCastResult Spell::CheckRange(bool strict)
|
||||
if (range_type == SPELL_RANGE_MELEE)
|
||||
{
|
||||
float real_max_range = max_range;
|
||||
if (!m_caster->IsCreature() && m_caster->isMoving() && target->isMoving() && !m_caster->IsWalking() && !target->IsWalking())
|
||||
if (!m_caster->IsCreature() && m_caster->HasLeewayMovement() && target->HasLeewayMovement())
|
||||
real_max_range -= MIN_MELEE_REACH; // Because of lag, we can not check too strictly here (is only used if both caster and target are moving)
|
||||
else
|
||||
real_max_range -= 2 * MIN_MELEE_REACH;
|
||||
|
||||
Reference in New Issue
Block a user