-
Notifications
You must be signed in to change notification settings - Fork 6k
/
instance_eye_of_eternity.cpp
290 lines (258 loc) · 10.7 KB
/
instance_eye_of_eternity.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "InstanceScript.h"
#include "eye_of_eternity.h"
#include "Player.h"
BossBoundaryData const boundaries =
{
{ DATA_MALYGOS_EVENT, new CircleBoundary(Position(754.362f, 1301.609985f), 280.0) } // sanity check boundary
};
class instance_eye_of_eternity : public InstanceMapScript
{
public:
instance_eye_of_eternity() : InstanceMapScript("instance_eye_of_eternity", 616) { }
InstanceScript* GetInstanceScript(InstanceMap* map) const override
{
return new instance_eye_of_eternity_InstanceMapScript(map);
}
struct instance_eye_of_eternity_InstanceMapScript : public InstanceScript
{
instance_eye_of_eternity_InstanceMapScript(Map* map) : InstanceScript(map)
{
SetHeaders(DataHeader);
SetBossNumber(MAX_ENCOUNTER);
LoadBossBoundaries(boundaries);
}
void OnPlayerEnter(Player* player) override
{
if (GetBossState(DATA_MALYGOS_EVENT) == DONE)
player->CastSpell(player, SPELL_SUMMOM_RED_DRAGON_BUDDY, true);
}
bool SetBossState(uint32 type, EncounterState state) override
{
if (!InstanceScript::SetBossState(type, state))
return false;
if (type == DATA_MALYGOS_EVENT)
{
if (state == FAIL)
{
for (GuidList::const_iterator itr_trigger = portalTriggers.begin(); itr_trigger != portalTriggers.end(); ++itr_trigger)
{
if (Creature* trigger = instance->GetCreature(*itr_trigger))
{
// just in case
trigger->RemoveAllAuras();
trigger->AI()->Reset();
}
}
SpawnGameObject(GO_EXIT_PORTAL, exitPortalPosition);
if (GameObject* platform = instance->GetGameObject(platformGUID))
platform->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED);
}
else if (state == DONE)
SpawnGameObject(GO_EXIT_PORTAL, exitPortalPosition);
}
return true;
}
/// @todo this should be handled in map, maybe add a summon function in map
// There is no other way afaik...
void SpawnGameObject(uint32 entry, Position const& pos)
{
GameObject* go = new GameObject();
if (!go->Create(entry, instance, PHASEMASK_NORMAL, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(),
0, 0, 0, 0, 120, GO_STATE_READY))
{
delete go;
return;
}
instance->AddToMap(go);
}
void OnGameObjectCreate(GameObject* go) override
{
switch (go->GetEntry())
{
case GO_NEXUS_RAID_PLATFORM:
platformGUID = go->GetGUID();
break;
case GO_FOCUSING_IRIS_10:
case GO_FOCUSING_IRIS_25:
irisGUID = go->GetGUID();
focusingIrisPosition = go->GetPosition();
break;
case GO_EXIT_PORTAL:
exitPortalGUID = go->GetGUID();
exitPortalPosition = go->GetPosition();
break;
case GO_HEART_OF_MAGIC_10:
case GO_HEART_OF_MAGIC_25:
heartOfMagicGUID = go->GetGUID();
break;
default:
break;
}
}
void OnCreatureCreate(Creature* creature) override
{
switch (creature->GetEntry())
{
case NPC_VORTEX_TRIGGER:
vortexTriggers.push_back(creature->GetGUID());
break;
case NPC_MALYGOS:
malygosGUID = creature->GetGUID();
break;
case NPC_PORTAL_TRIGGER:
portalTriggers.push_back(creature->GetGUID());
break;
case NPC_ALEXSTRASZA_BUNNY:
alexstraszaBunnyGUID = creature->GetGUID();
break;
case NPC_ALEXSTRASZAS_GIFT:
giftBoxBunnyGUID = creature->GetGUID();
break;
}
}
void OnUnitDeath(Unit* unit) override
{
if (unit->GetTypeId() != TYPEID_PLAYER)
return;
// Player continues to be moving after death no matter if spline will be cleared along with all movements,
// so on next world tick was all about delay if box will pop or not (when new movement will be registered)
// since in EoE you never stop falling. However root at this precise* moment works,
// it will get cleared on release. If by any chance some lag happen "Reload()" and "RepopMe()" works,
// last test I made now gave me 50/0 of this bug so I can't do more about it.
unit->SetControlled(true, UNIT_STATE_ROOT);
}
void ProcessEvent(WorldObject* /*obj*/, uint32 eventId) override
{
if (eventId == EVENT_FOCUSING_IRIS)
{
if (Creature* alexstraszaBunny = instance->GetCreature(alexstraszaBunnyGUID))
alexstraszaBunny->CastSpell(alexstraszaBunny, SPELL_IRIS_OPENED);
if (GameObject* iris = instance->GetGameObject(irisGUID))
iris->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
if (Creature* malygos = instance->GetCreature(malygosGUID))
malygos->AI()->DoAction(0); // ACTION_LAND_ENCOUNTER_START
if (GameObject* exitPortal = instance->GetGameObject(exitPortalGUID))
exitPortal->Delete();
}
}
void VortexHandling()
{
if (Creature* malygos = instance->GetCreature(malygosGUID))
{
ThreatContainer::StorageType const& threatList = malygos->getThreatManager().getThreatList();
for (GuidList::const_iterator itr_vortex = vortexTriggers.begin(); itr_vortex != vortexTriggers.end(); ++itr_vortex)
{
if (threatList.empty())
return;
uint8 counter = 0;
if (Creature* trigger = instance->GetCreature(*itr_vortex))
{
// each trigger have to cast the spell to 5 players.
for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
{
if (counter >= 5)
break;
if (Unit* target = (*itr)->getTarget())
{
Player* player = target->ToPlayer();
if (!player || player->IsGameMaster() || player->HasAura(SPELL_VORTEX_4))
continue;
player->CastSpell(trigger, SPELL_VORTEX_4, true);
counter++;
}
}
}
}
}
}
void PowerSparksHandling()
{
bool next = (lastPortalGUID == portalTriggers.back() || !lastPortalGUID ? true : false);
for (GuidList::const_iterator itr_trigger = portalTriggers.begin(); itr_trigger != portalTriggers.end(); ++itr_trigger)
{
if (next)
{
if (Creature* trigger = instance->GetCreature(*itr_trigger))
{
lastPortalGUID = trigger->GetGUID();
trigger->CastSpell(trigger, SPELL_PORTAL_OPENED, true);
return;
}
}
if (*itr_trigger == lastPortalGUID)
next = true;
}
}
void SetData(uint32 data, uint32 /*value*/) override
{
switch (data)
{
case DATA_VORTEX_HANDLING:
VortexHandling();
break;
case DATA_POWER_SPARKS_HANDLING:
PowerSparksHandling();
break;
case DATA_RESPAWN_IRIS:
SpawnGameObject(instance->GetDifficultyID() == DIFFICULTY_10_N ? GO_FOCUSING_IRIS_10 : GO_FOCUSING_IRIS_25, focusingIrisPosition);
break;
}
}
ObjectGuid GetGuidData(uint32 data) const override
{
switch (data)
{
case DATA_TRIGGER:
return vortexTriggers.front();
case DATA_MALYGOS:
return malygosGUID;
case DATA_PLATFORM:
return platformGUID;
case DATA_ALEXSTRASZA_BUNNY_GUID:
return alexstraszaBunnyGUID;
case DATA_HEART_OF_MAGIC_GUID:
return heartOfMagicGUID;
case DATA_FOCUSING_IRIS_GUID:
return irisGUID;
case DATA_GIFT_BOX_BUNNY_GUID:
return giftBoxBunnyGUID;
}
return ObjectGuid::Empty;
}
private:
GuidList vortexTriggers;
GuidList portalTriggers;
ObjectGuid malygosGUID;
ObjectGuid irisGUID;
ObjectGuid lastPortalGUID;
ObjectGuid platformGUID;
ObjectGuid exitPortalGUID;
ObjectGuid heartOfMagicGUID;
ObjectGuid alexstraszaBunnyGUID;
ObjectGuid giftBoxBunnyGUID;
Position focusingIrisPosition;
Position exitPortalPosition;
};
};
void AddSC_instance_eye_of_eternity()
{
new instance_eye_of_eternity();
}