diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 532d6bc08..d2ede363e 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3859,6 +3859,9 @@ void Spell::DoSummon(SpellEffectIndex eff_idx) spawnCreature->SavePetToDB(PET_SAVE_AS_CURRENT); ((Player*)m_caster)->PetSpellInitialize(); } + + if (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) + ((Creature*)m_caster)->AI()->JustSummoned((Creature*)spawnCreature); } void Spell::EffectLearnSpell(SpellEffectIndex eff_idx) diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index 12130d69e..eae836fd5 100644 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -23,6 +23,7 @@ #include "Player.h" #include "ObjectMgr.h" #include "SpellMgr.h" +#include "CreatureAI.h" Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM) { @@ -67,6 +68,9 @@ void Totem::Summon(Unit* owner) AIM_Initialize(); + if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI()) + ((Creature*)owner)->AI()->JustSummoned((Creature*)this); + // there are some totems, which exist just for their visual appeareance if (!GetSpell()) return; @@ -109,6 +113,9 @@ void Totem::UnSummon() } } } + + if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI()) + ((Creature*)owner)->AI()->SummonedCreatureDespawn((Creature*)this); } AddObjectToRemoveList(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 73451e3b1..da6419e08 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -699,6 +699,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // find player: owner of controlled `this` or `this` itself maybe Player *player = GetCharmerOrOwnerPlayerOrPlayerItself(); + + // find owner of pVictim, used for creature cases, AI calls + Unit* pOwner = pVictim->GetCharmerOrOwner(); + if(pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient()) player = ((Creature*)pVictim)->GetLootRecipient(); @@ -832,7 +836,11 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (pSummoner->AI()) pSummoner->AI()->SummonedCreatureJustDied(cVictim); } - + else if (pOwner && pOwner->GetTypeId() == TYPEID_UNIT) + { + if (((Creature*)pOwner)->AI()) + ((Creature*)pOwner)->AI()->SummonedCreatureJustDied(cVictim); + } // Dungeon specific stuff, only applies to players killing creatures if(cVictim->GetInstanceId()) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index deaa47d2d..bbc4d019d 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9505" + #define REVISION_NR "9506" #endif // __REVISION_NR_H__