Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_eye_of_eternity.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 "ScriptedCreature.h"
8#include "InstanceScript.h"
9#include "eye_of_eternity.h"
10#include "Player.h"
11
13{
14public:
15 instance_eye_of_eternity() : InstanceMapScript("instance_eye_of_eternity", 616) { }
16
21
23 {
38
40 {
41 if (!InstanceScript::SetBossState(type, state))
42 return false;
43
44 if (type == DATA_MALYGOS_EVENT)
45 {
46 if (state == FAIL)
47 {
48 for (std::list<uint64>::const_iterator itr_trigger = portalTriggers.begin(); itr_trigger != portalTriggers.end(); ++itr_trigger)
49 {
50 if (Creature* trigger = instance->GetCreature(*itr_trigger))
51 {
52 // just in case
53 trigger->RemoveAllAuras();
54 trigger->AI()->Reset();
55 }
56 }
57
59
60 if (GameObject* platform = instance->GetGameObject(platformGUID))
61 platform->RemoveFlag(GAMEOBJECT_FIELD_FLAGS, GO_FLAG_DESTROYED);
62 }
63 else if (state == DONE)
65 }
66 return true;
67 }
68
70 // There is no other way afaik...
72 {
73 GameObject* go = new GameObject;
74 if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, instance,
75 pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(),
76 0, 0, 0, 0, 120, GOState::GO_STATE_READY))
77 {
78 delete go;
79 return;
80 }
81
82 for (auto phase : go->GetPhases())
83 go->SetPhased(phase, false, true);
84
85 instance->AddToMap(go);
86 }
87
89 {
90 switch (go->GetEntry())
91 {
93 platformGUID = go->GetGUID();
94 break;
96 if (instance->GetDifficulty() == DIFFICULTY_10MAN_NORMAL)
97 {
98 irisGUID = go->GetGUID();
99 go->GetPosition(&focusingIrisPosition);
100 }
101 break;
103 if (instance->GetDifficulty() == DIFFICULTY_25MAN_NORMAL)
104 {
105 irisGUID = go->GetGUID();
106 go->GetPosition(&focusingIrisPosition);
107 }
108 break;
109 case GO_EXIT_PORTAL:
110 exitPortalGUID = go->GetGUID();
111 go->GetPosition(&exitPortalPosition);
112 break;
114 if (instance->GetDifficulty() == DIFFICULTY_10MAN_NORMAL)
115 heartOfMagicGUID = go->GetGUID();
116 break;
118 if (instance->GetDifficulty() == DIFFICULTY_25MAN_NORMAL)
119 heartOfMagicGUID = go->GetGUID();
120 break;
121 }
122 }
123
125 {
126 switch (creature->GetEntry())
127 {
129 vortexTriggers.push_back(creature->GetGUID());
130 break;
131 case NPC_MALYGOS:
132 malygosGUID = creature->GetGUID();
133 break;
135 portalTriggers.push_back(creature->GetGUID());
136 break;
138 alexstraszaBunnyGUID = creature->GetGUID();
139 break;
141 giftBoxBunnyGUID = creature->GetGUID();
142 break;
143 }
144 }
145
147 {
148 if (unit->GetTypeId() != TypeID::TYPEID_PLAYER)
149 return;
150
151 // Player continues to be moving after death no matter if spline will be cleared along with all movements,
152 // so on next world tick was all about delay if box will pop or not (when new movement will be registered)
153 // since in EoE you never stop falling. However root at this precise* moment works,
154 // it will get cleared on release. If by any chance some lag happen "Reload()" and "RepopMe()" works,
155 // last test I made now gave me 50/0 of this bug so I can't do more about it.
156 unit->SetControlled(true, UNIT_STATE_ROOT);
157 }
158
159 void ProcessEvent(WorldObject* /*obj*/, uint32 eventId) OVERRIDE
160 {
161 if (eventId == EVENT_FOCUSING_IRIS)
162 {
163 if (Creature* alexstraszaBunny = instance->GetCreature(alexstraszaBunnyGUID))
164 {
165 alexstraszaBunny->CastSpell(alexstraszaBunny, SPELL_IRIS_OPENED);
166 instance->GetGameObject(irisGUID)->SetFlag(GAMEOBJECT_FIELD_FLAGS, GO_FLAG_IN_USE);
167 }
168
169 if (Creature* malygos = instance->GetCreature(malygosGUID))
170 malygos->AI()->DoAction(0); // ACTION_LAND_ENCOUNTER_START
171
172 if (GameObject* exitPortal = instance->GetGameObject(exitPortalGUID))
173 exitPortal->Delete();
174 }
175 }
176
178 {
179 if (Creature* malygos = instance->GetCreature(malygosGUID))
180 {
181 std::list<HostileReference*> m_threatlist = malygos->getThreatManager().getThreatList();
182 for (std::list<uint64>::const_iterator itr_vortex = vortexTriggers.begin(); itr_vortex != vortexTriggers.end(); ++itr_vortex)
183 {
184 if (m_threatlist.empty())
185 return;
186
187 uint8 counter = 0;
188 if (Creature* trigger = instance->GetCreature(*itr_vortex))
189 {
190 // each trigger have to cast the spell to 5 players.
191 for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
192 {
193 if (counter >= 5)
194 break;
195
196 if (Unit* target = (*itr)->getTarget())
197 {
198 Player* player = target->ToPlayer();
199
200 if (!player || player->IsGameMaster() || player->HasAura(SPELL_VORTEX_4))
201 continue;
202
203 player->CastSpell(trigger, SPELL_VORTEX_4, true);
204 counter++;
205 }
206 }
207 }
208 }
209 }
210 }
211
213 {
214 bool next = (lastPortalGUID == portalTriggers.back() || !lastPortalGUID ? true : false);
215
216 for (std::list<uint64>::const_iterator itr_trigger = portalTriggers.begin(); itr_trigger != portalTriggers.end(); ++itr_trigger)
217 {
218 if (next)
219 {
220 if (Creature* trigger = instance->GetCreature(*itr_trigger))
221 {
222 lastPortalGUID = trigger->GetGUID();
223 trigger->CastSpell(trigger, SPELL_PORTAL_OPENED, true);
224 return;
225 }
226 }
227
228 if (*itr_trigger == lastPortalGUID)
229 next = true;
230 }
231 }
232
233 void SetData(uint32 data, uint32 /*value*/) OVERRIDE
234 {
235 switch (data)
236 {
239 break;
242 break;
245 break;
246 }
247 }
248
250 {
251 switch (data)
252 {
253 case DATA_TRIGGER:
254 return vortexTriggers.front();
255 case DATA_MALYGOS:
256 return malygosGUID;
257 case DATA_PLATFORM:
258 return platformGUID;
262 return heartOfMagicGUID;
264 return irisGUID;
266 return giftBoxBunnyGUID;
267 }
268
269 return 0;
270 }
271
272 std::string GetSaveData() OVERRIDE
273 {
275
276 std::ostringstream saveStream;
277 saveStream << "E E " << GetBossSaveData();
278
280 return saveStream.str();
281 }
282
283 void Load(const char* str) OVERRIDE
284 {
285 if (!str)
286 {
288 return;
289 }
290
292
293 char dataHead1, dataHead2;
294
295 std::istringstream loadStream(str);
296 loadStream >> dataHead1 >> dataHead2;
297
298 if (dataHead1 == 'E' && dataHead2 == 'E')
299 {
300 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
301 {
302 uint32 tmpState;
303 loadStream >> tmpState;
304 if (tmpState == IN_PROGRESS || tmpState > SPECIAL)
305 tmpState = NOT_STARTED;
306 SetBossState(i, EncounterState(tmpState));
307 }
308
310
312 }
313
314 private:
315 std::list<uint64> vortexTriggers;
316 std::list<uint64> portalTriggers;
327 };
328};
329
@ DIFFICULTY_25MAN_NORMAL
Definition DBCEnums.h:335
@ DIFFICULTY_10MAN_NORMAL
Definition DBCEnums.h:334
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
EncounterState
@ IN_PROGRESS
@ FAIL
@ 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)
@ TYPEID_PLAYER
Definition Object.h:55
@ HIGHGUID_GAMEOBJECT
#define sObjectMgr
Definition ObjectMgr.h:1617
@ GO_FLAG_IN_USE
@ GO_FLAG_DESTROYED
@ UNIT_STATE_ROOT
Definition Unit.h:522
@ GAMEOBJECT_FIELD_FLAGS
bool Create(uint32 guidlow, uint32 name_id, Map *map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
bool SetPhased(uint32 id, bool update, bool apply) OVERRIDE
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
std::string GetBossSaveData()
Definition Map.h:238
Player * ToPlayer()
Definition Object.h:204
bool IsGameMaster() const
Definition Player.h:1369
Definition Unit.h:1367
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)
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
std::set< uint32 > const & GetPhases() const
Definition Object.h:647
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
@ DATA_VORTEX_HANDLING
@ DATA_RESPAWN_IRIS
@ DATA_POWER_SPARKS_HANDLING
@ DATA_MALYGOS_EVENT
@ DATA_HEART_OF_MAGIC_GUID
@ DATA_TRIGGER
@ DATA_MALYGOS
@ DATA_ALEXSTRASZA_BUNNY_GUID
@ DATA_FOCUSING_IRIS_GUID
@ DATA_PLATFORM
@ DATA_GIFT_BOX_BUNNY_GUID
@ GO_FOCUSING_IRIS_25
@ GO_NEXUS_RAID_PLATFORM
@ GO_HEART_OF_MAGIC_10
@ GO_HEART_OF_MAGIC_25
@ GO_FOCUSING_IRIS_10
@ GO_EXIT_PORTAL
@ NPC_MALYGOS
@ NPC_PORTAL_TRIGGER
@ NPC_ALEXSTRASZAS_GIFT
@ NPC_VORTEX_TRIGGER
@ NPC_ALEXSTRASZA_BUNNY
@ SPELL_PORTAL_OPENED
@ SPELL_IRIS_OPENED
@ SPELL_VORTEX_4
@ EVENT_FOCUSING_IRIS
#define MAX_ENCOUNTER
void AddSC_instance_eye_of_eternity()
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