Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_magtheridons_lair.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/* ScriptData
7SDName: Instance_Magtheridons_Lair
8SD%Complete: 100
9SDComment:
10SDCategory: Hellfire Citadel, Magtheridon's lair
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "InstanceScript.h"
16#include "magtheridons_lair.h"
17
19{
20 SPELL_SOUL_TRANSFER = 30531, // core bug, does not support target 7
21 SPELL_BLAZE_TARGET = 30541, // core bug, does not support target 7
22};
23
24#define CHAMBER_CENTER_X -15.14
25#define CHAMBER_CENTER_Y 1.8
26#define CHAMBER_CENTER_Z -0.4
27
28#define MAX_ENCOUNTER 2
29
30#define EMOTE_BONDS_WEAKEN "'s bonds begin to weaken!"
31
33{
34 public:
36 : InstanceMapScript("instance_magtheridons_lair", 544)
37 {
38 }
39
41 {
45
47
49 std::set<uint64> ChannelerGUID;
51 std::set<uint64> ColumnGUID;
52
55
57 {
58 memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
59
61 ChannelerGUID.clear();
62 DoorGUID = 0;
63 ColumnGUID.clear();
64
65 CageTimer = 0;
66 RespawnTimer = 0;
67 }
68
70 {
71 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
73 return true;
74
75 return false;
76 }
77
79 {
80 switch (creature->GetEntry())
81 {
82 case 17257:
83 MagtheridonGUID = creature->GetGUID();
84 break;
85 case 17256:
86 ChannelerGUID.insert(creature->GetGUID());
87 break;
88 }
89 }
90
92 {
93 switch (go->GetEntry())
94 {
95 case 181713:
96 go->SetUInt32Value(GAMEOBJECT_FIELD_FLAGS, 0);
97 break;
98 case 183847:
99 DoorGUID = go->GetGUID();
100 break;
101 case 184653: // hall
102 case 184634: // six columns
103 case 184635:
104 case 184636:
105 case 184637:
106 case 184638:
107 case 184639:
108 ColumnGUID.insert(go->GetGUID());
109 break;
110 }
111 }
112
114 {
115 switch (type)
116 {
117 case DATA_MAGTHERIDON:
118 return MagtheridonGUID;
119 }
120 return 0;
121 }
122
123 void SetData(uint32 type, uint32 data) OVERRIDE
124 {
125 switch (type)
126 {
128 m_auiEncounter[0] = data;
129 if (data == NOT_STARTED)
130 RespawnTimer = 10000;
131 if (data != IN_PROGRESS)
133 break;
135 switch (data)
136 {
137 case NOT_STARTED: // Reset all channelers once one is reset.
138 if (m_auiEncounter[1] != NOT_STARTED)
139 {
141 for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
142 {
143 if (Creature* Channeler = instance->GetCreature(*i))
144 {
145 if (Channeler->IsAlive())
146 Channeler->AI()->EnterEvadeMode();
147 else
148 Channeler->Respawn();
149 }
150 }
151 CageTimer = 0;
153 }
154 break;
155 case IN_PROGRESS: // Event start.
156 if (m_auiEncounter[1] != IN_PROGRESS)
157 {
159 // Let all five channelers aggro.
160 for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
161 {
162 Creature* Channeler = instance->GetCreature(*i);
163 if (Channeler && Channeler->IsAlive())
164 Channeler->AI()->AttackStart(Channeler->SelectNearestTarget(999));
165 }
166 // Release Magtheridon after two minutes.
167 Creature* Magtheridon = instance->GetCreature(MagtheridonGUID);
168 if (Magtheridon && Magtheridon->IsAlive())
169 {
170 Magtheridon->MonsterTextEmote(EMOTE_BONDS_WEAKEN, 0);
171 CageTimer = 120000;
172 }
174 }
175 break;
176 case DONE: // Add buff and check if all channelers are dead.
177 for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
178 {
179 Creature* Channeler = instance->GetCreature(*i);
180 if (Channeler && Channeler->IsAlive())
181 {
182 //Channeler->CastSpell(Channeler, SPELL_SOUL_TRANSFER, true);
183 data = IN_PROGRESS;
184 break;
185 }
186 }
187 break;
188 }
189 m_auiEncounter[1] = data;
190 break;
191 case DATA_COLLAPSE:
192 // true - collapse / false - reset
193 for (std::set<uint64>::const_iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
195 break;
196 default:
197 break;
198 }
199 }
200
202 {
203 if (type == DATA_MAGTHERIDON_EVENT)
204 return m_auiEncounter[0];
205 return 0;
206 }
207
209 {
210 if (CageTimer)
211 {
212 if (CageTimer <= diff)
213 {
214 Creature* Magtheridon = instance->GetCreature(MagtheridonGUID);
215 if (Magtheridon && Magtheridon->IsAlive())
216 {
218 Magtheridon->AI()->AttackStart(Magtheridon->SelectNearestTarget(999));
219 }
220 CageTimer = 0;
221 } else CageTimer -= diff;
222 }
223
224 if (RespawnTimer)
225 {
226 if (RespawnTimer <= diff)
227 {
228 for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
229 {
230 if (Creature* Channeler = instance->GetCreature(*i))
231 {
232 if (Channeler->IsAlive())
233 Channeler->AI()->EnterEvadeMode();
234 else
235 Channeler->Respawn();
236 }
237 }
238 RespawnTimer = 0;
239 } else RespawnTimer -= diff;
240 }
241 }
242 };
243
248};
249
254
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
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ UNIT_STATE_STUNNED
Definition Unit.h:515
@ GAMEOBJECT_FIELD_FLAGS
@ SPELL_SOUL_TRANSFER
@ SPELL_BLAZE_TARGET
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
CreatureAI * AI() const
Definition Creature.h:483
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void DoUseDoorOrButton(uint64 guid, uint32 withRestoreTime=0, bool useAlternativeState=false)
void HandleGameObject(uint64 guid, bool open, GameObject *go=NULL)
Definition Map.h:238
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:16
void ClearUnitState(uint32 f)
Definition Unit.h:1489
bool IsAlive() const
Definition Unit.h:2032
void MonsterTextEmote(const char *text, WorldObject const *target, bool IsBossEmote=false)
Definition Object.cpp:2440
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
void AddSC_instance_magtheridons_lair()
#define EMOTE_BONDS_WEAKEN
#define MAX_ENCOUNTER
@ DATA_CHANNELER_EVENT
@ DATA_COLLAPSE
@ DATA_MAGTHERIDON
@ DATA_MAGTHERIDON_EVENT