TrinityCore
Loading...
Searching...
No Matches
instance_the_black_morass.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 "ScriptMgr.h"
19#include "Creature.h"
20#include "CreatureAI.h"
21#include "Containers.h"
22#include "EventMap.h"
23#include "InstanceScript.h"
24#include "Player.h"
25#include "the_black_morass.h"
26
27static constexpr ObjectData creatureData[] =
28{
31 { 0, 0 } // END
32};
33
34static Position const PortalPosition1 = { -2030.832f, 7024.944f, 23.07182f, 3.141593f };
35static Position const PortalPosition2 = { -1961.734f, 7029.528f, 21.8114f, 2.129302f };
36static Position const PortalPosition3 = { -1887.695f, 7106.557f, 22.0495f, 4.956735f };
37static Position const PortalPosition4 = { -1930.911f, 7183.597f, 23.00764f, 3.595378f };
38
40{
41public:
43
48
50 {
58
73
89
90 bool SetBossState(uint32 type, EncounterState state) override
91 {
92 if (!InstanceScript::SetBossState(type, state))
93 return false;
94
95 switch (type)
96 {
97 case DATA_DEJA:
98 case DATA_TEMPORUS:
99 if (state == DONE)
101 break;
102 case DATA_AEONUS:
103 if (state == DONE)
104 {
109 }
110 break;
111 default:
112 break;
113 }
114
115 return true;
116 }
117
118 void SetData(uint32 type, uint32 data) override
119 {
120 switch (type)
121 {
122 case DATA_EVENT:
123 EventState = data;
124 switch (data)
125 {
126 case IN_PROGRESS:
129 if (Creature* saat = GetCreature(DATA_SAAT))
130 saat->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
131 break;
132 case DONE:
133 if (Creature* medivh = GetCreature(DATA_MEDIVH))
134 medivh->AI()->DoAction(ACTION_EPILOGUE);
135 if (Creature* saat = GetCreature(DATA_SAAT))
137 break;
138 case FAIL:
139 DoResetEvent();
140 if (Creature* saat = GetCreature(DATA_SAAT))
142 break;
143 default:
144 break;
145 }
146 break;
147 case DATA_SHIELD_PCT:
148 if (data == SPECIAL && GetData(DATA_EVENT) == IN_PROGRESS)
149 {
151
153
154 switch (ShieldPercent)
155 {
156 case 75:
157 if (Creature* medivh = GetCreature(DATA_MEDIVH))
158 medivh->AI()->DoAction(ACTION_SHIELD_75);
159 break;
160 case 50:
161 if (Creature* medivh = GetCreature(DATA_MEDIVH))
162 medivh->AI()->DoAction(ACTION_SHIELD_50);
163 break;
164 case 25:
165 if (Creature* medivh = GetCreature(DATA_MEDIVH))
166 medivh->AI()->DoAction(ACTION_SHIELD_25);
167 break;
168 case 0:
169 if (Creature* medivh = GetCreature(DATA_MEDIVH))
170 medivh->AI()->DoAction(ACTION_SHIELD_0);
172 break;
173 default:
174 break;
175 }
176 }
177 break;
178 case DATA_RIFT:
179 switch (data)
180 {
181 case DONE:
184 break;
185 case SPECIAL:
189 break;
190 default:
191 break;
192 }
193 break;
194 default:
195 break;
196 }
197 }
198
199 uint32 GetData(uint32 type) const override
200 {
201 switch (type)
202 {
203 case DATA_EVENT:
204 return EventState;
205 case DATA_RIFT_COUNT:
206 return RiftPortalCount;
207 case DATA_SHIELD_PCT:
208 return ShieldPercent;
209 }
210
211 return 0;
212 }
213
214 void OnUnitDeath(Unit* unit) override
215 {
216 switch (unit->GetEntry())
217 {
218 case NPC_RIFT_LORD:
220 case NPC_RIFT_KEEPER:
223 break;
227 break;
228 default:
229 break;
230 }
231 }
232
234 {
235 // Spells are guessed
236 if (Creature* medivh = GetCreature(DATA_MEDIVH))
237 {
238 std::vector<uint32> availableSummonRiftSpells =
239 {
244 };
245
247 std::erase(availableSummonRiftSpells, LastSummonRiftSpell);
248
249 uint32 selectedSpell = Trinity::Containers::SelectRandomContainerElement(availableSummonRiftSpells);
250
251 LastSummonRiftSpell = selectedSpell;
252
253 medivh->CastSpell(nullptr, selectedSpell, true);
254
256 }
257 }
258
259 void ProcessEvent(WorldObject* /*gameObject*/, uint32 eventId) override
260 {
261 // Positions are sniffed but the way they are linked to events is guessed
262 switch (eventId)
263 {
265 if (Creature* medivh = GetCreature(DATA_MEDIVH))
267 break;
269 if (Creature* medivh = GetCreature(DATA_MEDIVH))
271 break;
273 if (Creature* medivh = GetCreature(DATA_MEDIVH))
275 break;
277 if (Creature* medivh = GetCreature(DATA_MEDIVH))
279 break;
280 default:
281 break;
282 }
283 }
284
285 void Update(uint32 diff) override
286 {
287 Events.Update(diff);
288
289 if (Events.ExecuteEvent() == EVENT_SUMMON_PORTAL)
290 {
294 if (RiftPortalCount != 6 && RiftPortalCount != 12 && RiftPortalCount != 18)
295 ScheduleEventNextPortal(RiftPortalCount > 12 ? 90s : 120s);
296 }
297 }
298
300 {
301 Events.RescheduleEvent(EVENT_SUMMON_PORTAL, nextPortalTime);
302 }
303
304 protected:
311 };
312
313};
314
uint32_t uint32
Definition Define.h:133
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
EncounterState
@ IN_PROGRESS
@ FAIL
@ DONE
@ SPECIAL
@ NOT_STARTED
@ TEMPSUMMON_MANUAL_DESPAWN
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition Random.cpp:62
@ UNIT_NPC_FLAG_QUESTGIVER
@ UNIT_NPC_FLAGS
@ DATA_EVENT
#define DataHeader
uint32 const EncounterCount
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void DoCastSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
Creature * GetCreature(uint32 type)
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue)
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
uint32 GetEntry() const
Definition Object.h:81
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition Player.cpp:8488
Definition Unit.h:783
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
static Position const PortalPosition4
static Position const PortalPosition1
static Position const PortalPosition3
void AddSC_instance_the_black_morass()
static Position const PortalPosition2
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:108
@ WORLD_STATE_BM_SHIELD
@ WORLD_STATE_BM_RIFT
@ WORLD_STATE_BM
@ ACTION_SHIELD_25
@ ACTION_EPILOGUE
@ ACTION_SHIELD_0
@ ACTION_SHIELD_75
@ ACTION_SHIELD_50
@ NPC_INFINITE_TIMEREAVER
@ NPC_SAAT
@ NPC_RIFT_LORD_ALT
@ NPC_INFINITE_CHRONO_LORD
@ NPC_RIFT_KEEPER
@ NPC_MEDIVH
@ NPC_RIFT_LORD
@ NPC_RIFT_KEEPER_ALT
@ DATA_MEDIVH
@ DATA_TEMPORUS
@ DATA_RIFT
@ DATA_SAAT
@ DATA_RIFT_COUNT
@ DATA_SHIELD_PCT
@ DATA_DEJA
@ DATA_AEONUS
#define TBMScriptName
@ SPELL_THE_MASTERS_TOUCH_COMPLETE
@ SPELL_SUMMON_TIME_RIFT_EFFECT_1
@ SPELL_SUMMON_TIME_RIFT_EFFECT_2
@ SPELL_SUMMON_TIME_RIFT_EFFECT_4
@ SPELL_THE_BLACK_MORASS_COMPLETE
@ SPELL_SUMMON_TIME_RIFT_EFFECT_3
@ EVENT_SUMMON_TIME_RIFT_3
@ EVENT_SUMMON_TIME_RIFT_1
@ EVENT_SUMMON_TIME_RIFT_2
@ EVENT_SUMMON_PORTAL
@ EVENT_SUMMON_TIME_RIFT_4