Core/Scenarios: Allow scripts to set instance scenario by id (#31104)

* add example at Stratholme service entrance
This commit is contained in:
Jason Dove
2025-07-08 22:26:37 +00:00
committed by GitHub
parent 04d44bd3a0
commit c7f5696479
8 changed files with 58 additions and 18 deletions

View File

@@ -33,7 +33,9 @@ EndContentData */
#include "GameObject.h"
#include "GameObjectAI.h"
#include "Group.h"
#include "ScenarioMgr.h"
#include "InstanceScript.h"
#include "Map.h"
#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "Player.h"
@@ -388,6 +390,25 @@ class spell_stratholme_haunting_phantoms : public AuraScript
}
};
static constexpr uint32 StratholmeLfgDungeonServiceEntrance = 274;
static constexpr uint32 StratholmeScenarioServiceEntrance = 637;
// 10107 - Areatrigger
class at_stratholme_service_entrance : public OnlyOnceAreaTriggerScript
{
public:
at_stratholme_service_entrance() : OnlyOnceAreaTriggerScript("at_stratholme_service_entrance") { }
bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
{
if (InstanceMap* map = player->GetMap()->ToInstanceMap())
if (map->GetLfgDungeonsId() == StratholmeLfgDungeonServiceEntrance)
map->SetInstanceScenario(sScenarioMgr->CreateInstanceScenario(map, StratholmeScenarioServiceEntrance));
return true;
}
};
void AddSC_stratholme()
{
new go_gauntlet_gate();
@@ -395,4 +416,5 @@ void AddSC_stratholme()
new npc_spectral_ghostly_citizen();
RegisterSpellScript(spell_ysida_saved_credit);
RegisterSpellScript(spell_stratholme_haunting_phantoms);
new at_stratholme_service_entrance();
}