TrinityCore
instance_zulfarrak.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 "GameObject.h"
20#include "InstanceScript.h"
21#include "Map.h"
22#include "MotionMaster.h"
23#include "TemporarySummon.h"
24#include "zulfarrak.h"
25
26enum Misc
27{
28 // Creatures
30
31 // Paths
32 PATH_ADDS = 652424
33};
34
35static constexpr DungeonEncounterData Encounters[] =
36{
37 { BOSS_HYDROMANCER_VELRATHA, { { 593 } } },
38 { BOSS_GAHZ_RILLA, { { 594 } } },
39 { BOSS_ANTU_SUL, { { 595 } } },
40 { BOSS_THEKA_THE_MARTYR, { { 596 } } },
41 { BOSS_WITCH_DOCTOR_ZUM_RAH, { { 597 } } },
42 { BOSS_NEKRUM_GUTCHEWER, { { 598 } } },
43 { BOSS_SHADOWPRIEST_SEZZ_ZIZ, { { 599 } } },
44 { BOSS_CHIEF_UKORZ_SANDSCALP, { { 600 } } },
45};
46
47int const pyramidSpawnTotal = 54;
48/* list of wave spawns: 0 = wave ID, 1 = creature id, 2 = x, 3 = y
49no z coordinat b/c they're all the same */
51 {1, 7789, 1894.64f, 1206.29f},
52 {1, 7787, 1890.08f, 1218.68f},
53 {1, 8876, 1883.76f, 1222.3f},
54 {1, 7789, 1874.18f, 1221.24f},
55 {1, 7787, 1892.28f, 1225.49f},
56 {1, 7788, 1889.94f, 1212.21f},
57 {1, 7787, 1879.02f, 1223.06f},
58 {1, 7789, 1874.45f, 1204.44f},
59 {1, 8876, 1898.23f, 1217.97f},
60 {1, 7787, 1882.07f, 1225.7f},
61 {1, 8877, 1896.46f, 1205.62f},
62 {1, 7787, 1886.97f, 1225.86f},
63 {1, 7787, 1894.72f, 1221.91f},
64 {1, 7787, 1883.5f, 1218.25f},
65 {1, 7787, 1886.93f, 1221.4f},
66 {1, 8876, 1889.82f, 1222.51f},
67 {1, 7788, 1893.07f, 1215.26f},
68 {1, 7788, 1878.57f, 1214.16f},
69 {1, 7788, 1883.74f, 1212.35f},
70 {1, 8877, 1877, 1207.27f},
71 {1, 8877, 1873.63f, 1204.65f},
72 {1, 8876, 1877.4f, 1216.41f},
73 {1, 8877, 1899.63f, 1202.52f},
74 {2, 7789, 1902.83f, 1223.41f},
75 {2, 8876, 1889.82f, 1222.51f},
76 {2, 7787, 1883.5f, 1218.25f},
77 {2, 7788, 1883.74f, 1212.35f},
78 {2, 8877, 1877, 1207.27f},
79 {2, 7787, 1890.08f, 1218.68f},
80 {2, 7789, 1894.64f, 1206.29f},
81 {2, 8876, 1877.4f, 1216.41f},
82 {2, 7787, 1892.28f, 1225.49f},
83 {2, 7788, 1893.07f, 1215.26f},
84 {2, 8877, 1896.46f, 1205.62f},
85 {2, 7789, 1874.45f, 1204.44f},
86 {2, 7789, 1874.18f, 1221.24f},
87 {2, 7787, 1879.02f, 1223.06f},
88 {2, 8876, 1898.23f, 1217.97f},
89 {2, 7787, 1882.07f, 1225.7f},
90 {2, 8877, 1873.63f, 1204.65f},
91 {2, 7787, 1886.97f, 1225.86f},
92 {2, 7788, 1878.57f, 1214.16f},
93 {2, 7787, 1894.72f, 1221.91f},
94 {2, 7787, 1886.93f, 1221.4f},
95 {2, 8876, 1883.76f, 1222.3f},
96 {2, 7788, 1889.94f, 1212.21f},
97 {2, 8877, 1899.63f, 1202.52f},
98 {3, 7788, 1878.57f, 1214.16f},
99 {3, 7787, 1894.72f, 1221.91f},
100 {3, 7787, 1886.93f, 1221.4f},
101 {3, 8876, 1883.76f, 1222.3f},
102 {3, 7788, 1889.94f, 1212.21f},
103 {3, 7275, 1889.23f, 1207.72f},
104 {3, 7796, 1879.77f, 1207.96f}
105};
106
107float Spawnsway[2][3] =
108{
109 {1884.86f, 1228.62f, 9},
110 {1887.53f, 1263, 41}
111};
112
114{
115public:
117
119 {
121 }
122
124 {
126 {
131 PyramidPhase = 0;
134 addGroupSize = 0;
135 waypoint = 0;
136 }
137
151
152 void OnCreatureCreate(Creature* creature) override
153 {
154 switch (creature->GetEntry())
155 {
156 case ENTRY_ZUM_RAH:
157 ZumrahGUID = creature->GetGUID();
158 break;
159 case ENTRY_BLY:
160 BlyGUID = creature->GetGUID();
161 creature->SetReactState(REACT_PASSIVE); // starts out passive (in a cage)
162 break;
163 case ENTRY_RAVEN:
164 RavenGUID = creature->GetGUID();
165 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
166 break;
167 case ENTRY_ORO:
168 OroGUID = creature->GetGUID();
169 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
170 break;
171 case ENTRY_WEEGLI:
172 WeegliGUID = creature->GetGUID();
173 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
174 break;
175 case ENTRY_MURTA:
176 MurtaGUID = creature->GetGUID();
177 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
178 break;
179 case NPC_GAHZRILLA:
181 creature->DespawnOrUnsummon();
182 else
184 break;
185 }
186 }
187
188 void OnUnitDeath(Unit* unit) override
189 {
190 switch (unit->GetEntry())
191 {
199 default: break;
200 }
201 }
202
204 {
205 switch (go->GetEntry())
206 {
207 case GO_END_DOOR:
208 EndDoorGUID = go->GetGUID();
209 break;
210 }
211 }
212
213 uint32 GetData(uint32 type) const override
214 {
215 switch (type)
216 {
217 case EVENT_PYRAMID:
218 return PyramidPhase;
219 }
220 return 0;
221 }
222
223 ObjectGuid GetGuidData(uint32 data) const override
224 {
225 switch (data)
226 {
227 case ENTRY_ZUM_RAH:
228 return ZumrahGUID;
229 case ENTRY_BLY:
230 return BlyGUID;
231 case ENTRY_RAVEN:
232 return RavenGUID;
233 case ENTRY_ORO:
234 return OroGUID;
235 case ENTRY_WEEGLI:
236 return WeegliGUID;
237 case ENTRY_MURTA:
238 return MurtaGUID;
239 case GO_END_DOOR:
240 return EndDoorGUID;
241 }
242 return ObjectGuid::Empty;
243 }
244
245 void SetData(uint32 type, uint32 data) override
246 {
247 switch (type)
248 {
249 case EVENT_PYRAMID:
250 PyramidPhase = data;
251 break;
252 }
253 }
254
255 virtual void Update(uint32 diff) override
256 {
257 switch (PyramidPhase)
258 {
261 break;
265 major_wave_Timer=120000;
267 addGroupSize=2;
268 break;
269 case PYRAMID_WAVE_1:
270 if (IsWaveAllDead())
271 {
273 major_wave_Timer = 10000; //give players a few seconds before wave 2 starts to rebuff
274 }
275 else
276 if (minor_wave_Timer<diff)
277 {
279 minor_wave_Timer=10000;
280 }
281 else
282 minor_wave_Timer -= diff;
283 break;
285 if (major_wave_Timer<diff)
286 {
287 // beginning 2nd wave!
291 addGroupSize=2;
292 }
293 else
294 major_wave_Timer -= diff;
295 break;
296 case PYRAMID_WAVE_2:
297 if (IsWaveAllDead())
298 {
301 major_wave_Timer = 5000; //give NPCs time to return to their home spots
302 }
303 else
304 if (minor_wave_Timer<diff)
305 {
307 minor_wave_Timer=10000;
308 }
309 else
310 minor_wave_Timer -= diff;
311 break;
313 if (major_wave_Timer<diff)
314 {
315 // move NPCs to bottom of stair
316 MoveNPCIfAlive(ENTRY_BLY, 1887.92f, 1228.179f, 9.98f, 4.78f);
317 MoveNPCIfAlive(ENTRY_MURTA, 1891.57f, 1228.68f, 9.69f, 4.78f);
318 MoveNPCIfAlive(ENTRY_ORO, 1897.23f, 1228.34f, 9.43f, 4.78f);
319 MoveNPCIfAlive(ENTRY_RAVEN, 1883.68f, 1227.95f, 9.543f, 4.78f);
320 MoveNPCIfAlive(ENTRY_WEEGLI, 1878.02f, 1227.65f, 9.485f, 4.78f);
322 }
323 else
324 major_wave_Timer -= diff;
325 break;
326 case PYRAMID_WAVE_3:
327 if (IsWaveAllDead()) // move NPCS to their final positions
328 {
330 MoveNPCIfAlive(ENTRY_BLY, 1883.82f, 1200.83f, 8.87f, 1.32f);
331 MoveNPCIfAlive(ENTRY_MURTA, 1891.83f, 1201.45f, 8.87f, 1.32f);
332 MoveNPCIfAlive(ENTRY_ORO, 1894.50f, 1204.40f, 8.87f, 1.32f);
333 MoveNPCIfAlive(ENTRY_RAVEN, 1874.11f, 1206.17f, 8.87f, 1.32f);
334 MoveNPCIfAlive(ENTRY_WEEGLI, 1877.52f, 1199.63f, 8.87f, 1.32f);
335 }
336 break;
337 };
338 }
339
341
342 void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o)
343 {
344 if (Creature* npc = instance->GetCreature(GetGuidData(entry)))
345 {
346 if (npc->IsAlive())
347 {
348 npc->SetWalk(true);
349 npc->GetMotionMaster()->MovePoint(1, x, y, z);
350 npc->SetHomePosition(x, y, z, o);
351 }
352 }
353 }
354
356 {
357 for (int i = 0; i < pyramidSpawnTotal; i++)
358 {
359 if (pyramidSpawns[i][0] == (float)wave)
360 {
361 Position pos = {pyramidSpawns[i][2], pyramidSpawns[i][3], 8.87f, 0};
362 if (TempSummon* ts = instance->SummonCreature(uint32(pyramidSpawns[i][1]), pos))
363 {
364 ts->GetMotionMaster()->MoveRandom(10);
365 addsAtBase.push_back(ts->GetGUID());
366 }
367 }
368 }
369 }
370
372 {
373 for (GuidList::iterator itr = addsAtBase.begin(); itr != addsAtBase.end(); ++itr)
374 {
375 if (Creature* add = instance->GetCreature((*itr)))
376 {
377 if (add->IsAlive())
378 return false;
379 }
380 }
381 for (GuidList::iterator itr = movedadds.begin(); itr != movedadds.end(); ++itr)
382 {
383 if (Creature* add = instance->GetCreature(((*itr))))
384 {
385 if (add->IsAlive())
386 return false;
387 }
388 }
389 return true;
390 }
391
393 {
394 //pop a add from list, send him up the stairs...
395 for (uint32 addCount = 0; addCount < count && !addsAtBase.empty(); addCount++)
396 {
397 if (Creature* add = instance->GetCreature(*addsAtBase.begin()))
398 {
399 add->GetMotionMaster()->MovePath(PATH_ADDS, false);
400 movedadds.push_back(add->GetGUID());
401 }
402 addsAtBase.erase(addsAtBase.begin());
403 }
404 }
405 };
406
407};
408
410{
411 new instance_zulfarrak();
412}
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ REACT_PASSIVE
Definition: UnitDefines.h:506
#define DataHeader
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
void SetHeaders(std::string const &dataHeaders)
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition: Object.cpp:1836
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Definition: Unit.h:627
InstanceScript * GetInstanceScript(InstanceMap *map) const override
#define MAX_ENCOUNTER
@ NPC_GAHZRILLA
@ PATH_ADDS
int const pyramidSpawnTotal
static constexpr DungeonEncounterData Encounters[]
float Spawnsway[2][3]
float pyramidSpawns[pyramidSpawnTotal][4]
void AddSC_instance_zulfarrak()
void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o)
@ BOSS_GAHZ_RILLA
Definition: zulfarrak.h:29
@ BOSS_WITCH_DOCTOR_ZUM_RAH
Definition: zulfarrak.h:32
@ BOSS_ANTU_SUL
Definition: zulfarrak.h:30
@ BOSS_NEKRUM_GUTCHEWER
Definition: zulfarrak.h:33
@ BOSS_CHIEF_UKORZ_SANDSCALP
Definition: zulfarrak.h:35
@ BOSS_THEKA_THE_MARTYR
Definition: zulfarrak.h:31
@ BOSS_SHADOWPRIEST_SEZZ_ZIZ
Definition: zulfarrak.h:34
@ BOSS_HYDROMANCER_VELRATHA
Definition: zulfarrak.h:28
@ GO_END_DOOR
Definition: zulfarrak.h:56
@ ENTRY_RAVEN
Definition: zulfarrak.h:48
@ ENTRY_NEKRUM
Definition: zulfarrak.h:53
@ ENTRY_ANTUSUL
Definition: zulfarrak.h:54
@ ENTRY_SANDSCALP
Definition: zulfarrak.h:42
@ ENTRY_VELRTHA
Definition: zulfarrak.h:52
@ ENTRY_ZUM_RAH
Definition: zulfarrak.h:43
@ ENTRY_GAHZRILLA
Definition: zulfarrak.h:45
@ ENTRY_MURTA
Definition: zulfarrak.h:51
@ ENTRY_WEEGLI
Definition: zulfarrak.h:50
@ ENTRY_ORO
Definition: zulfarrak.h:49
@ ENTRY_THEKA
Definition: zulfarrak.h:44
@ ENTRY_SEZZZIZ
Definition: zulfarrak.h:46
@ ENTRY_BLY
Definition: zulfarrak.h:47
@ EVENT_PYRAMID
Definition: zulfarrak.h:58
@ PYRAMID_WAVE_2
Definition: zulfarrak.h:69
@ PYRAMID_NOT_STARTED
Definition: zulfarrak.h:64
@ PYRAMID_ARRIVED_AT_STAIR
Definition: zulfarrak.h:66
@ PYRAMID_PRE_WAVE_2
Definition: zulfarrak.h:68
@ PYRAMID_KILLED_ALL_TROLLS
Definition: zulfarrak.h:72
@ PYRAMID_WAVE_3
Definition: zulfarrak.h:71
@ PYRAMID_WAVE_1
Definition: zulfarrak.h:67
@ PYRAMID_PRE_WAVE_3
Definition: zulfarrak.h:70
#define ZFScriptName
Definition: zulfarrak.h:23