[9506] Add missing AI calls to inform summoner of summon-related events

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-03-03 00:24:34 +01:00
parent 3a5f6ff0fb
commit d775eea9a4
4 changed files with 20 additions and 2 deletions

View file

@ -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)

View file

@ -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();

View file

@ -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())

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9505"
#define REVISION_NR "9506"
#endif // __REVISION_NR_H__