From 9a202dfd4a12ac115bbcadff509b8aaadad59dfd Mon Sep 17 00:00:00 2001 From: joschiwald Date: Wed, 20 Jan 2016 00:27:32 +0100 Subject: [PATCH] Scripts/ICC/Teleporter: moved gossips to db (cherry picked from commit ea38a7d95bb7d67005c7de1a924d288561b0da13) --- ...016_04_02_07_world_2016_01_20_00_world.sql | 70 ++++++++++++++++++ .../IcecrownCitadel/icecrown_citadel.h | 12 ++-- .../icecrown_citadel_teleport.cpp | 71 +++++++++---------- 3 files changed, 109 insertions(+), 44 deletions(-) create mode 100644 sql/updates/world/2016_04_02_07_world_2016_01_20_00_world.sql diff --git a/sql/updates/world/2016_04_02_07_world_2016_01_20_00_world.sql b/sql/updates/world/2016_04_02_07_world_2016_01_20_00_world.sql new file mode 100644 index 0000000000000..26ce069edd85e --- /dev/null +++ b/sql/updates/world/2016_04_02_07_world_2016_01_20_00_world.sql @@ -0,0 +1,70 @@ +DELETE FROM gossip_menu_option WHERE `menu_id` IN (11013, 11014, 11015, 11016, 11017, 11018); +INSERT INTO gossip_menu_option (`menu_id`, `id`, `option_icon`, `option_text`, `OptionBroadcastTextID`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `action_poi_id`, `box_coded`, `box_money`, `box_text`, `BoxBroadcastTextID`) VALUES +(11013, 1, 0, 'Teleport to the Oratory of the Damned.', 37722, 1, 1, 0, 0, 0, 0, '', 0), -- Light's Hammer +(11013, 3, 0, 'Teleport to the Rampart of Skulls.', 37723, 1, 1, 0, 0, 0, 0, '', 0), -- Light's Hammer +(11013, 4, 0, 'Teleport to the Deathbringer''s Rise.', 37724, 1, 1, 0, 0, 0, 0, '', 0), -- Light's Hammer +(11013, 5, 0, 'Teleport to the Upper Spire.', 37725, 1, 1, 0, 0, 0, 0, '', 0), -- Light's Hammer +(11013, 6, 0, 'Teleport to Sindragosa''s Lair.', 37728, 1, 1, 0, 0, 0, 0, '', 0), -- Light's Hammer + +(11014, 0, 0, 'Teleport to Light''s Hammer.', 37671, 1, 1, 0, 0, 0, 0, '', 0), -- Oratory of the Damned +(11014, 3, 0, 'Teleport to the Rampart of Skulls.', 37723, 1, 1, 0, 0, 0, 0, '', 0), -- Oratory of the Damned +(11014, 4, 0, 'Teleport to the Deathbringer''s Rise.', 37724, 1, 1, 0, 0, 0, 0, '', 0), -- Oratory of the Damned +(11014, 5, 0, 'Teleport to the Upper Spire.', 37725, 1, 1, 0, 0, 0, 0, '', 0), -- Oratory of the Damned +(11014, 6, 0, 'Teleport to Sindragosa''s Lair.', 37728, 1, 1, 0, 0, 0, 0, '', 0), -- Oratory of the Damned + +(11015, 0, 0, 'Teleport to Light''s Hammer.', 37671, 1, 1, 0, 0, 0, 0, '', 0), -- Rampart of Skulls +(11015, 1, 0, 'Teleport to the Oratory of the Damned.', 37722, 1, 1, 0, 0, 0, 0, '', 0), -- Rampart of Skulls +(11015, 4, 0, 'Teleport to the Deathbringer''s Rise.', 37724, 1, 1, 0, 0, 0, 0, '', 0), -- Rampart of Skulls +(11015, 5, 0, 'Teleport to the Upper Spire.', 37725, 1, 1, 0, 0, 0, 0, '', 0), -- Rampart of Skulls +(11015, 6, 0, 'Teleport to Sindragosa''s Lair.', 37728, 1, 1, 0, 0, 0, 0, '', 0), -- Rampart of Skulls + +(11016, 0, 0, 'Teleport to Light''s Hammer.', 37671, 1, 1, 0, 0, 0, 0, '', 0), -- Deathbringer's Rise +(11016, 1, 0, 'Teleport to the Oratory of the Damned.', 37722, 1, 1, 0, 0, 0, 0, '', 0), -- Deathbringer's Rise +(11016, 3, 0, 'Teleport to the Rampart of Skulls.', 37723, 1, 1, 0, 0, 0, 0, '', 0), -- Deathbringer's Rise +(11016, 5, 0, 'Teleport to the Upper Spire.', 37725, 1, 1, 0, 0, 0, 0, '', 0), -- Deathbringer's Rise +(11016, 6, 0, 'Teleport to Sindragosa''s Lair.', 37728, 1, 1, 0, 0, 0, 0, '', 0), -- Deathbringer's Rise + +(11017, 0, 0, 'Teleport to Light''s Hammer.', 37671, 1, 1, 0, 0, 0, 0, '', 0), -- Upper Spire +(11017, 1, 0, 'Teleport to the Oratory of the Damned.', 37722, 1, 1, 0, 0, 0, 0, '', 0), -- Upper Spire +(11017, 3, 0, 'Teleport to the Rampart of Skulls.', 37723, 1, 1, 0, 0, 0, 0, '', 0), -- Upper Spire +(11017, 4, 0, 'Teleport to the Deathbringer''s Rise.', 37724, 1, 1, 0, 0, 0, 0, '', 0), -- Upper Spire +(11017, 6, 0, 'Teleport to Sindragosa''s Lair.', 37728, 1, 1, 0, 0, 0, 0, '', 0), -- Upper Spire + +(11018, 0, 0, 'Teleport to Light''s Hammer.', 37671, 1, 1, 0, 0, 0, 0, '', 0), -- Sindragosa's Lair +(11018, 1, 0, 'Teleport to the Oratory of the Damned.', 37722, 1, 1, 0, 0, 0, 0, '', 0), -- Sindragosa's Lair +(11018, 3, 0, 'Teleport to the Rampart of Skulls.', 37723, 1, 1, 0, 0, 0, 0, '', 0), -- Sindragosa's Lair +(11018, 4, 0, 'Teleport to the Deathbringer''s Rise.', 37724, 1, 1, 0, 0, 0, 0, '', 0), -- Sindragosa's Lair +(11018, 5, 0, 'Teleport to the Upper Spire.', 37725, 1, 1, 0, 0, 0, 0, '', 0); -- Sindragosa's Lair + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup` IN (11013, 11014, 11015, 11016, 11017, 11018); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(15,11013,1,0,0,13,0,0,3,2,0,0,0,'','Show option ''Teleport to the Oratory of the Damned.'' only if BossState DATA_LORD_MARROWGAR is DONE'), +(15,11013,3,0,0,13,0,1,3,2,0,0,0,'','Show option ''Teleport to the Rampart of Skulls.'' only if BossState DATA_LADY_DEATHWHISPER is DONE'), +(15,11013,4,0,0,13,0,2,3,2,0,0,0,'','Show option ''Teleport to the Deathbringer''s Rise.'' only if BossState DATA_ICECROWN_GUNSHIP_BATTLE is DONE'), +(15,11013,5,0,0,13,0,41,3,0,0,0,0,'','Show option ''Teleport to the Upper Spire.'' only if DATA_UPPERSPIRE_TELE_ACT is DONE'), +(15,11013,6,0,0,13,0,10,3,2,0,0,0,'','Show option ''Teleport to Sindragosa''s Lair.'' only if BossState DATA_VALITHRIA_DREAMWALKER is DONE'), + +(15,11014,3,0,0,13,0,1,3,2,0,0,0,'','Show option ''Teleport to the Rampart of Skulls.'' only if BossState DATA_LADY_DEATHWHISPER is DONE'), +(15,11014,4,0,0,13,0,2,3,2,0,0,0,'','Show option ''Teleport to the Deathbringer''s Rise.'' only if BossState DATA_ICECROWN_GUNSHIP_BATTLE is DONE'), +(15,11014,5,0,0,13,0,41,3,0,0,0,0,'','Show option ''Teleport to the Upper Spire.'' only if DATA_UPPERSPIRE_TELE_ACT is DONE'), +(15,11014,6,0,0,13,0,10,3,2,0,0,0,'','Show option ''Teleport to Sindragosa''s Lair.'' only if BossState DATA_VALITHRIA_DREAMWALKER is DONE'), + +(15,11015,1,0,0,13,0,0,3,2,0,0,0,'','Show option ''Teleport to the Oratory of the Damned.'' only if BossState DATA_LORD_MARROWGAR is DONE'), +(15,11015,4,0,0,13,0,2,3,2,0,0,0,'','Show option ''Teleport to the Deathbringer''s Rise.'' only if BossState DATA_ICECROWN_GUNSHIP_BATTLE is DONE'), +(15,11015,5,0,0,13,0,41,3,0,0,0,0,'','Show option ''Teleport to the Upper Spire.'' only if DATA_UPPERSPIRE_TELE_ACT is DONE'), +(15,11015,6,0,0,13,0,10,3,2,0,0,0,'','Show option ''Teleport to Sindragosa''s Lair.'' only if BossState DATA_VALITHRIA_DREAMWALKER is DONE'), + +(15,11016,1,0,0,13,0,0,3,2,0,0,0,'','Show option ''Teleport to the Oratory of the Damned.'' only if BossState DATA_LORD_MARROWGAR is DONE'), +(15,11016,3,0,0,13,0,1,3,2,0,0,0,'','Show option ''Teleport to the Rampart of Skulls.'' only if BossState DATA_LADY_DEATHWHISPER is DONE'), +(15,11016,5,0,0,13,0,41,3,0,0,0,0,'','Show option ''Teleport to the Upper Spire.'' only if DATA_UPPERSPIRE_TELE_ACT is DONE'), +(15,11016,6,0,0,13,0,10,3,2,0,0,0,'','Show option ''Teleport to Sindragosa''s Lair.'' only if BossState DATA_VALITHRIA_DREAMWALKER is DONE'), + +(15,11017,1,0,0,13,0,0,3,2,0,0,0,'','Show option ''Teleport to the Oratory of the Damned.'' only if BossState DATA_LORD_MARROWGAR is DONE'), +(15,11017,3,0,0,13,0,1,3,2,0,0,0,'','Show option ''Teleport to the Rampart of Skulls.'' only if BossState DATA_LADY_DEATHWHISPER is DONE'), +(15,11017,4,0,0,13,0,2,3,2,0,0,0,'','Show option ''Teleport to the Deathbringer''s Rise.'' only if BossState DATA_ICECROWN_GUNSHIP_BATTLE is DONE'), +(15,11017,6,0,0,13,0,10,3,2,0,0,0,'','Show option ''Teleport to Sindragosa''s Lair.'' only if BossState DATA_VALITHRIA_DREAMWALKER is DONE'), + +(15,11018,1,0,0,13,0,0,3,2,0,0,0,'','Show option ''Teleport to the Oratory of the Damned.'' only if BossState DATA_LORD_MARROWGAR is DONE'), +(15,11018,3,0,0,13,0,1,3,2,0,0,0,'','Show option ''Teleport to the Rampart of Skulls.'' only if BossState DATA_LADY_DEATHWHISPER is DONE'), +(15,11018,4,0,0,13,0,2,3,2,0,0,0,'','Show option ''Teleport to the Deathbringer''s Rise.'' only if BossState DATA_ICECROWN_GUNSHIP_BATTLE is DONE'), +(15,11018,5,0,0,13,0,41,3,0,0,0,0,'','Show option ''Teleport to the Upper Spire.'' only if DATA_UPPERSPIRE_TELE_ACT is DONE'); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h index 2af8e7f36437a..5a5b7aefc0214 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h @@ -115,7 +115,7 @@ enum DataTypes DATA_ARTHAS_PLATFORM = 38, DATA_TERENAS_MENETHIL = 39, DATA_ENEMY_GUNSHIP = 40, - DATA_UPPERSPIRE_TELE_ACT = 41, + DATA_UPPERSPIRE_TELE_ACT = 41, /// also used by conditions DATA_BLOOD_QUEEN_LANA_THEL_COUNCIL = 42 }; @@ -569,14 +569,10 @@ class spell_trigger_spell_from_caster : public SpellScriptLoader TriggerCastFlags _triggerFlags; }; -template -CreatureAI* GetIcecrownCitadelAI(Creature* creature) +template +inline AI* GetIcecrownCitadelAI(T* obj) { - if (InstanceMap* instance = creature->GetMap()->ToInstanceMap()) - if (instance->GetInstanceScript()) - if (instance->GetScriptId() == sObjectMgr->GetScriptId(ICCScriptName)) - return new AI(creature); - return NULL; + return GetInstanceAI(obj, ICCScriptName); } #endif // ICECROWN_CITADEL_H_ diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp index 118e13d91ff7e..7e5661e5dbc64 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp @@ -15,6 +15,7 @@ * with this program. If not, see . */ +#include "GameObjectAI.h" #include "InstanceScript.h" #include "Player.h" #include "ScriptedGossip.h" @@ -22,57 +23,55 @@ #include "Spell.h" #include "icecrown_citadel.h" -#define GOSSIP_SENDER_ICC_PORT 631 +static std::vector const TeleportSpells = +{ + LIGHT_S_HAMMER_TELEPORT, // 0 + ORATORY_OF_THE_DAMNED_TELEPORT, // 1 + 0, // 2 + RAMPART_OF_SKULLS_TELEPORT, // 3 + DEATHBRINGER_S_RISE_TELEPORT, // 4 + UPPER_SPIRE_TELEPORT, // 5 + SINDRAGOSA_S_LAIR_TELEPORT // 6 +}; class icecrown_citadel_teleport : public GameObjectScript { + static_assert(DATA_UPPERSPIRE_TELE_ACT == 41, "icecrown_citadel.h DATA_UPPERSPIRE_TELE_ACT set to value != 41, gossip condition of the teleporters won't work as intended."); + public: icecrown_citadel_teleport() : GameObjectScript("icecrown_citadel_teleport") { } - bool OnGossipHello(Player* player, GameObject* go) override + struct icecrown_citadel_teleportAI : public GameObjectAI { - if (InstanceScript* instance = go->GetInstanceScript()) + icecrown_citadel_teleportAI(GameObject* go) : GameObjectAI(go) { - if (instance->GetBossState(DATA_LORD_MARROWGAR) == DONE) - { - if (go->GetEntry() != GO_SCOURGE_TRANSPORTER_LIGHTSHAMMER) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to Light's Hammer.", GOSSIP_SENDER_ICC_PORT, LIGHT_S_HAMMER_TELEPORT); - if (go->GetEntry() != GO_SCOURGE_TRANSPORTER_ORATORY) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Oratory of the Damned.", GOSSIP_SENDER_ICC_PORT, ORATORY_OF_THE_DAMNED_TELEPORT); - } - if (instance->GetBossState(DATA_LADY_DEATHWHISPER) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_RAMPART) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Rampart of Skulls.", GOSSIP_SENDER_ICC_PORT, RAMPART_OF_SKULLS_TELEPORT); - if (instance->GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_DEATHBRINGER) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Deathbringer's Rise.", GOSSIP_SENDER_ICC_PORT, DEATHBRINGER_S_RISE_TELEPORT); - if (instance->GetData(DATA_UPPERSPIRE_TELE_ACT) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_UPPERSPIRE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Upper Spire.", GOSSIP_SENDER_ICC_PORT, UPPER_SPIRE_TELEPORT); - /// @todo Gauntlet event before Sindragosa - if (instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_SINDRAGOSA) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to Sindragosa's Lair", GOSSIP_SENDER_ICC_PORT, SINDRAGOSA_S_LAIR_TELEPORT); } - player->SEND_GOSSIP_MENU(player->GetGossipTextId(go), go->GetGUID()); - return true; - } + bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + { + if (gossipListId >= TeleportSpells.size()) + return false; - bool OnGossipSelect(Player* player, GameObject* /*go*/, uint32 sender, uint32 action) override - { - player->PlayerTalkClass->ClearMenus(); - player->CLOSE_GOSSIP_MENU(); - SpellInfo const* spell = sSpellMgr->GetSpellInfo(action); - if (!spell) - return false; + player->PlayerTalkClass->ClearMenus(); + player->CLOSE_GOSSIP_MENU(); + SpellInfo const* spell = sSpellMgr->GetSpellInfo(TeleportSpells[gossipListId]); + if (!spell) + return false; - if (player->IsInCombat()) - { - Spell::SendCastResult(player, spell, 0, SPELL_FAILED_AFFECTING_COMBAT); - return true; - } + if (player->IsInCombat()) + { + Spell::SendCastResult(player, spell, 0, SPELL_FAILED_AFFECTING_COMBAT); + return true; + } - if (sender == GOSSIP_SENDER_ICC_PORT) player->CastSpell(player, spell, true); + return true; + } + }; - return true; + GameObjectAI* GetAI(GameObject* go) const override + { + return GetIcecrownCitadelAI(go); } };