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
104 void OnUnitDeath(Unit* unit) override
105 {
106 if (unit->GetGUID() == _immoGUID)
107 {
108 if (Creature* tortheldrin = instance->GetCreature(_tortheldrinGUID))
109 tortheldrin->SetFaction(FACTION_ENEMY);
110 }
111 else if (unit->GetGUID() == _tortheldrinGUID)
112 {
114 chest->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
115 }
116 }
117
119 {
121
122 switch (go->GetEntry())
123 {
124 case GO_CRYSTAL_01:
125 _crystalGUIDs[0] = go->GetGUID();
126 break;
127 case GO_CRYSTAL_02:
128 _crystalGUIDs[1] = go->GetGUID();
129 break;
130 case GO_CRYSTAL_03:
131 _crystalGUIDs[2] = go->GetGUID();
132 break;
133 case GO_CRYSTAL_04:
134 _crystalGUIDs[3] = go->GetGUID();
135 break;
136 case GO_CRYSTAL_05:
137 _crystalGUIDs[4] = go->GetGUID();
138 break;
139 case GO_FORCEFIELD:
140 _forcefieldGUID = go->GetGUID();
143 break;
144 case GO_PRINCE_CHEST:
146 break;
147 default:
148 break;
149 }
150 }
151
152 ObjectGuid GetGuidData(uint32 type) const override
153 {
154 switch (type)
155 {
156 case GO_CRYSTAL_01:
157 return _crystalGUIDs[0];
158 case GO_CRYSTAL_02:
159 return _crystalGUIDs[1];
160 case GO_CRYSTAL_03:
161 return _crystalGUIDs[2];
162 case GO_CRYSTAL_04:
163 return _crystalGUIDs[3];
164 case GO_CRYSTAL_05:
165 return _crystalGUIDs[4];
166 case GO_FORCEFIELD:
167 return _forcefieldGUID;
168 case GO_PRINCE_CHEST:
169 return _princechestGUID;
170 case NPC_IMMOLTHAR:
171 return _immoGUID;
172 case NPC_TORTHELDRIN:
173 return _tortheldrinGUID;
174 default:
175 break;
176 }
177 return ObjectGuid::Empty;
178 }
179
180 void Update(uint32 diff) override
181 {
182 _events.Update(diff);
183
184 while (uint32 eventId = _events.ExecuteEvent())
185 {
186 switch (eventId)
187 {
191 break;
196 break;
197 default:
198 break;
199 }
200 }
201 }
202
204 {
205 for (uint8 i = 0; i < 5; ++i) // we store creatures in a list for all 5 crystals
206 {
207 uint8 creatureCount = 0;
208
210 {
211 for (uint8 j = 0; j < 2; ++j) // once per creature type from CrystalMobs
212 {
213 std::list<Creature*> creatureList;
214 GetCreatureListWithEntryInGrid(creatureList, crystal, CrystalMobs[j], 30.0f);
215 for (std::list<Creature*>::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
216 {
217 _crystalCreatureGUIDs[i][creatureCount] = (*itr)->GetGUID();
218 ++creatureCount;
219 }
220 }
221 }
222 }
223 }
224
226 {
227 for (uint8 i = 0; i < _crystalGUIDs.size(); ++i)
228 {
229 bool _mobAlive = false;
231 if (!go)
232 continue;
233
234 if (go->GetGoState() == GO_STATE_READY)
235 {
236 for (uint8 j = 0; j < _crystalCreatureGUIDs[i].size(); ++j)
237 {
239 if (mob && mob->IsAlive())
240 {
241 _mobAlive = true;
242 break;
243 }
244 }
245 }
246
247 if (!_mobAlive && go->GetGoState() == GO_STATE_READY) // if all stored creatures are dead and go state is ready
248 {
250
251 switch (go->GetEntry())
252 {
253 case GO_CRYSTAL_01:
256 break;
257 case GO_CRYSTAL_02:
260 break;
261 case GO_CRYSTAL_03:
264 break;
265 case GO_CRYSTAL_04:
268 break;
269 case GO_CRYSTAL_05:
272 break;
273 default:
274 break;
275 }
276 }
277 }
278
281 {
282 // if all crystals are done, we set encounter forcefield to done
284 // activate forcefield to make it disappear
286 ffield->SetGoState(GO_STATE_ACTIVE);
287 // remove previously set non attackable flag
289 immo->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
290 }
291 }
292
293protected:
295 std::array<ObjectGuid, 5> _crystalGUIDs;
296 std::array<std::array<ObjectGuid, 4>, 5> _crystalCreatureGUIDs; // 5 different Crystals, maximum of 4 Creatures
301 };
302
304 {
306 }
307};
308
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:4425
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4392
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:783
bool IsAlive() const
Definition Unit.h:1247
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:968
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