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 case NPC_TORTHELDRIN:
116 _tortheldrinGUID = creature->GetGUID();
117 break;
118 default:
119 break;
120 }
121 }
122
123 void OnUnitDeath(Unit* unit) override
124 {
125 if (unit->GetGUID() == _immoGUID)
126 {
127 if (Creature* tortheldrin = instance->GetCreature(_tortheldrinGUID))
128 tortheldrin->SetFaction(FACTION_ENEMY);
129 }
130 else if (unit->GetGUID() == _tortheldrinGUID)
131 {
133 chest->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
134 }
135 else if (unit->GetEntry() == NPC_CHO_RUSH)
137 }
138
140 {
142
143 switch (go->GetEntry())
144 {
145 case GO_CRYSTAL_01:
146 _crystalGUIDs[0] = go->GetGUID();
147 break;
148 case GO_CRYSTAL_02:
149 _crystalGUIDs[1] = go->GetGUID();
150 break;
151 case GO_CRYSTAL_03:
152 _crystalGUIDs[2] = go->GetGUID();
153 break;
154 case GO_CRYSTAL_04:
155 _crystalGUIDs[3] = go->GetGUID();
156 break;
157 case GO_CRYSTAL_05:
158 _crystalGUIDs[4] = go->GetGUID();
159 break;
160 case GO_FORCEFIELD:
161 _forcefieldGUID = go->GetGUID();
164 break;
165 case GO_PRINCE_CHEST:
167 break;
168 default:
169 break;
170 }
171 }
172
173 ObjectGuid GetGuidData(uint32 type) const override
174 {
175 switch (type)
176 {
177 case GO_CRYSTAL_01:
178 return _crystalGUIDs[0];
179 case GO_CRYSTAL_02:
180 return _crystalGUIDs[1];
181 case GO_CRYSTAL_03:
182 return _crystalGUIDs[2];
183 case GO_CRYSTAL_04:
184 return _crystalGUIDs[3];
185 case GO_CRYSTAL_05:
186 return _crystalGUIDs[4];
187 case GO_FORCEFIELD:
188 return _forcefieldGUID;
189 case GO_PRINCE_CHEST:
190 return _princechestGUID;
191 case NPC_IMMOLTHAR:
192 return _immoGUID;
193 case NPC_TORTHELDRIN:
194 return _tortheldrinGUID;
195 default:
196 break;
197 }
198 return ObjectGuid::Empty;
199 }
200
201 void Update(uint32 diff) override
202 {
203 _events.Update(diff);
204
205 while (uint32 eventId = _events.ExecuteEvent())
206 {
207 switch (eventId)
208 {
212 break;
217 break;
218 default:
219 break;
220 }
221 }
222 }
223
225 {
226 for (uint8 i = 0; i < 5; ++i) // we store creatures in a list for all 5 crystals
227 {
228 uint8 creatureCount = 0;
229
231 {
232 for (uint8 j = 0; j < 2; ++j) // once per creature type from CrystalMobs
233 {
234 std::list<Creature*> creatureList;
235 GetCreatureListWithEntryInGrid(creatureList, crystal, CrystalMobs[j], 30.0f);
236 for (std::list<Creature*>::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
237 {
238 _crystalCreatureGUIDs[i][creatureCount] = (*itr)->GetGUID();
239 ++creatureCount;
240 }
241 }
242 }
243 }
244 }
245
247 {
248 for (uint8 i = 0; i < _crystalGUIDs.size(); ++i)
249 {
250 bool _mobAlive = false;
252 if (!go)
253 continue;
254
255 if (go->GetGoState() == GO_STATE_READY)
256 {
257 for (uint8 j = 0; j < _crystalCreatureGUIDs[i].size(); ++j)
258 {
260 if (mob && mob->IsAlive())
261 {
262 _mobAlive = true;
263 break;
264 }
265 }
266 }
267
268 if (!_mobAlive && go->GetGoState() == GO_STATE_READY) // if all stored creatures are dead and go state is ready
269 {
271
272 switch (go->GetEntry())
273 {
274 case GO_CRYSTAL_01:
277 break;
278 case GO_CRYSTAL_02:
281 break;
282 case GO_CRYSTAL_03:
285 break;
286 case GO_CRYSTAL_04:
289 break;
290 case GO_CRYSTAL_05:
293 break;
294 default:
295 break;
296 }
297 }
298 }
299
302 {
303 // if all crystals are done, we set encounter forcefield to done
305 // activate forcefield to make it disappear
307 ffield->SetGoState(GO_STATE_ACTIVE);
308 // remove previously set non attackable flag
310 immo->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
311 }
312 }
313
314protected:
316 std::array<ObjectGuid, 5> _crystalGUIDs;
317 std::array<std::array<ObjectGuid, 4>, 5> _crystalCreatureGUIDs; // 5 different Crystals, maximum of 4 Creatures
322 };
323
325 {
327 }
328};
329
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_FLAG_NOT_SELECTABLE
@ FACTION_ENEMY
@ GO_STATE_READY
@ GO_STATE_ACTIVE
@ UNIT_FLAG_NON_ATTACKABLE
#define DataHeader
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void Update(uint32 time)
Definition EventMap.h:77
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void SetGoState(GOState state)
GOState GetGoState() const
Definition GameObject.h:290
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:3588
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3578
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint32 GetEntry() const
Definition Object.h:89
Definition Unit.h:647
bool IsAlive() const
Definition Unit.h:1205
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:861
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
@ GO_PRINCE_CHEST
Definition diremaul.h:73
@ NPC_CHO_RUSH
Definition diremaul.h:62
@ NPC_IMMOLTHAR
Definition diremaul.h:58
@ NPC_TORTHELDRIN
Definition diremaul.h:59
@ 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