fix(Core/SmartAI): Don't add UNIT_STATE_MELEE_ATTACKING if unit is in ranged mode and not chasing (#26796)
This commit is contained in:
@@ -596,8 +596,26 @@ void SmartAI::UpdateAI(uint32 diff)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (mCanAutoAttack)
|
if (mCanAutoAttack)
|
||||||
|
{
|
||||||
|
UpdateMeleeStance();
|
||||||
DoMeleeAttackIfReady();
|
DoMeleeAttackIfReady();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SmartAI::UpdateMeleeStance()
|
||||||
|
{
|
||||||
|
// Ranged creatures should not switch to melee stance at distance
|
||||||
|
if (!_currentRangeMode || me->IsCrowdControlled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Unit* victim = me->GetVictim();
|
||||||
|
if (!victim)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool const canMelee = me->IsWithinMeleeRange(victim);
|
||||||
|
if (canMelee != me->HasUnitState(UNIT_STATE_MELEE_ATTACKING))
|
||||||
|
me->Attack(victim, canMelee);
|
||||||
|
}
|
||||||
|
|
||||||
bool SmartAI::IsEscortInvokerInRange()
|
bool SmartAI::IsEscortInvokerInRange()
|
||||||
{
|
{
|
||||||
@@ -927,7 +945,7 @@ void SmartAI::AttackStart(Unit* who)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (who && me->Attack(who, mCanAutoAttack))
|
if (who && me->Attack(who, mCanAutoAttack && !_currentRangeMode))
|
||||||
{
|
{
|
||||||
if (!me->HasUnitState(UNIT_STATE_NO_COMBAT_MOVEMENT))
|
if (!me->HasUnitState(UNIT_STATE_NO_COMBAT_MOVEMENT))
|
||||||
{
|
{
|
||||||
@@ -1202,7 +1220,12 @@ void SmartAI::SetCurrentRangeMode(bool on, float range)
|
|||||||
_attackDistance = range;
|
_attackDistance = range;
|
||||||
|
|
||||||
if (Unit* victim = me->GetVictim())
|
if (Unit* victim = me->GetVictim())
|
||||||
|
{
|
||||||
me->GetMotionMaster()->MoveChase(victim, _attackDistance);
|
me->GetMotionMaster()->MoveChase(victim, _attackDistance);
|
||||||
|
|
||||||
|
if (!on && mCanAutoAttack && !me->HasUnitState(UNIT_STATE_MELEE_ATTACKING))
|
||||||
|
me->Attack(victim, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmartAI::SetMainSpell(uint32 spellId)
|
void SmartAI::SetMainSpell(uint32 spellId)
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ private:
|
|||||||
uint32 mDespawnState;
|
uint32 mDespawnState;
|
||||||
void UpdateDespawn(const uint32 diff);
|
void UpdateDespawn(const uint32 diff);
|
||||||
void UpdateFollow(const uint32 diff);
|
void UpdateFollow(const uint32 diff);
|
||||||
|
void UpdateMeleeStance();
|
||||||
uint32 mEscortInvokerCheckTimer;
|
uint32 mEscortInvokerCheckTimer;
|
||||||
bool mJustReset;
|
bool mJustReset;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user