feat(Core/WorldState): improved WorldState scripting (#20141)

* implement world state script

based on
0b87ca9d9e

Co-authored-by: killerwife <killerwife@gmail.com>

* refactor to use onleave and onenter instead of spell_area

allows players to right click remove adal's buff

* add MapMgr.h

* refactor: use condition enum instead of uint32, prefix WORLD_STATE where needed

* remove lock from WorldState::Update

sWorldState->Update() is only called from World::Update

* remove unsafe SmartAI action of setWorldState

---------

Co-authored-by: killerwife <killerwife@gmail.com>
This commit is contained in:
Jelle Meeus
2024-11-12 16:15:27 +01:00
committed by GitHub
parent e80b0ce8b8
commit 3565e4a9eb
20 changed files with 785 additions and 37 deletions

View File

@@ -24,6 +24,7 @@
#include "ScriptedGossip.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
#include "WorldState.h"
enum q10935Exorcism
{
@@ -602,6 +603,26 @@ public:
}
};
struct go_magtheridons_head : public GameObjectAI
{
go_magtheridons_head(GameObject* gameObject) : GameObjectAI(gameObject) { }
void InitializeAI() override
{
me->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); // spawn head on spike
me->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
sWorldState->HandleExternalEvent(WORLD_STATE_CUSTOM_EVENT_ON_MAGTHERIDON_HEAD_SPAWN, me->GetPositionX() > 0.f ? TEAM_HORDE : TEAM_ALLIANCE);
}
void OnStateChanged(uint32 state, Unit* /*unit*/) override
{
if (state == GO_JUST_DEACTIVATED)
{
sWorldState->HandleExternalEvent(WORLD_STATE_CUSTOM_EVENT_ON_MAGTHERIDON_HEAD_DESPAWN, me->GetPositionX() > 0.f ? TEAM_HORDE : TEAM_ALLIANCE);
}
}
};
void AddSC_hellfire_peninsula()
{
// Ours
@@ -615,4 +636,5 @@ void AddSC_hellfire_peninsula()
new go_beacon();
RegisterCreatureAI(npc_magister_aledis);
RegisterGameObjectAI(go_magtheridons_head);
}