Jump to content

[patch][6319] Let Summoner Has Access To Minions


Guest megamage

Recommended Posts

In official like, all (as far as I know) summon effects are implemented using spells. But in current SD2, most summon effects are calling summoncreature() function. Because there are some defects for summon spells. One defect is that summoner cannot access minions. Using this patch, creature can access minions which are summoned by spells.

For example, a boss summon some minions and then need to cast some buff on these minions. Without this patch we need some complicated method to access its minions.

Index: Object.cpp
===================================================================
--- Object.cpp        (revision 6307)
+++ Object.cpp        (working copy)
@@ -1310,6 +1311,9 @@

        pCreature->Summon(spwtype, despwtime);

+        if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI())
+                ((Creature*)this)->AI()->JustSummoned(pCreature);
+
        //return the creature therewith the summoner has access to it
        return pCreature;
}
Index: CreatureAI.h
===================================================================
--- CreatureAI.h        (revision 6307)
+++ CreatureAI.h        (working copy)
@@ -68,6 +68,10 @@
                // Called when the creature kills a unit
                virtual void KilledUnit(Unit *) {}

+                virtual void JustSummoned(Creature* ) {}
+
                virtual void SummonedCreatureDespawn(Creature* /*unit*/) {}

                // Called when hit by a spell

Link to comment
Share on other sites

so for example.. i could have an npc which summons a mob.. this mob does whatever...

Using the caster script I now can check if the creature exists or is still alive ?

In the old fashioned way I would have added a function in the Minion which would send data back to the Creator.. like

void JustDied(Unit* Killer){

.
.
.
    Creature* Summoner = ((Creature*)Unit::GetUnit((*m_creature), guidofmysummoner));
    ((SummonerAI*)Summoner->AI())->minionAlive=false;
.
.
.
}

In my eyes the possibility to get rid of this workaround...would help to make many scripts simpler.. Quests like Protect me, spawn x mobs, if all mobs are dead, alright.. and stuff xD

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