Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_oculus.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 "oculus.h"
10#include "Player.h"
11
12#define MAX_ENCOUNTER 4
13
14/* The Occulus encounters:
150 - Drakos the Interrogator
161 - Varos Cloudstrider
172 - Mage-Lord Urom
183 - Ley-Guardian Eregos */
19
21{
22public:
23 instance_oculus() : InstanceMapScript("instance_oculus", 578) { }
24
29
31 {
33
35 {
37
38 drakosGUID = 0;
39 varosGUID = 0;
40 uromGUID = 0;
41 eregosGUID = 0;
42
43 platformUrom = 0;
45
47
48 gwhelpList.clear();
49 gameObjectList.clear();
50
52 eternosGUID = 0;
53 verdisaGUID = 0;
54}
55
57 {
58 Creature* creature = unit->ToCreature();
59 if (!creature)
60 return;
61
62 if (creature->GetEntry() != NPC_CENTRIFUGE_CONSTRUCT)
63 return;
64
66
68 if (Creature* varos = instance->GetCreature(varosGUID))
69 varos->RemoveAllAuras();
70 }
71
73 {
75 {
76 player->SendUpdateWorldState(WORLD_STATE_CENTRIFUGE_CONSTRUCT_SHOW, 1);
78 } else
79 {
80 player->SendUpdateWorldState(WORLD_STATE_CENTRIFUGE_CONSTRUCT_SHOW, 0);
81 player->SendUpdateWorldState(WORLD_STATE_CENTRIFUGE_CONSTRUCT_AMOUNT, 0);
82 }
83 }
84
85 void ProcessEvent(WorldObject* /*unit*/, uint32 eventId) OVERRIDE
86 {
87 if (eventId != EVENT_CALL_DRAGON)
88 return;
89
90 Creature* varos = instance->GetCreature(varosGUID);
91
92 if (!varos)
93 return;
94
95 if (Creature* drake = varos->SummonCreature(NPC_AZURE_RING_GUARDIAN, varos->GetPositionX(), varos->GetPositionY(), varos->GetPositionZ()+40))
96 drake->AI()->DoAction(ACTION_CALL_DRAGON_EVENT);
97 }
98
100 {
101 switch (creature->GetEntry())
102 {
103 case NPC_DRAKOS:
104 drakosGUID = creature->GetGUID();
105 break;
106 case NPC_VAROS:
107 varosGUID = creature->GetGUID();
109 creature->SetPhaseMask(1, true);
110 break;
111 case NPC_UROM:
112 uromGUID = creature->GetGUID();
114 creature->SetPhaseMask(1, true);
115 break;
116 case NPC_EREGOS:
117 eregosGUID = creature->GetGUID();
119 creature->SetPhaseMask(1, true);
120 break;
122 if (creature->IsAlive())
124 break;
126 belgaristraszGUID = creature->GetGUID();
128 {
129 creature->SetWalk(true),
130 creature->GetMotionMaster()->MovePoint(0, 941.453f, 1044.1f, 359.967f),
131 creature->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
132 }
133 break;
134 case NPC_ETERNOS:
135 eternosGUID = creature->GetGUID();
137 {
138 creature->SetWalk(true),
139 creature->GetMotionMaster()->MovePoint(0, 943.202f, 1059.35f, 359.967f),
140 creature->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
141 }
142 break;
143 case NPC_VERDISA:
144 verdisaGUID = creature->GetGUID();
146 {
147 creature->SetWalk(true),
148 creature->GetMotionMaster()->MovePoint(0, 949.188f, 1032.91f, 359.967f),
149 creature->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
150 }
151 break;
154 {
155 creature->SetPhaseMask(1, true);
156 gwhelpList.push_back(creature->GetGUID());
157 }
158 break;
159 }
160 }
161
163 {
164 switch (go->GetEntry())
165 {
168 go->SetGoState(GOState::GO_STATE_ACTIVE);
169 else
170 go->SetGoState(GOState::GO_STATE_READY);
171 gameObjectList.push_back(go->GetGUID());
172 break;
175 eregosCacheGUID = go->GetGUID();
176 break;
177 default:
178 break;
179 }
180 }
181
183 {
184 if (!InstanceScript::SetBossState(type, state))
185 return false;
186
187 switch (type)
188 {
190 if (state == DONE)
191 {
195 FreeDragons();
196 if (Creature* varos = instance->GetCreature(varosGUID))
197 varos->SetPhaseMask(1, true);
198 }
199 break;
200 case DATA_VAROS_EVENT:
201 if (state == DONE)
202 {
204 if (Creature* urom = instance->GetCreature(uromGUID))
205 urom->SetPhaseMask(1, true);
206 }
207 break;
208 case DATA_UROM_EVENT:
209 if (state == DONE)
210 {
211 if (Creature* eregos = instance->GetCreature(eregosGUID))
212 {
213 eregos->SetPhaseMask(1, true);
215 }
216 }
217 break;
219 if (state == DONE)
221 break;
222 }
223
224 return true;
225 }
226
227 void SetData(uint32 type, uint32 data) OVERRIDE
228 {
229 switch (type)
230 {
232 platformUrom = data;
233 break;
234 }
235 }
236
238 {
239 switch (type)
240 {
242 // used by condition system
244 }
245
246 return 0;
247 }
248
249 uint64 GetData64(uint32 identifier) const OVERRIDE
250 {
251 switch (identifier)
252 {
253 case DATA_DRAKOS: return drakosGUID;
254 case DATA_VAROS: return varosGUID;
255 case DATA_UROM: return uromGUID;
256 case DATA_EREGOS: return eregosGUID;
257 }
258
259 return 0;
260 }
261
263 {
264 if (gameObjectList.empty())
265 return;
266
267 for (std::list<uint64>::const_iterator itr = gameObjectList.begin(); itr != gameObjectList.end(); ++itr)
268 {
269 if (GameObject* go = instance->GetGameObject(*itr))
270 go->SetGoState(GOState::GO_STATE_ACTIVE);
271 }
272 }
273
275 {
276 if (Creature* belgaristrasz = instance->GetCreature(belgaristraszGUID))
277 belgaristrasz->SetWalk(true),
278 belgaristrasz->GetMotionMaster()->MovePoint(0, 941.453f, 1044.1f, 359.967f);
279 if (Creature* eternos = instance->GetCreature(eternosGUID))
280 eternos->SetWalk(true),
281 eternos->GetMotionMaster()->MovePoint(0, 943.202f, 1059.35f, 359.967f);
282 if (Creature* verdisa = instance->GetCreature(verdisaGUID))
283 verdisa->SetWalk(true),
284 verdisa->GetMotionMaster()->MovePoint(0, 949.188f, 1032.91f, 359.967f);
285 }
286
288 {
289 if (gwhelpList.empty())
290 return;
291
292 for (std::list<uint64>::const_iterator itr = gwhelpList.begin(); itr != gwhelpList.end(); ++itr)
293 if (Creature* gwhelp = instance->GetCreature(*itr))
294 gwhelp->SetPhaseMask(1, true);
295 }
296
297 std::string GetSaveData() OVERRIDE
298 {
300
301 std::ostringstream saveStream;
302 saveStream << "T O " << GetBossSaveData();
303
304 str_data = saveStream.str();
305
307 return str_data;
308 }
309
310 void Load(const char* in) OVERRIDE
311 {
312 if (!in)
313 {
315 return;
316 }
317
319
320 char dataHead1, dataHead2;
321
322 std::istringstream loadStream(in);
323 loadStream >> dataHead1 >> dataHead2;
324
325 if (dataHead1 == 'T' && dataHead2 == 'O')
326 {
327 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
328 {
329 uint32 tmpState;
330 loadStream >> tmpState;
331 if (tmpState == IN_PROGRESS || tmpState > SPECIAL)
332 tmpState = NOT_STARTED;
333 SetBossState(i, EncounterState(tmpState));
334 }
336
338 }
339 private:
344
348
351
353
354 std::string str_data;
355
356 std::list<uint64> gameObjectList;
357 std::list<uint64> gwhelpList;
358 };
359};
360
362{
363 new instance_oculus();
364}
@ DAY
Definition Common.h:121
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_ACTIVE
Definition GameObject.h:576
@ GO_STATE_READY
Definition GameObject.h:577
#define OUT_LOAD_INST_DATA_FAIL
EncounterState
@ 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)
@ UNIT_NPC_FLAG_GOSSIP
Definition Unit.h:687
@ UNIT_FIELD_NPC_FLAGS
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
std::string GetBossSaveData()
EncounterState GetBossState(uint32 id) const
void DoRespawnGameObject(uint64 guid, uint32 timeToDespawn=MINUTE)
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue)
Definition Map.h:238
uint32 GetEntry() const
Definition Object.h:125
Creature * ToCreature()
Definition Object.h:207
Definition Unit.h:1367
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition Object.cpp:2703
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
#define MAX_ENCOUNTER
void AddSC_instance_oculus()
@ ACTION_CALL_DRAGON_EVENT
Definition oculus.h:58
@ GO_EREGOS_CACHE_H
Definition oculus.h:48
@ GO_EREGOS_CACHE_N
Definition oculus.h:47
@ GO_DRAGON_CAGE_DOOR
Definition oculus.h:46
@ DATA_VAROS
Definition oculus.h:21
@ DATA_EREGOS
Definition oculus.h:23
@ DATA_DRAKOS
Definition oculus.h:20
@ DATA_UROM
Definition oculus.h:22
@ WORLD_STATE_CENTRIFUGE_CONSTRUCT_AMOUNT
Definition oculus.h:64
@ WORLD_STATE_CENTRIFUGE_CONSTRUCT_SHOW
Definition oculus.h:63
@ EVENT_CALL_DRAGON
Definition oculus.h:53
@ NPC_DRAKOS
Definition oculus.h:28
@ NPC_CENTRIFUGE_CONSTRUCT
Definition oculus.h:34
@ NPC_ETERNOS
Definition oculus.h:40
@ NPC_VERDISA
Definition oculus.h:38
@ NPC_EREGOS
Definition oculus.h:31
@ NPC_BELGARISTRASZ
Definition oculus.h:39
@ NPC_UROM
Definition oculus.h:30
@ NPC_GREATER_WHELP
Definition oculus.h:41
@ NPC_VAROS
Definition oculus.h:29
@ NPC_AZURE_RING_GUARDIAN
Definition oculus.h:33
@ DATA_VAROS_EVENT
Definition oculus.h:12
@ DATA_UROM_EVENT
Definition oculus.h:13
@ DATA_DRAKOS_EVENT
Definition oculus.h:11
@ DATA_UROM_PLATAFORM
Definition oculus.h:15
@ DATA_EREGOS_EVENT
Definition oculus.h:14
float GetPositionZ() const
Definition Object.h:330
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
uint64 GetData64(uint32 identifier) const OVERRIDE
void SetData(uint32 type, uint32 data) OVERRIDE
bool SetBossState(uint32 type, EncounterState state) OVERRIDE
void ProcessEvent(WorldObject *, uint32 eventId) OVERRIDE
void OnCreatureCreate(Creature *creature) OVERRIDE