Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_gundrak.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 "gundrak.h"
9#include "Player.h"
10#include "TemporarySummon.h"
11
12#define MAX_ENCOUNTER 5
13
14/* GunDrak encounters:
150 - Slad'Ran
161 - Moorabi
172 - Drakkari Colossus
183 - Gal'Darah
194 - Eck the Ferocious
20*/
21
23{
24public:
25 instance_gundrak() : InstanceMapScript("instance_gundrak", 604) { }
26
31
33 {
38
41
45
51
66
68
75
76 std::set<uint64> DwellerGUIDs;
77
78 std::string str_data;
79
123
125 {
126 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
127 if (m_auiEncounter[i] == IN_PROGRESS)
128 return true;
129
130 return false;
131 }
132
134 {
135 switch (creature->GetEntry())
136 {
138 sladRanGUID = creature->GetGUID();
139 break;
140 case CREATURE_MOORABI:
141 moorabiGUID = creature->GetGUID();
142 break;
144 galDarahGUID = creature->GetGUID();
145 break;
147 drakkariColossusGUID = creature->GetGUID();
148 break;
149 case CREATURE_ECK:
150 eckTheFerociousGUID = creature->GetGUID();
151 break;
153 if (creature->IsAlive())
154 DwellerGUIDs.insert(creature->GetGUID());
155 break;
156 }
157 }
158
160 {
161 switch (go->GetEntry())
162 {
163 case GO_SLADRAN_ALTAR:
164 sladRanAltarGUID = go->GetGUID();
165 // Make sure that they start out as unusuable
167 if (m_auiEncounter[0] == DONE)
168 {
171 else
172 {
173 ++phase;
174 go->SetGoState(GOState::GO_STATE_ACTIVE);
175 }
176 }
177 break;
178 case GO_MOORABI_ALTAR:
179 moorabiAltarGUID = go->GetGUID();
180 // Make sure that they start out as unusuable
182 if (m_auiEncounter[0] == DONE)
183 {
186 else
187 {
188 ++phase;
189 go->SetGoState(GOState::GO_STATE_ACTIVE);
190 }
191 }
192 break;
194 drakkariColossusAltarGUID = go->GetGUID();
195 // Make sure that they start out as unusuable
197 if (m_auiEncounter[0] == DONE)
198 {
201 else
202 {
203 ++phase;
204 go->SetGoState(GOState::GO_STATE_ACTIVE);
205 }
206 }
207 break;
209 sladRanStatueGUID = go->GetGUID();
210 go->SetGoState(sladRanStatueState);
211 break;
213 moorabiStatueGUID = go->GetGUID();
214 go->SetGoState(moorabiStatueState);
215 break;
217 galDarahStatueGUID = go->GetGUID();
218 go->SetGoState(galDarahStatueState);
219 break;
221 drakkariColossusStatueGUID = go->GetGUID();
222 go->SetGoState(drakkariColossusStatueState);
223 break;
225 eckTheFerociousDoorGUID = go->GetGUID();
226 if (isHeroic && m_auiEncounter[1] == DONE)
227 HandleGameObject(0, true, go);
228 break;
230 eckTheFerociousDoorBehindGUID = go->GetGUID();
231 if (isHeroic && m_auiEncounter[4] == DONE)
232 HandleGameObject(0, true, go);
233 break;
235 galDarahDoor1GUID = go->GetGUID();
236 if (m_auiEncounter[3] == DONE)
237 HandleGameObject(0, true, go);
238 break;
240 galDarahDoor2GUID = go->GetGUID();
241 if (m_auiEncounter[3] == DONE)
242 HandleGameObject(0, true, go);
243 break;
244 case GO_BRIDGE:
245 bridgeGUID = go->GetGUID();
246 go->SetGoState(bridgeState);
247 break;
248 case GO_COLLISION:
249 collisionGUID = go->GetGUID();
250 go->SetGoState(collisionState);
251
252 // Can't spawn here with SpawnGameObject because go isn't added to world yet...
254 spawnSupport = true;
255 break;
257 galDarahDoor3GUID = go->GetGUID();
258 if (m_auiEncounter[3] != IN_PROGRESS)
260 break;
261 }
262 }
263
264 void SetData(uint32 type, uint32 data) OVERRIDE
265 {
266 switch (type)
267 {
269 m_auiEncounter[0] = data;
270 if (data == DONE)
271 {
272 GameObject* go = instance->GetGameObject(sladRanAltarGUID);
273 if (go)
275 }
276 break;
278 m_auiEncounter[1] = data;
279 if (data == DONE)
280 {
281 GameObject* go = instance->GetGameObject(moorabiAltarGUID);
282 if (go)
284 if (isHeroic)
286 }
287 break;
289 m_auiEncounter[2] = data;
290 if (data == DONE)
291 {
292 GameObject* go = instance->GetGameObject(drakkariColossusAltarGUID);
293 if (go)
295 }
296 break;
298 m_auiEncounter[3] = data;
299 if (data == DONE)
300 {
303 }
304 HandleGameObject(galDarahDoor3GUID, data == IN_PROGRESS ? false : true);
305 break;
307 m_auiEncounter[4] = data;
308 if (isHeroic && data == DONE)
310 break;
311 }
312
313 if (data == DONE)
314 SaveToDB();
315 }
316
318 {
319 if (type == DATA_RUIN_DWELLER_DIED)
320 DwellerGUIDs.erase(data);
321 else if (type == DATA_STATUE_ACTIVATE)
322 {
323 toActivate = data;
324 timer = 3500;
325 ++phase;
326 }
327 }
328
330 {
331 switch (type)
332 {
334 return m_auiEncounter[0];
336 return m_auiEncounter[1];
338 return m_auiEncounter[2];
340 return m_auiEncounter[3];
342 return m_auiEncounter[4];
344 return DwellerGUIDs.size();
345 }
346
347 return 0;
348 }
349
351 {
352 switch (type)
353 {
355 return sladRanAltarGUID;
357 return moorabiAltarGUID;
361 return sladRanStatueGUID;
363 return moorabiStatueGUID;
369 return toActivate;
370 }
371
372 return 0;
373 }
374
375 std::string GetSaveData() OVERRIDE
376 {
378
379 std::ostringstream saveStream;
380 saveStream << "G D " << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' '
381 << m_auiEncounter[2] << ' ' << m_auiEncounter[3] << ' ' << m_auiEncounter[4]; // << ' '
382 /*
383 << (sladRanStatueGUID ? GetObjState(sladRanStatueGUID) : (0)) << ' ' << (moorabiStatueGUID ? GetObjState(moorabiStatueGUID) : (1)) << ' '
384 << (drakkariColossusStatueGUID ? GetObjState(drakkariColossusStatueGUID) : 0) << ' ' << (galDarahStatueGUID ? GetObjState(galDarahStatueGUID) : GOState::GO_STATE_READY) << ' '
385 << (bridgeGUID ? GetObjState(bridgeGUID) : GOState::GO_STATE_ACTIVE) << ' ' << (collisionGUID ? GetObjState(collisionGUID) : GOState::GO_STATE_READY);*/
386
387 str_data = saveStream.str();
388
390 return str_data;
391 }
392
393 void Load(const char* in) OVERRIDE
394 {
395 if (!in)
396 {
398 return;
399 }
400
402
403 char dataHead1, dataHead2;
404 uint16 data0, data1, data2, data3, data4, data5, data6, data7, data8, data9, data10;
405
406 std::istringstream loadStream(in);
407 loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3
408 >> data4 >> data5 >> data6 >> data7 >> data8 >> data9 >> data10;
409
410 if (dataHead1 == 'G' && dataHead2 == 'D')
411 {
412 m_auiEncounter[0] = data0;
413 m_auiEncounter[1] = data1;
414 m_auiEncounter[2] = data2;
415 m_auiEncounter[3] = data3;
416 m_auiEncounter[4] = data4;
421 bridgeState = GOState(data9);
422 collisionState = GOState(data10);
423
424 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
425 if (m_auiEncounter[i] == IN_PROGRESS)
428
430 }
431
433 {
434 // Spawn the support for the bridge if necessary
435 if (spawnSupport)
436 {
437 if (GameObject* collision = instance->GetGameObject(collisionGUID))
438 collision->SummonGameObject(192743, collision->GetPositionX(), collision->GetPositionY(), collision->GetPositionZ(), collision->GetOrientation(), 0, 0, 0, 0, 0);
439 spawnSupport = false;
440 }
441
442 // If there is nothing to activate, then return
443 if (!toActivate)
444 return;
445
446 if (timer < diff)
447 {
448 timer = 0;
449 if (toActivate == bridgeGUID)
450 {
451 GameObject* bridge = instance->GetGameObject(bridgeGUID);
452 GameObject* collision = instance->GetGameObject(collisionGUID);
453 GameObject* sladRanStatue = instance->GetGameObject(sladRanStatueGUID);
454 GameObject* moorabiStatue = instance->GetGameObject(moorabiStatueGUID);
455 GameObject* drakkariColossusStatue = instance->GetGameObject(drakkariColossusStatueGUID);
456 GameObject* galDarahStatue = instance->GetGameObject(galDarahStatueGUID);
457
458 toActivate = 0;
459
460 if (bridge && collision && sladRanStatue && moorabiStatue && drakkariColossusStatue && galDarahStatue)
461 {
466 drakkariColossusStatue->SetGoState(GOState::GO_STATE_ACTIVE_ALTERNATIVE);
468
469 // Add the GO that solidifies the bridge so you can walk on it
470 spawnSupport = true;
471 SaveToDB();
472 }
473 }
474 else
475 {
476 uint32 spell = 0;
477 GameObject* altar = NULL;
479 {
480 spell = 57071;
481 altar = instance->GetGameObject(sladRanAltarGUID);
482 }
483 else if (toActivate == moorabiStatueGUID)
484 {
485 spell = 57068;
486 altar = instance->GetGameObject(moorabiAltarGUID);
487 }
489 {
490 spell = 57072;
491 altar = instance->GetGameObject(drakkariColossusAltarGUID);
492 }
493
494 // This is a workaround to make the beam cast properly. The caster should be ID 30298 but since the spells
495 // all are with scripted target for that same ID, it will hit itself.
496 if (altar)
497 if (Creature* trigger = altar->SummonCreature(18721, altar->GetPositionX(), altar->GetPositionY(), altar->GetPositionZ() + 3, altar->GetOrientation(), TempSummonType::TEMPSUMMON_CORPSE_DESPAWN, 5000))
498 {
499 // Set the trigger model to invisible
500 trigger->SetDisplayId(11686);
501 trigger->CastSpell(trigger, spell, false);
502 }
503
504 if (GameObject* statueGO = instance->GetGameObject(toActivate))
506
507 toActivate = 0;
508
509 if (phase == 3)
511 else
512 SaveToDB(); // Don't save in between last statue and bridge turning in case of crash leading to stuck instance
513 }
514 }
515 else
516 timer -= diff;
517 }
518
520 {
521 if (GameObject* go = instance->GetGameObject(guid))
522 return go->GetGoState();
524 }
525 };
526};
527
529{
530public:
531 go_gundrak_altar() : GameObjectScript("go_gundrak_altar") { }
532
534 {
535 InstanceScript* instance = go->GetInstanceScript();
536 uint64 statueGUID = 0;
537
539 go->SetGoState(GOState::GO_STATE_ACTIVE);
540
541 if (instance)
542 {
543 switch (go->GetEntry())
544 {
545 case GO_SLADRAN_ALTAR:
546 statueGUID = instance->GetData64(DATA_SLAD_RAN_STATUE);
547 break;
548 case GO_MOORABI_ALTAR:
549 statueGUID = instance->GetData64(DATA_MOORABI_STATUE);
550 break;
552 statueGUID = instance->GetData64(DATA_DRAKKARI_COLOSSUS_STATUE);
553 break;
554 }
555
556 if (!instance->GetData64(DATA_STATUE_ACTIVATE))
557 {
558 instance->SetData64(DATA_STATUE_ACTIVATE, statueGUID);
560 go->SetGoState(GOState::GO_STATE_ACTIVE);
561 }
562 return true;
563 }
564 return false;
565 }
566};
567
569{
570 new instance_gundrak();
571 new go_gundrak_altar();
572}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
GOState
Definition GameObject.h:575
@ GO_STATE_ACTIVE
Definition GameObject.h:576
@ GO_STATE_READY
Definition GameObject.h:577
@ GO_STATE_ACTIVE_ALTERNATIVE
Definition GameObject.h:578
#define OUT_LOAD_INST_DATA_FAIL
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
#define OUT_SAVE_INST_DATA_COMPLETE
#define OUT_LOAD_INST_DATA_COMPLETE
#define OUT_SAVE_INST_DATA
#define OUT_LOAD_INST_DATA(a)
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:72
@ GO_FLAG_NOT_SELECTABLE
@ GAMEOBJECT_FIELD_FLAGS
void SetGoState(GOState state)
GameObjectScript(const char *name)
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void HandleGameObject(uint64 guid, bool open, GameObject *go=NULL)
Definition Map.h:238
bool IsHeroic() const
Definition Map.cpp:3044
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition Object.cpp:2703
virtual void SetData64(uint32, uint64)
Definition ZoneScript.h:33
virtual uint64 GetData64(uint32) const
Definition ZoneScript.h:32
bool OnGossipHello(Player *, GameObject *go) OVERRIDE
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
@ DATA_SLAD_RAN_ALTAR
Definition gundrak.h:21
@ DATA_DRAKKARI_COLOSSUS
Definition gundrak.h:27
@ DATA_RUIN_DWELLER_DIED
Definition gundrak.h:28
@ DATA_STATUE_ACTIVATE
Definition gundrak.h:29
@ DATA_DRAKKARI_COLOSSUS_ALTAR
Definition gundrak.h:23
@ DATA_MOORABI_STATUE
Definition gundrak.h:25
@ DATA_MOORABI_ALTAR
Definition gundrak.h:22
@ DATA_SLAD_RAN_STATUE
Definition gundrak.h:24
@ DATA_DRAKKARI_COLOSSUS_STATUE
Definition gundrak.h:26
@ GO_GALDARAH_DOOR2
Definition gundrak.h:54
@ GO_GALDARAH_DOOR1
Definition gundrak.h:53
@ GO_DRAKKARI_COLOSSUS_STATUE
Definition gundrak.h:50
@ GO_COLLISION
Definition gundrak.h:57
@ GO_BRIDGE
Definition gundrak.h:56
@ GO_GALDARAH_DOOR3
Definition gundrak.h:55
@ GO_ECK_THE_FEROCIOUS_DOOR_BEHIND
Definition gundrak.h:52
@ GO_GALDARAH_STATUE
Definition gundrak.h:49
@ GO_ECK_THE_FEROCIOUS_DOOR
Definition gundrak.h:51
@ GO_SLADRAN_STATUE
Definition gundrak.h:47
@ GO_MOORABI_ALTAR
Definition gundrak.h:45
@ GO_SLADRAN_ALTAR
Definition gundrak.h:44
@ GO_MOORABI_STATUE
Definition gundrak.h:48
@ GO_DRAKKARI_COLOSSUS_ALTAR
Definition gundrak.h:46
@ CREATURE_DRAKKARICOLOSSUS
Definition gundrak.h:38
@ CREATURE_RUIN_DWELLER
Definition gundrak.h:34
@ CREATURE_ECK
Definition gundrak.h:39
@ CREATURE_SLAD_RAN
Definition gundrak.h:35
@ CREATURE_GALDARAH
Definition gundrak.h:37
@ CREATURE_MOORABI
Definition gundrak.h:36
@ DATA_ECK_THE_FEROCIOUS_EVENT
Definition gundrak.h:15
@ DATA_GAL_DARAH_EVENT
Definition gundrak.h:14
@ DATA_DRAKKARI_COLOSSUS_EVENT
Definition gundrak.h:13
@ DATA_ALIVE_RUIN_DWELLERS
Definition gundrak.h:16
@ DATA_MOORABI_EVENT
Definition gundrak.h:12
@ DATA_SLAD_RAN_EVENT
Definition gundrak.h:11
void AddSC_instance_gundrak()
#define MAX_ENCOUNTER
float GetPositionZ() const
Definition Object.h:330
float GetOrientation() const
Definition Object.h:331
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
void SetData64(uint32 type, uint64 data) OVERRIDE
void SetData(uint32 type, uint32 data) OVERRIDE