TrinityCore
instance_shattered_halls.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/* ScriptData
19SDName: Instance_Shattered_Halls
20SD%Complete: 50
21SDComment: instance not complete
22SDCategory: Hellfire Citadel, Shattered Halls
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "InstanceScript.h"
27#include "Map.h"
28#include "Player.h"
29#include "ScriptedCreature.h"
30#include "shattered_halls.h"
31#include "SpellAuras.h"
32#include "TemporarySummon.h"
33
35{
39};
40
42{
43 { DATA_NETHEKURSE, {{ 1936 }} },
44 { DATA_PORUNG, {{ 1935 }} },
45 { DATA_OMROGG, {{ 1937 }} },
46 { DATA_KARGATH, {{ 1938 }} },
47};
48
50{
51 public:
53
55 {
57 }
58
60 {
62 {
68 executed = 0;
69 _team = 0;
70 }
71
72 void OnPlayerEnter(Player* player) override
73 {
74 Aura* ex = nullptr;
75
76 if (!_team)
77 _team = player->GetTeam();
78
79 player->CastSpell(player, SPELL_REMOVE_KARGATH_EXECUTIONER, true);
80
82 return;
83
84 switch (executed)
85 {
86 case 0:
87 ex = player->AddAura(SPELL_KARGATH_EXECUTIONER_1, player);
88 break;
89 case 1:
90 ex = player->AddAura(SPELL_KARGATH_EXECUTIONER_2, player);
91 break;
92 case 2:
93 ex = player->AddAura(SPELL_KARGATH_EXECUTIONER_3, player);
94 break;
95 default:
96 break;
97 }
98
99 if (ex)
101 }
102
103 void OnCreatureCreate(Creature* creature) override
104 {
105 if (!_team)
106 {
107 Map::PlayerList const& players = instance->GetPlayers();
108 if (!players.isEmpty())
109 if (Player* player = players.begin()->GetSource())
110 _team = player->GetTeam();
111 }
112
113 switch (creature->GetEntry())
114 {
116 nethekurseGUID = creature->GetGUID();
117 break;
119 kargathGUID = creature->GetGUID();
120 break;
122 if (_team == HORDE)
123 creature->UpdateEntry(NPC_DRISELLA);
124 break;
128 executionerGUID = creature->GetGUID();
129 break;
132 victimsGUID[0] = creature->GetGUID();
133 break;
136 victimsGUID[1] = creature->GetGUID();
137 break;
140 victimsGUID[2] = creature->GetGUID();
141 break;
142 }
143 }
144
145 void OnUnitDeath(Unit* unit) override
146 {
147 if (unit->GetEntry() == NPC_BLOOD_GUARD_PORUNG)
149 }
150
151 bool SetBossState(uint32 type, EncounterState state) override
152 {
153 if (!InstanceScript::SetBossState(type, state))
154 return false;
155
156 switch (type)
157 {
159 if (state == DONE)
160 {
162 executionTimer = 0;
163 }
164 break;
165 case DATA_KARGATH:
166 if (Creature* executioner = instance->GetCreature(executionerGUID))
167 executioner->AI()->Reset(); // trigger removal of IMMUNE_TO_PC flag
168 break;
169 case DATA_OMROGG:
170 break;
171 }
172 return true;
173 }
174
175 ObjectGuid GetGuidData(uint32 data) const override
176 {
177 switch (data)
178 {
180 return nethekurseGUID;
182 return kargathGUID;
184 return executionerGUID;
188 return victimsGUID[data - DATA_FIRST_PRISONER];
189 default:
190 return ObjectGuid::Empty;
191 }
192 }
193
194 void AfterDataLoad() override
195 {
196 // timed events are not resumable after reset/crash
198 executionTimer = 0;
199 }
200
201 uint32 GetData(uint32 type) const override
202 {
203 switch (type)
204 {
206 return executed;
208 return _team;
209 default:
210 return 0;
211 }
212 }
213
214 void Update(uint32 diff) override
215 {
216 if (!executionTimer)
217 return;
218
219 if (executionTimer <= diff)
220 {
222 switch (++executed)
223 {
224 case 1:
227 break;
228 case 2:
231 break;
232 default:
233 executionTimer = 0;
234 break;
235 }
236
237 if (Creature* executioner = instance->GetCreature(executionerGUID))
238 executioner->AI()->SetData(DATA_PRISONERS_EXECUTED, executed);
239 }
240 else
241 executionTimer -= diff;
242 }
243
244 private:
249
253 };
254};
255
257{
259}
@ IN_MILLISECONDS
Definition: Common.h:35
@ MINUTE
Definition: Common.h:29
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
EncounterState
@ DONE
@ HORDE
#define DataHeader
uint32 const EncounterCount
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:892
bool UpdateEntry(uint32 entry, CreatureData const *data=nullptr, bool updateLevel=true)
Definition: Creature.cpp:577
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void DoCastSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
void LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
void LoadDoorData(DoorData const *data)
void SetHeaders(std::string const &dataHeaders)
bool isEmpty() const
Definition: LinkedList.h:110
iterator begin()
Definition: MapRefManager.h:34
PlayerList const & GetPlayers() const
Definition: Map.h:367
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
bool IsEmpty() const
Definition: ObjectGuid.h:319
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Team GetTeam() const
Definition: Player.h:2235
FROM * GetSource() const
Definition: Reference.h:96
Definition: Unit.h:627
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:11618
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ DATA_TEAM_IN_INSTANCE
void AddSC_instance_shattered_halls()
DoorData const doorData[]
DungeonEncounterData const encounters[]
#define SHScriptName
Definition: sethekk_halls.h:23
@ DATA_PORUNG
@ DATA_KARGATH
@ DATA_OMROGG
@ DATA_SHATTERED_EXECUTIONER
@ DATA_SECOND_PRISONER
@ DATA_PRISONERS_EXECUTED
@ DATA_NETHEKURSE
@ DATA_THIRD_PRISONER
@ DATA_FIRST_PRISONER
@ NPC_ALLIANCE_VICTIM_1
@ NPC_HORDE_VICTIM_2
@ NPC_BLOOD_GUARD_PORUNG
@ NPC_CAPTAIN_ALINA
@ NPC_ALLIANCE_VICTIM_2
@ NPC_SHATTERED_EXECUTIONER
@ NPC_DRISELLA
@ NPC_GRAND_WARLOCK_NETHEKURSE
@ NPC_RANDY_WHIZZLESPROCKET
@ NPC_HORDE_VICTIM_1
@ NPC_KARGATH_BLADEFIST
@ NPC_CAPTAIN_BONESHATTER
@ GO_GRAND_WARLOCK_CHAMBER_DOOR_1
@ GO_GRAND_WARLOCK_CHAMBER_DOOR_2
@ SPELL_KARGATH_EXECUTIONER_2
@ SPELL_KARGATH_EXECUTIONER_3
@ SPELL_REMOVE_KARGATH_EXECUTIONER
@ SPELL_KARGATH_EXECUTIONER_1
uint32 const VictimCount