TrinityCore
instance_gundrak.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 "InstanceScript.h"
19#include "Creature.h"
20#include "EventMap.h"
21#include "GameObject.h"
22#include "GameObjectAI.h"
23#include "gundrak.h"
24#include "Map.h"
25#include "ScriptMgr.h"
26
28{
35};
36
38{
40 { 0, 0 } // END
41};
42
44{
54 { 0, 0 } // END
55};
56
58{
59 { DATA_SLAD_RAN, {{ 1978 }} },
60 { DATA_DRAKKARI_COLOSSUS, {{ 1983 }} },
61 { DATA_MOORABI, {{ 1980 }} },
62 { DATA_GAL_DARAH, {{ 1981 }} },
63 { DATA_ECK_THE_FEROCIOUS, {{ 1988 }} }
64};
65
66Position const EckSpawnPoint = { 1643.877930f, 936.278015f, 107.204948f, 0.668432f };
67
69{
70 public:
72
74 {
76 {
82
86 }
87
88 void OnCreatureCreate(Creature* creature) override
89 {
90 switch (creature->GetEntry())
91 {
93 if (creature->IsAlive())
94 DwellerGUIDs.insert(creature->GetGUID());
95 break;
96 default:
97 break;
98 }
99
101 }
102
104 {
105 switch (go->GetEntry())
106 {
109 {
112 else
114 }
115 break;
116 case GO_MOORABI_ALTAR:
118 {
121 else
123 }
124 break;
127 {
130 else
132 }
133 break;
136 break;
139 break;
142 break;
145 break;
147 // Don't store door on non-heroic
148 if (!instance->IsHeroic())
149 return;
150 break;
151 case GO_TRAPDOOR:
153 break;
154 case GO_COLLISION:
156 break;
157 default:
158 break;
159 }
160
162 }
163
164 void OnUnitDeath(Unit* unit) override
165 {
166 if (unit->GetEntry() == NPC_RUIN_DWELLER)
167 {
168 DwellerGUIDs.erase(unit->GetGUID());
169
170 if (DwellerGUIDs.empty())
172 }
173 }
174
175 bool SetBossState(uint32 type, EncounterState state) override
176 {
177 if (!InstanceScript::SetBossState(type, state))
178 return false;
179
180 switch (type)
181 {
182 case DATA_SLAD_RAN:
183 if (state == DONE)
185 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
186 break;
188 if (state == DONE)
190 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
191 break;
192 case DATA_MOORABI:
193 if (state == DONE)
195 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
196 break;
197 default:
198 break;
199 }
200
201 return true;
202 }
203
204 bool CheckRequiredBosses(uint32 bossId, Player const* player = nullptr) const override
205 {
206 if (_SkipCheckRequiredBosses(player))
207 return true;
208
209 switch (bossId)
210 {
213 return false;
214 break;
215 case DATA_GAL_DARAH:
219 return false;
220 break;
221 default:
222 break;
223 }
224
225 return true;
226 }
227
228 bool IsBridgeReady() const
229 {
231 }
232
233 void SetData(uint32 type, uint32 data) override
234 {
235 if (type == DATA_STATUE_ACTIVATE)
236 {
237 switch (data)
238 {
241 break;
244 break;
245 case GO_MOORABI_ALTAR:
247 break;
248 default:
249 break;
250 }
251 }
252 }
253
254 void AfterDataLoad() override
255 {
262
263 if (IsBridgeReady())
265 }
266
268 {
269 if (GameObject* go = GetGameObject(type))
270 go->SetGoState(state);
271
272 switch (type)
273 {
275 SladRanStatueState = state;
276 break;
279 break;
281 MoorabiStatueState = state;
282 break;
283 default:
284 break;
285 }
286 }
287
288 void Update(uint32 diff) override
289 {
290 Events.Update(diff);
291
292 while (uint32 eventId = Events.ExecuteEvent())
293 {
294 uint32 spellId = 0;
295 uint32 altarId = 0;
296 switch (eventId)
297 {
299 spellId = SPELL_FIRE_BEAM_SNAKE;
300 altarId = DATA_SLAD_RAN_ALTAR;
301 break;
305 break;
307 spellId = SPELL_FIRE_BEAM_MAMMOTH;
308 altarId = DATA_MOORABI_ALTAR;
309 break;
310 case DATA_BRIDGE:
311 for (uint32 type = DATA_SLAD_RAN_STATUE; type <= DATA_GAL_DARAH_STATUE; ++type)
315 return;
316 default:
317 return;
318 }
319
320 if (GameObject* altar = GetGameObject(altarId))
321 if (Creature* trigger = altar->FindNearestCreature(NPC_ALTAR_TRIGGER, 10.0f))
322 trigger->CastSpell(nullptr, spellId, true);
323
324 // eventId equals statueId
326
327 if (IsBridgeReady())
329 }
330 }
331
332 protected:
335
339 };
340
342 {
344 }
345};
346
348{
349 go_gundrak_altar(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
350
352
353 bool OnGossipHello(Player* /*player*/) override
354 {
357
359 return true;
360 }
361};
362
364{
365 new instance_gundrak();
367}
uint32_t uint32
Definition: Define.h:142
EncounterState
@ DONE
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:68
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:393
@ GO_FLAG_NOT_SELECTABLE
GOState
@ GO_STATE_READY
@ GO_STATE_DESTROYED
@ GO_STATE_ACTIVE
#define DataHeader
uint32 const EncounterCount
GameObject *const me
Definition: GameObjectAI.h:50
void SetGoState(GOState state)
void RemoveFlag(GameObjectFlags flags)
Definition: GameObject.h:275
void SetFlag(GameObjectFlags flags)
Definition: GameObject.h:274
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
void LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
virtual void OnGameObjectCreate(GameObject *go) override
void LoadDoorData(DoorData const *data)
GameObject * GetGameObject(uint32 type)
bool _SkipCheckRequiredBosses(Player const *player=nullptr) const
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
bool IsHeroic() const
Definition: Map.cpp:3282
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Definition: Unit.h:627
bool IsAlive() const
Definition: Unit.h:1164
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
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ SPELL_FIRE_BEAM_MAMMOTH
Definition: gundrak.h:86
@ SPELL_FIRE_BEAM_ELEMENTAL
Definition: gundrak.h:88
@ SPELL_FIRE_BEAM_SNAKE
Definition: gundrak.h:87
#define GundrakScriptName
Definition: gundrak.h:23
#define RegisterGundrakGameObjectAI(ai_name)
Definition: gundrak.h:100
constexpr Milliseconds TIMER_STATUE_ACTIVATION
Definition: gundrak.h:91
@ DATA_SLAD_RAN
Definition: gundrak.h:31
@ DATA_SLAD_RAN_ALTAR
Definition: gundrak.h:38
@ DATA_DRAKKARI_COLOSSUS
Definition: gundrak.h:32
@ DATA_MOORABI
Definition: gundrak.h:33
@ DATA_STATUE_ACTIVATE
Definition: gundrak.h:51
@ DATA_COLLISION
Definition: gundrak.h:48
@ DATA_GAL_DARAH
Definition: gundrak.h:34
@ DATA_GAL_DARAH_STATUE
Definition: gundrak.h:45
@ DATA_DRAKKARI_COLOSSUS_ALTAR
Definition: gundrak.h:39
@ DATA_MOORABI_STATUE
Definition: gundrak.h:44
@ DATA_MOORABI_ALTAR
Definition: gundrak.h:40
@ DATA_ECK_THE_FEROCIOUS
Definition: gundrak.h:35
@ DATA_SLAD_RAN_STATUE
Definition: gundrak.h:42
@ DATA_DRAKKARI_COLOSSUS_STATUE
Definition: gundrak.h:43
@ DATA_TRAPDOOR
Definition: gundrak.h:47
@ DATA_BRIDGE
Definition: gundrak.h:49
@ GO_GAL_DARAH_DOOR_2
Definition: gundrak.h:78
@ GO_DRAKKARI_COLOSSUS_STATUE
Definition: gundrak.h:74
@ GO_GAL_DARAH_DOOR_1
Definition: gundrak.h:77
@ GO_SLAD_RAN_STATUE
Definition: gundrak.h:71
@ GO_ECK_THE_FEROCIOUS_DOOR_BEHIND
Definition: gundrak.h:76
@ GO_ECK_THE_FEROCIOUS_DOOR
Definition: gundrak.h:75
@ GO_TRAPDOOR
Definition: gundrak.h:80
@ GO_MOORABI_ALTAR
Definition: gundrak.h:69
@ GO_MOORABI_STATUE
Definition: gundrak.h:72
@ GO_SLAD_RAN_ALTAR
Definition: gundrak.h:68
@ GO_GAL_DARAH_DOOR_3
Definition: gundrak.h:79
@ GO_GAL_DARAH_STATUE
Definition: gundrak.h:73
@ GO_DRAKKARI_COLOSSUS_ALTAR
Definition: gundrak.h:70
@ NPC_ECK_THE_FEROCIOUS
Definition: gundrak.h:61
@ NPC_RUIN_DWELLER
Definition: gundrak.h:60
@ NPC_ALTAR_TRIGGER
Definition: gundrak.h:62
@ NPC_DRAKKARI_COLOSSUS
Definition: gundrak.h:59
ObjectData const gameObjectData[]
void AddSC_instance_gundrak()
ObjectData const creatureData[]
DoorData const doorData[]
Position const EckSpawnPoint
DungeonEncounterData const encounters[]
go_gundrak_altar(GameObject *go)
bool OnGossipHello(Player *) override
InstanceScript * instance
bool SetBossState(uint32 type, EncounterState state) override
void OnCreatureCreate(Creature *creature) override
void SetData(uint32 type, uint32 data) override
bool CheckRequiredBosses(uint32 bossId, Player const *player=nullptr) const override