Jump to content

[patch]MiniPet OwnerKilledUnit


Guest anti-freak

Recommended Posts

What bug does the patch fix?

There are some quest where you have to kill creatures for a minipet (to feed it or something like that). I found some code parts in SD2 which are not supported in mangos (function not called).

I added a call in the dealdamage function, and a prototype in the creatureAI class.

Who has been writing this patch?

me

diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h
index 60b619c..141ba27 100644
--- a/src/game/CreatureAI.h
+++ b/src/game/CreatureAI.h
@@ -101,6 +101,9 @@ class MANGOS_DLL_SPEC CreatureAI
        // Called when the creature kills a unit
        virtual void KilledUnit(Unit *) {}

+        // Called when its owner kills a unit
+        virtual void OwnerKilledUnit(Unit* /*pVictim*/) {}
+
        // Called when the creature summon successfully other creature
        virtual void JustSummoned(Creature* ) {}

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 4ce0ade..d43c622 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -785,6 +785,13 @@ 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);
+        // Call OwnerKilledUnit for MiniPets
+        else if(GetTypeId() == TYPEID_PLAYER)
+        {
+            Player *pPlayer = dynamic_cast<Player*>(this);
+            if (pPlayer && pPlayer->GetMiniPet())
+                pPlayer->GetMiniPet()->AI()->OwnerKilledUnit(pVictim);
+        }

        // 10% durability loss on death
        // clean InHateListOf

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use