TrinityCore
Loading...
Searching...
No Matches
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
35
40
53
54static constexpr DungeonEncounterData encounters[] =
55{
56 { DATA_SLAD_RAN, {{ 1978 }} },
57 { DATA_DRAKKARI_COLOSSUS, {{ 1983 }} },
58 { DATA_MOORABI, {{ 1980 }} },
59 { DATA_GAL_DARAH, {{ 1981 }} },
60 { DATA_ECK_THE_FEROCIOUS, {{ 1988 }} }
61};
62
63static constexpr Position EckSpawnPoint = { 1643.877930f, 936.278015f, 107.204948f, 0.668432f };
64
66{
67 public:
69
71 {
84
85 void OnCreatureCreate(Creature* creature) override
86 {
87 switch (creature->GetEntry())
88 {
90 if (creature->IsAlive())
91 DwellerGUIDs.insert(creature->GetGUID());
92 break;
93 default:
94 break;
95 }
96
98 }
99
101 {
102 switch (go->GetEntry())
103 {
106 {
109 else
111 }
112 break;
113 case GO_MOORABI_ALTAR:
115 {
118 else
120 }
121 break;
124 {
127 else
129 }
130 break;
133 break;
136 break;
139 break;
142 break;
144 // Don't store door on non-heroic
145 if (!instance->IsHeroic())
146 return;
147 break;
148 case GO_TRAPDOOR:
150 break;
151 case GO_COLLISION:
153 break;
154 default:
155 break;
156 }
157
159 }
160
161 void OnUnitDeath(Unit* unit) override
162 {
163 if (unit->GetEntry() == NPC_RUIN_DWELLER)
164 {
165 DwellerGUIDs.erase(unit->GetGUID());
166
167 if (DwellerGUIDs.empty())
169 }
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_SLAD_RAN:
180 if (state == DONE)
182 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
183 break;
185 if (state == DONE)
187 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
188 break;
189 case DATA_MOORABI:
190 if (state == DONE)
192 go->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
193 break;
194 default:
195 break;
196 }
197
198 return true;
199 }
200
201 bool CheckRequiredBosses(uint32 bossId, Player const* player = nullptr) const override
202 {
203 if (_SkipCheckRequiredBosses(player))
204 return true;
205
206 switch (bossId)
207 {
210 return false;
211 break;
212 case DATA_GAL_DARAH:
216 return false;
217 break;
218 default:
219 break;
220 }
221
222 return true;
223 }
224
229
230 void SetData(uint32 type, uint32 data) override
231 {
232 if (type == DATA_STATUE_ACTIVATE)
233 {
234 switch (data)
235 {
238 break;
241 break;
242 case GO_MOORABI_ALTAR:
244 break;
245 default:
246 break;
247 }
248 }
249 }
250
263
265 {
266 if (GameObject* go = GetGameObject(type))
267 go->SetGoState(state);
268
269 switch (type)
270 {
272 SladRanStatueState = state;
273 break;
276 break;
278 MoorabiStatueState = state;
279 break;
280 default:
281 break;
282 }
283 }
284
285 void Update(uint32 diff) override
286 {
287 Events.Update(diff);
288
289 while (uint32 eventId = Events.ExecuteEvent())
290 {
291 uint32 spellId = 0;
292 uint32 altarId = 0;
293 switch (eventId)
294 {
296 spellId = SPELL_FIRE_BEAM_SNAKE;
297 altarId = DATA_SLAD_RAN_ALTAR;
298 break;
302 break;
304 spellId = SPELL_FIRE_BEAM_MAMMOTH;
305 altarId = DATA_MOORABI_ALTAR;
306 break;
307 case DATA_BRIDGE:
308 for (uint32 type = DATA_SLAD_RAN_STATUE; type <= DATA_GAL_DARAH_STATUE; ++type)
312 return;
313 default:
314 return;
315 }
316
317 if (GameObject* altar = GetGameObject(altarId))
318 if (Creature* trigger = altar->FindNearestCreature(NPC_ALTAR_TRIGGER, 10.0f))
319 trigger->CastSpell(nullptr, spellId, true);
320
321 // eventId equals statueId
323
324 if (IsBridgeReady())
326 }
327 }
328
329 protected:
332
336 };
337
339 {
341 }
342};
343
345{
346 go_gundrak_altar(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
347
349
350 bool OnGossipHello(Player* /*player*/) override
351 {
354
356 return true;
357 }
358};
359
uint32_t uint32
Definition Define.h:154
EncounterState
@ DONE
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:432
@ GO_FLAG_NOT_SELECTABLE
GOState
@ GO_STATE_READY
@ GO_STATE_DESTROYED
@ GO_STATE_ACTIVE
#define DataHeader
uint32 const EncounterCount
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
GameObject *const me
void SetGoState(GOState state)
void RemoveFlag(GameObjectFlags flags)
Definition GameObject.h:278
void SetFlag(GameObjectFlags flags)
Definition GameObject.h:277
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
void LoadObjectData(std::span< ObjectData const > creatureData, std::span< ObjectData const > gameObjectData)
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(uint32 type)
bool _SkipCheckRequiredBosses(Player const *player=nullptr) const
bool IsHeroic() const
Definition Map.cpp:3311
uint32 GetEntry() const
Definition Object.h:89
Definition Unit.h:635
bool IsAlive() const
Definition Unit.h:1185
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
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1517
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
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
static constexpr ObjectData creatureData[]
void AddSC_instance_gundrak()
static constexpr DoorData doorData[]
static constexpr Position EckSpawnPoint
static constexpr ObjectData gameObjectData[]
static constexpr DungeonEncounterData encounters[]
go_gundrak_altar(GameObject *go)
bool OnGossipHello(Player *) override
InstanceScript * instance
bool SetBossState(uint32 type, EncounterState state) override
void SetData(uint32 type, uint32 data) override
bool CheckRequiredBosses(uint32 bossId, Player const *player=nullptr) const override