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 "ObjectAccessor.h"
29#include "ScriptedCreature.h"
30#include "ScriptMgr.h"
31#include "diremaul.h"
32
33// Bosses (East)
34// 0 - Pusillin
35// 1 - Lethtendris
36// 2 - Hydrospawn
37// 3 - Zevrim Thornhoof
38// 4 - Alzzin the Wildshaper
39
40// West
41// 5 - Tendris Warpwood
42// 6 - Magister Kalendris
43// 7 - Tsu'zee
44// 8 - Illyanna Ravenoak
45// 9 - Immol'thar
46// 10 - Prince Tortheldrin
47// 17 - CRYSTAL_01
48// 18 - CRYSTAL_02
49// 19 - CRYSTAL_03
50// 20 - CRYSTAL_04
51// 21 - CRYSTAL_05
52// 22 - FORCEFIELD
53
54// North
55// 11 - Guard Mol'dar
56// 12 - Stomper Kreeg
57// 13 - Guard Fengus
58// 14 - Guard Slip'kik
59// 15 - Captain Kromcrush
60// 16 - King Gordok
61
63
65
71
73{
74public:
75 instance_dire_maul() : InstanceMapScript("instance_dire_maul", 429) { }
76
78 {
84
85 void OnCreatureCreate(Creature* creature) override
86 {
87 switch (creature->GetEntry())
88 {
89 case NPC_IMMOLTHAR:
90 _immoGUID = creature->GetGUID();
91 // we make Immolthar non attackable, otherwise players with pets can pull him out of the forcefield
92 // TODO: this change isnt correct but since of today (13.09.2020) mmaps dont support doors
95 break;
96 case NPC_TORTHELDRIN:
97 _tortheldrinGUID = creature->GetGUID();
98 break;
99 default:
100 break;
101 }
102 }
103
105 {
107
108 switch (go->GetEntry())
109 {
110 case GO_CRYSTAL_01:
111 _crystalGUIDs[0] = go->GetGUID();
112 break;
113 case GO_CRYSTAL_02:
114 _crystalGUIDs[1] = go->GetGUID();
115 break;
116 case GO_CRYSTAL_03:
117 _crystalGUIDs[2] = go->GetGUID();
118 break;
119 case GO_CRYSTAL_04:
120 _crystalGUIDs[3] = go->GetGUID();
121 break;
122 case GO_CRYSTAL_05:
123 _crystalGUIDs[4] = go->GetGUID();
124 break;
125 case GO_FORCEFIELD:
126 _forcefieldGUID = go->GetGUID();
129 break;
130 case GO_PRINCE_CHEST:
132 break;
133 default:
134 break;
135 }
136 }
137
138 ObjectGuid GetGuidData(uint32 type) const override
139 {
140 switch (type)
141 {
142 case GO_CRYSTAL_01:
143 return _crystalGUIDs[0];
144 case GO_CRYSTAL_02:
145 return _crystalGUIDs[1];
146 case GO_CRYSTAL_03:
147 return _crystalGUIDs[2];
148 case GO_CRYSTAL_04:
149 return _crystalGUIDs[3];
150 case GO_CRYSTAL_05:
151 return _crystalGUIDs[4];
152 case GO_FORCEFIELD:
153 return _forcefieldGUID;
154 case GO_PRINCE_CHEST:
155 return _princechestGUID;
156 case NPC_IMMOLTHAR:
157 return _immoGUID;
158 case NPC_TORTHELDRIN:
159 return _tortheldrinGUID;
160 default:
161 break;
162 }
163 return ObjectGuid::Empty;
164 }
165
166 void Update(uint32 diff) override
167 {
168 _events.Update(diff);
169
170 while (uint32 eventId = _events.ExecuteEvent())
171 {
172 switch (eventId)
173 {
177 break;
182 break;
183 default:
184 break;
185 }
186 }
187 }
188
190 {
191 for (uint8 i = 0; i < 5; ++i) // we store creatures in a list for all 5 crystals
192 {
193 uint8 creatureCount = 0;
194
196 {
197 for (uint8 j = 0; j < 2; ++j) // once per creature type from CrystalMobs
198 {
199 std::list<Creature*> creatureList;
200 GetCreatureListWithEntryInGrid(creatureList, crystal, CrystalMobs[j], 30.0f);
201 for (std::list<Creature*>::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
202 {
203 _crystalCreatureGUIDs[i][creatureCount] = (*itr)->GetGUID();
204 ++creatureCount;
205 }
206 }
207 }
208 }
209 }
210
212 {
213 for (uint8 i = 0; i < _crystalGUIDs.size(); ++i)
214 {
215 bool _mobAlive = false;
217 if (!go)
218 continue;
219
220 if (go->GetGoState() == GO_STATE_READY)
221 {
222 for (uint8 j = 0; j < _crystalCreatureGUIDs[i].size(); ++j)
223 {
225 if (mob && mob->IsAlive())
226 {
227 _mobAlive = true;
228 break;
229 }
230 }
231 }
232
233 if (!_mobAlive && go->GetGoState() == GO_STATE_READY) // if all stored creatures are dead and go state is ready
234 {
236
237 switch (go->GetEntry())
238 {
239 case GO_CRYSTAL_01:
242 break;
243 case GO_CRYSTAL_02:
246 break;
247 case GO_CRYSTAL_03:
250 break;
251 case GO_CRYSTAL_04:
254 break;
255 case GO_CRYSTAL_05:
258 break;
259 default:
260 break;
261 }
262 }
263 }
264
267 {
268 // if all crystals are done, we set encounter forcefield to done
270 // activate forcefield to make it disappear
272 ffield->SetGoState(GO_STATE_ACTIVE);
273 // remove previously set non attackable flag
275 immo->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
276 }
277 }
278
279 void OnUnitDeath(Unit* unit) override
280 {
281 if (unit->GetGUID() == _immoGUID)
282 {
283 if (Creature* tortheldrin = instance->GetCreature(_tortheldrinGUID))
284 tortheldrin->SetFaction(FACTION_ENEMY);
285 }
286
287 if (unit->GetGUID() == _tortheldrinGUID)
288 {
290 chest->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
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
302 };
303
305 {
307 }
308};
309
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ 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
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void SetGoState(GOState state)
GOState GetGoState() const
Definition GameObject.h:178
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
virtual void OnGameObjectCreate(GameObject *go) override
void SetHeaders(std::string const &dataHeaders)
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:4430
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4397
static ObjectGuid const Empty
Definition ObjectGuid.h:140
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
Definition Unit.h:769
bool IsAlive() const
Definition Unit.h:1234
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ GO_CRYSTAL_01
Definition diremaul.h:47
@ GO_CRYSTAL_03
Definition diremaul.h:49
@ GO_CRYSTAL_02
Definition diremaul.h:48
@ GO_CRYSTAL_04
Definition diremaul.h:50
@ GO_CRYSTAL_05
Definition diremaul.h:51
@ GO_PRINCE_CHEST
Definition diremaul.h:52
@ NPC_IMMOLTHAR
Definition diremaul.h:38
@ NPC_TORTHELDRIN
Definition diremaul.h:39
@ NPC_ARCANE_ABERRATION
Definition diremaul.h:40
@ NPC_MANA_REMNANT
Definition diremaul.h:41
@ DATA_CRYSTAL_01
Definition diremaul.h:28
@ DATA_CRYSTAL_05
Definition diremaul.h:32
@ DATA_CRYSTAL_03
Definition diremaul.h:30
@ DATA_CRYSTAL_02
Definition diremaul.h:29
@ DATA_FORCEFIELD
Definition diremaul.h:33
@ DATA_CRYSTAL_04
Definition diremaul.h:31
uint32 const CrystalMobs[2]
uint8 const EncounterCount
void AddSC_instance_dire_maul()
@ EVENT_CRYSTAL_CREATURE_CHECK
@ EVENT_CRYSTAL_CREATURE_STORE
std::array< std::array< ObjectGuid, 4 >, 5 > _crystalCreatureGUIDs
@ GO_FORCEFIELD