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
34
35static constexpr ObjectData creatureData[] =
36{
38};
39
40static constexpr ObjectData gameObjectData[] =
41{
43};
44
45static constexpr DungeonEncounterData encounters[] =
46{
47 { DATA_THE_MAKER, {{ 1922 }} },
48 { DATA_BROGGOK, {{ 1924 }} },
49 { DATA_KELIDAN_THE_BREAKER, {{ 1923 }} }
50};
51
53{
54 public:
56
58 {
72
73 void OnCreatureCreate(Creature* creature) override
74 {
76
77 switch (creature->GetEntry())
78 {
79 case NPC_THE_MAKER:
80 TheMakerGUID = creature->GetGUID();
81 break;
82 case NPC_BROGGOK:
83 BroggokGUID = creature->GetGUID();
84 break;
86 KelidanTheBreakerGUID = creature->GetGUID();
87 break;
88 case NPC_PRISONER1:
89 case NPC_PRISONER2:
90 StorePrisoner(creature);
91 break;
92 default:
93 break;
94 }
95 }
96
97 void OnUnitDeath(Unit* unit) override
98 {
99 if (unit->GetTypeId() == TYPEID_UNIT && (unit->GetEntry() == NPC_PRISONER1 || unit->GetEntry() == NPC_PRISONER2))
100 PrisonerDied(unit->GetGUID());
101 }
102
104 {
106
107 switch (go->GetEntry())
108 {
110 PrisonDoor4GUID = go->GetGUID();
111 [[fallthrough]];
116 case GO_SUMMON_DOOR:
117 AddDoor(go, true);
118 break;
119 case GO_BROGGOK_LEVER:
121 break;
124 break;
127 break;
130 break;
133 break;
136 break;
139 break;
142 break;
145 break;
146 default:
147 break;
148 }
149 }
150
151 ObjectGuid GetGuidData(uint32 type) const override
152 {
153 switch (type)
154 {
155 case DATA_THE_MAKER:
156 return TheMakerGUID;
157 case DATA_BROGGOK:
158 return BroggokGUID;
162 return BroggokLeverGUID;
163 }
164
165 return ObjectGuid::Empty;
166 }
167
168 bool SetBossState(uint32 type, EncounterState state) override
169 {
170 if (!InstanceScript::SetBossState(type, state))
171 return false;
172
173 switch (type)
174 {
175 case DATA_BROGGOK:
176 switch (state)
177 {
178 case IN_PROGRESS:
180 break;
181 case NOT_STARTED:
182 ResetPrisons();
183 break;
184 default:
185 break;
186 }
187 break;
188 default:
189 break;
190 }
191
192 return true;
193 }
194
213
214 void ResetPrisoners(GuidSet& prisoners)
215 {
216 for (GuidSet::const_iterator i = prisoners.begin(); i != prisoners.end();)
217 {
218 if (Creature * prisoner = instance->GetCreature(*i))
219 {
220 if (!prisoner->IsAlive())
221 i = prisoners.erase(i);
222 else
223 ++i;
224
225 ResetPrisoner(prisoner);
226 }
227 else
228 ++i;
229 }
230 }
231
232 void ResetPrisoner(Creature* prisoner)
233 {
234 if (!prisoner->IsAlive())
235 prisoner->Respawn(true);
237 prisoner->SetImmuneToAll(true);
238 if (prisoner->IsAIEnabled())
239 prisoner->AI()->EnterEvadeMode();
240 }
241
242 void StorePrisoner(Creature* creature)
243 {
244 float posX = creature->GetPositionX();
245 float posY = creature->GetPositionY();
246 float posZ = creature->GetPositionZ();
247
248 if (posX >= 405.0f && posX <= 423.0f && posZ <= 17)
249 {
250 if (posY >= 106.0f && posY <= 123.0f)
251 {
252 PrisonersCell5.insert(creature->GetGUID());
254 }
255 else if (posY >= 76.0f && posY <= 91.0f)
256 {
257 PrisonersCell6.insert(creature->GetGUID());
259 }
260 else return;
261 }
262 else if (posX >= 490.0f && posX <= 506.0f && posZ <= 17)
263 {
264 if (posY >= 106.0f && posY <= 123.0f)
265 {
266 PrisonersCell7.insert(creature->GetGUID());
268 }
269 else if (posY >= 76.0f && posY <= 91.0f)
270 {
271 PrisonersCell8.insert(creature->GetGUID());
273 }
274 else
275 return;
276 }
277 else
278 return;
279
280 ResetPrisoner(creature);
281 }
282
284 {
285 if (PrisonersCell5.find(guid) != PrisonersCell5.end() && --PrisonerCounter5 <= 0)
287 else if (PrisonersCell6.find(guid) != PrisonersCell6.end() && --PrisonerCounter6 <= 0)
289 else if (PrisonersCell7.find(guid) != PrisonersCell7.end() && --PrisonerCounter7 <= 0)
291 else if (PrisonersCell8.find(guid) != PrisonersCell8.end() && --PrisonerCounter8 <= 0)
293 }
294
296 {
297 switch (id)
298 {
302 break;
306 break;
310 break;
314 break;
315 case DATA_DOOR_4:
317 if (Creature* broggok = instance->GetCreature(BroggokGUID))
318 broggok->AI()->DoAction(ACTION_ACTIVATE_BROGGOK);
319 break;
320 }
321 }
322
323 void ActivatePrisoners(GuidSet const& prisoners)
324 {
325 for (GuidSet::const_iterator i = prisoners.begin(); i != prisoners.end(); ++i)
326 if (Creature* prisoner = instance->GetCreature(*i))
327 {
328 prisoner->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
329 prisoner->SetImmuneToAll(false);
330 prisoner->AI()->DoZoneInCombat();
331 }
332 }
333
334 protected:
338
341
343
348
353 };
354
356 {
358 }
359};
360
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
EncounterState
@ IN_PROGRESS
@ NOT_STARTED
@ TYPEID_UNIT
Definition ObjectGuid.h:43
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:432
@ UNIT_FLAG_NON_ATTACKABLE
#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
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
void Respawn(bool force=false)
void SetImmuneToAll(bool apply) override
Definition Creature.h:181
CreatureAI * AI() const
Definition Creature.h:228
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 LoadObjectData(std::span< ObjectData const > creatureData, std::span< ObjectData const > gameObjectData)
InstanceMap * instance
void SetHeaders(std::string_view dataHeaders)
void LoadDungeonEncounterData(std::span< DungeonEncounterData const > encounters)
virtual void OnGameObjectCreate(GameObject *go) override
virtual void AddDoor(GameObject *door, bool add)
void LoadDoorData(std::span< DoorData const > data)
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint32 GetEntry() const
Definition Object.h:89
Definition Unit.h:635
bool IsAlive() const
Definition Unit.h:1185
bool IsAIEnabled() const
Definition Unit.h:666
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:846
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
static constexpr DoorData doorData[]
static constexpr ObjectData gameObjectData[]
static constexpr DungeonEncounterData encounters[]
void AddSC_instance_blood_furnace()
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetPositionZ() const
Definition Position.h:89
bool SetBossState(uint32 type, EncounterState state) override