TrinityCore
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 {
52 {
53 }
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 SpellInfo const* spell = sSpellMgr->GetSpellInfo(TeleportSpells[gossipListId], DIFFICULTY_NONE);
63 if (!spell)
64 return false;
65
66 if (player->IsInCombat())
67 {
68 ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, player->GetMapId(), spell->Id, player->GetMap()->GenerateLowGuid<HighGuid::Cast>());
69 Spell::SendCastResult(player, spell, {}, castId, SPELL_FAILED_AFFECTING_COMBAT);
70 return true;
71 }
72
73 // If the player is on the ship, Unit::NearTeleport() will try to keep the player on the ship, causing issues.
74 // For that we simply always remove the player from the ship.
75 if (TransportBase* transport = player->GetTransport())
76 transport->RemovePassenger(player);
77
78 me->CastSpell(player, spell->Id, true);
79 return true;
80 }
81 };
82
83 GameObjectAI* GetAI(GameObject* go) const override
84 {
85 return GetIcecrownCitadelAI<icecrown_citadel_teleportAI>(go);
86 }
87};
88
90{
91 public:
92 at_frozen_throne_teleport() : AreaTriggerScript("at_frozen_throne_teleport") { }
93
94 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
95 {
96 if (player->IsInCombat())
97 {
98 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(FROZEN_THRONE_TELEPORT, DIFFICULTY_NONE))
99 {
100 ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, player->GetMapId(), spell->Id, player->GetMap()->GenerateLowGuid<HighGuid::Cast>());
101 Spell::SendCastResult(player, spell, {}, castId, SPELL_FAILED_AFFECTING_COMBAT);
102 }
103 return true;
104 }
105
106 if (InstanceScript* instance = player->GetInstanceScript())
107 {
108 if (instance->GetBossState(DATA_PROFESSOR_PUTRICIDE) == DONE && instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) == DONE &&
109 instance->GetBossState(DATA_SINDRAGOSA) == DONE && instance->GetBossState(DATA_THE_LICH_KING) != IN_PROGRESS)
110 player->CastSpell(player, FROZEN_THRONE_TELEPORT, true);
111 }
112
113 return true;
114 }
115};
116
118{
121}
@ DIFFICULTY_NONE
Definition: DBCEnums.h:874
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ DONE
void ClearGossipMenuFor(Player *player)
void CloseGossipMenuFor(Player *player)
@ SPELL_FAILED_AFFECTING_COMBAT
#define sSpellMgr
Definition: SpellMgr.h:849
@ SPELL_CAST_SOURCE_NORMAL
Definition: Spell.h:146
GameObject *const me
Definition: GameObjectAI.h:50
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:519
uint32 const Id
Definition: SpellInfo.h:325
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, int32 *param1=nullptr, int32 *param2=nullptr)
Definition: Spell.cpp:4643
bool IsInCombat() const
Definition: Unit.h:1043
constexpr uint32 GetMapId() const
Definition: Position.h:201
Map * GetMap() const
Definition: Object.h:624
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
TransportBase * GetTransport() const
Definition: Object.h:750
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