TrinityCore
Loading...
Searching...
No Matches
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 "Player.h"
24#include "TemporarySummon.h"
25#include "zulfarrak.h"
26
27enum Misc
28{
29 // Creatures
31
32 // Paths
33 PATH_ADDS = 652424
34};
35
36int const pyramidSpawnTotal = 54;
37/* list of wave spawns: 0 = wave ID, 1 = creature id, 2 = x, 3 = y
38no z coordinat b/c they're all the same */
40 {1, 7789, 1894.64f, 1206.29f},
41 {1, 7787, 1890.08f, 1218.68f},
42 {1, 8876, 1883.76f, 1222.3f},
43 {1, 7789, 1874.18f, 1221.24f},
44 {1, 7787, 1892.28f, 1225.49f},
45 {1, 7788, 1889.94f, 1212.21f},
46 {1, 7787, 1879.02f, 1223.06f},
47 {1, 7789, 1874.45f, 1204.44f},
48 {1, 8876, 1898.23f, 1217.97f},
49 {1, 7787, 1882.07f, 1225.7f},
50 {1, 8877, 1896.46f, 1205.62f},
51 {1, 7787, 1886.97f, 1225.86f},
52 {1, 7787, 1894.72f, 1221.91f},
53 {1, 7787, 1883.5f, 1218.25f},
54 {1, 7787, 1886.93f, 1221.4f},
55 {1, 8876, 1889.82f, 1222.51f},
56 {1, 7788, 1893.07f, 1215.26f},
57 {1, 7788, 1878.57f, 1214.16f},
58 {1, 7788, 1883.74f, 1212.35f},
59 {1, 8877, 1877, 1207.27f},
60 {1, 8877, 1873.63f, 1204.65f},
61 {1, 8876, 1877.4f, 1216.41f},
62 {1, 8877, 1899.63f, 1202.52f},
63 {2, 7789, 1902.83f, 1223.41f},
64 {2, 8876, 1889.82f, 1222.51f},
65 {2, 7787, 1883.5f, 1218.25f},
66 {2, 7788, 1883.74f, 1212.35f},
67 {2, 8877, 1877, 1207.27f},
68 {2, 7787, 1890.08f, 1218.68f},
69 {2, 7789, 1894.64f, 1206.29f},
70 {2, 8876, 1877.4f, 1216.41f},
71 {2, 7787, 1892.28f, 1225.49f},
72 {2, 7788, 1893.07f, 1215.26f},
73 {2, 8877, 1896.46f, 1205.62f},
74 {2, 7789, 1874.45f, 1204.44f},
75 {2, 7789, 1874.18f, 1221.24f},
76 {2, 7787, 1879.02f, 1223.06f},
77 {2, 8876, 1898.23f, 1217.97f},
78 {2, 7787, 1882.07f, 1225.7f},
79 {2, 8877, 1873.63f, 1204.65f},
80 {2, 7787, 1886.97f, 1225.86f},
81 {2, 7788, 1878.57f, 1214.16f},
82 {2, 7787, 1894.72f, 1221.91f},
83 {2, 7787, 1886.93f, 1221.4f},
84 {2, 8876, 1883.76f, 1222.3f},
85 {2, 7788, 1889.94f, 1212.21f},
86 {2, 8877, 1899.63f, 1202.52f},
87 {3, 7788, 1878.57f, 1214.16f},
88 {3, 7787, 1894.72f, 1221.91f},
89 {3, 7787, 1886.93f, 1221.4f},
90 {3, 8876, 1883.76f, 1222.3f},
91 {3, 7788, 1889.94f, 1212.21f},
92 {3, 7275, 1889.23f, 1207.72f},
93 {3, 7796, 1879.77f, 1207.96f}
94};
95
96float Spawnsway[2][3] =
97{
98 {1884.86f, 1228.62f, 9},
99 {1887.53f, 1263, 41}
100};
101
103{
104public:
106
108 {
110 }
111
113 {
124
138
139 void OnCreatureCreate(Creature* creature) override
140 {
141 switch (creature->GetEntry())
142 {
143 case ENTRY_ZUM_RAH:
144 ZumrahGUID = creature->GetGUID();
145 break;
146 case ENTRY_BLY:
147 BlyGUID = creature->GetGUID();
148 creature->SetReactState(REACT_PASSIVE); // starts out passive (in a cage)
149 break;
150 case ENTRY_RAVEN:
151 RavenGUID = creature->GetGUID();
152 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
153 break;
154 case ENTRY_ORO:
155 OroGUID = creature->GetGUID();
156 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
157 break;
158 case ENTRY_WEEGLI:
159 WeegliGUID = creature->GetGUID();
160 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
161 break;
162 case ENTRY_MURTA:
163 MurtaGUID = creature->GetGUID();
164 creature->SetReactState(REACT_PASSIVE);// starts out passive (in a cage)
165 break;
166 case NPC_GAHZRILLA:
168 creature->DisappearAndDie();
169 else
171 break;
172 }
173 }
174
176 {
177 switch (go->GetEntry())
178 {
179 case GO_END_DOOR:
180 EndDoorGUID = go->GetGUID();
181 break;
182 }
183 }
184
185 uint32 GetData(uint32 type) const override
186 {
187 switch (type)
188 {
189 case EVENT_PYRAMID:
190 return PyramidPhase;
191 }
192 return 0;
193 }
194
195 ObjectGuid GetGuidData(uint32 data) const override
196 {
197 switch (data)
198 {
199 case ENTRY_ZUM_RAH:
200 return ZumrahGUID;
201 case ENTRY_BLY:
202 return BlyGUID;
203 case ENTRY_RAVEN:
204 return RavenGUID;
205 case ENTRY_ORO:
206 return OroGUID;
207 case ENTRY_WEEGLI:
208 return WeegliGUID;
209 case ENTRY_MURTA:
210 return MurtaGUID;
211 case GO_END_DOOR:
212 return EndDoorGUID;
213 }
214 return ObjectGuid::Empty;
215 }
216
217 void SetData(uint32 type, uint32 data) override
218 {
219 switch (type)
220 {
221 case EVENT_PYRAMID:
222 PyramidPhase = data;
223 break;
224 }
225 }
226
227 virtual void Update(uint32 diff) override
228 {
229 switch (PyramidPhase)
230 {
233 break;
237 major_wave_Timer=120000;
239 addGroupSize=2;
240 break;
241 case PYRAMID_WAVE_1:
242 if (IsWaveAllDead())
243 {
245 major_wave_Timer = 10000; //give players a few seconds before wave 2 starts to rebuff
246 }
247 else
248 if (minor_wave_Timer<diff)
249 {
251 minor_wave_Timer=10000;
252 }
253 else
254 minor_wave_Timer -= diff;
255 break;
257 if (major_wave_Timer<diff)
258 {
259 // beginning 2nd wave!
263 addGroupSize=2;
264 }
265 else
266 major_wave_Timer -= diff;
267 break;
268 case PYRAMID_WAVE_2:
269 if (IsWaveAllDead())
270 {
273 major_wave_Timer = 5000; //give NPCs time to return to their home spots
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 // move NPCs to bottom of stair
288 MoveNPCIfAlive(ENTRY_BLY, 1887.92f, 1228.179f, 9.98f, 4.78f);
289 MoveNPCIfAlive(ENTRY_MURTA, 1891.57f, 1228.68f, 9.69f, 4.78f);
290 MoveNPCIfAlive(ENTRY_ORO, 1897.23f, 1228.34f, 9.43f, 4.78f);
291 MoveNPCIfAlive(ENTRY_RAVEN, 1883.68f, 1227.95f, 9.543f, 4.78f);
292 MoveNPCIfAlive(ENTRY_WEEGLI, 1878.02f, 1227.65f, 9.485f, 4.78f);
294 }
295 else
296 major_wave_Timer -= diff;
297 break;
298 case PYRAMID_WAVE_3:
299 if (IsWaveAllDead()) // move NPCS to their final positions
300 {
302 MoveNPCIfAlive(ENTRY_BLY, 1883.82f, 1200.83f, 8.87f, 1.32f);
303 MoveNPCIfAlive(ENTRY_MURTA, 1891.83f, 1201.45f, 8.87f, 1.32f);
304 MoveNPCIfAlive(ENTRY_ORO, 1894.50f, 1204.40f, 8.87f, 1.32f);
305 MoveNPCIfAlive(ENTRY_RAVEN, 1874.11f, 1206.17f, 8.87f, 1.32f);
306 MoveNPCIfAlive(ENTRY_WEEGLI, 1877.52f, 1199.63f, 8.87f, 1.32f);
307 }
308 break;
309 };
310 }
311
313
314 void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o)
315 {
316 if (Creature* npc = instance->GetCreature(GetGuidData(entry)))
317 {
318 if (npc->IsAlive())
319 {
320 npc->SetWalk(true);
321 npc->GetMotionMaster()->MovePoint(1, x, y, z);
322 npc->SetHomePosition(x, y, z, o);
323 }
324 }
325 }
326
328 {
329 for (int i = 0; i < pyramidSpawnTotal; i++)
330 {
331 if (pyramidSpawns[i][0] == (float)wave)
332 {
333 Position pos = {pyramidSpawns[i][2], pyramidSpawns[i][3], 8.87f, 0};
335 ts->GetMotionMaster()->MoveRandom(10);
336 addsAtBase.push_back(ts->GetGUID());
337 }
338 }
339 }
340
342 {
343 for (GuidList::iterator itr = addsAtBase.begin(); itr != addsAtBase.end(); ++itr)
344 {
345 if (Creature* add = instance->GetCreature((*itr)))
346 {
347 if (add->IsAlive())
348 return false;
349 }
350 }
351 for (GuidList::iterator itr = movedadds.begin(); itr != movedadds.end(); ++itr)
352 {
353 if (Creature* add = instance->GetCreature(((*itr))))
354 {
355 if (add->IsAlive())
356 return false;
357 }
358 }
359 return true;
360 }
361
363 {
364 //pop a add from list, send him up the stairs...
365 for (uint32 addCount = 0; addCount<count && !addsAtBase.empty(); addCount++)
366 {
367 if (Creature* add = instance->GetCreature(*addsAtBase.begin()))
368 {
369 add->GetMotionMaster()->MovePath(PATH_ADDS, false);
370 movedadds.push_back(add->GetGUID());
371 }
372 addsAtBase.erase(addsAtBase.begin());
373 }
374 }
375 };
376
377};
378
uint32_t uint32
Definition Define.h:133
@ IN_PROGRESS
@ NOT_STARTED
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:261
@ REACT_PASSIVE
#define DataHeader
void SetReactState(ReactStates st)
Definition Creature.h:119
void DisappearAndDie()
Definition Creature.h:73
InstanceMap * instance
void SetHeaders(std::string const &dataHeaders)
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1852
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4397
void MoveRandom(float wanderDistance=0.0f)
static ObjectGuid const Empty
Definition ObjectGuid.h:140
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
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)
@ GO_END_DOOR
Definition zulfarrak.h:35
@ ENTRY_RAVEN
Definition zulfarrak.h:30
@ ENTRY_ZUM_RAH
Definition zulfarrak.h:28
@ ENTRY_MURTA
Definition zulfarrak.h:33
@ ENTRY_WEEGLI
Definition zulfarrak.h:32
@ ENTRY_ORO
Definition zulfarrak.h:31
@ ENTRY_BLY
Definition zulfarrak.h:29
@ EVENT_PYRAMID
Definition zulfarrak.h:37
@ PYRAMID_WAVE_2
Definition zulfarrak.h:53
@ PYRAMID_NOT_STARTED
Definition zulfarrak.h:48
@ PYRAMID_ARRIVED_AT_STAIR
Definition zulfarrak.h:50
@ PYRAMID_PRE_WAVE_2
Definition zulfarrak.h:52
@ PYRAMID_KILLED_ALL_TROLLS
Definition zulfarrak.h:56
@ PYRAMID_WAVE_3
Definition zulfarrak.h:55
@ PYRAMID_WAVE_1
Definition zulfarrak.h:51
@ PYRAMID_PRE_WAVE_3
Definition zulfarrak.h:54
#define ZFScriptName
Definition zulfarrak.h:23