diff --git a/sql/scriptdev2/scriptdev2.sql b/sql/scriptdev2/scriptdev2.sql index 0342eb2f1f..0c29c672c3 100644 --- a/sql/scriptdev2/scriptdev2.sql +++ b/sql/scriptdev2/scriptdev2.sql @@ -1249,6 +1249,7 @@ UPDATE creature_template SET ScriptName='boss_laj' WHERE entry=17980; UPDATE creature_template SET ScriptName='boss_warp_splinter' WHERE entry=17977; UPDATE creature_template SET ScriptName='mob_warp_splinter_treant' WHERE entry=19949; UPDATE creature_template SET ScriptName='boss_thorngrin' WHERE entry IN(17978); +UPDATE instance_template SET ScriptName='instance_botanica' WHERE map=553; /* THE ARCATRAZ */ UPDATE instance_template SET ScriptName='instance_arcatraz' WHERE map=552; diff --git a/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.cpp b/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.cpp index 95e9b59c04..9927ac0948 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.cpp @@ -32,18 +32,33 @@ instance_shattered_halls::instance_shattered_halls(Map* pMap) : ScriptedInstance m_team(0), m_executionStage(0), m_prisonersLeft(3), - m_legionnaireIntroTimer(1000), m_gauntletStopped(false) { Initialize(); } +enum SHHActions +{ + SHH_TRIGGER_LEGIONNAIRE, + SHH_ACTION_MAX, +}; + void instance_shattered_halls::Initialize() { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); GauntletReset(); instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_002, 0); instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_003, 0); + + // Event got triggered on wotlk classic when player moved at + // Position: X: 69.95503 Y: 124.538864 Z: -13.209421 O: 1.5825446 + auto posCheck = [](Unit const* unit) -> bool { return unit->GetPositionY() > 124.5f; }; + auto successEvent = [&]() + { + // Trigger Legionnaire group 04 and 05 + instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_003, 1); + }; + AddInstanceEvent(SHH_TRIGGER_LEGIONNAIRE, posCheck, successEvent); } void instance_shattered_halls::OnPlayerEnter(Player* pPlayer) @@ -388,25 +403,7 @@ void instance_shattered_halls::DoBeginArcherAttack(bool leftOrRight) void instance_shattered_halls::Update(uint32 diff) { - if (m_legionnaireIntroTimer) - { - if (m_legionnaireIntroTimer <= diff) - { - m_legionnaireIntroTimer = 1000; - for (const auto& data : instance->GetPlayers()) - { - // Event got triggered on wotlk classic when player moved at - // Position: X: 69.95503 Y: 124.538864 Z: -13.209421 O: 1.5825446 - if (data.getSource()->GetPositionY() > 124.5f) - { - m_legionnaireIntroTimer = 0; - // Trigger Legionnaire group 04 and 05 - instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_003, 1); - } - } - } - else m_legionnaireIntroTimer -= diff; - } + UpdateTimers(diff); if (m_auiEncounter[TYPE_GAUNTLET] == IN_PROGRESS) { @@ -551,6 +548,21 @@ void instance_shattered_halls::Update(uint32 diff) m_executionTimer -= diff; } +void instance_shattered_halls::AddInstanceEvent(uint32 id, std::function check, std::function successEvent) +{ + AddCustomAction(id, false, [instance = this->instance, check = check, successEvent = successEvent]() + { + for (const auto& data : instance->GetPlayers()) + { + if (check(data.getSource())) + { + successEvent(); + return; + } + } + }); +} + void instance_shattered_halls::FailGauntlet() { // If success despawn all, else respawn permanents diff --git a/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.h b/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.h index d368ad1d25..b322b3c970 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.h +++ b/src/game/AI/ScriptDevAI/scripts/outland/hellfire_citadel/shattered_halls/shattered_halls.h @@ -6,6 +6,7 @@ #define DEF_SHATTERED_H #include "World/WorldStateDefines.h" +#include "AI/ScriptDevAI/base/TimerAI.h" enum { @@ -121,7 +122,7 @@ static SpawnLocation aSoldiersLocs[] = {NPC_OFFICER_ALLIANCE, NPC_OFFICER_HORDE, 138.241f, -84.198f, 1.907f, 0.055f} }; -class instance_shattered_halls : public ScriptedInstance +class instance_shattered_halls : public ScriptedInstance, public TimerManager { public: instance_shattered_halls(Map* map); @@ -158,6 +159,8 @@ class instance_shattered_halls : public ScriptedInstance void Update(const uint32 diff) override; + void AddInstanceEvent(uint32 id, std::function check, std::function successEvent); + private: void DoCastGroupDebuff(uint32 spellId); void FailGauntlet(); @@ -171,7 +174,6 @@ class instance_shattered_halls : public ScriptedInstance uint32 m_team; uint8 m_executionStage; uint8 m_prisonersLeft; - uint32 m_legionnaireIntroTimer; std::vector m_gauntletPermanentGuids; GuidVector m_gauntletTemporaryGuids; diff --git a/src/game/AI/ScriptDevAI/system/ScriptLoader.cpp b/src/game/AI/ScriptDevAI/system/ScriptLoader.cpp index 568bb4cfe3..e4381c36e8 100644 --- a/src/game/AI/ScriptDevAI/system/ScriptLoader.cpp +++ b/src/game/AI/ScriptDevAI/system/ScriptLoader.cpp @@ -332,6 +332,7 @@ extern void AddSC_boss_warbringer_omrogg(); extern void AddSC_boss_warchief_kargath_bladefist(); extern void AddSC_shattered_halls(); extern void AddSC_instance_shattered_halls(); +extern void AddSC_instance_botanica(); extern void AddSC_arcatraz(); // TK, arcatraz extern void AddSC_boss_dalliah(); extern void AddSC_boss_harbinger_skyriss(); @@ -696,6 +697,7 @@ void AddScripts() AddSC_boss_warchief_kargath_bladefist(); AddSC_shattered_halls(); AddSC_instance_shattered_halls(); + AddSC_instance_botanica(); AddSC_arcatraz(); // TK, arcatraz AddSC_boss_dalliah(); AddSC_boss_harbinger_skyriss();