TrinityCore
instance_blood_furnace.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 "ScriptMgr.h"
19#include "blood_furnace.h"
20#include "GameObject.h"
21#include "InstanceScript.h"
22#include "Map.h"
23#include "ScriptedCreature.h"
24
26{
34};
35
37{
39 { 0, 0 } // END
40};
41
43{
45 { 0, 0 } //END
46};
47
49{
50 { DATA_THE_MAKER, {{ 1922 }} },
51 { DATA_BROGGOK, {{ 1924 }} },
52 { DATA_KELIDAN_THE_BREAKER, {{ 1923 }} }
53};
54
56{
57 public:
59
61 {
63 {
69
74 }
75
76 void OnCreatureCreate(Creature* creature) override
77 {
79
80 switch (creature->GetEntry())
81 {
82 case NPC_THE_MAKER:
83 TheMakerGUID = creature->GetGUID();
84 break;
85 case NPC_BROGGOK:
86 BroggokGUID = creature->GetGUID();
87 break;
89 KelidanTheBreakerGUID = creature->GetGUID();
90 break;
91 case NPC_PRISONER1:
92 case NPC_PRISONER2:
93 StorePrisoner(creature);
94 break;
95 default:
96 break;
97 }
98 }
99
100 void OnUnitDeath(Unit* unit) override
101 {
102 if (unit->GetTypeId() == TYPEID_UNIT && (unit->GetEntry() == NPC_PRISONER1 || unit->GetEntry() == NPC_PRISONER2))
103 PrisonerDied(unit->GetGUID());
104 }
105
107 {
109
110 switch (go->GetEntry())
111 {
113 PrisonDoor4GUID = go->GetGUID();
114 [[fallthrough]];
119 case GO_SUMMON_DOOR:
120 AddDoor(go, true);
121 break;
122 case GO_BROGGOK_LEVER:
124 break;
127 break;
130 break;
133 break;
136 break;
139 break;
142 break;
145 break;
148 break;
149 default:
150 break;
151 }
152 }
153
154 ObjectGuid GetGuidData(uint32 type) const override
155 {
156 switch (type)
157 {
158 case DATA_THE_MAKER:
159 return TheMakerGUID;
160 case DATA_BROGGOK:
161 return BroggokGUID;
165 return BroggokLeverGUID;
166 }
167
168 return ObjectGuid::Empty;
169 }
170
171 bool SetBossState(uint32 type, EncounterState state) override
172 {
173 if (!InstanceScript::SetBossState(type, state))
174 return false;
175
176 switch (type)
177 {
178 case DATA_BROGGOK:
179 switch (state)
180 {
181 case IN_PROGRESS:
183 break;
184 case NOT_STARTED:
185 ResetPrisons();
186 break;
187 default:
188 break;
189 }
190 break;
191 default:
192 break;
193 }
194
195 return true;
196 }
197
199 {
203
207
211
215 }
216
217 void ResetPrisoners(GuidSet& prisoners)
218 {
219 for (GuidSet::const_iterator i = prisoners.begin(); i != prisoners.end();)
220 {
221 if (Creature * prisoner = instance->GetCreature(*i))
222 {
223 if (!prisoner->IsAlive())
224 i = prisoners.erase(i);
225 else
226 ++i;
227
228 ResetPrisoner(prisoner);
229 }
230 else
231 ++i;
232 }
233 }
234
235 void ResetPrisoner(Creature* prisoner)
236 {
237 if (!prisoner->IsAlive())
238 prisoner->Respawn(true);
240 prisoner->SetImmuneToAll(true);
241 if (prisoner->IsAIEnabled())
242 prisoner->AI()->EnterEvadeMode();
243 }
244
245 void StorePrisoner(Creature* creature)
246 {
247 float posX = creature->GetPositionX();
248 float posY = creature->GetPositionY();
249 float posZ = creature->GetPositionZ();
250
251 if (posX >= 405.0f && posX <= 423.0f && posZ <= 17)
252 {
253 if (posY >= 106.0f && posY <= 123.0f)
254 {
255 PrisonersCell5.insert(creature->GetGUID());
257 }
258 else if (posY >= 76.0f && posY <= 91.0f)
259 {
260 PrisonersCell6.insert(creature->GetGUID());
262 }
263 else return;
264 }
265 else if (posX >= 490.0f && posX <= 506.0f && posZ <= 17)
266 {
267 if (posY >= 106.0f && posY <= 123.0f)
268 {
269 PrisonersCell7.insert(creature->GetGUID());
271 }
272 else if (posY >= 76.0f && posY <= 91.0f)
273 {
274 PrisonersCell8.insert(creature->GetGUID());
276 }
277 else
278 return;
279 }
280 else
281 return;
282
283 ResetPrisoner(creature);
284 }
285
287 {
288 if (PrisonersCell5.find(guid) != PrisonersCell5.end() && --PrisonerCounter5 <= 0)
290 else if (PrisonersCell6.find(guid) != PrisonersCell6.end() && --PrisonerCounter6 <= 0)
292 else if (PrisonersCell7.find(guid) != PrisonersCell7.end() && --PrisonerCounter7 <= 0)
294 else if (PrisonersCell8.find(guid) != PrisonersCell8.end() && --PrisonerCounter8 <= 0)
296 }
297
299 {
300 switch (id)
301 {
305 break;
309 break;
313 break;
317 break;
318 case DATA_DOOR_4:
320 if (Creature* broggok = instance->GetCreature(BroggokGUID))
321 broggok->AI()->DoAction(ACTION_ACTIVATE_BROGGOK);
322 break;
323 }
324 }
325
326 void ActivatePrisoners(GuidSet const& prisoners)
327 {
328 for (GuidSet::const_iterator i = prisoners.begin(); i != prisoners.end(); ++i)
329 if (Creature* prisoner = instance->GetCreature(*i))
330 {
331 prisoner->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
332 prisoner->SetImmuneToAll(false);
333 prisoner->AI()->DoZoneInCombat();
334 }
335 }
336
337 protected:
341
344
346
351
356 };
357
359 {
361 }
362};
363
365{
367}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
EncounterState
@ IN_PROGRESS
@ NOT_STARTED
@ TYPEID_UNIT
Definition: ObjectGuid.h:40
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:393
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:145
#define DataHeader
uint32 const EncounterCount
@ GO_PRISON_CELL_DOOR_5
Definition: blood_furnace.h:72
@ GO_PRISON_CELL_DOOR_8
Definition: blood_furnace.h:75
@ GO_PRISON_DOOR_05
Definition: blood_furnace.h:65
@ GO_PRISON_CELL_DOOR_1
Definition: blood_furnace.h:68
@ GO_PRISON_CELL_DOOR_2
Definition: blood_furnace.h:69
@ GO_PRISON_DOOR_03
Definition: blood_furnace.h:63
@ GO_SUMMON_DOOR
Definition: blood_furnace.h:66
@ GO_PRISON_CELL_DOOR_3
Definition: blood_furnace.h:70
@ GO_PRISON_CELL_DOOR_7
Definition: blood_furnace.h:74
@ GO_PRISON_CELL_DOOR_4
Definition: blood_furnace.h:71
@ GO_PRISON_CELL_DOOR_6
Definition: blood_furnace.h:73
@ GO_PRISON_DOOR_01
Definition: blood_furnace.h:61
@ GO_PRISON_DOOR_04
Definition: blood_furnace.h:64
@ GO_PRISON_DOOR_02
Definition: blood_furnace.h:62
@ GO_BROGGOK_LEVER
Definition: blood_furnace.h:77
@ NPC_PRISONER1
Definition: blood_furnace.h:53
@ NPC_BROGGOK
Definition: blood_furnace.h:51
@ NPC_KELIDAN_THE_BREAKER
Definition: blood_furnace.h:52
@ NPC_PRISONER2
Definition: blood_furnace.h:54
@ NPC_THE_MAKER
Definition: blood_furnace.h:50
#define BFScriptName
Definition: blood_furnace.h:23
@ DATA_BROGGOK_LEVER
Definition: blood_furnace.h:45
@ DATA_THE_MAKER
Definition: blood_furnace.h:31
@ DATA_PRISON_CELL2
Definition: blood_furnace.h:38
@ DATA_PRISON_CELL1
Definition: blood_furnace.h:37
@ DATA_PRISON_CELL3
Definition: blood_furnace.h:39
@ DATA_PRISON_CELL7
Definition: blood_furnace.h:43
@ DATA_PRISON_CELL5
Definition: blood_furnace.h:41
@ DATA_BROGGOK
Definition: blood_furnace.h:32
@ DATA_KELIDAN_THE_BREAKER
Definition: blood_furnace.h:33
@ DATA_PRISON_CELL6
Definition: blood_furnace.h:42
@ DATA_PRISON_CELL8
Definition: blood_furnace.h:44
@ DATA_PRISON_CELL4
Definition: blood_furnace.h:40
@ DATA_DOOR_4
Definition: blood_furnace.h:36
@ ACTION_ACTIVATE_BROGGOK
Definition: blood_furnace.h:82
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Respawn(bool force=false)
Definition: Creature.cpp:2303
void SetImmuneToAll(bool apply) override
Definition: Creature.h:167
CreatureAI * AI() const
Definition: Creature.h:214
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
void LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
virtual void OnGameObjectCreate(GameObject *go) override
virtual void AddDoor(GameObject *door, bool add)
void LoadDoorData(DoorData const *data)
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Definition: Unit.h:627
bool IsAlive() const
Definition: Unit.h:1164
bool IsAIEnabled() const
Definition: Unit.h:658
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:833
InstanceScript * GetInstanceScript(InstanceMap *map) const override
ObjectData const gameObjectData[]
ObjectData const creatureData[]
DoorData const doorData[]
DungeonEncounterData const encounters[]
void AddSC_instance_blood_furnace()
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetPositionZ() const
Definition: Position.h:78
bool SetBossState(uint32 type, EncounterState state) override