mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[10778] Make AI call OwnerKilledUnit() more proper.
Affect any pet that are not being controlled (minipet/guardian/protector) and will also apply to pets owned by another creature. Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
962acb5198
commit
0c85afea79
3 changed files with 27 additions and 12 deletions
|
|
@ -785,18 +785,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||||
|
|
||||||
// Call KilledUnit for creatures
|
// Call KilledUnit for creatures
|
||||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
|
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
|
||||||
{
|
|
||||||
((Creature*)this)->AI()->KilledUnit(pVictim);
|
((Creature*)this)->AI()->KilledUnit(pVictim);
|
||||||
}
|
|
||||||
else if (GetTypeId() == TYPEID_PLAYER)
|
// Call AI OwnerKilledUnit (for any current summoned minipet/guardian/protector)
|
||||||
{
|
PetOwnerKilledUnit(pVictim);
|
||||||
// currently not known if other pet types (not controllable) may have some action at owner kills
|
|
||||||
if (Pet* pProtector = GetProtectorPet())
|
|
||||||
{
|
|
||||||
if (pProtector->AI())
|
|
||||||
pProtector->AI()->OwnerKilledUnit(pVictim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// achievement stuff
|
// achievement stuff
|
||||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||||
|
|
@ -1082,6 +1074,27 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PetOwnerKilledUnitHelper
|
||||||
|
{
|
||||||
|
explicit PetOwnerKilledUnitHelper(Unit* pVictim) : m_victim(pVictim) {}
|
||||||
|
void operator()(Unit* pTarget) const
|
||||||
|
{
|
||||||
|
if (pTarget->GetTypeId() == TYPEID_UNIT)
|
||||||
|
{
|
||||||
|
if (((Creature*)pTarget)->AI())
|
||||||
|
((Creature*)pTarget)->AI()->OwnerKilledUnit(m_victim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Unit* m_victim;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Unit::PetOwnerKilledUnit(Unit* pVictim)
|
||||||
|
{
|
||||||
|
// for minipet and guardians (including protector)
|
||||||
|
CallForAllControlledUnits(PetOwnerKilledUnitHelper(pVictim), CONTROLLED_MINIPET|CONTROLLED_GUARDIANS);
|
||||||
|
}
|
||||||
|
|
||||||
void Unit::CastStop(uint32 except_spellid)
|
void Unit::CastStop(uint32 except_spellid)
|
||||||
{
|
{
|
||||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
|
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
|
||||||
|
|
|
||||||
|
|
@ -1327,6 +1327,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss);
|
uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss);
|
||||||
int32 DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical = false, uint32 absorb = 0);
|
int32 DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical = false, uint32 absorb = 0);
|
||||||
|
|
||||||
|
void PetOwnerKilledUnit(Unit* pVictim);
|
||||||
|
|
||||||
void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL);
|
void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL);
|
||||||
void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage );
|
void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10777"
|
#define REVISION_NR "10778"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue