mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +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
|
// 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 (killer && (killer->IsPet() || killer->IsTotem()))
|
||||||
if (Unit* owner = killer->GetOwner())
|
if (Unit* owner = killer->GetOwner())
|
||||||
|
{
|
||||||
owner->ProcDamageAndSpell(victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_EX_NONE, 0, attackType, spellProto);
|
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())
|
if (killer != victim && !victim->IsCritter())
|
||||||
killer->ProcDamageAndSpell(victim, killer ? PROC_FLAG_KILL : 0, PROC_FLAG_KILLED, PROC_EX_NONE, 0, attackType, spellProto);
|
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);
|
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)
|
void ScriptMgr::OnPlayerKilledByCreature(Creature* killer, Player* killed)
|
||||||
{
|
{
|
||||||
#ifdef ELUNA
|
#ifdef ELUNA
|
||||||
|
|||||||
@@ -780,6 +780,9 @@ class PlayerScript : public ScriptObject
|
|||||||
// Called when a player kills a creature
|
// Called when a player kills a creature
|
||||||
virtual void OnCreatureKill(Player* /*killer*/, Creature* /*killed*/) { }
|
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
|
// Called when a player is killed by a creature
|
||||||
virtual void OnPlayerKilledByCreature(Creature* /*killer*/, Player* /*killed*/) { }
|
virtual void OnPlayerKilledByCreature(Creature* /*killer*/, Player* /*killed*/) { }
|
||||||
|
|
||||||
@@ -1227,6 +1230,7 @@ class ScriptMgr
|
|||||||
void OnPlayerReleasedGhost(Player* player);
|
void OnPlayerReleasedGhost(Player* player);
|
||||||
void OnPVPKill(Player* killer, Player* killed);
|
void OnPVPKill(Player* killer, Player* killed);
|
||||||
void OnCreatureKill(Player* killer, Creature* killed);
|
void OnCreatureKill(Player* killer, Creature* killed);
|
||||||
|
void OnCreatureKilledByPet(Player* petOwner, Creature* killed);
|
||||||
void OnPlayerKilledByCreature(Creature* killer, Player* killed);
|
void OnPlayerKilledByCreature(Creature* killer, Player* killed);
|
||||||
void OnPlayerLevelChanged(Player* player, uint8 oldLevel);
|
void OnPlayerLevelChanged(Player* player, uint8 oldLevel);
|
||||||
void OnPlayerFreeTalentPointsChanged(Player* player, uint32 newPoints);
|
void OnPlayerFreeTalentPointsChanged(Player* player, uint32 newPoints);
|
||||||
|
|||||||
Reference in New Issue
Block a user