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 "Player.h"
23#include "ScriptedGossip.h"
24#include "ScriptMgr.h"
25#include "SpellScript.h"
26#include "VehicleDefines.h"
27
28static constexpr std::array<uint32, 7> TeleportSpells =
29{
32 0, // 2
37};
38
40{
41 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.");
42
44
45 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
46 {
47 if (gossipListId >= TeleportSpells.size())
48 return false;
49
50 ClearGossipMenuFor(player);
51 CloseGossipMenuFor(player);
52 if (!TeleportSpells[gossipListId])
53 return false;
54
55 me->CastSpell(player, TeleportSpells[gossipListId], true);
56 return true;
57 }
58};
59
61{
62public:
63 at_frozen_throne_teleport() : AreaTriggerScript("at_frozen_throne_teleport") { }
64
65 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
66 {
67 InstanceScript* instance = player->GetInstanceScript();
68 if (!instance)
69 return true;
70
73 || instance->GetBossState(DATA_SINDRAGOSA) != DONE
75 return true;
76
77 player->CastSpell(player, FROZEN_THRONE_TELEPORT, true);
78 return true;
79 }
80};
81
83{
85 {
86 Unit const* target = GetExplTargetUnit();
87 if (!target)
89
90 if (target->IsInCombat())
92
93 return SPELL_CAST_OK;
94 }
95
96 void OnPrecast() override
97 {
98 // If the player is on the ship, Unit::NearTeleport() will try to keep the player on the ship, causing issues.
99 // For that we simply always remove the player from the ship.
100 Unit* target = GetExplTargetUnit();
101 if (TransportBase* transport = target->GetTransport())
102 transport->RemovePassenger(target);
103 }
104
109};
110
uint32_t uint32
Definition Define.h:154
@ IN_PROGRESS
@ DONE
#define RegisterGameObjectAIWithFactory(ai_name, factory_fn)
Definition ScriptMgr.h:1419
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
void ClearGossipMenuFor(Player *player)
void CloseGossipMenuFor(Player *player)
SpellCastResult
@ SPELL_FAILED_AFFECTING_COMBAT
@ SPELL_FAILED_BAD_TARGETS
@ SPELL_CAST_OK
#define SpellCheckCastFn(F)
GameObject *const me
GameObjectAI(GameObject *go, uint32 scriptId={}) noexcept
EncounterState GetBossState(uint32 id) const
HookList< CheckCastHandler > OnCheckCast
Unit * GetExplTargetUnit() const
Definition Unit.h:635
bool IsInCombat() const
Definition Unit.h:1058
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
TransportBase * GetTransport() const
Definition Object.h:537
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
void AddSC_icecrown_citadel_teleport()
static constexpr std::array< uint32, 7 > TeleportSpells
@ 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
AI * GetIcecrownCitadelAI(T *obj)
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override