feat(Core/GameObject): Expand IsSummonedBy() to GameObjects (#14789)
Co-authored-by: jackpoz <giacomopoz@gmail.com>
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "TemporarySummon.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "GameObject.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Pet.h"
|
||||
@@ -250,11 +252,23 @@ void TempSummon::InitStats(uint32 duration)
|
||||
|
||||
void TempSummon::InitSummon()
|
||||
{
|
||||
Unit* owner = GetSummonerUnit();
|
||||
WorldObject* owner = GetSummoner();
|
||||
if (owner)
|
||||
{
|
||||
if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
||||
owner->ToCreature()->AI()->JustSummoned(this);
|
||||
if (owner->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
if (owner->ToCreature()->IsAIEnabled)
|
||||
{
|
||||
owner->ToCreature()->AI()->JustSummoned(this);
|
||||
}
|
||||
}
|
||||
else if (owner->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
if (owner->ToGameObject()->AI())
|
||||
{
|
||||
owner->ToGameObject()->AI()->JustSummoned(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Xinef: Allow to call this hook when npc is summoned by gameobject, in this case pass this as summoner to avoid possible null checks
|
||||
@@ -290,9 +304,17 @@ void TempSummon::UnSummon(uint32 msTime)
|
||||
return;
|
||||
}
|
||||
|
||||
Unit* owner = GetSummonerUnit();
|
||||
if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
||||
owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
|
||||
if (WorldObject* owner = GetSummoner())
|
||||
{
|
||||
if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
||||
{
|
||||
owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
|
||||
}
|
||||
else if (owner->GetTypeId() == TYPEID_GAMEOBJECT && owner->ToGameObject()->AI())
|
||||
{
|
||||
owner->ToGameObject()->AI()->SummonedCreatureDespawn(this);
|
||||
}
|
||||
}
|
||||
|
||||
AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user