TrinityCore
instance_zulaman.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 "ScriptMgr.h"
19#include "Creature.h"
20#include "GameObject.h"
21#include "InstanceScript.h"
22#include "Map.h"
23#include "ScriptedCreature.h"
24#include "zulaman.h"
25
27{
28 { DATA_AKILZON, {{ 1189 }} },
29 { DATA_NALORAKK, {{ 1190 }} },
30 { DATA_JANALAI, {{ 1191 }} },
31 { DATA_HALAZZI, {{ 1192 }} },
32 { DATA_HEXLORD, {{ 1193 }} },
33 { DATA_DAAKARA, {{ 1194 }} }
34};
35
37{
38 public:
40
42 {
44 ZulAmanState(*this, "TimedRunState", NOT_STARTED)
45 {
49
50 SpeedRunTimer = 15;
52 }
53
54 void OnCreatureCreate(Creature* creature) override
55 {
56 switch (creature->GetEntry())
57 {
58 case NPC_AKILZON:
59 AkilzonGUID = creature->GetGUID();
60 break;
61 case NPC_NALORAKK:
62 NalorakkGUID = creature->GetGUID();
63 break;
64 case NPC_JANALAI:
65 JanalaiGUID = creature->GetGUID();
66 break;
67 case NPC_HALAZZI:
68 HalazziGUID = creature->GetGUID();
69 break;
70 case NPC_HEXLORD:
71 HexLordMalacrassGUID = creature->GetGUID();
72 break;
73 case NPC_DAAKARA:
74 DaakaraGUID = creature->GetGUID();
75 break;
76 case NPC_VOLJIN:
77 VoljinGUID = creature->GetGUID();
78 break;
80 HexLordTriggerGUID = creature->GetGUID();
81 break;
82 default:
83 break;
84 }
85 }
86
87 void OnGameObjectCreate(GameObject* go) override
88 {
89 switch (go->GetEntry())
90 {
91 case GO_STRANGE_GONG:
93 break;
94 case GO_MASSIVE_GATE:
95 MasiveGateGUID = go->GetGUID();
96 AddDoor(go, true);
99 break;
100 default:
101 break;
102 }
103 }
104
106 {
107 switch (go->GetEntry())
108 {
109 case GO_MASSIVE_GATE:
110 AddDoor(go, false);
111 break;
112 default:
113 break;
114 }
115 }
116
117 ObjectGuid GetGuidData(uint32 type) const override
118 {
119 switch (type)
120 {
121 case DATA_AKILZON:
122 return AkilzonGUID;
123 case DATA_NALORAKK:
124 return NalorakkGUID;
125 case DATA_JANALAI:
126 return JanalaiGUID;
127 case DATA_HALAZZI:
128 return HalazziGUID;
129 case DATA_HEXLORD:
131 case DATA_DAAKARA:
132 return DaakaraGUID;
134 return HexLordTriggerGUID;
136 return StrangeGongGUID;
138 return MasiveGateGUID;
139 default:
140 break;
141 }
142
143 return ObjectGuid::Empty;
144 }
145
146 void SetData(uint32 type, uint32 data) override
147 {
148 switch (type)
149 {
151 {
152 if (data == IN_PROGRESS)
153 {
157 SpeedRunTimer = 15;
158 ZulAmanState = data;
159 }
160 break;
161 }
162 default:
163 break;
164 }
165 }
166
167 uint32 GetData(uint32 type) const override
168 {
169 switch (type)
170 {
172 return ZulAmanState;
173 default:
174 break;
175 }
176
177 return 0;
178 }
179
180 bool SetBossState(uint32 type, EncounterState state) override
181 {
182 if (!InstanceScript::SetBossState(type, state))
183 return false;
184
185 if (state == DONE)
186 {
188 {
190
191 if (ZulAmanBossCount < 2)
192 {
195 }
196 else if (ZulAmanBossCount == 4)
197 {
201 }
202 }
203 }
204
205 switch (type)
206 {
207 case DATA_AKILZON:
208 break;
209 case DATA_NALORAKK:
210 break;
211 case DATA_JANALAI:
212 break;
213 case DATA_HALAZZI:
214 case DATA_HEXLORD:
215 case DATA_DAAKARA:
216 break;
217 default:
218 break;
219 }
220
221 return true;
222 }
223
224 void ProcessEvent(WorldObject* /*obj*/, uint32 eventId, WorldObject* /*invoker*/) override
225 {
226 switch (eventId)
227 {
229 if (Creature* voljin = instance->GetCreature(VoljinGUID))
230 {
231 if (voljin->IsAIEnabled())
232 voljin->AI()->DoAction(ACTION_START_ZULAMAN);
233 }
234 break;
235 default:
236 break;
237 }
238 }
239
240 void Update(uint32 diff) override
241 {
242 if (events.Empty())
243 return;
244
245 events.Update(diff);
246
247 while (uint32 eventId = events.ExecuteEvent())
248 {
249 switch (eventId)
250 {
253 if (SpeedRunTimer)
255 else
256 {
260 }
261 break;
262 default:
263 break;
264 }
265 }
266 }
267
268 void AfterDataLoad() override
269 {
270 // Speed run cannot be resumed after reset/crash
272 {
273 SpeedRunTimer = 0;
275 }
276 }
277
278 protected:
293 };
294
296 {
297 return new instance_zulaman_InstanceScript(map);
298 }
299};
300
302{
303 new instance_zulaman();
304}
uint32_t uint32
Definition: Define.h:142
EncounterState
@ IN_PROGRESS
@ FAIL
@ DONE
@ NOT_STARTED
@ GO_STATE_ACTIVE
#define DataHeader
uint32 const EncounterCount
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
bool Empty() const
Definition: EventMap.h:84
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void CancelEvent(uint32 eventId)
Definition: EventMap.cpp:131
void SetGoState(GOState state)
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void LoadDungeonEncounterData(T const &encounters)
void DoUpdateWorldState(int32 worldStateId, int32 value)
InstanceMap * instance
virtual void AddDoor(GameObject *door, bool add)
void SetHeaders(std::string const &dataHeaders)
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
InstanceScript * GetInstanceScript(InstanceMap *map) const override
void AddSC_instance_zulaman()
DungeonEncounterData const encounters[]
void OnCreatureCreate(Creature *creature) override
void SetData(uint32 type, uint32 data) override
void ProcessEvent(WorldObject *, uint32 eventId, WorldObject *) override
PersistentInstanceScriptValue< uint32 > ZulAmanState
ObjectGuid GetGuidData(uint32 type) const override
bool SetBossState(uint32 type, EncounterState state) override
@ WORLD_STATE_ZULAMAN_TIMER_ENABLED
Definition: zulaman.h:79
@ WORLD_STATE_ZULAMAN_TIMER
Definition: zulaman.h:80
@ NPC_HEXLORD_TRIGGER
Definition: zulaman.h:57
@ NPC_AKILZON
Definition: zulaman.h:49
@ NPC_JANALAI
Definition: zulaman.h:51
@ NPC_NALORAKK
Definition: zulaman.h:50
@ NPC_DAAKARA
Definition: zulaman.h:54
@ NPC_HALAZZI
Definition: zulaman.h:52
@ NPC_VOLJIN
Definition: zulaman.h:56
@ NPC_HEXLORD
Definition: zulaman.h:53
#define ZulamanScriptName
Definition: zulaman.h:24
@ DATA_AKILZON
Definition: zulaman.h:30
@ DATA_STRANGE_GONG
Definition: zulaman.h:40
@ DATA_ZULAMAN_STATE
Definition: zulaman.h:44
@ DATA_NALORAKK
Definition: zulaman.h:31
@ DATA_DAAKARA
Definition: zulaman.h:35
@ DATA_HEXLORD
Definition: zulaman.h:34
@ DATA_MASSIVE_GATE
Definition: zulaman.h:41
@ DATA_JANALAI
Definition: zulaman.h:32
@ DATA_HALAZZI
Definition: zulaman.h:33
@ DATA_HEXLORD_TRIGGER
Definition: zulaman.h:38
@ ACTION_START_ZULAMAN
Definition: zulaman.h:74
@ GO_STRANGE_GONG
Definition: zulaman.h:62
@ GO_MASSIVE_GATE
Definition: zulaman.h:63
@ EVENT_UPDATE_ZULAMAN_TIMER
Definition: zulaman.h:69
@ EVENT_START_ZULAMAN
Definition: zulaman.h:68