mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
Fix some combat behaviour of NPC-Pets
Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
177bc78108
commit
eca3586d74
6 changed files with 22 additions and 16 deletions
|
|
@ -324,7 +324,7 @@ void Unit::Update( uint32 update_diff, uint32 p_time )
|
|||
getThreatManager().UpdateForClient(update_diff);
|
||||
|
||||
// update combat timer only for players and pets
|
||||
if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->IsPet() || ((Creature*)this)->isCharmed()))
|
||||
if (isInCombat() && GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
{
|
||||
// Check UNIT_STAT_MELEE_ATTACKING or UNIT_STAT_CHASE (without UNIT_STAT_FOLLOW in this case) so pets can reach far away
|
||||
// targets without stopping half way there and running off.
|
||||
|
|
@ -928,8 +928,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
|||
}
|
||||
|
||||
// if damage pVictim call AI reaction
|
||||
if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
|
||||
((Creature*)pVictim)->AI()->AttackedBy(this);
|
||||
pVictim->AttackedBy(this);
|
||||
}
|
||||
|
||||
if(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
|
||||
|
|
@ -2546,8 +2545,7 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
|
|||
GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
|
||||
|
||||
// if damage pVictim call AI reaction
|
||||
if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
|
||||
((Creature*)pVictim)->AI()->AttackedBy(this);
|
||||
pVictim->AttackedBy(this);
|
||||
|
||||
// extra attack only at any non extra attack (normal case)
|
||||
if(!extra && extraAttacks)
|
||||
|
|
@ -5682,6 +5680,17 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Unit::AttackedBy(Unit* attacker)
|
||||
{
|
||||
// trigger AI reaction
|
||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
|
||||
((Creature*)this)->AI()->AttackedBy(attacker);
|
||||
|
||||
// trigger pet AI reaction
|
||||
if (Pet* pet = GetPet())
|
||||
pet->AttackedBy(attacker);
|
||||
}
|
||||
|
||||
bool Unit::AttackStop(bool targetSwitch /*=false*/)
|
||||
{
|
||||
if (!m_attacking)
|
||||
|
|
@ -9995,8 +10004,7 @@ void Unit::SetFeared(bool apply, ObjectGuid casterGuid, uint32 spellID, uint32 t
|
|||
|
||||
// attack caster if can
|
||||
if (Unit* caster = IsInWorld() ? GetMap()->GetUnit(casterGuid) : NULL)
|
||||
if (c->AI())
|
||||
c->AI()->AttackedBy(caster);
|
||||
c->AttackedBy(caster);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue