fix(Scripts/Outland): store creatures as GUIDs instead of raw pointers (#25642)
This commit is contained in:
@@ -469,38 +469,51 @@ public:
|
|||||||
|
|
||||||
struct go_beaconAI : public GameObjectAI
|
struct go_beaconAI : public GameObjectAI
|
||||||
{
|
{
|
||||||
go_beaconAI(GameObject* gameObject) : GameObjectAI(gameObject) { }
|
explicit go_beaconAI(GameObject* gameObject) : GameObjectAI(gameObject) { }
|
||||||
|
|
||||||
std::list<Creature*> creatureList;
|
|
||||||
|
|
||||||
void OnStateChanged(uint32 state, Unit* /*unit*/) override
|
void OnStateChanged(uint32 state, Unit* /*unit*/) override
|
||||||
{
|
{
|
||||||
if (state == GO_ACTIVATED)
|
if (state == GO_ACTIVATED)
|
||||||
{
|
{
|
||||||
|
std::list<Creature*> creatureList;
|
||||||
|
|
||||||
|
_whelpGUIDs.clear();
|
||||||
me->GetCreaturesWithEntryInRange(creatureList, 40, NPC_STONESCHYE_WHELP);
|
me->GetCreaturesWithEntryInRange(creatureList, 40, NPC_STONESCHYE_WHELP);
|
||||||
{
|
|
||||||
for (Creature* whelp : creatureList)
|
for (Creature* whelp : creatureList)
|
||||||
{
|
{
|
||||||
if (whelp && whelp->IsAlive() && !whelp->IsInCombat() && whelp->GetMotionMaster()->GetCurrentMovementGeneratorType() != HOME_MOTION_TYPE)
|
if (!whelp)
|
||||||
whelp->GetMotionMaster()->MovePoint(0, me->GetNearPosition(4.0f, whelp->GetOrientation()));
|
continue;
|
||||||
}
|
|
||||||
|
_whelpGUIDs.push_back(whelp->GetGUID());
|
||||||
|
|
||||||
|
MotionMaster* motionMaster = whelp->GetMotionMaster();
|
||||||
|
if (whelp->IsAlive() && !whelp->IsInCombat() && motionMaster && motionMaster->GetCurrentMovementGeneratorType() != HOME_MOTION_TYPE)
|
||||||
|
motionMaster->MovePoint(0, me->GetNearPosition(4.0f, whelp->GetOrientation()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (state == GO_JUST_DEACTIVATED)
|
else if (state == GO_JUST_DEACTIVATED)
|
||||||
{
|
{
|
||||||
|
for (ObjectGuid const& guid : _whelpGUIDs)
|
||||||
{
|
{
|
||||||
for (Creature* whelp : creatureList)
|
if (Creature* whelp = ObjectAccessor::GetCreature(*me, guid))
|
||||||
{
|
{
|
||||||
if (whelp && whelp->IsAlive() && !whelp->IsInCombat() && whelp->GetMotionMaster()->GetCurrentMovementGeneratorType() != HOME_MOTION_TYPE)
|
MotionMaster* motionMaster = whelp->GetMotionMaster();
|
||||||
whelp->GetMotionMaster()->MoveTargetedHome();
|
if (whelp->IsAlive() && !whelp->IsInCombat() && motionMaster && motionMaster->GetCurrentMovementGeneratorType() != HOME_MOTION_TYPE)
|
||||||
|
motionMaster->MoveTargetedHome();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_whelpGUIDs.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
creatureList.clear();
|
_whelpGUIDs.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
GuidList _whelpGUIDs;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameObjectAI* GetAI(GameObject* go) const override
|
GameObjectAI* GetAI(GameObject* go) const override
|
||||||
|
|||||||
Reference in New Issue
Block a user