feat(Core/Scripting): Implement AfterInstanceGameObjectCreate() global hook (#17935)
This commit is contained in:
@@ -70,6 +70,7 @@ void InstanceScript::OnGameObjectCreate(GameObject* go)
|
|||||||
{
|
{
|
||||||
AddObject(go);
|
AddObject(go);
|
||||||
AddDoor(go);
|
AddDoor(go);
|
||||||
|
sScriptMgr->AfterInstanceGameObjectCreate(instance, go);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceScript::OnGameObjectRemove(GameObject* go)
|
void InstanceScript::OnGameObjectRemove(GameObject* go)
|
||||||
|
|||||||
@@ -232,6 +232,20 @@ void ScriptMgr::OnBeforeSetBossState(uint32 id, EncounterState newState, Encount
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when a game object is created inside an instance
|
||||||
|
*
|
||||||
|
* @param instance A pointer to the [map] object of the instance
|
||||||
|
* @param go The object being added
|
||||||
|
*/
|
||||||
|
void ScriptMgr::AfterInstanceGameObjectCreate(Map* instance, GameObject* go)
|
||||||
|
{
|
||||||
|
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||||
|
{
|
||||||
|
script->AfterInstanceGameObjectCreate(instance, go);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
GlobalScript::GlobalScript(const char* name)
|
GlobalScript::GlobalScript(const char* name)
|
||||||
: ScriptObject(name)
|
: ScriptObject(name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ public:
|
|||||||
|
|
||||||
// Called when any raid boss has their state updated (e.g. pull, reset, kill)
|
// Called when any raid boss has their state updated (e.g. pull, reset, kill)
|
||||||
virtual void OnBeforeSetBossState(uint32 /*id*/, EncounterState /*newState*/, EncounterState /*oldState*/, Map* /*instance*/) { }
|
virtual void OnBeforeSetBossState(uint32 /*id*/, EncounterState /*newState*/, EncounterState /*oldState*/, Map* /*instance*/) { }
|
||||||
|
|
||||||
|
// Called when a gameobject is created by an instance
|
||||||
|
virtual void AfterInstanceGameObjectCreate(Map* /*instance*/, GameObject* /*go*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -518,6 +518,7 @@ public: /* GlobalScript */
|
|||||||
bool OnAllowedToLootContainerCheck(Player const* player, ObjectGuid source);
|
bool OnAllowedToLootContainerCheck(Player const* player, ObjectGuid source);
|
||||||
void OnInstanceIdRemoved(uint32 instanceId);
|
void OnInstanceIdRemoved(uint32 instanceId);
|
||||||
void OnBeforeSetBossState(uint32 id, EncounterState newState, EncounterState oldState, Map* instance);
|
void OnBeforeSetBossState(uint32 id, EncounterState newState, EncounterState oldState, Map* instance);
|
||||||
|
void AfterInstanceGameObjectCreate(Map* instance, GameObject* go);
|
||||||
|
|
||||||
public: /* Scheduled scripts */
|
public: /* Scheduled scripts */
|
||||||
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
||||||
|
|||||||
Reference in New Issue
Block a user