TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "Player.h"
26#include "ScriptMgr.h"
27
29{
35 { 0, 0, DOOR_TYPE_ROOM } // END
36};
37
39{
41 { 0, 0 } // END
42};
43
45{
55 { 0, 0 } // END
56};
57
58Position const EckSpawnPoint = { 1643.877930f, 936.278015f, 107.204948f, 0.668432f };
59
61{
62 public:
64
66 {
68 {
73
77 }
78
79 void OnCreatureCreate(Creature* creature) override
80 {
81 switch (creature->GetEntry())
82 {
84 if (creature->IsAlive())
85 DwellerGUIDs.insert(creature->GetGUID());
86 break;
87 default:
88 break;
89 }
90
92 }
93
94 void OnGameObjectCreate(GameObject* go) override
95 {
96 switch (go->GetEntry())
97 {
100 {
103 else
105 }
106 break;
107 case GO_MOORABI_ALTAR:
109 {
112 else
114 }
115 break;
118 {
121 else
123 }
124 break;
127 break;
130 break;
133 break;
136 break;
138 // Don't store door on non-heroic
139 if (!instance->IsHeroic())
140 return;
141 break;
142 case GO_TRAPDOOR:
144 break;
145 case GO_COLLISION:
147 break;
148 default:
149 break;
150 }
151
153 }
154
155 void OnUnitDeath(Unit* unit) override
156 {
157 if (unit->GetEntry() == NPC_RUIN_DWELLER)
158 {
159 DwellerGUIDs.erase(unit->GetGUID());
160
161 if (DwellerGUIDs.empty())
163 }
164 }
165
166 bool SetBossState(uint32 type, EncounterState state) override
167 {
168 if (!InstanceScript::SetBossState(type, state))
169 return false;
170
171 switch (type)
172 {
173 case DATA_SLAD_RAN:
174 if (state == DONE)
176 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
177 break;
179 if (state == DONE)
181 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
182 break;
183 case DATA_MOORABI:
184 if (state == DONE)
186 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
187 break;
188 default:
189 break;
190 }
191
192 return true;
193 }
194
195 bool CheckRequiredBosses(uint32 bossId, Player const* player = nullptr) const override
196 {
197 if (_SkipCheckRequiredBosses(player))
198 return true;
199
200 switch (bossId)
201 {
204 return false;
205 break;
206 case DATA_GAL_DARAH:
210 return false;
211 break;
212 default:
213 break;
214 }
215
216 return true;
217 }
218
219 bool IsBridgeReady() const
220 {
222 }
223
224 void SetData(uint32 type, uint32 data) override
225 {
226 if (type == DATA_STATUE_ACTIVATE)
227 {
228 switch (data)
229 {
232 break;
235 break;
236 case GO_MOORABI_ALTAR:
238 break;
239 default:
240 break;
241 }
242 }
243 }
244
245 void WriteSaveDataMore(std::ostringstream& data) override
246 {
247 data << uint32(SladRanStatueState) << ' ';
248 data << uint32(DrakkariColossusStatueState) << ' ';
249 data << uint32(MoorabiStatueState) << ' ';
250 }
251
252 void ReadSaveDataMore(std::istringstream& data) override
253 {
254 uint32 temp;
255
256 data >> temp;
258
259 data >> temp;
261
262 data >> temp;
264
265 if (IsBridgeReady())
267 }
268
270 {
271 if (GameObject* go = GetGameObject(type))
272 go->SetGoState(state);
273
274 switch (type)
275 {
277 SladRanStatueState = state;
278 break;
281 break;
283 MoorabiStatueState = state;
284 break;
285 default:
286 break;
287 }
288 }
289
290 void Update(uint32 diff) override
291 {
292 Events.Update(diff);
293
294 while (uint32 eventId = Events.ExecuteEvent())
295 {
296 uint32 spellId = 0;
297 uint32 altarId = 0;
298 switch (eventId)
299 {
301 spellId = SPELL_FIRE_BEAM_SNAKE;
302 altarId = DATA_SLAD_RAN_ALTAR;
303 break;
307 break;
309 spellId = SPELL_FIRE_BEAM_MAMMOTH;
310 altarId = DATA_MOORABI_ALTAR;
311 break;
312 case DATA_BRIDGE:
313 for (uint32 type = DATA_SLAD_RAN_STATUE; type <= DATA_GAL_DARAH_STATUE; ++type)
317 SaveToDB();
318 return;
319 default:
320 return;
321 }
322
323 if (GameObject* altar = GetGameObject(altarId))
324 if (Creature* trigger = altar->FindNearestCreature(NPC_ALTAR_TRIGGER, 10.0f))
325 trigger->CastSpell(nullptr, spellId, true);
326
327 // eventId equals statueId
329
330 if (IsBridgeReady())
332
333 SaveToDB();
334 }
335 }
336
337 protected:
340
344 };
345
347 {
349 }
350};
351
353{
354 go_gundrak_altar(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
355
357
358 bool OnGossipHello(Player* /*player*/) override
359 {
362
364 return true;
365 }
366};
367
369{
370 new instance_gundrak();
372}
uint32_t uint32
Definition: Define.h:133
EncounterState
@ DONE
@ DOOR_TYPE_ROOM
@ DOOR_TYPE_PASSAGE
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:66
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:261
@ GO_FLAG_NOT_SELECTABLE
GOState
@ GO_STATE_READY
@ GO_STATE_DESTROYED
@ GO_STATE_ACTIVE
Events
#define DataHeader
uint32 const EncounterCount
GameObject *const me
Definition: GameObjectAI.h:35
void SetGoState(GOState state)
void RemoveFlag(GameObjectFlags flags)
Definition: GameObject.h:172
void SetFlag(GameObjectFlags flags)
Definition: GameObject.h:171
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
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:4254
uint32 GetEntry() const
Definition: Object.h:80
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:77
Definition: Player.h:915
Definition: Unit.h:769
bool IsAlive() const
Definition: Unit.h:1234
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:1992
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2099
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:56
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_COLLISION
Definition: gundrak.h:81
@ 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
go_gundrak_altar(GameObject *go)
bool OnGossipHello(Player *) override
InstanceScript * instance
void WriteSaveDataMore(std::ostringstream &data) override
bool SetBossState(uint32 type, EncounterState state) override
void OnCreatureCreate(Creature *creature) override
void ReadSaveDataMore(std::istringstream &data) override
void SetData(uint32 type, uint32 data) override
bool CheckRequiredBosses(uint32 bossId, Player const *player=nullptr) const override