mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +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
|
||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
|
||||
{
|
||||
((Creature*)this)->AI()->KilledUnit(pVictim);
|
||||
}
|
||||
else if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Call AI OwnerKilledUnit (for any current summoned minipet/guardian/protector)
|
||||
PetOwnerKilledUnit(pVictim);
|
||||
|
||||
// achievement stuff
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
|
|
@ -1082,6 +1074,27 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
|||
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)
|
||||
{
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue