TrinityCore
Loading...
Searching...
No Matches
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 "SpellAuraEffects.h"
32#include "SpellAuras.h"
33#include "SpellScript.h"
34#include "TemporarySummon.h"
35
42
50
52{
53 public:
55
60
62 {
73
74 void OnPlayerEnter(Player* player) override
75 {
76 Aura* ex = nullptr;
77
78 if (!_team)
79 _team = player->GetTeam();
80
81 player->CastSpell(player, SPELL_REMOVE_KARGATH_EXECUTIONER, true);
82
84 return;
85
86 switch (executed)
87 {
88 case 0:
89 ex = player->AddAura(SPELL_KARGATH_EXECUTIONER_1, player);
90 break;
91 case 1:
92 ex = player->AddAura(SPELL_KARGATH_EXECUTIONER_2, player);
93 break;
94 case 2:
95 ex = player->AddAura(SPELL_KARGATH_EXECUTIONER_3, player);
96 break;
97 default:
98 break;
99 }
100
101 if (ex)
103 }
104
105 void OnCreatureCreate(Creature* creature) override
106 {
108
109 if (!_team)
110 {
111 Map::PlayerList const& players = instance->GetPlayers();
112 if (!players.isEmpty())
113 if (Player* player = players.begin()->GetSource())
114 _team = player->GetTeam();
115 }
116
117 switch (creature->GetEntry())
118 {
120 kargathGUID = creature->GetGUID();
121 break;
123 if (_team == HORDE)
124 creature->UpdateEntry(NPC_DRISELLA);
125 break;
129 executionerGUID = creature->GetGUID();
130 SaveToDB();
131 break;
134 victimsGUID[0] = creature->GetGUID();
135 break;
138 victimsGUID[1] = creature->GetGUID();
139 break;
142 victimsGUID[2] = creature->GetGUID();
143 break;
144 }
145 }
146
147 void OnUnitDeath(Unit* unit) override
148 {
149 if (unit->GetEntry() == NPC_BLOOD_GUARD_PORUNG)
151 }
152
153 bool SetBossState(uint32 type, EncounterState state) override
154 {
155 if (!InstanceScript::SetBossState(type, state))
156 return false;
157
158 switch (type)
159 {
161 if (state == DONE)
162 {
164 executionTimer = 0;
165 SaveToDB();
166 }
167 break;
168 case DATA_KARGATH:
169 if (Creature* executioner = instance->GetCreature(executionerGUID))
170 executioner->AI()->Reset(); // trigger removal of IMMUNE_TO_PC flag
171 break;
172 case DATA_OMROGG:
173 break;
174 }
175 return true;
176 }
177
178 ObjectGuid GetGuidData(uint32 data) const override
179 {
180 switch (data)
181 {
183 return kargathGUID;
185 return executionerGUID;
189 return victimsGUID[data - DATA_FIRST_PRISONER];
190 default:
191 return ObjectGuid::Empty;
192 }
193 }
194
195 void WriteSaveDataMore(std::ostringstream& data) override
196 {
197 if (!instance->IsHeroic())
198 return;
199
200 data << uint32(executed) << ' '
201 << executionTimer << ' ';
202 }
203
204 void ReadSaveDataMore(std::istringstream& data) override
205 {
206 if (!instance->IsHeroic())
207 return;
208
209 uint32 readbuff;
210 data >> readbuff;
211 executed = uint8(readbuff);
212 data >> readbuff;
213
214 if (executed > VictimCount)
215 {
217 executionTimer = 0;
218 return;
219 }
220
221 if (!readbuff)
222 return;
223
224 Creature* executioner = nullptr;
225
227 if (Creature* kargath = instance->GetCreature(kargathGUID))
230
231 if (executioner)
232 for (uint8 i = executed; i < VictimCount; ++i)
234
235 executionTimer = readbuff;
236 }
237
238 uint32 GetData(uint32 type) const override
239 {
240 switch (type)
241 {
243 return executed;
245 return _team;
246 default:
247 return 0;
248 }
249 }
250
251 void Update(uint32 diff) override
252 {
253 if (!executionTimer)
254 return;
255
256 if (executionTimer <= diff)
257 {
259 switch (++executed)
260 {
261 case 1:
264 break;
265 case 2:
268 break;
269 default:
270 executionTimer = 0;
271 break;
272 }
273
274 if (Creature* executioner = instance->GetCreature(executionerGUID))
275 executioner->AI()->SetData(DATA_PRISONERS_EXECUTED, executed);
276
277 SaveToDB();
278 }
279 else
280 executionTimer -= diff;
281 }
282
283 private:
287
291 };
292};
293
@ IN_MILLISECONDS
Definition Common.h:35
@ MINUTE
Definition Common.h:29
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
EncounterState
@ DONE
@ DOOR_TYPE_ROOM
@ DOOR_TYPE_PASSAGE
@ HORDE
#define DataHeader
uint32 const EncounterCount
void SetDuration(int32 duration, bool withMods=false)
bool UpdateEntry(uint32 entry, CreatureData const *data=nullptr, bool updateLevel=true)
Definition Creature.cpp:540
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
void DoCastSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
InstanceMap * instance
void LoadDoorData(DoorData const *data)
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
bool isEmpty() const
Definition LinkedList.h:108
iterator begin()
void LoadGrid(float x, float y)
Definition Map.cpp:578
bool IsHeroic() const
Definition Map.cpp:4256
PlayerList const & GetPlayers() const
Definition Map.h:448
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4397
static ObjectGuid const Empty
Definition ObjectGuid.h:140
bool IsEmpty() const
Definition ObjectGuid.h:172
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetTeam() const
Definition Player.h:1832
FROM * GetSource() const
Definition Reference.h:96
Definition Unit.h:769
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:11964
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1992
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ DATA_TEAM_IN_INSTANCE
void AddSC_instance_shattered_halls()
ObjectData const creatureData[]
DoorData const doorData[]
#define SHScriptName
Position const Executioner
@ DATA_PORUNG
@ DATA_KARGATH
@ DATA_OMROGG
@ DATA_SHATTERED_EXECUTIONER
@ DATA_SECOND_PRISONER
@ DATA_RIGHT_HEAD
@ DATA_PRISONERS_EXECUTED
@ DATA_NETHEKURSE
@ DATA_THIRD_PRISONER
@ DATA_FIRST_PRISONER
@ DATA_LEFT_HEAD
@ NPC_ALLIANCE_VICTIM_1
@ NPC_HORDE_VICTIM_2
@ NPC_LEFT_HEAD
@ NPC_BLOOD_GUARD_PORUNG
@ NPC_CAPTAIN_ALINA
@ NPC_ALLIANCE_VICTIM_2
@ NPC_RIGHT_HEAD
@ 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
FactionSpawnerHelper const executionerVictims[VictimCount]
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80