Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_zulfarrak.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "InstanceScript.h"
8#include "zulfarrak.h"
9#include "Player.h"
10#include "TemporarySummon.h"
11
12enum Misc
13{
14 // Creatures
16
17 // Paths
18 PATH_ADDS = 81553
19};
20
21int const pyramidSpawnTotal = 54;
22/* list of wave spawns: 0 = wave ID, 1 = creature id, 2 = x, 3 = y
23no z coordinat b/c they're all the same */
25 {1, 7789, 1894.64f, 1206.29f},
26 {1, 7787, 1890.08f, 1218.68f},
27 {1, 8876, 1883.76f, 1222.3f},
28 {1, 7789, 1874.18f, 1221.24f},
29 {1, 7787, 1892.28f, 1225.49f},
30 {1, 7788, 1889.94f, 1212.21f},
31 {1, 7787, 1879.02f, 1223.06f},
32 {1, 7789, 1874.45f, 1204.44f},
33 {1, 8876, 1898.23f, 1217.97f},
34 {1, 7787, 1882.07f, 1225.7f},
35 {1, 8877, 1896.46f, 1205.62f},
36 {1, 7787, 1886.97f, 1225.86f},
37 {1, 7787, 1894.72f, 1221.91f},
38 {1, 7787, 1883.5f, 1218.25f},
39 {1, 7787, 1886.93f, 1221.4f},
40 {1, 8876, 1889.82f, 1222.51f},
41 {1, 7788, 1893.07f, 1215.26f},
42 {1, 7788, 1878.57f, 1214.16f},
43 {1, 7788, 1883.74f, 1212.35f},
44 {1, 8877, 1877, 1207.27f},
45 {1, 8877, 1873.63f, 1204.65f},
46 {1, 8876, 1877.4f, 1216.41f},
47 {1, 8877, 1899.63f, 1202.52f},
48 {2, 7789, 1902.83f, 1223.41f},
49 {2, 8876, 1889.82f, 1222.51f},
50 {2, 7787, 1883.5f, 1218.25f},
51 {2, 7788, 1883.74f, 1212.35f},
52 {2, 8877, 1877, 1207.27f},
53 {2, 7787, 1890.08f, 1218.68f},
54 {2, 7789, 1894.64f, 1206.29f},
55 {2, 8876, 1877.4f, 1216.41f},
56 {2, 7787, 1892.28f, 1225.49f},
57 {2, 7788, 1893.07f, 1215.26f},
58 {2, 8877, 1896.46f, 1205.62f},
59 {2, 7789, 1874.45f, 1204.44f},
60 {2, 7789, 1874.18f, 1221.24f},
61 {2, 7787, 1879.02f, 1223.06f},
62 {2, 8876, 1898.23f, 1217.97f},
63 {2, 7787, 1882.07f, 1225.7f},
64 {2, 8877, 1873.63f, 1204.65f},
65 {2, 7787, 1886.97f, 1225.86f},
66 {2, 7788, 1878.57f, 1214.16f},
67 {2, 7787, 1894.72f, 1221.91f},
68 {2, 7787, 1886.93f, 1221.4f},
69 {2, 8876, 1883.76f, 1222.3f},
70 {2, 7788, 1889.94f, 1212.21f},
71 {2, 8877, 1899.63f, 1202.52f},
72 {3, 7788, 1878.57f, 1214.16f},
73 {3, 7787, 1894.72f, 1221.91f},
74 {3, 7787, 1886.93f, 1221.4f},
75 {3, 8876, 1883.76f, 1222.3f},
76 {3, 7788, 1889.94f, 1212.21f},
77 {3, 7275, 1889.23f, 1207.72f},
78 {3, 7796, 1879.77f, 1207.96f}
79};
80
81float Spawnsway[2][3] =
82{
83 {1884.86f, 1228.62f, 9},
84 {1887.53f, 1263, 41}
85};
86
88{
89public:
90 instance_zulfarrak() : InstanceMapScript("instance_zulfarrak", 209) { }
91
96
98 {
100
114
116 {
118 ZumrahGUID = 0;
119 BlyGUID = 0;
120 WeegliGUID = 0;
121 OroGUID = 0;
122 RavenGUID = 0;
123 MurtaGUID = 0;
124 EndDoorGUID = 0;
125 PyramidPhase = 0;
128 addGroupSize = 0;
129 waypoint = 0;
130 }
131
133 {
134 switch (creature->GetEntry())
135 {
136 case ENTRY_ZUM_RAH:
137 ZumrahGUID = creature->GetGUID();
138 break;
139 case ENTRY_BLY:
140 BlyGUID = creature->GetGUID();
141 creature->SetReactState(REACT_PASSIVE); // starts out passive (in a cage)
142 break;
143 case ENTRY_RAVEN:
144 RavenGUID = creature->GetGUID();
145 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
146 break;
147 case ENTRY_ORO:
148 OroGUID = creature->GetGUID();
149 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
150 break;
151 case ENTRY_WEEGLI:
152 WeegliGUID = creature->GetGUID();
153 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
154 break;
155 case ENTRY_MURTA:
156 MurtaGUID = creature->GetGUID();
157 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
158 break;
159 case NPC_GAHZRILLA:
161 creature->DisappearAndDie();
162 else
164 break;
165 }
166 }
167
169 {
170 switch (go->GetEntry())
171 {
172 case GO_END_DOOR:
173 EndDoorGUID = go->GetGUID();
174 break;
175 }
176 }
177
179 {
180 switch (type)
181 {
182 case EVENT_PYRAMID:
183 return PyramidPhase;
184 }
185 return 0;
186 }
187
189 {
190 switch (data)
191 {
192 case ENTRY_ZUM_RAH:
193 return ZumrahGUID;
194 case ENTRY_BLY:
195 return BlyGUID;
196 case ENTRY_RAVEN:
197 return RavenGUID;
198 case ENTRY_ORO:
199 return OroGUID;
200 case ENTRY_WEEGLI:
201 return WeegliGUID;
202 case ENTRY_MURTA:
203 return MurtaGUID;
204 case GO_END_DOOR:
205 return EndDoorGUID;
206 }
207 return 0;
208 }
209
210 void SetData(uint32 type, uint32 data) OVERRIDE
211 {
212 switch (type)
213 {
214 case EVENT_PYRAMID:
215 PyramidPhase=data;
216 break;
217 };
218 }
219
220 virtual void Update(uint32 diff)
221 {
222 switch (PyramidPhase)
223 {
226 break;
230 major_wave_Timer=120000;
232 addGroupSize=2;
233 break;
234 case PYRAMID_WAVE_1:
235 if (IsWaveAllDead())
236 {
238 major_wave_Timer = 10000; //give players a few seconds before wave 2 starts to rebuff
239 }
240 else
241 if (minor_wave_Timer<diff)
242 {
244 minor_wave_Timer=10000;
245 }
246 else
247 minor_wave_Timer -= diff;
248 break;
250 if (major_wave_Timer<diff)
251 {
252 // beginning 2nd wave!
256 addGroupSize=2;
257 }
258 else
259 major_wave_Timer -= diff;
260 break;
261 case PYRAMID_WAVE_2:
262 if (IsWaveAllDead())
263 {
266 major_wave_Timer = 5000; //give NPCs time to return to their home spots
267 }
268 else
269 if (minor_wave_Timer<diff)
270 {
272 minor_wave_Timer=10000;
273 }
274 else
275 minor_wave_Timer -= diff;
276 break;
278 if (major_wave_Timer<diff)
279 {
280 // move NPCs to bottom of stair
281 MoveNPCIfAlive(ENTRY_BLY, 1887.92f, 1228.179f, 9.98f, 4.78f);
282 MoveNPCIfAlive(ENTRY_MURTA, 1891.57f, 1228.68f, 9.69f, 4.78f);
283 MoveNPCIfAlive(ENTRY_ORO, 1897.23f, 1228.34f, 9.43f, 4.78f);
284 MoveNPCIfAlive(ENTRY_RAVEN, 1883.68f, 1227.95f, 9.543f, 4.78f);
285 MoveNPCIfAlive(ENTRY_WEEGLI, 1878.02f, 1227.65f, 9.485f, 4.78f);
287 }
288 else
289 major_wave_Timer -= diff;
290 break;
291 case PYRAMID_WAVE_3:
292 if (IsWaveAllDead()) // move NPCS to their final positions
293 {
295 MoveNPCIfAlive(ENTRY_BLY, 1883.82f, 1200.83f, 8.87f, 1.32f);
296 MoveNPCIfAlive(ENTRY_MURTA, 1891.83f, 1201.45f, 8.87f, 1.32f);
297 MoveNPCIfAlive(ENTRY_ORO, 1894.50f, 1204.40f, 8.87f, 1.32f);
298 MoveNPCIfAlive(ENTRY_RAVEN, 1874.11f, 1206.17f, 8.87f, 1.32f);
299 MoveNPCIfAlive(ENTRY_WEEGLI, 1877.52f, 1199.63f, 8.87f, 1.32f);
300 }
301 break;
302 };
303 }
304
305 std::list<uint64> addsAtBase, movedadds;
306
307 void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o)
308 {
309 if (Creature* npc = instance->GetCreature(GetData64(entry)))
310 {
311 if (npc->IsAlive())
312 {
313 npc->SetWalk(true);
314 npc->GetMotionMaster()->MovePoint(1, x, y, z);
315 npc->SetHomePosition(x, y, z, o);
316 }
317 }
318 }
319
321 {
322 for (int i = 0; i < pyramidSpawnTotal; i++)
323 {
324 if (pyramidSpawns[i][0] == (float)wave)
325 {
326 Position pos = {pyramidSpawns[i][2], pyramidSpawns[i][3], 8.87f, 0};
327 TempSummon* ts = instance->SummonCreature(uint32(pyramidSpawns[i][1]), pos);
328 ts->GetMotionMaster()->MoveRandom(10);
329 addsAtBase.push_back(ts->GetGUID());
330 }
331 }
332 }
333
335 {
336 for (std::list<uint64>::iterator itr = addsAtBase.begin(); itr != addsAtBase.end(); ++itr)
337 {
338 if (Creature* add = instance->GetCreature((*itr)))
339 {
340 if (add->IsAlive())
341 return false;
342 }
343 }
344 for (std::list<uint64>::iterator itr = movedadds.begin(); itr != movedadds.end(); ++itr)
345 {
346 if (Creature* add = instance->GetCreature(((*itr))))
347 {
348 if (add->IsAlive())
349 return false;
350 }
351 }
352 return true;
353 }
354
356 {
357 //pop a add from list, send him up the stairs...
358 for (uint32 addCount = 0; addCount<count && !addsAtBase.empty(); addCount++)
359 {
360 if (Creature* add = instance->GetCreature(*addsAtBase.begin()))
361 {
362 add->GetMotionMaster()->MovePath(PATH_ADDS, false);
363 movedadds.push_back(add->GetGUID());
364 }
365 addsAtBase.erase(addsAtBase.begin());
366 }
367 }
368 };
369};
370
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ IN_PROGRESS
@ NOT_STARTED
@ REACT_PASSIVE
Definition Unit.h:1156
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
Definition Map.h:238
void MoveRandom(float spawndist=0.0f)
uint64 GetGUID() const
Definition Object.h:119
MotionMaster * GetMotionMaster()
Definition Unit.h:2605
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
@ NPC_GAHZRILLA
int const pyramidSpawnTotal
float Spawnsway[2][3]
float pyramidSpawns[pyramidSpawnTotal][4]
void AddSC_instance_zulfarrak()
void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o)
@ PYRAMID_WAVE_2
Definition zulfarrak.h:36
@ PYRAMID_NOT_STARTED
Definition zulfarrak.h:31
@ PYRAMID_ARRIVED_AT_STAIR
Definition zulfarrak.h:33
@ PYRAMID_PRE_WAVE_2
Definition zulfarrak.h:35
@ PYRAMID_KILLED_ALL_TROLLS
Definition zulfarrak.h:39
@ PYRAMID_WAVE_3
Definition zulfarrak.h:38
@ PYRAMID_WAVE_1
Definition zulfarrak.h:34
@ PYRAMID_PRE_WAVE_3
Definition zulfarrak.h:37
@ GO_END_DOOR
Definition zulfarrak.h:18
@ ENTRY_RAVEN
Definition zulfarrak.h:13
@ ENTRY_ZUM_RAH
Definition zulfarrak.h:11
@ ENTRY_MURTA
Definition zulfarrak.h:16
@ ENTRY_WEEGLI
Definition zulfarrak.h:15
@ ENTRY_ORO
Definition zulfarrak.h:14
@ ENTRY_BLY
Definition zulfarrak.h:12
@ EVENT_PYRAMID
Definition zulfarrak.h:20