mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 10:37:02 +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
|
|
@ -145,7 +145,10 @@ void PetAI::UpdateAI(const uint32 diff)
|
|||
_stopAttack();
|
||||
return;
|
||||
}
|
||||
else if (m_creature->IsStopped() || m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
|
||||
|
||||
bool meleeReach = m_creature->CanReachWithMeleeAttack(m_creature->getVictim());
|
||||
|
||||
if (m_creature->IsStopped() || meleeReach)
|
||||
{
|
||||
// required to be stopped cases
|
||||
if (m_creature->IsStopped() && m_creature->IsNonMeleeSpellCasted(false))
|
||||
|
|
@ -156,7 +159,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
|||
return;
|
||||
}
|
||||
// not required to be stopped case
|
||||
else if (m_creature->isAttackReady() && m_creature->canReachWithAttack(m_creature->getVictim()))
|
||||
else if (m_creature->isAttackReady() && meleeReach)
|
||||
{
|
||||
m_creature->AttackerStateUpdate(m_creature->getVictim());
|
||||
|
||||
|
|
@ -168,7 +171,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
|||
//if pet misses its target, it will also be the first in threat list
|
||||
m_creature->getVictim()->AddThreat(m_creature);
|
||||
|
||||
if( _needToStop() )
|
||||
if (_needToStop())
|
||||
_stopAttack();
|
||||
}
|
||||
}
|
||||
|
|
@ -350,6 +353,6 @@ void PetAI::AttackedBy(Unit *attacker)
|
|||
{
|
||||
//when attacked, fight back in case 1)no victim already AND 2)not set to passive AND 3)not set to stay, unless can it can reach attacker with melee attack anyway
|
||||
if(!m_creature->getVictim() && m_creature->GetCharmInfo() && !m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE) &&
|
||||
(!m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY) || m_creature->canReachWithAttack(attacker)))
|
||||
(!m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY) || m_creature->CanReachWithMeleeAttack(attacker)))
|
||||
AttackStart(attacker);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue