TrinityCore
Loading...
Searching...
No Matches
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
35
37{
39 { 0, 0 } // END
40};
41
43{
45 { 0, 0 } //END
46};
47
49{
50 public:
52
54 {
67
68 void OnCreatureCreate(Creature* creature) override
69 {
71
72 switch (creature->GetEntry())
73 {
74 case NPC_THE_MAKER:
75 TheMakerGUID = creature->GetGUID();
76 break;
77 case NPC_BROGGOK:
78 BroggokGUID = creature->GetGUID();
79 break;
81 KelidanTheBreakerGUID = creature->GetGUID();
82 break;
83 case NPC_PRISONER1:
84 case NPC_PRISONER2:
85 StorePrisoner(creature);
86 break;
87 default:
88 break;
89 }
90 }
91
92 void OnUnitDeath(Unit* unit) override
93 {
94 if (unit->GetTypeId() == TYPEID_UNIT && (unit->GetEntry() == NPC_PRISONER1 || unit->GetEntry() == NPC_PRISONER2))
95 PrisonerDied(unit->GetGUID());
96 }
97
98 void OnGameObjectCreate(GameObject* go) override
99 {
101
102 switch (go->GetEntry())
103 {
105 PrisonDoor4GUID = go->GetGUID();
106 break;
107 case GO_BROGGOK_LEVER:
109 break;
112 break;
115 break;
118 break;
121 break;
124 break;
127 break;
130 break;
133 break;
134 default:
135 break;
136 }
137 }
138
139 ObjectGuid GetGuidData(uint32 type) const override
140 {
141 switch (type)
142 {
143 case DATA_THE_MAKER:
144 return TheMakerGUID;
145 case DATA_BROGGOK:
146 return BroggokGUID;
150 return BroggokLeverGUID;
151 }
152
153 return ObjectGuid::Empty;
154 }
155
156 bool SetBossState(uint32 type, EncounterState state) override
157 {
158 if (!InstanceScript::SetBossState(type, state))
159 return false;
160
161 switch (type)
162 {
163 case DATA_BROGGOK:
164 switch (state)
165 {
166 case IN_PROGRESS:
168 break;
169 case NOT_STARTED:
170 ResetPrisons();
171 break;
172 default:
173 break;
174 }
175 break;
176 default:
177 break;
178 }
179
180 return true;
181 }
182
201
202 void ResetPrisoners(GuidSet& prisoners)
203 {
204 for (GuidSet::const_iterator i = prisoners.begin(); i != prisoners.end();)
205 {
206 if (Creature * prisoner = instance->GetCreature(*i))
207 {
208 if (!prisoner->IsAlive())
209 i = prisoners.erase(i);
210 else
211 ++i;
212
213 ResetPrisoner(prisoner);
214 }
215 else
216 ++i;
217 }
218 }
219
220 void ResetPrisoner(Creature* prisoner)
221 {
222 if (!prisoner->IsAlive())
223 prisoner->Respawn(true);
224 prisoner->SetImmuneToAll(true);
225 if (prisoner->IsAIEnabled())
226 prisoner->AI()->EnterEvadeMode();
227 }
228
229 void StorePrisoner(Creature* creature)
230 {
231 float posX = creature->GetPositionX();
232 float posY = creature->GetPositionY();
233 float posZ = creature->GetPositionZ();
234
235 if (posX >= 405.0f && posX <= 423.0f && posZ <= 17)
236 {
237 if (posY >= 106.0f && posY <= 123.0f)
238 {
239 PrisonersCell5.insert(creature->GetGUID());
241 }
242 else if (posY >= 76.0f && posY <= 91.0f)
243 {
244 PrisonersCell6.insert(creature->GetGUID());
246 }
247 else return;
248 }
249 else if (posX >= 490.0f && posX <= 506.0f && posZ <= 17)
250 {
251 if (posY >= 106.0f && posY <= 123.0f)
252 {
253 PrisonersCell7.insert(creature->GetGUID());
255 }
256 else if (posY >= 76.0f && posY <= 91.0f)
257 {
258 PrisonersCell8.insert(creature->GetGUID());
260 }
261 else
262 return;
263 }
264 else
265 return;
266
267 ResetPrisoner(creature);
268 }
269
271 {
272 if (PrisonersCell5.find(guid) != PrisonersCell5.end() && --PrisonerCounter5 <= 0)
274 else if (PrisonersCell6.find(guid) != PrisonersCell6.end() && --PrisonerCounter6 <= 0)
276 else if (PrisonersCell7.find(guid) != PrisonersCell7.end() && --PrisonerCounter7 <= 0)
278 else if (PrisonersCell8.find(guid) != PrisonersCell8.end() && --PrisonerCounter8 <= 0)
280 }
281
283 {
284 switch (id)
285 {
289 break;
293 break;
297 break;
301 break;
302 case DATA_DOOR_4:
304 if (Creature* broggok = instance->GetCreature(BroggokGUID))
305 broggok->AI()->DoAction(ACTION_ACTIVATE_BROGGOK);
306 break;
307 }
308 }
309
310 void ActivatePrisoners(GuidSet const& prisoners)
311 {
312 for (GuidSet::const_iterator i = prisoners.begin(); i != prisoners.end(); ++i)
313 if (Creature* prisoner = instance->GetCreature(*i))
314 {
315 prisoner->SetImmuneToAll(false);
316 prisoner->AI()->DoZoneInCombat();
317 }
318 }
319
320 protected:
324
327
329
334
339 };
340
342 {
344 }
345};
346
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
EncounterState
@ IN_PROGRESS
@ NOT_STARTED
@ DOOR_TYPE_ROOM
@ DOOR_TYPE_PASSAGE
@ TYPEID_UNIT
Definition ObjectGuid.h:38
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:260
#define DataHeader
uint32 const EncounterCount
@ GO_PRISON_CELL_DOOR_5
@ GO_PRISON_CELL_DOOR_8
@ GO_PRISON_DOOR_05
@ GO_PRISON_CELL_DOOR_1
@ GO_PRISON_CELL_DOOR_2
@ GO_PRISON_DOOR_03
@ GO_SUMMON_DOOR
@ GO_PRISON_CELL_DOOR_3
@ GO_PRISON_CELL_DOOR_7
@ GO_PRISON_CELL_DOOR_4
@ GO_PRISON_CELL_DOOR_6
@ GO_PRISON_DOOR_01
@ GO_PRISON_DOOR_04
@ GO_PRISON_DOOR_02
@ GO_BROGGOK_LEVER
@ NPC_PRISONER1
@ NPC_BROGGOK
@ NPC_KELIDAN_THE_BREAKER
@ NPC_PRISONER2
@ NPC_THE_MAKER
#define BFScriptName
@ DATA_BROGGOK_LEVER
@ DATA_THE_MAKER
@ DATA_PRISON_CELL2
@ DATA_PRISON_CELL1
@ DATA_PRISON_CELL3
@ DATA_PRISON_CELL7
@ DATA_PRISON_CELL5
@ DATA_BROGGOK
@ DATA_KELIDAN_THE_BREAKER
@ DATA_PRISON_CELL6
@ DATA_PRISON_CELL8
@ DATA_PRISON_CELL4
@ DATA_DOOR_4
@ ACTION_ACTIVATE_BROGGOK
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
void Respawn(bool force=false)
void SetImmuneToAll(bool apply) override
Definition Creature.h:126
CreatureAI * AI() const
Definition Creature.h:154
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)
InstanceMap * instance
virtual void OnGameObjectCreate(GameObject *go) override
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:4397
static ObjectGuid const Empty
Definition ObjectGuid.h:140
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
Definition Unit.h:769
bool IsAlive() const
Definition Unit.h:1234
bool IsAIEnabled() const
Definition Unit.h:798
InstanceScript * GetInstanceScript(InstanceMap *map) const override
ObjectData const gameObjectData[]
ObjectData const creatureData[]
DoorData const doorData[]
void AddSC_instance_blood_furnace()
float GetPositionZ() const
Definition Position.h:81
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
bool SetBossState(uint32 type, EncounterState state) override