Core/Creatures: moved summon AI hooks to SummonInfo API

This commit is contained in:
Ovahlord committed 2025-08-23 08:08:02 +02:00
1 parent a4551319fe
commit 73effb91ad
3 files changed
+20 -16

No files matched your search

+4 -10
View File
@@ -337,17 +337,11 @@ void Creature::RemoveFromWorld()
// If the creature about to despawn, unregister it for the summoner
if (SummonInfo* summonInfo = GetSummonInfo())
{
if (Unit* summoner = summonInfo->GetUnitSummoner())
{
summoner->UnregisterSummon(summonInfo);
// Perform cleanup actions if needed
summonInfo->HandlePreUnsummonActions();
if (summonInfo->GetControl() == SummonPropertiesControl::Pet)
{
summoner->SetPetGUID(ObjectGuid::Empty);
//if (Player* playerSummoner = summoner->ToPlayer())
// playerSummoner->SendRemoveControlBar();
}
}
if (Unit* summoner = summonInfo->GetUnitSummoner())
summoner->UnregisterSummon(summonInfo);
}
if (GetZoneScript())
@@ -19,6 +19,7 @@
#include "CharmInfo.h"
#include "Creature.h"
#include "CreatureAI.h"
#include "DBCEnums.h"
#include "DBCStores.h"
#include "Log.h"
@@ -156,10 +157,12 @@ void SummonInfo::HandlePreSummonActions()
void SummonInfo::HandlePostSummonActions()
{
// Register Pet and enable its control
if (_control == SummonPropertiesControl::Pet)
Unit* summoner = GetUnitSummoner();
if (summoner)
{
if (Unit* summoner = GetUnitSummoner())
// Register Pet and enable its control
if (_control == SummonPropertiesControl::Pet)
{
_summonedCreature->SetOwnerGUID(summoner->GetGUID());
@@ -176,6 +179,13 @@ void SummonInfo::HandlePostSummonActions()
}
}
}
// Infoke JustSummoned and IsSummonedBy AI hooks
if (summoner->IsCreature() && summoner->IsAIEnabled())
summoner->ToCreature()->AI()->JustSummoned(_summonedCreature);
if (_summonedCreature->IsAIEnabled())
_summonedCreature->AI()->IsSummonedBy(summoner);
}
}
@@ -192,6 +202,9 @@ void SummonInfo::HandlePreUnsummonActions()
if (Player* player = summoner->ToPlayer())
player->SendRemoveControlBar();
}
if (summoner->IsCreature() && summoner->IsAIEnabled())
summoner->ToCreature()->AI()->SummonedCreatureDespawn(_summonedCreature);
}
void SummonInfo::UpdateRemainingDuration(Milliseconds deltaTime)
-3
View File
@@ -8863,9 +8863,6 @@ void Unit::UnregisterSummon(SummonInfo* summon)
if (!summon)
return;
// Perform cleanup actions if needed
summon->HandlePreUnsummonActions();
SummonPropertiesSlot slot = summon->GetSummonSlot();
if (slot == SummonPropertiesSlot::None)
{