Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_uldaman.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/* ScriptData
6SDName: instance_uldaman
7SD%Complete: 99
8SDComment: Need some cosmetics updates when archeadas door are closing (Guardians Waypoints).
9SDCategory: Uldaman
10EndScriptData */
11
12#include "ScriptMgr.h"
13#include "InstanceScript.h"
14#include "uldaman.h"
15
21
23{
25};
26
28{
29public:
30 instance_uldaman() : InstanceMapScript("instance_uldaman", 70) { }
31
33 {
35
37 {
38 memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
39
40 archaedasGUID = 0;
41 ironayaGUID = 0;
43
47
49
50 keystoneGUID = 0;
51
52 ironayaSealDoorTimer = 27000; //animation time
53 keystoneCheck = false;
54 }
55
57 {
58 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
60 return true;
61
62 return false;
63 }
64
68
73
75
78
79 std::vector<uint64> stoneKeepers;
80 std::vector<uint64> altarOfTheKeeperCounts;
81 std::vector<uint64> vaultWalkers;
82 std::vector<uint64> earthenGuardians;
83 std::vector<uint64> archaedasWallMinions; // minions lined up around the wall
84
86 std::string str_data;
87
89 {
90 switch (go->GetEntry())
91 {
92 case GO_ALTAR_OF_THE_KEEPER_TEMPLE_DOOR: // lock the door
93 {
94 altarOfTheKeeperTempleDoor = go->GetGUID();
95
96 if (m_auiEncounter[0] == DONE)
97 HandleGameObject(0, true, go);
98 break;
99 }
101 {
102 archaedasTempleDoor = go->GetGUID();
103
104 if (m_auiEncounter[0] == DONE)
105 HandleGameObject(0, true, go);
106 break;
107 }
109 {
110 go->SetGoState(GOState::GO_STATE_READY);
111 go->SetUInt32Value(GAMEOBJECT_FIELD_FLAGS, 33);
112 ancientVaultDoor = go->GetGUID();
113
114 if (m_auiEncounter[1] == DONE)
115 HandleGameObject(0, true, go);
116 break;
117 }
119 {
120 ironayaSealDoor = go->GetGUID();
121
122 if (m_auiEncounter[2] == DONE)
123 HandleGameObject(0, true, go);
124 break;
125 }
126 case GO_KEYSTONE:
127 {
128 keystoneGUID = go->GetGUID();
129
130 if (m_auiEncounter[2] == DONE)
131 {
132 HandleGameObject(0, true, go);
134 }
135 break;
136 }
137 default:
138 break;
139 }
140 }
141
142 void SetFrozenState(Creature* creature)
143 {
144 creature->setFaction(35);
145 creature->RemoveAllAuras();
146 //creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_ANIMATION_FROZEN);
149 }
150
151 void SetDoor(uint64 guid, bool open)
152 {
153 GameObject* go = instance->GetGameObject(guid);
154 if (!go)
155 return;
156
157 HandleGameObject(guid, open);
158 }
159
160 void BlockGO(uint64 guid)
161 {
162 GameObject* go = instance->GetGameObject(guid);
163 if (!go)
164 return;
165
167 }
168
170 {
172 {
173 for (std::vector<uint64>::const_iterator i = stoneKeepers.begin(); i != stoneKeepers.end(); ++i)
174 {
175 Creature* target = instance->GetCreature(*i);
176 if (!target || !target->IsAlive())
177 continue;
179 target->setFaction(14);
181 return; // only want the first one we find
182 }
183 // if we get this far than all four are dead so open the door
185 SetDoor(archaedasTempleDoor, true); //open next the door too
186 }
187 }
188
190 {
191 Creature* archaedas = instance->GetCreature(archaedasGUID);
192 if (!archaedas)
193 return;
194
195 for (std::vector<uint64>::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
196 {
197 Creature* target = instance->GetCreature(*i);
198 if (!target || !target->IsAlive() || target->getFaction() == 14)
199 continue;
200 archaedas->CastSpell(target, SPELL_AWAKEN_VAULT_WALKER, true);
201 target->CastSpell(target, SPELL_ARCHAEDAS_AWAKEN, true);
204 target->setFaction(14);
205 return; // only want the first one we find
206 }
207 }
208
209 // used when Archaedas dies. All active minions must be despawned.
211 {
212 // first despawn any aggroed wall minions
213 for (std::vector<uint64>::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
214 {
215 Creature* target = instance->GetCreature(*i);
216 if (!target || target->isDead() || target->getFaction() != 14)
217 continue;
219 target->RemoveCorpse();
220 }
221
222 // Vault Walkers
223 for (std::vector<uint64>::const_iterator i = vaultWalkers.begin(); i != vaultWalkers.end(); ++i)
224 {
225 Creature* target = instance->GetCreature(*i);
226 if (!target || target->isDead() || target->getFaction() != 14)
227 continue;
229 target->RemoveCorpse();
230 }
231
232 // Earthen Guardians
233 for (std::vector<uint64>::const_iterator i = earthenGuardians.begin(); i != earthenGuardians.end(); ++i)
234 {
235 Creature* target = instance->GetCreature(*i);
236 if (!target || target->isDead() || target->getFaction() != 14)
237 continue;
239 target->RemoveCorpse();
240 }
241 }
242
244 {
245 Creature* archaedas = instance->GetCreature(archaedasGUID);
246 if (!archaedas)
247 return;
248
249 if (Unit::GetUnit(*archaedas, target))
250 {
251 archaedas->CastSpell(archaedas, SPELL_ARCHAEDAS_AWAKEN, false);
252 whoWokeuiArchaedasGUID = target;
253 }
254 }
255
257 {
258 Creature* ironaya = instance->GetCreature(ironayaGUID);
259 if (!ironaya)
260 return;
261
262 ironaya->setFaction(415);
265 }
266
268 {
269 // first respawn any aggroed wall minions
270 for (std::vector<uint64>::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
271 {
272 Creature* target = instance->GetCreature(*i);
273 if (target && target->isDead())
274 {
275 target->Respawn();
277 SetFrozenState(target);
278 }
279 }
280
281 // Vault Walkers
282 for (std::vector<uint64>::const_iterator i = vaultWalkers.begin(); i != vaultWalkers.end(); ++i)
283 {
284 Creature* target = instance->GetCreature(*i);
285 if (target && target->isDead())
286 {
287 target->Respawn();
289 SetFrozenState(target);
290 }
291 }
292
293 // Earthen Guardians
294 for (std::vector<uint64>::const_iterator i = earthenGuardians.begin(); i != earthenGuardians.end(); ++i)
295 {
296 Creature* target = instance->GetCreature(*i);
297 if (target && target->isDead())
298 {
299 target->Respawn();
301 SetFrozenState(target);
302 }
303 }
304 }
305
307 {
308 if (!keystoneCheck)
309 return;
310
311 if (ironayaSealDoorTimer <= diff)
312 {
314
317
318 SetData(DATA_IRONAYA_DOOR, DONE); //save state
319 keystoneCheck = false;
320 }
321 else
322 ironayaSealDoorTimer -= diff;
323 }
324
325 void SetData(uint32 type, uint32 data) OVERRIDE
326 {
327 switch (type)
328 {
329 case DATA_ALTAR_DOORS:
330 {
331 m_auiEncounter[0] = data;
332 if (data == DONE)
334 break;
335 }
337 {
338 m_auiEncounter[1] = data;
339 if (data == DONE) //archeadas defeat
340 {
341 SetDoor(archaedasTempleDoor, true); //re open enter door
343 }
344 break;
345 }
347 {
348 m_auiEncounter[2] = data;
349 break;
350 }
352 {
354 break;
355 }
356 case DATA_MINIONS:
357 {
358 switch (data)
359 {
360 case NOT_STARTED:
361 {
362 if (m_auiEncounter[0] == DONE) //if players opened the doors
364
366 break;
367 }
368 case IN_PROGRESS:
369 {
371 break;
372 }
373 case SPECIAL:
374 {
376 break;
377 }
378 }
379 break;
380 }
382 {
383 keystoneCheck = true;
384 break;
385 }
386 default:
387 break;
388 }
389
390 if (data == DONE)
391 {
393
394 std::ostringstream saveStream;
395 saveStream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2];
396
397 str_data = saveStream.str();
398
399 SaveToDB();
401 }
402 }
403
405 {
406 // Archaedas
407 if (type == 0)
408 {
409 ActivateArchaedas (data);
410 SetDoor(archaedasTempleDoor, false); //close when event is started
411 }
412 }
413
414 std::string GetSaveData() OVERRIDE
415 {
416 return str_data;
417 }
418
419 void Load(const char* in) OVERRIDE
420 {
421 if (!in)
422 {
424 return;
425 }
426
428
429 std::istringstream loadStream(in);
430 loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2];
431
432 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
433 {
434 if (m_auiEncounter[i] == IN_PROGRESS)
436 }
437
439 }
440
442 {
443 switch (creature->GetEntry())
444 {
445 case 4857: // Stone Keeper
446 {
447 SetFrozenState(creature);
448 stoneKeepers.push_back(creature->GetGUID());
449 break;
450 }
451 case 7309: // Earthen Custodian
452 {
453 archaedasWallMinions.push_back(creature->GetGUID());
454 break;
455 }
456 case 7077: // Earthen Hallshaper
457 {
458 archaedasWallMinions.push_back(creature->GetGUID());
459 break;
460 }
461 case 7076: // Earthen Guardian
462 {
463 earthenGuardians.push_back(creature->GetGUID());
464 break;
465 }
466 case 7228: // Ironaya
467 {
468 ironayaGUID = creature->GetGUID();
469
470 if (m_auiEncounter[2] != DONE)
471 SetFrozenState(creature);
472 break;
473 }
474 case 10120: // Vault Walker
475 {
476 vaultWalkers.push_back(creature->GetGUID());
477 break;
478 }
479 case 2748: // Archaedas
480 {
481 archaedasGUID = creature->GetGUID();
482 break;
483 }
484 }
485 }
486
487 uint64 GetData64(uint32 identifier) const OVERRIDE
488 {
489 switch (identifier)
490 {
491 case 0:
493 case 1:
494 case 2:
495 case 3:
496 case 4:
497 return vaultWalkers.at(identifier - 1);
498 case 5:
499 case 6:
500 case 7:
501 case 8:
502 case 9:
503 case 10:
504 return earthenGuardians.at(identifier - 5);
505 default:
506 break;
507 }
508
509 return 0;
510 } // end GetData64
511
512 void ProcessEvent(WorldObject* /*gameObject*/, uint32 eventId) OVERRIDE
513 {
514 switch (eventId)
515 {
517 {
518 SetData(DATA_STONE_KEEPERS, IN_PROGRESS); // activate the Stone Keepers
519 break;
520 }
521 default:
522 break;
523 }
524 }
525 };
526
531};
532
534{
535 new instance_uldaman();
536}
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
@ GO_STATE_READY
Definition GameObject.h:577
#define OUT_LOAD_INST_DATA_FAIL
@ IN_PROGRESS
@ DONE
@ SPECIAL
@ 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)
@ GO_FLAG_INTERACT_COND
@ JUST_DIED
Definition Unit.h:504
@ UNIT_FLAG_DISABLE_MOVE
Definition Unit.h:627
@ UNIT_FLAG_NOT_SELECTABLE
Definition Unit.h:650
@ UNIT_FIELD_FLAGS
@ GAMEOBJECT_FIELD_FLAGS
@ SPELL_AWAKEN_VAULT_WALKER
@ SPELL_ARCHAEDAS_AWAKEN
void Respawn(bool force=false)
void RemoveCorpse(bool setSpawnTime=true)
Definition Creature.cpp:230
void setDeathState(DeathState s) OVERRIDE
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void HandleGameObject(uint64 guid, bool open, GameObject *go=NULL)
Definition Map.h:238
void MoveTargetedHome()
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:1038
void setFaction(uint32 faction)
Definition Unit.h:1699
uint32 getFaction() const
Definition Unit.h:1695
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
MotionMaster * GetMotionMaster()
Definition Unit.h:2605
bool IsAlive() const
Definition Unit.h:2032
static Unit * GetUnit(WorldObject &object, uint64 guid)
Definition Unit.cpp:4895
void RemoveAllAuras()
bool isDead() const
Definition Unit.h:2040
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:36
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
#define MAX_ENCOUNTER
@ SPELL_AWAKEN_VAULT_WALKER
@ SPELL_ARCHAEDAS_AWAKEN
void AddSC_instance_uldaman()
@ EVENT_SUB_BOSS_AGGRO
void SetData64(uint32 type, uint64 data) OVERRIDE
void ProcessEvent(WorldObject *, uint32 eventId) OVERRIDE
void SetData(uint32 type, uint32 data) OVERRIDE
uint64 GetData64(uint32 identifier) const OVERRIDE
@ GO_ANCIENT_VAULT_DOOR
Definition uldaman.h:25
@ GO_ARCHAEDAS_TEMPLE_DOOR
Definition uldaman.h:23
@ GO_ALTAR_OF_THE_KEEPER_TEMPLE_DOOR
Definition uldaman.h:24
@ GO_KEYSTONE
Definition uldaman.h:27
@ GO_IRONAYA_SEAL_DOOR
Definition uldaman.h:26
@ DATA_ALTAR_DOORS
Definition uldaman.h:13
@ DATA_ANCIENT_DOOR
Definition uldaman.h:14
@ DATA_IRONAYA_SEAL
Definition uldaman.h:18
@ DATA_IRONAYA_DOOR
Definition uldaman.h:15
@ DATA_MINIONS
Definition uldaman.h:17
@ DATA_STONE_KEEPERS
Definition uldaman.h:16