From 93fe2eebddb1be24dd5fc2af20a646203230f721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E4=BD=A9=E8=8C=B9?= Date: Sat, 10 Sep 2022 22:07:05 -0600 Subject: [PATCH] Script Scarab Gong (ported from Vmangos) --- sql/world/base/zone_silithus.sql | 20 ++- src/IndividualProgression.cpp | 1 + src/IndividualProgression.h | 1 - src/IndividualProgression_loader.cpp | 2 + src/vanillaScripts/aq_scripts.cpp | 195 +++++++++++++++++++++++++++ 5 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 src/vanillaScripts/aq_scripts.cpp diff --git a/sql/world/base/zone_silithus.sql b/sql/world/base/zone_silithus.sql index 8d7b90e..b629ae6 100644 --- a/sql/world/base/zone_silithus.sql +++ b/sql/world/base/zone_silithus.sql @@ -10,9 +10,9 @@ INSERT INTO `gameobject` (`id`, `map`, `position_x`, `position_y`, `position_z`, DELETE FROM `gameobject` WHERE `id`=176148; INSERT INTO `gameobject` (`id`, `map`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES (176148, 1, -8133.34, 1525.13, 17.1904, 6.28103, 0.00107995, -0.999999, 600, 100, 1); --- Ghost Gate +-- Ghost Gate - should not be placed, remove it if it is present DELETE FROM `gameobject` WHERE `id`=180322; -INSERT INTO `gameobject` (`id`, `map`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES (180322, 1, -8132.76, 1525.19, 6.19048, 6.27739, 0.00289526, -0.999996, 25, 100, 1); +# INSERT INTO `gameobject` (`id`, `map`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES (180322, 1, -8132.76, 1525.19, 6.19048, 6.27739, 0.00289526, -0.999996, 25, 100, 1); -- Gate of Ahn'Qiraj UPDATE `gameobject_template_addon` SET `flags`=4 WHERE `entry`=176146; @@ -21,4 +21,18 @@ UPDATE `gameobject_template_addon` SET `flags`=4 WHERE `entry`=176146; UPDATE `gameobject_template_addon` SET `flags`=4 WHERE `entry`=176147; -- Ahn'Qiraj Gate Runes -UPDATE `gameobject_template_addon` SET `flags`=4 WHERE `entry`=176148; \ No newline at end of file +UPDATE `gameobject_template_addon` SET `flags`=4 WHERE `entry`=176148; + +-- Scarab Gong +-- See related AC PR: https://github.com/azerothcore/azerothcore-wotlk/pull/12879/files +UPDATE `gameobject_template` SET `type` = 2, `ScriptName` = "gobject_scarab_gong" WHERE `entry` = 180717; +UPDATE `gameobject` SET `id` = 180717 WHERE `guid` = 49451; +DELETE FROM `gameobject_questender` WHERE `quest`=8743; +INSERT INTO `gameobject_questender` (`id`, `quest`) VALUES (180717, 8743); +DELETE FROM `gameobject_queststarter` WHERE `quest`=8743; +INSERT INTO `gameobject_queststarter` (`id`, `quest`) VALUES (180717, 8743); + +SET @STRING_ENTRY := 41100; +DELETE FROM `acore_string` WHERE `entry` IN (@STRING_ENTRY); +INSERT INTO `acore_string` (`entry`, `content_default`) VALUES +(@STRING_ENTRY, '%s, Champion of the Bronze Dragonflight, has rung the Scarab Gong. The ancient gates of Ahn''Qiraj open, revealing the horrors of a forgotten war...'); diff --git a/src/IndividualProgression.cpp b/src/IndividualProgression.cpp index f81b28c..e01c936 100644 --- a/src/IndividualProgression.cpp +++ b/src/IndividualProgression.cpp @@ -6,6 +6,7 @@ static float vanillaPowerAdjustment, vanillaHealthAdjustment, tbcPowerAdjustment, tbcHealthAdjustment, vanillaHealingAdjustment, tbcHealingAdjustment, previousGearTuning; static bool enabled, questXpFix, hunterPetLevelFix, requirePreAQQuests, enforceGroupRules, fishingFix; +static questXpMapType questXpMap; class gobject_ipp_wotlk : public GameObjectScript { diff --git a/src/IndividualProgression.h b/src/IndividualProgression.h index 81e910c..1859028 100644 --- a/src/IndividualProgression.h +++ b/src/IndividualProgression.h @@ -16,7 +16,6 @@ #include "GameObject.h" typedef std::unordered_map questXpMapType; -questXpMapType questXpMap; enum ProgressionBossIDs { diff --git a/src/IndividualProgression_loader.cpp b/src/IndividualProgression_loader.cpp index 3124f51..f25bb9d 100644 --- a/src/IndividualProgression_loader.cpp +++ b/src/IndividualProgression_loader.cpp @@ -31,6 +31,7 @@ void AddSC_boss_sapphiron_40(); void AddSC_boss_thaddius_40(); void AddSC_npc_omarion(); void AddSC_Ipp_Wotlk_Modded_Scripts(); +void AddSC_aq_scripts(); void Addmod_individual_progressionScripts() @@ -63,5 +64,6 @@ void Addmod_individual_progressionScripts() AddSC_boss_thaddius_40(); AddSC_npc_omarion(); AddSC_Ipp_Wotlk_Modded_Scripts(); + AddSC_aq_scripts(); } diff --git a/src/vanillaScripts/aq_scripts.cpp b/src/vanillaScripts/aq_scripts.cpp new file mode 100644 index 0000000..cbec53a --- /dev/null +++ b/src/vanillaScripts/aq_scripts.cpp @@ -0,0 +1,195 @@ +#include "ScriptMgr.h" +#include "Player.h" +#include "GameObjectAI.h" +#include "ScriptedCreature.h" +#include "ScriptedGossip.h" + +enum +{ + QUEST_BANG_A_GONG = 8743, + + GO_GATE_OF_AHN_QIRAJ = 176146, + GO_GLYPH_OF_AHN_QIRAJ = 176148, + GO_ROOTS_OF_AHN_QIRAJ = 176147, + GO_AQ_GHOST_GATE = 180322, + + GLOBAL_TEXT_CHAMPION = 41100, + + SOUND_ROOTS_OPEN = 7114, + SOUND_DOOR_OPEN = 7115, + SOUND_RUNES_OPEN = 7116, + + STAGE_OPEN_GATES = 0, + STAGE_WAR = 1, + STAGE_RESET = 2 +}; + +class gobject_scarab_gong : public GameObjectScript +{ +private: + +public: + gobject_scarab_gong() : GameObjectScript("gobject_scarab_gong") + {} + + struct gobject_scarab_gongAI : GameObjectAI + { + uint32 eventTimer; + uint32 eventStep; + uint32 eventStage; + + GameObject *go_aq_barrier; + GameObject *go_aq_gate_runes; + GameObject *go_aq_gate_roots; + // Invisible AQ barrier - removed by server during event, but we are allow event to repeat, so we do not place it +// GameObject *go_aq_ghost_gate; + + explicit gobject_scarab_gongAI(GameObject *object) : GameObjectAI(object) + { + eventTimer = 0; + eventStep = 0; + eventStage = STAGE_OPEN_GATES; + // The Gong normally needs the quest active to interact, but we need to make it available for players to re-use + me->RemoveGameObjectFlag(GO_FLAG_INTERACT_COND); + }; + + void UpdateAI(uint32 diff) override + { + if (eventTimer) + { + if (eventTimer <= diff) + { + switch (eventStage) + { + case STAGE_OPEN_GATES: + return HandleOpeningStage(); + case STAGE_WAR: + return HandleWarStage(); + case STAGE_RESET: + return ResetAQGates(); + } + } else + eventTimer -= diff; + } + }; + + void NextStage(uint32 timeUntil = 100) + { + eventStage++; + eventStep = 0; + eventTimer = timeUntil; + } + + void HandleOpeningStage() + { + switch (eventStep) + { + case 0: + go_aq_gate_roots->ResetDoorOrButton(); + go_aq_gate_roots->UseDoorOrButton(); + me->PlayDirectSound(SOUND_ROOTS_OPEN); + + eventTimer = 5000; + break; + + case 1: + go_aq_gate_runes->ResetDoorOrButton(); + go_aq_gate_runes->UseDoorOrButton(); + me->PlayDirectSound(SOUND_RUNES_OPEN); + + eventTimer = 8000; + break; + case 2: + go_aq_barrier->ResetDoorOrButton(); + go_aq_barrier->UseDoorOrButton(); + me->PlayDirectSound(SOUND_DOOR_OPEN); + + NextStage(10000); + return; + } + + eventStep++; + } + + void HandleWarStage() + { + // Not handled in Individual Progression, so we go right to resetting the gate timer + NextStage(5 * MINUTE * IN_MILLISECONDS); + } + + void EventDone() + { + NextStage(0); + eventStage = STAGE_OPEN_GATES; + } + + void ResetAQGates() + { +// go_aq_ghost_gate->SetGoState(GO_STATE_READY); + go_aq_barrier->SetGoState(GO_STATE_READY); + go_aq_gate_runes->SetGoState(GO_STATE_READY); + go_aq_gate_roots->ResetDoorOrButton(); + go_aq_gate_roots->SetGoState(GO_STATE_READY); + + EventDone(); + } + + void OpenGate(Player *player, bool announce) + { + go_aq_barrier = GetClosestGameObjectWithEntry(me, GO_GATE_OF_AHN_QIRAJ, 150); + go_aq_gate_runes = GetClosestGameObjectWithEntry(me, GO_GLYPH_OF_AHN_QIRAJ, 150); + go_aq_gate_roots = GetClosestGameObjectWithEntry(me, GO_ROOTS_OF_AHN_QIRAJ, 150); +// go_aq_ghost_gate = GetClosestGameObjectWithEntry(me, GO_AQ_GHOST_GATE, 150); + + if (!go_aq_barrier || !go_aq_gate_runes || !go_aq_gate_roots) + return; + + // The door is already open - don't open it again + if (go_aq_barrier->GetGoState() == GO_STATE_ACTIVE) + return; + + if (announce) + sWorld->SendWorldText(GLOBAL_TEXT_CHAMPION, player->GetName().c_str()); + + eventTimer += 1000; + eventStage = STAGE_OPEN_GATES; + } + }; + + GameObjectAI *GetAI(GameObject *object) const override + { + return new gobject_scarab_gongAI(object); + } + + bool OnQuestReward(Player *player, GameObject *go, Quest const *quest, uint32 opt) override + { + if (quest->GetQuestId() != QUEST_BANG_A_GONG) + return false; + + if (auto *gongAI = dynamic_cast(go->AI())) + gongAI->OpenGate(player, true); + + return true; + } + + bool OnGossipHello(Player* player, GameObject* go) override + { + if (player->GetQuestStatus(QUEST_BANG_A_GONG) == QUEST_STATUS_REWARDED) + { + if (auto *gongAI = dynamic_cast(go->AI())) + gongAI->OpenGate(player, false); + } + else + { + player->PrepareQuestMenu(go->GetGUID()); + player->SendPreparedQuest(go->GetGUID()); + } + return true; + } +}; + +void AddSC_aq_scripts() +{ + new gobject_scarab_gong(); +} +