TrinityCore
Loading...
Searching...
No Matches
instance_dire_maul.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/*
19This placeholder for the instance is needed for dungeon finding to be able
20to give credit after the boss defined in lastEncounterDungeon is killed.
21Without it, the party doing random dungeon won't get satchel of spoils and
22gets instead the deserter debuff.
23*/
24
25#include "GameObject.h"
26#include "InstanceScript.h"
27#include "Map.h"
28#include "ScriptedCreature.h"
29#include "ScriptMgr.h"
30#include "diremaul.h"
31
32// Bosses (East)
33// 0 - Pusillin
34// 1 - Lethtendris
35// 2 - Hydrospawn
36// 3 - Zevrim Thornhoof
37// 4 - Alzzin the Wildshaper
38
39// West
40// 5 - Tendris Warpwood
41// 6 - Magister Kalendris
42// 7 - Tsu'zee
43// 8 - Illyanna Ravenoak
44// 9 - Immol'thar
45// 10 - Prince Tortheldrin
46// 17 - CRYSTAL_01
47// 18 - CRYSTAL_02
48// 19 - CRYSTAL_03
49// 20 - CRYSTAL_04
50// 21 - CRYSTAL_05
51// 22 - FORCEFIELD
52
53// North
54// 11 - Guard Mol'dar
55// 12 - Stomper Kreeg
56// 13 - Guard Fengus
57// 14 - Guard Slip'kik
58// 15 - Captain Kromcrush
59// 16 - King Gordok
60// 23 - Cho'Rush the Observer
61
63
69
71{
72 { DATA_LETHTENDRIS, {{ 345 }} },
73 { DATA_HYDROSPAWN, {{ 344 }} },
74 { DATA_ZEVRIM_THORNHOOF, {{ 343 }} },
75 { DATA_ALZZIN_THE_WILDSHAPER, {{ 346 }} },
76 { DATA_TENDRIS_WARPWOOD, {{ 350 }} },
77 { DATA_MAGISTER_KALENDRIS, {{ 348 }} },
78 { DATA_ILLYANNA_RAVENOAK, {{ 347 }} },
79 { DATA_IMMOLTHAR, {{ 349 }} },
80 { DATA_PRINCE_TORTHELDRIN, {{ 361 }} },
81 { DATA_GUARD_MOLDAR, {{ 362 }} },
82 { DATA_STOMPER_KREEG, {{ 363 }} },
83 { DATA_GUARD_FENGUS, {{ 364 }} },
84 { DATA_GUARD_SLIPKIK, {{ 365 }} },
85 { DATA_CAPTAIN_KROMCRUSH, {{ 366 }} },
86 { DATA_CHO_RUSH_THE_OBSERVER, {{ 367 }} },
87 { DATA_KING_GORDOK, {{ 368 }} }
88};
89
91{
92public:
93 instance_dire_maul() : InstanceMapScript("instance_dire_maul", 429) { }
94
96 {
103
104 void OnCreatureCreate(Creature* creature) override
105 {
106 switch (creature->GetEntry())
107 {
108 case NPC_IMMOLTHAR:
109 _immoGUID = creature->GetGUID();
110 // we make Immolthar non attackable, otherwise players with pets can pull him out of the forcefield
111 // TODO: this change isnt correct but since of today (13.09.2020) mmaps dont support doors
114 break;
115 default:
116 break;
117 }
118 }
119
120 void OnUnitDeath(Unit* unit) override
121 {
122 if (unit->GetEntry() == NPC_CHO_RUSH)
124 }
125
127 {
129
130 switch (go->GetEntry())
131 {
132 case GO_CRYSTAL_01:
133 _crystalGUIDs[0] = go->GetGUID();
134 break;
135 case GO_CRYSTAL_02:
136 _crystalGUIDs[1] = go->GetGUID();
137 break;
138 case GO_CRYSTAL_03:
139 _crystalGUIDs[2] = go->GetGUID();
140 break;
141 case GO_CRYSTAL_04:
142 _crystalGUIDs[3] = go->GetGUID();
143 break;
144 case GO_CRYSTAL_05:
145 _crystalGUIDs[4] = go->GetGUID();
146 break;
147 case GO_FORCEFIELD:
148 _forcefieldGUID = go->GetGUID();
151 break;
152 default:
153 break;
154 }
155 }
156
157 ObjectGuid GetGuidData(uint32 type) const override
158 {
159 switch (type)
160 {
161 case GO_CRYSTAL_01:
162 return _crystalGUIDs[0];
163 case GO_CRYSTAL_02:
164 return _crystalGUIDs[1];
165 case GO_CRYSTAL_03:
166 return _crystalGUIDs[2];
167 case GO_CRYSTAL_04:
168 return _crystalGUIDs[3];
169 case GO_CRYSTAL_05:
170 return _crystalGUIDs[4];
171 case GO_FORCEFIELD:
172 return _forcefieldGUID;
173 case NPC_IMMOLTHAR:
174 return _immoGUID;
175 default:
176 break;
177 }
178 return ObjectGuid::Empty;
179 }
180
181 void Update(uint32 diff) override
182 {
183 _events.Update(diff);
184
185 while (uint32 eventId = _events.ExecuteEvent())
186 {
187 switch (eventId)
188 {
192 break;
197 break;
198 default:
199 break;
200 }
201 }
202 }
203
205 {
206 for (uint8 i = 0; i < 5; ++i) // we store creatures in a list for all 5 crystals
207 {
208 uint8 creatureCount = 0;
209
211 {
212 for (uint8 j = 0; j < 2; ++j) // once per creature type from CrystalMobs
213 {
214 std::list<Creature*> creatureList;
215 GetCreatureListWithEntryInGrid(creatureList, crystal, CrystalMobs[j], 30.0f);
216 for (std::list<Creature*>::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
217 {
218 _crystalCreatureGUIDs[i][creatureCount] = (*itr)->GetGUID();
219 ++creatureCount;
220 }
221 }
222 }
223 }
224 }
225
227 {
228 for (uint8 i = 0; i < _crystalGUIDs.size(); ++i)
229 {
230 bool _mobAlive = false;
232 if (!go)
233 continue;
234
235 if (go->GetGoState() == GO_STATE_READY)
236 {
237 for (uint8 j = 0; j < _crystalCreatureGUIDs[i].size(); ++j)
238 {
240 if (mob && mob->IsAlive())
241 {
242 _mobAlive = true;
243 break;
244 }
245 }
246 }
247
248 if (!_mobAlive && go->GetGoState() == GO_STATE_READY) // if all stored creatures are dead and go state is ready
249 {
251
252 switch (go->GetEntry())
253 {
254 case GO_CRYSTAL_01:
257 break;
258 case GO_CRYSTAL_02:
261 break;
262 case GO_CRYSTAL_03:
265 break;
266 case GO_CRYSTAL_04:
269 break;
270 case GO_CRYSTAL_05:
273 break;
274 default:
275 break;
276 }
277 }
278 }
279
282 {
283 // if all crystals are done, we set encounter forcefield to done
285 // activate forcefield to make it disappear
287 ffield->SetGoState(GO_STATE_ACTIVE);
288 // remove previously set non attackable flag
290 immo->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
291 }
292 }
293
294protected:
296 std::array<ObjectGuid, 5> _crystalGUIDs;
297 std::array<std::array<ObjectGuid, 4>, 5> _crystalCreatureGUIDs; // 5 different Crystals, maximum of 4 Creatures
300 };
301
303 {
305 }
306};
307
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ DONE
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
@ GO_STATE_READY
@ GO_STATE_ACTIVE
@ UNIT_FLAG_NON_ATTACKABLE
#define DataHeader
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void SetGoState(GOState state)
GOState GetGoState() const
Definition GameObject.h:284
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
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
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3552
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint32 GetEntry() const
Definition Object.h:89
Definition Unit.h:635
bool IsAlive() const
Definition Unit.h:1185
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:846
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ GO_CRYSTAL_01
Definition diremaul.h:68
@ GO_CRYSTAL_03
Definition diremaul.h:70
@ GO_CRYSTAL_02
Definition diremaul.h:69
@ GO_CRYSTAL_04
Definition diremaul.h:71
@ GO_CRYSTAL_05
Definition diremaul.h:72
@ NPC_CHO_RUSH
Definition diremaul.h:62
@ NPC_IMMOLTHAR
Definition diremaul.h:58
@ NPC_ARCANE_ABERRATION
Definition diremaul.h:60
@ NPC_MANA_REMNANT
Definition diremaul.h:61
@ DATA_CRYSTAL_01
Definition diremaul.h:45
@ DATA_GUARD_MOLDAR
Definition diremaul.h:39
@ DATA_STOMPER_KREEG
Definition diremaul.h:40
@ DATA_CRYSTAL_05
Definition diremaul.h:49
@ DATA_ILLYANNA_RAVENOAK
Definition diremaul.h:36
@ DATA_LETHTENDRIS
Definition diremaul.h:29
@ DATA_CRYSTAL_03
Definition diremaul.h:47
@ DATA_CAPTAIN_KROMCRUSH
Definition diremaul.h:43
@ DATA_CHO_RUSH_THE_OBSERVER
Definition diremaul.h:51
@ DATA_GUARD_SLIPKIK
Definition diremaul.h:42
@ DATA_TENDRIS_WARPWOOD
Definition diremaul.h:33
@ DATA_HYDROSPAWN
Definition diremaul.h:30
@ DATA_KING_GORDOK
Definition diremaul.h:44
@ DATA_CRYSTAL_02
Definition diremaul.h:46
@ DATA_ALZZIN_THE_WILDSHAPER
Definition diremaul.h:32
@ DATA_PRINCE_TORTHELDRIN
Definition diremaul.h:38
@ DATA_FORCEFIELD
Definition diremaul.h:50
@ DATA_IMMOLTHAR
Definition diremaul.h:37
@ DATA_ZEVRIM_THORNHOOF
Definition diremaul.h:31
@ DATA_MAGISTER_KALENDRIS
Definition diremaul.h:34
@ DATA_GUARD_FENGUS
Definition diremaul.h:41
@ DATA_CRYSTAL_04
Definition diremaul.h:48
uint32 const CrystalMobs[2]
void AddSC_instance_dire_maul()
DungeonEncounterData const encounters[]
@ EVENT_CRYSTAL_CREATURE_CHECK
@ EVENT_CRYSTAL_CREATURE_STORE
#define MAX_ENCOUNTER
std::array< std::array< ObjectGuid, 4 >, 5 > _crystalCreatureGUIDs
@ GO_FORCEFIELD
Definition zulgurub.h:83