TrinityCore
Loading...
Searching...
No Matches
instance_oculus.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#include "oculus.h"
19#include "Creature.h"
20#include "CreatureAI.h"
21#include "EventMap.h"
22#include "GameObject.h"
23#include "InstanceScript.h"
24#include "Map.h"
25#include "MotionMaster.h"
26#include "ScriptMgr.h"
27#include "PhasingHandler.h"
28#include "TemporarySummon.h"
29
34
35static constexpr DungeonEncounterData encounters[] =
36{
37 { DATA_DRAKOS, {{ 528, 529, 2016 }} },
38 { DATA_VAROS, {{ 530, 531, 2015 }} },
39 { DATA_UROM, {{ 532, 533, 2014 }} },
40 { DATA_EREGOS, {{ 534, 535, 2013 }} }
41};
42
43static constexpr Position VerdisaMove = { 949.188f, 1032.91f, 359.967f, 1.093027f };
44static constexpr Position BelgaristraszMove = { 941.453f, 1044.1f, 359.967f, 0.1984709f };
45static constexpr Position EternosMove = { 943.202f, 1059.35f, 359.967f, 5.757278f };
46
48{
49 public:
51
53 {
63
64 void OnCreatureCreate(Creature* creature) override
65 {
66 switch (creature->GetEntry())
67 {
68 case NPC_DRAKOS:
69 DrakosGUID = creature->GetGUID();
70 break;
71 case NPC_VAROS:
72 VarosGUID = creature->GetGUID();
74 PhasingHandler::AddPhase(creature, 170, true);
75 else
76 PhasingHandler::RemovePhase(creature, 170, true);
77 break;
78 case NPC_UROM:
79 UromGUID = creature->GetGUID();
81 PhasingHandler::AddPhase(creature, 170, true);
82 else
83 PhasingHandler::RemovePhase(creature, 170, true);
84 break;
85 case NPC_EREGOS:
86 EregosGUID = creature->GetGUID();
88 PhasingHandler::AddPhase(creature, 170, true);
89 else
90 PhasingHandler::RemovePhase(creature, 170, true);
91 break;
93 if (creature->IsAlive())
95 break;
97 BelgaristraszGUID = creature->GetGUID();
99 {
101 creature->Relocate(BelgaristraszMove);
102 }
103 break;
104 case NPC_ETERNOS:
105 EternosGUID = creature->GetGUID();
107 {
109 creature->Relocate(EternosMove);
110 }
111 break;
112 case NPC_VERDISA:
113 VerdisaGUID = creature->GetGUID();
115 {
117 creature->Relocate(VerdisaMove);
118 }
119 break;
122 GreaterWhelpList.push_back(creature->GetGUID());
123 else
124 PhasingHandler::AddPhase(creature, 170, true);
125 break;
126 default:
127 break;
128 }
129 }
130
132 {
134
135 switch (go->GetEntry())
136 {
139 EregosCacheGUID = go->GetGUID();
140 break;
141 default:
142 break;
143 }
144 }
145
146 void OnUnitDeath(Unit* unit) override
147 {
148 Creature* creature = unit->ToCreature();
149 if (!creature)
150 return;
151
152 if (creature->GetEntry() == NPC_CENTRIFUGE_CONSTRUCT)
153 {
155
157 if (Creature* varos = instance->GetCreature(VarosGUID))
158 varos->RemoveAllAuras();
159 }
160 }
161
162 void ProcessEvent(WorldObject* /*unit*/, uint32 eventId, WorldObject* /*invoker*/) override
163 {
164 if (eventId != EVENT_CALL_DRAGON)
165 return;
166
167 if (Creature* varos = instance->GetCreature(VarosGUID))
168 if (Creature* drake = varos->SummonCreature(NPC_AZURE_RING_GUARDIAN, varos->GetPositionX(), varos->GetPositionY(), varos->GetPositionZ() + 40))
169 drake->AI()->DoAction(ACTION_CALL_DRAGON_EVENT);
170 }
171
172 bool SetBossState(uint32 type, EncounterState state) override
173 {
174 if (!InstanceScript::SetBossState(type, state))
175 return false;
176
177 switch (type)
178 {
179 case DATA_DRAKOS:
180 if (state == DONE)
181 {
184 FreeDragons();
185 if (Creature* varos = instance->GetCreature(VarosGUID))
186 PhasingHandler::RemovePhase(varos, 170, true);
188 }
189 break;
190 case DATA_VAROS:
191 if (state == DONE)
192 {
195 PhasingHandler::RemovePhase(urom, 170, true);
196 }
197 break;
198 case DATA_UROM:
199 if (state == DONE)
200 {
201 if (Creature* eregos = instance->GetCreature(EregosGUID))
202 {
203 PhasingHandler::RemovePhase(eregos, 170, true);
206 }
207 }
208 break;
209 case DATA_EREGOS:
210 if (state == DONE)
211 {
213 {
214 cache->SetRespawnTime(cache->GetRespawnDelay());
215 cache->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
216 }
217 }
218 break;
219 }
220
221 return true;
222 }
223
224 uint32 GetData(uint32 type) const override
225 {
226 if (type == DATA_CONSTRUCTS)
227 {
229 return KILL_NO_CONSTRUCT;
230 else if (CentrifugueConstructCounter == 1)
231 return KILL_ONE_CONSTRUCT;
232 else
233 return KILL_MORE_CONSTRUCT;
234 }
235
236 return KILL_NO_CONSTRUCT;
237 }
238
239 ObjectGuid GetGuidData(uint32 type) const override
240 {
241 switch (type)
242 {
243 case DATA_DRAKOS:
244 return DrakosGUID;
245 case DATA_VAROS:
246 return VarosGUID;
247 case DATA_UROM:
248 return UromGUID;
249 case DATA_EREGOS:
250 return EregosGUID;
251 default:
252 break;
253 }
254
255 return ObjectGuid::Empty;
256 }
257
259 {
260 if (Creature* belgaristrasz = instance->GetCreature(BelgaristraszGUID))
261 {
262 belgaristrasz->SetWalk(true);
263 belgaristrasz->GetMotionMaster()->MovePoint(POINT_MOVE_OUT, BelgaristraszMove);
264 }
265
266 if (Creature* eternos = instance->GetCreature(EternosGUID))
267 {
268 eternos->SetWalk(true);
269 eternos->GetMotionMaster()->MovePoint(POINT_MOVE_OUT, EternosMove);
270 }
271
272 if (Creature* verdisa = instance->GetCreature(VerdisaGUID))
273 {
274 verdisa->SetWalk(true);
275 verdisa->GetMotionMaster()->MovePoint(POINT_MOVE_OUT, VerdisaMove);
276 }
277 }
278
279 void Update(uint32 diff) override
280 {
281 events.Update(diff);
282
283 while (uint32 eventId = events.ExecuteEvent())
284 {
285 switch (eventId)
286 {
288 if (Creature* varos = instance->GetCreature(VarosGUID))
289 varos->AI()->Talk(SAY_VAROS_INTRO_TEXT);
290 break;
292 if (Creature* eregos = instance->GetCreature(EregosGUID))
293 eregos->AI()->Talk(SAY_EREGOS_INTRO_TEXT);
294 break;
295 default:
296 break;
297 }
298 }
299 }
300
302 {
303 for (ObjectGuid guid : GreaterWhelpList)
304 if (Creature* gwhelp = instance->GetCreature(guid))
305 PhasingHandler::RemovePhase(gwhelp, 170, true);
306 }
307
308 protected:
313
317
319
321
323
325 };
326
328 {
329 return new instance_oculus_InstanceMapScript(map);
330 }
331};
332
334{
335 new instance_oculus();
336}
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
EncounterState
@ DONE
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:433
@ GO_FLAG_NOT_SELECTABLE
@ UNIT_NPC_FLAG_GOSSIP
#define DataHeader
uint32 const EncounterCount
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void DoUpdateWorldState(int32 worldStateId, int32 value)
InstanceMap * instance
void SetHeaders(std::string_view dataHeaders)
void LoadDungeonEncounterData(std::span< DungeonEncounterData const > encounters)
EncounterState GetBossState(uint32 id) const
virtual void OnGameObjectCreate(GameObject *go) override
void LoadDoorData(std::span< DoorData const > data)
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3552
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
static void AddPhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
static void RemovePhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
Definition Unit.h:635
bool IsAlive() const
Definition Unit.h:1185
void SetNpcFlag(NPCFlags flags)
Definition Unit.h:997
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1398
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr Position VerdisaMove
static constexpr Position BelgaristraszMove
static constexpr DoorData doorData[]
static constexpr Position EternosMove
static constexpr DungeonEncounterData encounters[]
void AddSC_instance_oculus()
@ DATA_VAROS
Definition oculus.h:32
@ DATA_EREGOS
Definition oculus.h:34
@ DATA_DRAKOS
Definition oculus.h:31
@ DATA_UROM
Definition oculus.h:33
@ DATA_CONSTRUCTS
Definition oculus.h:36
@ WORLD_STATE_CENTRIFUGE_CONSTRUCT_AMOUNT
Definition oculus.h:77
@ WORLD_STATE_CENTRIFUGE_CONSTRUCT_SHOW
Definition oculus.h:76
@ POINT_MOVE_OUT
Definition oculus.h:107
@ GO_EREGOS_CACHE_H
Definition oculus.h:61
@ GO_EREGOS_CACHE_N
Definition oculus.h:60
@ GO_DRAGON_CAGE_DOOR
Definition oculus.h:59
@ NPC_DRAKOS
Definition oculus.h:41
@ NPC_CENTRIFUGE_CONSTRUCT
Definition oculus.h:47
@ NPC_ETERNOS
Definition oculus.h:53
@ NPC_VERDISA
Definition oculus.h:51
@ NPC_EREGOS
Definition oculus.h:44
@ NPC_BELGARISTRASZ
Definition oculus.h:52
@ NPC_UROM
Definition oculus.h:43
@ NPC_GREATER_WHELP
Definition oculus.h:54
@ NPC_VAROS
Definition oculus.h:42
@ NPC_AZURE_RING_GUARDIAN
Definition oculus.h:46
@ SAY_VAROS_INTRO_TEXT
Definition oculus.h:89
@ SAY_EREGOS_INTRO_TEXT
Definition oculus.h:88
@ EVENT_VAROS_INTRO
Definition oculus.h:94
@ EVENT_EREGOS_INTRO
Definition oculus.h:95
@ ACTION_CALL_DRAGON_EVENT
Definition oculus.h:71
#define OculusScriptName
Definition oculus.h:23
@ EVENT_CALL_DRAGON
Definition oculus.h:66
@ KILL_NO_CONSTRUCT
Definition oculus.h:100
@ KILL_ONE_CONSTRUCT
Definition oculus.h:101
@ KILL_MORE_CONSTRUCT
Definition oculus.h:102
constexpr void Relocate(float x, float y)
Definition Position.h:74
ObjectGuid GetGuidData(uint32 type) const override
void ProcessEvent(WorldObject *, uint32 eventId, WorldObject *) override
bool SetBossState(uint32 type, EncounterState state) override
void OnCreatureCreate(Creature *creature) override