From b7c2d309e666a21877977597e17ab9b4728fff0b Mon Sep 17 00:00:00 2001 From: Mihapro Date: Fri, 15 Jul 2016 14:39:41 +0200 Subject: [6.x] Core/Battlefield: Tol Barad (#17124) --- .../eastern_kingdoms_script_loader.cpp | 2 + .../scripts/EasternKingdoms/zone_tol_barad.cpp | 131 +++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 src/server/scripts/EasternKingdoms/zone_tol_barad.cpp (limited to 'src/server/scripts') diff --git a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp index adf7219d2a3..123d4102794 100644 --- a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp +++ b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp @@ -193,6 +193,7 @@ void AddSC_stormwind_city(); void AddSC_stranglethorn_vale(); void AddSC_swamp_of_sorrows(); void AddSC_tirisfal_glades(); +void AddSC_tol_barad(); void AddSC_undercity(); void AddSC_western_plaguelands(); void AddSC_wetlands(); @@ -379,6 +380,7 @@ void AddEasternKingdomsScripts() AddSC_stranglethorn_vale(); AddSC_swamp_of_sorrows(); AddSC_tirisfal_glades(); + AddSC_tol_barad(); AddSC_undercity(); AddSC_western_plaguelands(); AddSC_wetlands(); diff --git a/src/server/scripts/EasternKingdoms/zone_tol_barad.cpp b/src/server/scripts/EasternKingdoms/zone_tol_barad.cpp new file mode 100644 index 00000000000..54534a3d301 --- /dev/null +++ b/src/server/scripts/EasternKingdoms/zone_tol_barad.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2008-2016 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "BattlefieldMgr.h" +#include "BattlefieldTB.h" +#include "Battlefield.h" +#include "ScriptSystem.h" +#include "WorldSession.h" +#include "ScriptedCreature.h" +#include "ScriptedGossip.h" +#include "SpellScript.h" +#include "Player.h" + +enum TBSpiritGuide +{ + SPELL_CHANNEL_SPIRIT_HEAL = 22011, + + GOSSIP_OPTION_ID_SLAGWORKS = 0, + GOSSIP_OPTION_ID_IRONCLAD_GARRISON = 1, + GOSSIP_OPTION_ID_WARDENS_VIGIL = 2, + GOSSIP_OPTION_ID_EAST_SPIRE = 3, + GOSSIP_OPTION_ID_WEST_SPIRE = 4, + GOSSIP_OPTION_ID_SOUTH_SPIRE = 5, +}; + +class npc_tb_spirit_guide : public CreatureScript +{ + public: + npc_tb_spirit_guide() : CreatureScript("npc_tb_spirit_guide") { } + + struct npc_tb_spirit_guideAI : public ScriptedAI + { + npc_tb_spirit_guideAI(Creature* creature) : ScriptedAI(creature) { } + + void UpdateAI(uint32 /*diff*/) override + { + if (!me->HasUnitState(UNIT_STATE_CASTING)) + DoCast(me, SPELL_CHANNEL_SPIRIT_HEAL); + } + + void sGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + { + player->PlayerTalkClass->SendCloseGossip(); + + uint32 areaId = 0; + switch (gossipListId) + { + case GOSSIP_OPTION_ID_SLAGWORKS: + areaId = TB_GY_SLAGWORKS; + break; + case GOSSIP_OPTION_ID_IRONCLAD_GARRISON: + areaId = TB_GY_IRONCLAD_GARRISON; + break; + case GOSSIP_OPTION_ID_WARDENS_VIGIL: + areaId = TB_GY_WARDENS_VIGIL; + break; + case GOSSIP_OPTION_ID_EAST_SPIRE: + areaId = TB_GY_EAST_SPIRE; + break; + case GOSSIP_OPTION_ID_WEST_SPIRE: + areaId = TB_GY_WEST_SPIRE; + break; + case GOSSIP_OPTION_ID_SOUTH_SPIRE: + areaId = TB_GY_SOUTH_SPIRE; + break; + default: + return; + } + + if (WorldSafeLocsEntry const* safeLoc = sWorldSafeLocsStore.LookupEntry(areaId)) + player->TeleportTo(safeLoc->MapID, safeLoc->Loc.X, safeLoc->Loc.Y, safeLoc->Loc.Z, 0); + } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_tb_spirit_guideAI(creature); + } +}; + +// 85123 - Siege Cannon - selects random target +class spell_siege_cannon : public SpellScriptLoader +{ +public: + spell_siege_cannon() : SpellScriptLoader("spell_siege_cannon") { } + + class spell_siege_cannon_SpellScript : public SpellScript + { + PrepareSpellScript(spell_siege_cannon_SpellScript); + + void SelectRandomTarget(std::list& targets) + { + if (targets.empty()) + return; + + WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_siege_cannon_SpellScript::SelectRandomTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_siege_cannon_SpellScript(); + } +}; + +void AddSC_tol_barad() +{ + new npc_tb_spirit_guide(); + new spell_siege_cannon(); +} -- cgit v1.2.3