TrinityCore
Loading...
Searching...
No Matches
instance_onyxias_lair.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/* ScriptData
19SDName: Instance_Onyxias_Lair
20SD%Complete: 100
21SDComment:
22SDCategory: Onyxia's Lair
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "AreaBoundary.h"
27#include "CellImpl.h"
28#include "GridNotifiersImpl.h"
29#include "InstanceScript.h"
30#include "onyxias_lair.h"
31#include "TemporarySummon.h"
32
34{
35 { DATA_ONYXIA, new CircleBoundary(Position(-34.3697f, -212.3296f), 100.0) }
36};
37
39{
40public:
42
44 {
46 }
47
49 {
63
64 //Eruption is a BFS graph problem
65 //One map to remember all floor, one map to keep floor that still need to erupt and one queue to know what needs to be removed
66
67 void OnCreatureCreate(Creature* creature) override
68 {
69 switch (creature->GetEntry())
70 {
71 case NPC_ONYXIA:
72 onyxiaGUID = creature->GetGUID();
73 break;
74 }
75 }
76
77 void OnGameObjectCreate(GameObject* go) override
78 {
79 if ((go->GetGOInfo()->displayId == 4392 || go->GetGOInfo()->displayId == 4472) && go->GetGOInfo()->trap.spellId == 17731)
80 {
81 FloorEruptionGUID[0].insert(std::make_pair(go->GetGUID(), 0));
82 return;
83 }
84
85 switch (go->GetEntry())
86 {
88 Position goPos = go->GetPosition();
90 {
91 temp->AI()->DoZoneInCombat();
93 }
94 break;
95 }
96 }
97
98 void OnGameObjectRemove(GameObject* go) override
99 {
100 if ((go->GetGOInfo()->displayId == 4392 || go->GetGOInfo()->displayId == 4472) && go->GetGOInfo()->trap.spellId == 17731)
101 {
102 FloorEruptionGUID[0].erase(go->GetGUID());
103 return;
104 }
105 }
106
107 void FloorEruption(ObjectGuid floorEruptedGUID)
108 {
109 if (GameObject* floorEruption = instance->GetGameObject(floorEruptedGUID))
110 {
111 //THIS GOB IS A TRAP - What shall i do? =(
112 //Cast it spell? Copyed Heigan method
113 floorEruption->SendCustomAnim(floorEruption->GetGoAnimProgress());
116 floorEruption->CastSpell(floorEruption, floorEruption->GetGOInfo()->trap.spellId, args);
117
118 //Get all immediatly nearby floors
119 std::list<GameObject*> nearFloorList;
120 Trinity::GameObjectInRangeCheck check(floorEruption->GetPositionX(), floorEruption->GetPositionY(), floorEruption->GetPositionZ(), 15);
121 Trinity::GameObjectListSearcher<Trinity::GameObjectInRangeCheck> searcher(floorEruption, nearFloorList, check);
122 Cell::VisitGridObjects(floorEruption, searcher, SIZE_OF_GRIDS);
123 //remove all that are not present on FloorEruptionGUID[1] and update treeLen on each GUID
124 for (std::list<GameObject*>::const_iterator itr = nearFloorList.begin(); itr != nearFloorList.end(); ++itr)
125 {
126 if (((*itr)->GetGOInfo()->displayId == 4392 || (*itr)->GetGOInfo()->displayId == 4472) && (*itr)->GetGOInfo()->trap.spellId == 17731)
127 {
128 ObjectGuid nearFloorGUID = (*itr)->GetGUID();
129 if (FloorEruptionGUID[1].find(nearFloorGUID) != FloorEruptionGUID[1].end() && (*FloorEruptionGUID[1].find(nearFloorGUID)).second == 0)
130 {
131 (*FloorEruptionGUID[1].find(nearFloorGUID)).second = (*FloorEruptionGUID[1].find(floorEruptedGUID)).second+1;
132 FloorEruptionGUIDQueue.push(nearFloorGUID);
133 }
134 }
135 }
136 }
137 FloorEruptionGUID[1].erase(floorEruptedGUID);
138 }
139
140 bool SetBossState(uint32 type, EncounterState state) override
141 {
142 if (!InstanceScript::SetBossState(type, state))
143 return false;
144
145 switch (type)
146 {
147 case DATA_ONYXIA:
148 if (state == IN_PROGRESS)
150 break;
151 }
152 return true;
153 }
154
155 void SetData(uint32 type, uint32 data) override
156 {
157 switch (type)
158 {
160 if (data == PHASE_BREATH) //Used to mark the liftoff phase
161 {
164 onyxiaLiftoffTimer = 10000;
165 }
166 break;
168 if (data == IN_PROGRESS)
169 {
171 }
172 else if (data == FAIL)
173 {
175 }
176 break;
177 }
178 }
179
180 void SetGuidData(uint32 type, ObjectGuid data) override
181 {
182 switch (type)
183 {
186 FloorEruptionGUIDQueue.push(data);
187 eruptTimer = 2500;
188 break;
189 }
190 }
191
192 ObjectGuid GetGuidData(uint32 data) const override
193 {
194 switch (data)
195 {
196 case NPC_ONYXIA:
197 return onyxiaGUID;
198 }
199
200 return ObjectGuid::Empty;
201 }
202
203 void Update(uint32 diff) override
204 {
206 {
208 {
210 if (manyWhelpsCounter >= 50)
212 } else onyxiaLiftoffTimer -= diff;
213 }
214
215 if (!FloorEruptionGUIDQueue.empty())
216 {
217 if (eruptTimer <= diff)
218 {
219 ObjectGuid frontGuid = FloorEruptionGUIDQueue.front();
220 std::map<ObjectGuid, uint32>::iterator itr = FloorEruptionGUID[1].find(frontGuid);
221 if (itr != FloorEruptionGUID[1].end())
222 {
223 uint32 treeHeight = itr->second;
224
225 do
226 {
227 FloorEruption(frontGuid);
229 if (FloorEruptionGUIDQueue.empty())
230 break;
231
232 frontGuid = FloorEruptionGUIDQueue.front();
233 itr = FloorEruptionGUID[1].find(frontGuid);
234 } while (itr != FloorEruptionGUID[1].end() && itr->second == treeHeight);
235 }
236
237 eruptTimer = 1000;
238 }
239 else
240 eruptTimer -= diff;
241 }
242 }
243
244 bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* /*source*/, Unit const* /*target = nullptr*/, uint32 /*miscValue1 = 0*/) override
245 {
246 switch (criteriaId)
247 {
248 case ACHIEV_CRITERIA_MANY_WHELPS_10_PLAYER: // Criteria for achievement 4403: Many Whelps! Handle It! (10 player) Hatch 50 eggs in 10s
249 case ACHIEV_CRITERIA_MANY_WHELPS_25_PLAYER: // Criteria for achievement 4406: Many Whelps! Handle It! (25 player) Hatch 50 eggs in 10s
251 case ACHIEV_CRITERIA_DEEP_BREATH_10_PLAYER: // Criteria for achievement 4404: She Deep Breaths More (10 player) Everybody evade Deep Breath
252 case ACHIEV_CRITERIA_DEEP_BREATH_25_PLAYER: // Criteria for achievement 4407: She Deep Breaths More (25 player) Everybody evade Deep Breath
254 }
255 return false;
256 }
257
258 protected:
259 std::map<ObjectGuid, uint32> FloorEruptionGUID[2];
260 std::queue<ObjectGuid> FloorEruptionGUIDQueue;
267 };
268};
269
uint32_t uint32
Definition Define.h:133
#define SIZE_OF_GRIDS
Definition GridDefines.h:38
EncounterState
@ IN_PROGRESS
@ FAIL
@ TEMPSUMMON_CORPSE_DESPAWN
#define DataHeader
uint32 const EncounterCount
@ GO_WHELP_SPAWNER
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:102
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void LoadBossBoundaries(BossBoundaryData const &data)
void SetHeaders(std::string const &dataHeaders)
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:4430
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
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1992
InstanceScript * GetInstanceScript(InstanceMap *map) const override
void AddSC_instance_onyxias_lair()
BossBoundaryData const boundaries
@ DATA_SHE_DEEP_BREATH_MORE
@ DATA_ONYXIA_PHASE
@ PHASE_BREATH
@ NPC_WHELP
@ NPC_ONYXIA
@ DATA_FLOOR_ERUPTION_GUID
@ DATA_ONYXIA
@ ACHIEV_CRITERIA_MANY_WHELPS_10_PLAYER
@ ACHIEV_CRITERIA_DEEP_BREATH_25_PLAYER
@ ACHIEV_CRITERIA_DEEP_BREATH_10_PLAYER
@ ACHIEV_CRITERIA_MANY_WHELPS_25_PLAYER
#define OnyxiaScriptName
ObjectGuid OriginalCaster
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:168
struct GameObjectTemplate::@191::@198 trap
void GetPosition(float &x, float &y) const
Definition Position.h:84
bool SetBossState(uint32 type, EncounterState state) override
bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const *, Unit const *, uint32) override