TrinityCore
instance_eye_of_eternity.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 "AreaBoundary.h"
20#include "Creature.h"
21#include "CreatureAI.h"
22#include "eye_of_eternity.h"
23#include "GameObject.h"
24#include "InstanceScript.h"
25#include "Map.h"
26#include "Player.h"
27
29{
30 { DATA_MALYGOS_EVENT, new CircleBoundary(Position(754.362f, 1301.609985f), 280.0) } // sanity check boundary
31};
32
34{
35 { DATA_MALYGOS_EVENT, {{ 1094 }} }
36};
37
39{
40public:
42
44 {
46 }
47
49 {
51 {
56 }
57
58 void OnPlayerEnter(Player* player) override
59 {
61 player->CastSpell(player, SPELL_SUMMOM_RED_DRAGON_BUDDY, true);
62 }
63
64 void OnPlayerLeave(Player* player) override
65 {
66 if (!player->IsAlive())
67 player->SetControlled(false, UNIT_STATE_ROOT);
68 }
69
70 bool SetBossState(uint32 type, EncounterState state) override
71 {
72 if (!InstanceScript::SetBossState(type, state))
73 return false;
74
75 if (type == DATA_MALYGOS_EVENT)
76 {
77 if (state == FAIL)
78 {
79 for (ObjectGuid const& portalTriggerGuid : portalTriggers)
80 {
81 if (Creature* trigger = instance->GetCreature(portalTriggerGuid))
82 {
83 // just in case
84 trigger->RemoveAllAuras();
85 trigger->AI()->Reset();
86 }
87 }
88
90
92 platform->RemoveFlag(GO_FLAG_DESTROYED);
93 }
94 else if (state == DONE)
96 }
97 return true;
98 }
99
101 // There is no other way afaik...
102 void SpawnGameObject(uint32 entry, Position const& pos)
103 {
105 instance->AddToMap(go);
106 }
107
109 {
110 switch (go->GetEntry())
111 {
113 platformGUID = go->GetGUID();
114 break;
117 irisGUID = go->GetGUID();
119 break;
120 case GO_EXIT_PORTAL:
121 exitPortalGUID = go->GetGUID();
123 break;
127 break;
128 default:
129 break;
130 }
131 }
132
133 void OnCreatureCreate(Creature* creature) override
134 {
135 switch (creature->GetEntry())
136 {
138 vortexTriggers.push_back(creature->GetGUID());
139 break;
140 case NPC_MALYGOS:
141 malygosGUID = creature->GetGUID();
142 break;
144 portalTriggers.push_back(creature->GetGUID());
145 break;
147 alexstraszaBunnyGUID = creature->GetGUID();
148 break;
150 giftBoxBunnyGUID = creature->GetGUID();
151 break;
152 }
153 }
154
155 void OnUnitDeath(Unit* unit) override
156 {
157 if (unit->GetTypeId() != TYPEID_PLAYER)
158 return;
159
160 // Player continues to be moving after death no matter if spline will be cleared along with all movements,
161 // so on next world tick was all about delay if box will pop or not (when new movement will be registered)
162 // since in EoE you never stop falling. However root at this precise* moment works,
163 // it will get cleared on release. If by any chance some lag happen "Reload()" and "RepopMe()" works,
164 // last test I made now gave me 50/0 of this bug so I can't do more about it.
165 unit->SetControlled(true, UNIT_STATE_ROOT);
166 }
167
168 void ProcessEvent(WorldObject* /*obj*/, uint32 eventId, WorldObject* /*invoker*/) override
169 {
170 if (eventId == EVENT_FOCUSING_IRIS)
171 {
172 if (Creature* alexstraszaBunny = instance->GetCreature(alexstraszaBunnyGUID))
173 alexstraszaBunny->CastSpell(alexstraszaBunny, SPELL_IRIS_OPENED);
174
176 iris->SetFlag(GO_FLAG_IN_USE);
177
178 if (Creature* malygos = instance->GetCreature(malygosGUID))
179 malygos->AI()->DoAction(0); // ACTION_LAND_ENCOUNTER_START
180
182 exitPortal->Delete();
183 }
184 }
185
187 {
188 if (Creature* malygos = instance->GetCreature(malygosGUID))
189 {
190 for (GuidList::const_iterator itr_vortex = vortexTriggers.begin(); itr_vortex != vortexTriggers.end(); ++itr_vortex)
191 {
192 uint8 counter = 0;
193 if (Creature* trigger = instance->GetCreature(*itr_vortex))
194 {
195 // each trigger have to cast the spell to 5 players.
196 for (auto* ref : malygos->GetThreatManager().GetUnsortedThreatList())
197 {
198 if (counter >= 5)
199 break;
200
201 if (Player* player = ref->GetVictim()->ToPlayer())
202 {
203 if (player->IsGameMaster() || player->HasAura(SPELL_VORTEX_4))
204 continue;
205
206 player->CastSpell(trigger, SPELL_VORTEX_4, true);
207 counter++;
208 }
209 }
210 }
211 }
212 }
213 }
214
216 {
217 bool next = (lastPortalGUID == portalTriggers.back() || !lastPortalGUID ? true : false);
218
219 for (GuidList::const_iterator itr_trigger = portalTriggers.begin(); itr_trigger != portalTriggers.end(); ++itr_trigger)
220 {
221 if (next)
222 {
223 if (Creature* trigger = instance->GetCreature(*itr_trigger))
224 {
225 lastPortalGUID = trigger->GetGUID();
226 trigger->CastSpell(trigger, SPELL_PORTAL_OPENED, true);
227 return;
228 }
229 }
230
231 if (*itr_trigger == lastPortalGUID)
232 next = true;
233 }
234 }
235
236 void SetData(uint32 data, uint32 /*value*/) override
237 {
238 switch (data)
239 {
242 break;
245 break;
248 break;
249 }
250 }
251
252 ObjectGuid GetGuidData(uint32 data) const override
253 {
254 switch (data)
255 {
256 case DATA_TRIGGER:
257 return vortexTriggers.front();
258 case DATA_MALYGOS:
259 return malygosGUID;
260 case DATA_PLATFORM:
261 return platformGUID;
265 return heartOfMagicGUID;
267 return irisGUID;
269 return giftBoxBunnyGUID;
270 }
271
272 return ObjectGuid::Empty;
273 }
274
275 private:
288 };
289};
290
292{
294}
@ DIFFICULTY_10_N
Definition: DBCEnums.h:877
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
EncounterState
@ FAIL
@ DONE
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ GO_FLAG_IN_USE
@ GO_FLAG_DESTROYED
@ GO_STATE_READY
@ UNIT_STATE_ROOT
Definition: Unit.h:265
#define DataHeader
static GameObject * CreateGameObject(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit=0)
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void LoadBossBoundaries(BossBoundaryData const &data)
void SetHeaders(std::string const &dataHeaders)
bool AddToMap(T *)
Definition: Map.cpp:550
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3489
Difficulty GetDifficultyID() const
Definition: Map.h:324
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
Definition: Unit.h:627
void SetControlled(bool apply, UnitState state)
Definition: Unit.cpp:10911
bool IsAlive() const
Definition: Unit.h:1164
Unit * GetVictim() const
Definition: Unit.h:715
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ DATA_VORTEX_HANDLING
@ DATA_RESPAWN_IRIS
@ DATA_POWER_SPARKS_HANDLING
@ DATA_MALYGOS_EVENT
@ GO_FOCUSING_IRIS_25
@ GO_NEXUS_RAID_PLATFORM
@ GO_HEART_OF_MAGIC_10
@ GO_HEART_OF_MAGIC_25
@ GO_FOCUSING_IRIS_10
@ GO_EXIT_PORTAL
@ EVENT_FOCUSING_IRIS
@ NPC_MALYGOS
@ NPC_PORTAL_TRIGGER
@ NPC_ALEXSTRASZAS_GIFT
@ NPC_VORTEX_TRIGGER
@ NPC_ALEXSTRASZA_BUNNY
@ SPELL_PORTAL_OPENED
@ SPELL_IRIS_OPENED
@ SPELL_VORTEX_4
@ SPELL_SUMMOM_RED_DRAGON_BUDDY
@ DATA_HEART_OF_MAGIC_GUID
@ DATA_TRIGGER
@ DATA_MALYGOS
@ DATA_ALEXSTRASZA_BUNNY_GUID
@ DATA_FOCUSING_IRIS_GUID
@ DATA_PLATFORM
@ DATA_GIFT_BOX_BUNNY_GUID
#define EoEScriptName
BossBoundaryData const boundaries
void AddSC_instance_eye_of_eternity()
DungeonEncounterData const encounters[]
#define MAX_ENCOUNTER
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
constexpr float GetOrientation() const
Definition: Position.h:79
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
Definition: GameObject.cpp:118
void ProcessEvent(WorldObject *, uint32 eventId, WorldObject *) override