TrinityCore
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
31{
34};
35
37{
38 { DATA_DRAKOS, {{ 528, 529, 2016 }} },
39 { DATA_VAROS, {{ 530, 531, 2015 }} },
40 { DATA_UROM, {{ 532, 533, 2014 }} },
41 { DATA_EREGOS, {{ 534, 535, 2013 }} }
42};
43
44Position const VerdisaMove = { 949.188f, 1032.91f, 359.967f, 1.093027f };
45Position const BelgaristraszMove = { 941.453f, 1044.1f, 359.967f, 0.1984709f };
46Position const EternosMove = { 943.202f, 1059.35f, 359.967f, 5.757278f };
47
49{
50 public:
52
54 {
56 {
61
63 }
64
65 void OnCreatureCreate(Creature* creature) override
66 {
67 switch (creature->GetEntry())
68 {
69 case NPC_DRAKOS:
70 DrakosGUID = creature->GetGUID();
71 break;
72 case NPC_VAROS:
73 VarosGUID = creature->GetGUID();
75 PhasingHandler::AddPhase(creature, 170, true);
76 else
77 PhasingHandler::RemovePhase(creature, 170, true);
78 break;
79 case NPC_UROM:
80 UromGUID = creature->GetGUID();
82 PhasingHandler::AddPhase(creature, 170, true);
83 else
84 PhasingHandler::RemovePhase(creature, 170, true);
85 break;
86 case NPC_EREGOS:
87 EregosGUID = creature->GetGUID();
89 PhasingHandler::AddPhase(creature, 170, true);
90 else
91 PhasingHandler::RemovePhase(creature, 170, true);
92 break;
94 if (creature->IsAlive())
96 break;
98 BelgaristraszGUID = creature->GetGUID();
100 {
102 creature->Relocate(BelgaristraszMove);
103 }
104 break;
105 case NPC_ETERNOS:
106 EternosGUID = creature->GetGUID();
108 {
110 creature->Relocate(EternosMove);
111 }
112 break;
113 case NPC_VERDISA:
114 VerdisaGUID = creature->GetGUID();
116 {
118 creature->Relocate(VerdisaMove);
119 }
120 break;
123 GreaterWhelpList.push_back(creature->GetGUID());
124 else
125 PhasingHandler::AddPhase(creature, 170, true);
126 break;
127 default:
128 break;
129 }
130 }
131
133 {
135
136 switch (go->GetEntry())
137 {
140 EregosCacheGUID = go->GetGUID();
141 break;
142 default:
143 break;
144 }
145 }
146
147 void OnUnitDeath(Unit* unit) override
148 {
149 Creature* creature = unit->ToCreature();
150 if (!creature)
151 return;
152
153 if (creature->GetEntry() == NPC_CENTRIFUGE_CONSTRUCT)
154 {
156
158 if (Creature* varos = instance->GetCreature(VarosGUID))
159 varos->RemoveAllAuras();
160 }
161 }
162
163 void ProcessEvent(WorldObject* /*unit*/, uint32 eventId, WorldObject* /*invoker*/) override
164 {
165 if (eventId != EVENT_CALL_DRAGON)
166 return;
167
168 if (Creature* varos = instance->GetCreature(VarosGUID))
169 if (Creature* drake = varos->SummonCreature(NPC_AZURE_RING_GUARDIAN, varos->GetPositionX(), varos->GetPositionY(), varos->GetPositionZ() + 40))
170 drake->AI()->DoAction(ACTION_CALL_DRAGON_EVENT);
171 }
172
173 bool SetBossState(uint32 type, EncounterState state) override
174 {
175 if (!InstanceScript::SetBossState(type, state))
176 return false;
177
178 switch (type)
179 {
180 case DATA_DRAKOS:
181 if (state == DONE)
182 {
185 FreeDragons();
186 if (Creature* varos = instance->GetCreature(VarosGUID))
187 PhasingHandler::RemovePhase(varos, 170, true);
189 }
190 break;
191 case DATA_VAROS:
192 if (state == DONE)
193 {
196 PhasingHandler::RemovePhase(urom, 170, true);
197 }
198 break;
199 case DATA_UROM:
200 if (state == DONE)
201 {
202 if (Creature* eregos = instance->GetCreature(EregosGUID))
203 {
204 PhasingHandler::RemovePhase(eregos, 170, true);
207 }
208 }
209 break;
210 case DATA_EREGOS:
211 if (state == DONE)
212 {
214 {
215 cache->SetRespawnTime(cache->GetRespawnDelay());
216 cache->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
217 }
218 }
219 break;
220 }
221
222 return true;
223 }
224
225 uint32 GetData(uint32 type) const override
226 {
227 if (type == DATA_CONSTRUCTS)
228 {
230 return KILL_NO_CONSTRUCT;
231 else if (CentrifugueConstructCounter == 1)
232 return KILL_ONE_CONSTRUCT;
233 else
234 return KILL_MORE_CONSTRUCT;
235 }
236
237 return KILL_NO_CONSTRUCT;
238 }
239
240 ObjectGuid GetGuidData(uint32 type) const override
241 {
242 switch (type)
243 {
244 case DATA_DRAKOS:
245 return DrakosGUID;
246 case DATA_VAROS:
247 return VarosGUID;
248 case DATA_UROM:
249 return UromGUID;
250 case DATA_EREGOS:
251 return EregosGUID;
252 default:
253 break;
254 }
255
256 return ObjectGuid::Empty;
257 }
258
260 {
261 if (Creature* belgaristrasz = instance->GetCreature(BelgaristraszGUID))
262 {
263 belgaristrasz->SetWalk(true);
264 belgaristrasz->GetMotionMaster()->MovePoint(POINT_MOVE_OUT, BelgaristraszMove);
265 }
266
267 if (Creature* eternos = instance->GetCreature(EternosGUID))
268 {
269 eternos->SetWalk(true);
270 eternos->GetMotionMaster()->MovePoint(POINT_MOVE_OUT, EternosMove);
271 }
272
273 if (Creature* verdisa = instance->GetCreature(VerdisaGUID))
274 {
275 verdisa->SetWalk(true);
276 verdisa->GetMotionMaster()->MovePoint(POINT_MOVE_OUT, VerdisaMove);
277 }
278 }
279
280 void Update(uint32 diff) override
281 {
282 events.Update(diff);
283
284 while (uint32 eventId = events.ExecuteEvent())
285 {
286 switch (eventId)
287 {
289 if (Creature* varos = instance->GetCreature(VarosGUID))
290 varos->AI()->Talk(SAY_VAROS_INTRO_TEXT);
291 break;
293 if (Creature* eregos = instance->GetCreature(EregosGUID))
294 eregos->AI()->Talk(SAY_EREGOS_INTRO_TEXT);
295 break;
296 default:
297 break;
298 }
299 }
300 }
301
303 {
304 for (ObjectGuid guid : GreaterWhelpList)
305 if (Creature* gwhelp = instance->GetCreature(guid))
306 PhasingHandler::RemovePhase(gwhelp, 170, true);
307 }
308
309 protected:
314
318
320
322
324
326 };
327
329 {
330 return new instance_oculus_InstanceMapScript(map);
331 }
332};
333
335{
336 new instance_oculus();
337}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
EncounterState
@ DONE
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ GO_FLAG_NOT_SELECTABLE
@ UNIT_NPC_FLAG_GOSSIP
Definition: UnitDefines.h:297
#define DataHeader
uint32 const EncounterCount
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void LoadDungeonEncounterData(T const &encounters)
void DoUpdateWorldState(int32 worldStateId, int32 value)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
virtual void OnGameObjectCreate(GameObject *go) override
void LoadDoorData(DoorData const *data)
void SetHeaders(std::string const &dataHeaders)
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3489
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
static Creature * ToCreature(Object *o)
Definition: Object.h:219
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static void AddPhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
static void RemovePhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
Definition: Unit.h:627
bool IsAlive() const
Definition: Unit.h:1164
void SetNpcFlag(NPCFlags flags)
Definition: Unit.h:982
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:2025
InstanceScript * GetInstanceScript(InstanceMap *map) const override
DoorData const doorData[]
Position const BelgaristraszMove
Position const VerdisaMove
Position const EternosMove
DungeonEncounterData const 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:63
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