mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +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
|
|
@ -1766,7 +1766,8 @@ void Creature::SendAIReaction(AiReaction reactionType)
|
||||||
|
|
||||||
void Creature::CallAssistance()
|
void Creature::CallAssistance()
|
||||||
{
|
{
|
||||||
if( !m_AlreadyCallAssistance && getVictim() && !IsPet() && !isCharmed())
|
// FIXME: should player pets call for assistance?
|
||||||
|
if (!m_AlreadyCallAssistance && getVictim() && !isCharmed())
|
||||||
{
|
{
|
||||||
SetNoCallAssistance(true);
|
SetNoCallAssistance(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1226,7 +1226,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, uint32 effectMask)
|
||||||
unit->SetStandState(UNIT_STAND_STATE_STAND);
|
unit->SetStandState(UNIT_STAND_STATE_STAND);
|
||||||
|
|
||||||
if (!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI())
|
if (!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI())
|
||||||
((Creature*)unit)->AI()->AttackedBy(realCaster);
|
unit->AttackedBy(realCaster);
|
||||||
|
|
||||||
unit->AddThreat(realCaster);
|
unit->AddThreat(realCaster);
|
||||||
unit->SetInCombatWith(realCaster);
|
unit->SetInCombatWith(realCaster);
|
||||||
|
|
|
||||||
|
|
@ -4005,9 +4005,7 @@ void Aura::HandleModPossess(bool apply, bool Real)
|
||||||
if(target->GetTypeId() == TYPEID_UNIT)
|
if(target->GetTypeId() == TYPEID_UNIT)
|
||||||
{
|
{
|
||||||
((Creature*)target)->AIM_Initialize();
|
((Creature*)target)->AIM_Initialize();
|
||||||
|
target->AttackedBy(caster);
|
||||||
if (((Creature*)target)->AI())
|
|
||||||
((Creature*)target)->AI()->AttackedBy(caster);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4200,8 +4198,7 @@ void Aura::HandleModCharm(bool apply, bool Real)
|
||||||
if(target->GetTypeId() == TYPEID_UNIT)
|
if(target->GetTypeId() == TYPEID_UNIT)
|
||||||
{
|
{
|
||||||
((Creature*)target)->AIM_Initialize();
|
((Creature*)target)->AIM_Initialize();
|
||||||
if (((Creature*)target)->AI())
|
target->AttackedBy(caster);
|
||||||
((Creature*)target)->AI()->AttackedBy(caster);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5061,8 +5061,7 @@ void Spell::EffectPickPocket(SpellEffectIndex /*eff_idx*/)
|
||||||
{
|
{
|
||||||
// Reveal action + get attack
|
// Reveal action + get attack
|
||||||
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||||
if (((Creature*)unitTarget)->AI())
|
unitTarget->AttackedBy(m_caster);
|
||||||
((Creature*)unitTarget)->AI()->AttackedBy(m_caster);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ void Unit::Update( uint32 update_diff, uint32 p_time )
|
||||||
getThreatManager().UpdateForClient(update_diff);
|
getThreatManager().UpdateForClient(update_diff);
|
||||||
|
|
||||||
// update combat timer only for players and pets
|
// 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
|
// 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.
|
// 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 damage pVictim call AI reaction
|
||||||
if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
|
pVictim->AttackedBy(this);
|
||||||
((Creature*)pVictim)->AI()->AttackedBy(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
|
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);
|
GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
|
||||||
|
|
||||||
// if damage pVictim call AI reaction
|
// if damage pVictim call AI reaction
|
||||||
if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
|
pVictim->AttackedBy(this);
|
||||||
((Creature*)pVictim)->AI()->AttackedBy(this);
|
|
||||||
|
|
||||||
// extra attack only at any non extra attack (normal case)
|
// extra attack only at any non extra attack (normal case)
|
||||||
if(!extra && extraAttacks)
|
if(!extra && extraAttacks)
|
||||||
|
|
@ -5682,6 +5680,17 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
|
||||||
return true;
|
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*/)
|
bool Unit::AttackStop(bool targetSwitch /*=false*/)
|
||||||
{
|
{
|
||||||
if (!m_attacking)
|
if (!m_attacking)
|
||||||
|
|
@ -9995,8 +10004,7 @@ void Unit::SetFeared(bool apply, ObjectGuid casterGuid, uint32 spellID, uint32 t
|
||||||
|
|
||||||
// attack caster if can
|
// attack caster if can
|
||||||
if (Unit* caster = IsInWorld() ? GetMap()->GetUnit(casterGuid) : NULL)
|
if (Unit* caster = IsInWorld() ? GetMap()->GetUnit(casterGuid) : NULL)
|
||||||
if (c->AI())
|
c->AttackedBy(caster);
|
||||||
c->AI()->AttackedBy(caster);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1152,6 +1152,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
bool Attack(Unit *victim, bool meleeAttack);
|
bool Attack(Unit *victim, bool meleeAttack);
|
||||||
|
void AttackedBy(Unit* attacker);
|
||||||
void CastStop(uint32 except_spellid = 0);
|
void CastStop(uint32 except_spellid = 0);
|
||||||
bool AttackStop(bool targetSwitch = false);
|
bool AttackStop(bool targetSwitch = false);
|
||||||
void RemoveAllAttackers();
|
void RemoveAllAttackers();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue