TrinityCore
Loading...
Searching...
No Matches
go_icecrown_citadel_teleport.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "icecrown_citadel.h"
19#include "GameObject.h"
20#include "GameObjectAI.h"
21#include "InstanceScript.h"
22#include "Map.h"
23#include "Player.h"
24#include "ScriptedGossip.h"
25#include "ScriptMgr.h"
26#include "Spell.h"
27#include "SpellInfo.h"
28#include "SpellMgr.h"
29#include "Transport.h"
30
31static std::vector<uint32> const TeleportSpells =
32{
35 0, // 2
40};
41
43{
44 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.");
45
46 public:
47 icecrown_citadel_teleport() : GameObjectScript("icecrown_citadel_teleport") { }
48
50 {
54
55 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
56 {
57 if (gossipListId >= TeleportSpells.size())
58 return false;
59
60 ClearGossipMenuFor(player);
61 CloseGossipMenuFor(player);
62
63 uint32 const teleportSpell = TeleportSpells[gossipListId];
64 SpellInfo const* spell = sSpellMgr->GetSpellInfo(teleportSpell);
65 if (!spell)
66 return false;
67
68 if (player->IsInCombat())
69 {
71 return true;
72 }
73
74 // If the player is on the ship, Unit::NearTeleport() will try to keep the player on the ship, causing issues.
75 // For that we simply always remove the player from the ship.
76 if (Transport* transport = player->GetTransport())
77 transport->RemovePassenger(player);
78
79 player->CastSpell(player, teleportSpell, true);
80 return true;
81 }
82 };
83
84 GameObjectAI* GetAI(GameObject* go) const override
85 {
86 return GetIcecrownCitadelAI<icecrown_citadel_teleportAI>(go);
87 }
88};
89
91{
92 public:
93 at_frozen_throne_teleport() : AreaTriggerScript("at_frozen_throne_teleport") { }
94
95 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
96 {
97 if (player->IsInCombat())
98 {
99 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(FROZEN_THRONE_TELEPORT))
101 return true;
102 }
103
104 if (InstanceScript* instance = player->GetInstanceScript())
105 {
106 if (instance->GetBossState(DATA_PROFESSOR_PUTRICIDE) == DONE && instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) == DONE &&
107 instance->GetBossState(DATA_SINDRAGOSA) == DONE && instance->GetBossState(DATA_THE_LICH_KING) != IN_PROGRESS)
108 player->CastSpell(player, FROZEN_THRONE_TELEPORT, true);
109 }
110
111 return true;
112 }
113};
114
uint32_t uint32
Definition Define.h:133
@ IN_PROGRESS
@ DONE
void ClearGossipMenuFor(Player *player)
void CloseGossipMenuFor(Player *player)
@ SPELL_FAILED_AFFECTING_COMBAT
#define sSpellMgr
Definition SpellMgr.h:738
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, uint32 *param1=nullptr, uint32 *param2=nullptr)
Definition Spell.cpp:4177
bool IsInCombat() const
Definition Unit.h:1144
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
Transport * GetTransport() const
Definition Object.h:564
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
GameObjectAI * GetAI(GameObject *go) const override
static std::vector< uint32 > const TeleportSpells
void AddSC_icecrown_citadel_teleport()
@ ORATORY_OF_THE_DAMNED_TELEPORT
@ FROZEN_THRONE_TELEPORT
@ DEATHBRINGER_S_RISE_TELEPORT
@ SINDRAGOSA_S_LAIR_TELEPORT
@ LIGHT_S_HAMMER_TELEPORT
@ UPPER_SPIRE_TELEPORT
@ RAMPART_OF_SKULLS_TELEPORT
@ DATA_THE_LICH_KING
@ DATA_SINDRAGOSA
@ DATA_UPPERSPIRE_TELE_ACT
@ DATA_BLOOD_QUEEN_LANA_THEL
@ DATA_PROFESSOR_PUTRICIDE
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override