TrinityCore
instance_uldaman.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/* ScriptData
19SDName: instance_uldaman
20SD%Complete: 80%
21SDComment: Need some cosmetics updates when archeadas door are closing (Guardians Waypoints).
22SDCategory: Uldaman
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "Creature.h"
27#include "CreatureAI.h"
28#include "GameObject.h"
29#include "InstanceScript.h"
30#include "Map.h"
31#include "MotionMaster.h"
32#include "ObjectAccessor.h"
33#include "uldaman.h"
34
36{
41};
42
44{
46};
47
49{
50 SAY_AGGRO = 0
51};
52
53static constexpr DungeonEncounterData Encounters[] =
54{
55 { BOSS_REVELOSH, { { 547 } } },
56 { BOSS_THE_LOST_DWARVES, { { 548 } } },
57 { BOSS_IRONAYA, { { 549 } } },
58 { BOSS_ANCIENT_STONE_KEEPER, { { 551 } } },
59 { BOSS_GALGANN_FIREHAMMER, { { 552 } } },
60 { BOSS_GRIMLOK, { { 553 } } },
61 { BOSS_ARCHAEDAS, { { 554 } } },
62 { BOSS_OBSIDIAN_SENTINEL, { { 1887 } } },
63};
64
65const Position IronayaPoint = { -231.228f, 246.6135f, -49.01617f, 0.0f };
66
68{
69 public:
71
73 {
75 {
79
80 ironayaActive = false;
81 altarDoorsDone = false;
82 ironayaSealDoorTimer = 27000; //animation time
83 keystoneCheck = false;
84 }
85
89
91
94
98
100
103
108 GuidVector archaedasWallMinions; // minions lined up around the wall
109
111 {
112 switch (go->GetEntry())
113 {
114 case GO_ALTAR_OF_THE_KEEPER_TEMPLE_DOOR: // lock the door
116
117 if (altarDoorsDone)
119 break;
120
123
124 if (altarDoorsDone)
126 break;
127
132
135 break;
136
138 ironayaSealDoor = go->GetGUID();
139
140 if (ironayaActive)
142 break;
143
144 case GO_KEYSTONE:
145 keystoneGUID = go->GetGUID();
146
147 if (ironayaActive)
148 {
151 }
152 break;
153 }
154 }
155
156 void SetFrozenState(Creature* creature)
157 {
158 creature->SetFaction(FACTION_FRIENDLY);
159 creature->RemoveAllAuras();
160 creature->SetUninteractible(true);
161 creature->SetControlled(true, UNIT_STATE_ROOT);
162 creature->AddAura(SPELL_MINION_FREEZE_ANIM, creature);
163 }
164
165 void SetDoor(ObjectGuid guid, bool open)
166 {
167 GameObject* go = instance->GetGameObject(guid);
168 if (!go)
169 return;
170
171 HandleGameObject(guid, open);
172 }
173
175 {
176 GameObject* go = instance->GetGameObject(guid);
177 if (!go)
178 return;
179
181 }
182
184 {
186 {
187 for (GuidVector::const_iterator i = stoneKeepers.begin(); i != stoneKeepers.end(); ++i)
188 {
189 Creature* target = instance->GetCreature(*i);
190 if (!target || !target->IsAlive())
191 continue;
192 target->SetControlled(false, UNIT_STATE_ROOT);
194 target->SetUninteractible(false);
196
197 return; // only want the first one we find
198 }
199 // if we get this far than all four are dead so open the door
201 SetDoor(archaedasTempleDoor, true); //open next the door too
202 }
203 }
204
206 {
208 if (!archaedas)
209 return;
210
211 for (GuidVector::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
212 {
213 Creature* target = instance->GetCreature(*i);
214 if (!target || !target->IsAlive() || target->GetFaction() == FACTION_MONSTER)
215 continue;
216 target->SetControlled(false, UNIT_STATE_ROOT);
217 target->SetUninteractible(false);
220 archaedas->CastSpell(target, SPELL_AWAKEN_VAULT_WALKER, true);
221 target->CastSpell(target, SPELL_ARCHAEDAS_AWAKEN, true);
222
223 return; // only want the first one we find
224 }
225 }
226
227 // used when Archaedas dies. All active minions must be despawned.
229 {
230 // first despawn any aggroed wall minions
231 for (GuidVector::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
232 {
233 Creature* target = instance->GetCreature(*i);
234 if (!target || target->isDead() || target->GetFaction() != FACTION_MONSTER)
235 continue;
236 target->DespawnOrUnsummon();
237 }
238
239 // Vault Walkers
240 for (GuidVector::const_iterator i = vaultWalkers.begin(); i != vaultWalkers.end(); ++i)
241 {
242 Creature* target = instance->GetCreature(*i);
243 if (!target || target->isDead() || target->GetFaction() != FACTION_MONSTER)
244 continue;
245 target->DespawnOrUnsummon();
246 }
247
248 // Earthen Guardians
249 for (GuidVector::const_iterator i = earthenGuardians.begin(); i != earthenGuardians.end(); ++i)
250 {
251 Creature* target = instance->GetCreature(*i);
252 if (!target || target->isDead() || target->GetFaction() != FACTION_MONSTER)
253 continue;
254 target->DespawnOrUnsummon();
255 }
256 }
257
259 {
261 if (!archaedas)
262 return;
263
264 if (ObjectAccessor::GetUnit(*archaedas, target))
265 {
266 archaedas->RemoveAura(SPELL_FREEZE_ANIM);
267 archaedas->CastSpell(archaedas, SPELL_ARCHAEDAS_AWAKEN, false);
268 archaedas->SetFaction(FACTION_TITAN);
269 archaedas->SetUninteractible(false);
270 whoWokeuiArchaedasGUID = target;
271 }
272 }
273
275 {
277 if (!ironaya)
278 return;
279
280 ironaya->SetFaction(FACTION_TITAN);
281 ironaya->SetControlled(false, UNIT_STATE_ROOT);
282 ironaya->SetUninteractible(false);
283
284 ironaya->GetMotionMaster()->Clear();
285 ironaya->GetMotionMaster()->MovePoint(0, IronayaPoint);
287
288 ironaya->AI()->Talk(SAY_AGGRO);
289 ironayaActive = true;
290 }
291
293 {
294 // first respawn any aggroed wall minions
295 for (GuidVector::const_iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
296 {
297 Creature* target = instance->GetCreature(*i);
298 if (target && target->isDead())
299 {
300 target->Respawn();
302 SetFrozenState(target);
303 }
304 }
305
306 // Vault Walkers
307 for (GuidVector::const_iterator i = vaultWalkers.begin(); i != vaultWalkers.end(); ++i)
308 {
309 Creature* target = instance->GetCreature(*i);
310 if (target && target->isDead())
311 {
312 target->Respawn();
314 SetFrozenState(target);
315 }
316 }
317
318 // Earthen Guardians
319 for (GuidVector::const_iterator i = earthenGuardians.begin(); i != earthenGuardians.end(); ++i)
320 {
321 Creature* target = instance->GetCreature(*i);
322 if (target && target->isDead())
323 {
324 target->Respawn();
326 SetFrozenState(target);
327 }
328 }
329 }
330 void Update(uint32 diff) override
331 {
332 if (!keystoneCheck)
333 return;
334
335 if (ironayaSealDoorTimer <= diff)
336 {
338
341
342 keystoneCheck = false;
343 }
344 else
345 ironayaSealDoorTimer -= diff;
346 }
347
348 bool SetBossState(uint32 id, EncounterState state) override
349 {
350 if (!InstanceScript::SetBossState(id, state))
351 return false;
352
353 switch (id)
354 {
355 case BOSS_ARCHAEDAS:
356 if (state == DONE) //archeadas defeat
357 {
358 SetDoor(archaedasTempleDoor, true); //re open enter door
360 }
361 break;
362 }
363
364 return true;
365 }
366
367 void SetData(uint32 type, uint32 data) override
368 {
369 switch (type)
370 {
371 case DATA_ALTAR_DOORS:
372 altarDoorsDone = data == DONE;
373 if (data == DONE)
375 break;
376
379 break;
380
383 break;
384
385 case DATA_MINIONS:
386 switch (data)
387 {
388 case NOT_STARTED:
389 if (altarDoorsDone) //if players opened the doors
391
393 break;
394
395 case IN_PROGRESS:
397 break;
398
399 case SPECIAL:
401 break;
402 }
403 break;
404
406 keystoneCheck = true;
407 break;
408 }
409 }
410
411 void SetGuidData(uint32 type, ObjectGuid data) override
412 {
413 // Archaedas
414 if (type == 0)
415 {
416 ActivateArchaedas (data);
417 SetDoor(archaedasTempleDoor, false); //close when event is started
418 }
419 }
420
421 void OnCreatureCreate(Creature* creature) override
422 {
423 switch (creature->GetEntry())
424 {
425 case 4857: // Stone Keeper
426 SetFrozenState (creature);
427 stoneKeepers.push_back(creature->GetGUID());
428 break;
429
430 case 7309: // Earthen Custodian
431 archaedasWallMinions.push_back(creature->GetGUID());
432 break;
433
434 case 7077: // Earthen Hallshaper
435 archaedasWallMinions.push_back(creature->GetGUID());
436 break;
437
438 case 7076: // Earthen Guardian
439 earthenGuardians.push_back(creature->GetGUID());
440 break;
441
442 case 7228: // Ironaya
443 ironayaGUID = creature->GetGUID();
444
445 if (!ironayaActive)
446 SetFrozenState (creature);
447 break;
448
449 case 10120: // Vault Walker
450 vaultWalkers.push_back(creature->GetGUID());
451 break;
452
453 case 2748: // Archaedas
454 archaedasGUID = creature->GetGUID();
455 break;
456
457 }
458 }
459
460 void OnUnitDeath(Unit* unit) override
461 {
462 switch (unit->GetEntry())
463 {
465 //case ?: SetBossState(BOSS_THE_LOST_DWARVES, DONE); break;
470 default: break;
471 }
472 }
473
474 ObjectGuid GetGuidData(uint32 identifier) const override
475 {
476 switch (identifier)
477 {
478 case 0:
480 case 1:
481 case 2:
482 case 3:
483 case 4:
484 return vaultWalkers.at(identifier - 1);
485 case 5:
486 case 6:
487 case 7:
488 case 8:
489 case 9:
490 case 10:
491 return earthenGuardians.at(identifier - 5);
492 default:
493 break;
494 }
495
496 return ObjectGuid::Empty;
497 } // end GetGuidData
498
499 void ProcessEvent(WorldObject* /*gameObject*/, uint32 eventId, WorldObject* /*invoker*/) override
500 {
501 switch (eventId)
502 {
504 SetData(DATA_STONE_KEEPERS, IN_PROGRESS); // activate the Stone Keepers
505 break;
506 default:
507 break;
508 }
509 }
510 };
511
513 {
515 }
516};
517
519{
520 new instance_uldaman();
521}
uint32_t uint32
Definition: Define.h:142
EncounterState
@ IN_PROGRESS
@ DONE
@ SPECIAL
@ NOT_STARTED
std::vector< ObjectGuid > GuidVector
Definition: ObjectGuid.h:395
Spells
Definition: PlayerAI.cpp:32
@ GO_FLAG_INTERACT_COND
@ GO_FLAG_NODESPAWN
@ GO_FLAG_IN_USE
@ FACTION_FRIENDLY
@ FACTION_TITAN
@ FACTION_MONSTER
@ GO_STATE_READY
@ UNIT_STATE_ROOT
Definition: Unit.h:265
#define DataHeader
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:371
void Respawn(bool force=false)
Definition: Creature.cpp:2303
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
CreatureAI * AI() const
Definition: Creature.h:214
void SetGoState(GOState state)
void ReplaceAllFlags(GameObjectFlags flags)
Definition: GameObject.h:276
void SetFlag(GameObjectFlags flags)
Definition: GameObject.h:274
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
void LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void SetHeaders(std::string const &dataHeaders)
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3489
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void MoveTargetedHome()
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
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3685
void SetControlled(bool apply, UnitState state)
Definition: Unit.cpp:10911
void SetFaction(uint32 faction) override
Definition: Unit.h:859
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:11618
bool IsAlive() const
Definition: Unit.h:1164
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
uint32 GetFaction() const override
Definition: Unit.h:858
void RemoveAllAuras()
Definition: Unit.cpp:4242
bool isDead() const
Definition: Unit.h:1166
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:91
InstanceScript * GetInstanceScript(InstanceMap *map) const override
#define MAX_ENCOUNTER
const Position IronayaPoint
static constexpr DungeonEncounterData Encounters[]
@ SPELL_FREEZE_ANIM
@ SPELL_MINION_FREEZE_ANIM
@ SPELL_AWAKEN_VAULT_WALKER
@ SPELL_ARCHAEDAS_AWAKEN
void AddSC_instance_uldaman()
IronayaTalk
@ SAY_AGGRO
@ EVENT_SUB_BOSS_AGGRO
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
ObjectGuid GetGuidData(uint32 identifier) const override
void ProcessEvent(WorldObject *, uint32 eventId, WorldObject *) override
bool SetBossState(uint32 id, EncounterState state) override
void SetData(uint32 type, uint32 data) override
void SetGuidData(uint32 type, ObjectGuid data) override
@ BOSS_ANCIENT_STONE_KEEPER
Definition: uldaman.h:31
@ BOSS_OBSIDIAN_SENTINEL
Definition: uldaman.h:35
@ BOSS_GRIMLOK
Definition: uldaman.h:33
@ BOSS_REVELOSH
Definition: uldaman.h:28
@ BOSS_GALGANN_FIREHAMMER
Definition: uldaman.h:32
@ BOSS_ARCHAEDAS
Definition: uldaman.h:34
@ BOSS_THE_LOST_DWARVES
Definition: uldaman.h:29
@ BOSS_IRONAYA
Definition: uldaman.h:30
@ DATA_ALTAR_DOORS
Definition: uldaman.h:42
@ DATA_IRONAYA_SEAL
Definition: uldaman.h:46
@ DATA_IRONAYA_DOOR
Definition: uldaman.h:43
@ DATA_MINIONS
Definition: uldaman.h:45
@ DATA_STONE_KEEPERS
Definition: uldaman.h:44
#define UldamanScriptName
Definition: uldaman.h:23
@ NPC_ANCIENT_STONE_KEEPER
Definition: uldaman.h:52
@ NPC_OBSIDIAN_SENTINEL
Definition: uldaman.h:55
@ NPC_GALGANN_FIREHAMMER
Definition: uldaman.h:53
@ NPC_GRIMLOK
Definition: uldaman.h:54
@ NPC_REVELOSH
Definition: uldaman.h:51
@ GO_ANCIENT_VAULT_DOOR
Definition: uldaman.h:62
@ GO_ARCHAEDAS_TEMPLE_DOOR
Definition: uldaman.h:60
@ GO_ALTAR_OF_THE_KEEPER_TEMPLE_DOOR
Definition: uldaman.h:61
@ GO_KEYSTONE
Definition: uldaman.h:64
@ GO_IRONAYA_SEAL_DOOR
Definition: uldaman.h:63