mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
Module hook for kills performed by pets/totems (#912)
* Add hook for pet/totem kills * Use method to cast unit to creature
This commit is contained in:
@@ -16421,7 +16421,10 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
|
||||
// Do KILL and KILLED procs. KILL proc is called only for the unit who landed the killing blow (and its owner - for pets and totems) regardless of who tapped the victim
|
||||
if (killer && (killer->IsPet() || killer->IsTotem()))
|
||||
if (Unit* owner = killer->GetOwner())
|
||||
{
|
||||
owner->ProcDamageAndSpell(victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_EX_NONE, 0, attackType, spellProto);
|
||||
sScriptMgr->OnCreatureKilledByPet( killer->GetCharmerOrOwnerPlayerOrPlayerItself(), victim->ToCreature());
|
||||
}
|
||||
|
||||
if (killer != victim && !victim->IsCritter())
|
||||
killer->ProcDamageAndSpell(victim, killer ? PROC_FLAG_KILL : 0, PROC_FLAG_KILLED, PROC_EX_NONE, 0, attackType, spellProto);
|
||||
|
||||
@@ -1383,6 +1383,11 @@ void ScriptMgr::OnCreatureKill(Player* killer, Creature* killed)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnCreatureKill(killer, killed);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnCreatureKilledByPet(Player* petOwner, Creature* killed)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnCreatureKilledByPet(petOwner, killed);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerKilledByCreature(Creature* killer, Player* killed)
|
||||
{
|
||||
#ifdef ELUNA
|
||||
|
||||
@@ -780,6 +780,9 @@ class PlayerScript : public ScriptObject
|
||||
// Called when a player kills a creature
|
||||
virtual void OnCreatureKill(Player* /*killer*/, Creature* /*killed*/) { }
|
||||
|
||||
// Called when a player's pet kills a creature
|
||||
virtual void OnCreatureKilledByPet(Player* /*PetOwner*/, Creature* /*killed*/) { }
|
||||
|
||||
// Called when a player is killed by a creature
|
||||
virtual void OnPlayerKilledByCreature(Creature* /*killer*/, Player* /*killed*/) { }
|
||||
|
||||
@@ -1227,6 +1230,7 @@ class ScriptMgr
|
||||
void OnPlayerReleasedGhost(Player* player);
|
||||
void OnPVPKill(Player* killer, Player* killed);
|
||||
void OnCreatureKill(Player* killer, Creature* killed);
|
||||
void OnCreatureKilledByPet(Player* petOwner, Creature* killed);
|
||||
void OnPlayerKilledByCreature(Creature* killer, Player* killed);
|
||||
void OnPlayerLevelChanged(Player* player, uint8 oldLevel);
|
||||
void OnPlayerFreeTalentPointsChanged(Player* player, uint32 newPoints);
|
||||
|
||||
Reference in New Issue
Block a user