Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_onyxias_lair.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/* ScriptData
7SDName: Instance_Onyxias_Lair
8SD%Complete: 100
9SDComment:
10SDCategory: Onyxia's Lair
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "InstanceScript.h"
15#include "Cell.h"
16#include "CellImpl.h"
17#include "GridNotifiers.h"
18#include "GridNotifiersImpl.h"
19#include "onyxias_lair.h"
20#include "TemporarySummon.h"
21
23{
24public:
25 instance_onyxias_lair() : InstanceMapScript("instance_onyxias_lair", 249) { }
26
31
33 {
35
36 //Eruption is a BFS graph problem
37 //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
38
51
53 {
54 switch (creature->GetEntry())
55 {
56 case NPC_ONYXIA:
57 onyxiaGUID = creature->GetGUID();
58 break;
59 }
60 }
61
63 {
64 if ((go->GetGOInfo()->displayId == 4392 || go->GetGOInfo()->displayId == 4472) && go->GetGOInfo()->trap.spellId == 17731)
65 {
66 FloorEruptionGUID[0].insert(std::make_pair(go->GetGUID(), 0));
67 return;
68 }
69
70 switch (go->GetEntry())
71 {
73 Position goPos;
74 go->GetPosition(&goPos);
76 {
77 temp->SetInCombatWithZone();
79 }
80 break;
81 }
82 }
83
85 {
86 if ((go->GetGOInfo()->displayId == 4392 || go->GetGOInfo()->displayId == 4472) && go->GetGOInfo()->trap.spellId == 17731)
87 {
88 FloorEruptionGUID[0].erase(go->GetGUID());
89 return;
90 }
91 }
92
93 void FloorEruption(uint64 floorEruptedGUID)
94 {
95 if (GameObject* floorEruption = instance->GetGameObject(floorEruptedGUID))
96 {
97 //THIS GOB IS A TRAP - What shall i do? =(
98 //Cast it spell? Copyed Heigan method
99 floorEruption->SendCustomAnim(floorEruption->GetGoAnimProgress());
100 floorEruption->CastSpell(NULL, DifficultyID(instance->GetSpawnMode()) == DIFFICULTY_10MAN_NORMAL ? 17731 : 69294); //pFloorEruption->GetGOInfo()->trap.spellId
101
102 //Get all immediatly nearby floors
103 std::list<GameObject*> nearFloorList;
104 Skyfire::GameObjectInRangeCheck check(floorEruption->GetPositionX(), floorEruption->GetPositionY(), floorEruption->GetPositionZ(), 15);
105 Skyfire::GameObjectListSearcher<Skyfire::GameObjectInRangeCheck> searcher(floorEruption, nearFloorList, check);
106 floorEruption->VisitNearbyGridObject(999, searcher);
107 //remove all that are not present on FloorEruptionGUID[1] and update treeLen on each GUID
108 for (std::list<GameObject*>::const_iterator itr = nearFloorList.begin(); itr != nearFloorList.end(); ++itr)
109 {
110 if (((*itr)->GetGOInfo()->displayId == 4392 || (*itr)->GetGOInfo()->displayId == 4472) && (*itr)->GetGOInfo()->trap.spellId == 17731)
111 {
112 uint64 nearFloorGUID = (*itr)->GetGUID();
113 if (FloorEruptionGUID[1].find(nearFloorGUID) != FloorEruptionGUID[1].end() && (*FloorEruptionGUID[1].find(nearFloorGUID)).second == 0)
114 {
115 (*FloorEruptionGUID[1].find(nearFloorGUID)).second = (*FloorEruptionGUID[1].find(floorEruptedGUID)).second+1;
116 FloorEruptionGUIDQueue.push(nearFloorGUID);
117 }
118 }
119 }
120 }
121 FloorEruptionGUID[1].erase(floorEruptedGUID);
122 }
123
125 {
126 if (!InstanceScript::SetBossState(type, state))
127 return false;
128
129 switch (type)
130 {
131 case DATA_ONYXIA:
132 if (state == IN_PROGRESS)
134 break;
135 }
136 return true;
137 }
138
139 void SetData(uint32 type, uint32 data) OVERRIDE
140 {
141 switch (type)
142 {
144 if (data == PHASE_BREATH) //Used to mark the liftoff phase
145 {
148 onyxiaLiftoffTimer = 10000;
149 }
150 break;
152 if (data == IN_PROGRESS)
153 {
155 }
156 else if (data == FAIL)
157 {
159 }
160 break;
161 }
162 }
163
165 {
166 switch (type)
167 {
170 FloorEruptionGUIDQueue.push(data);
171 eruptTimer = 2500;
172 break;
173 }
174 }
175
177 {
178 switch (data)
179 {
180 case NPC_ONYXIA:
181 return onyxiaGUID;
182 }
183
184 return 0;
185 }
186
188 {
190 {
192 {
194 if (manyWhelpsCounter >= 50)
196 } else onyxiaLiftoffTimer -= diff;
197 }
198
199 if (!FloorEruptionGUIDQueue.empty())
200 {
201 if (eruptTimer <= diff)
202 {
203 uint32 treeHeight = 0;
204 do
205 {
206 treeHeight = (*FloorEruptionGUID[1].find(FloorEruptionGUIDQueue.front())).second;
209 } while (!FloorEruptionGUIDQueue.empty() && (*FloorEruptionGUID[1].find(FloorEruptionGUIDQueue.front())).second == treeHeight);
210 eruptTimer = 1000;
211 }
212 else
213 eruptTimer -= diff;
214 }
215 }
216
217 bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* /*source*/, Unit const* /*target = NULL*/, uint32 /*miscValue1 = 0*/) OVERRIDE
218 {
219 switch (criteriaId)
220 {
221 case ACHIEV_CRITERIA_MANY_WHELPS_10_PLAYER: // Criteria for achievement 4403: Many Whelps! Handle It! (10 player) Hatch 50 eggs in 10s
222 case ACHIEV_CRITERIA_MANY_WHELPS_25_PLAYER: // Criteria for achievement 4406: Many Whelps! Handle It! (25 player) Hatch 50 eggs in 10s
224 case ACHIEV_CRITERIA_DEEP_BREATH_10_PLAYER: // Criteria for achievement 4404: She Deep Breaths More (10 player) Everybody evade Deep Breath
225 case ACHIEV_CRITERIA_DEEP_BREATH_25_PLAYER: // Criteria for achievement 4407: She Deep Breaths More (25 player) Everybody evade Deep Breath
227 }
228 return false;
229 }
230
231 std::string GetSaveData() OVERRIDE
232 {
234
235 std::ostringstream saveStream;
236 saveStream << "O L " << GetBossSaveData();
237
239 return saveStream.str();
240 }
241
242 void Load(const char* strIn) OVERRIDE
243 {
244 if (!strIn)
245 {
247 return;
248 }
249
250 OUT_LOAD_INST_DATA(strIn);
251
252 char dataHead1, dataHead2;
253
254 std::istringstream loadStream(strIn);
255 loadStream >> dataHead1 >> dataHead2;
256
257 if (dataHead1 == 'O' && dataHead2 == 'L')
258 {
259 for (uint8 i = 0; i < EncounterCount; ++i)
260 {
261 uint32 tmpState;
262 loadStream >> tmpState;
263 if (tmpState == IN_PROGRESS || tmpState > SPECIAL)
264 tmpState = NOT_STARTED;
265
266 SetBossState(i, EncounterState(tmpState));
267 }
268 }
269 else
271
273 }
274
275 protected:
276 std::map<uint64, uint32> FloorEruptionGUID[2];
277 std::queue<uint64> FloorEruptionGUIDQueue;
284 };
285};
286
DifficultyID
Definition DBCEnums.h:330
@ DIFFICULTY_10MAN_NORMAL
Definition DBCEnums.h:334
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
#define OUT_LOAD_INST_DATA_FAIL
EncounterState
@ IN_PROGRESS
@ FAIL
@ SPECIAL
@ NOT_STARTED
#define OUT_SAVE_INST_DATA_COMPLETE
#define OUT_LOAD_INST_DATA_COMPLETE
#define OUT_SAVE_INST_DATA
#define OUT_LOAD_INST_DATA(a)
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:72
uint32 const EncounterCount
@ GO_WHELP_SPAWNER
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
std::string GetBossSaveData()
EncounterState GetBossState(uint32 id) const
Definition Map.h:238
Definition Unit.h:1367
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition Object.cpp:2703
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
void AddSC_instance_onyxias_lair()
@ PHASE_BREATH
@ DATA_FLOOR_ERUPTION_GUID
@ DATA_SHE_DEEP_BREATH_MORE
@ DATA_ONYXIA_PHASE
@ NPC_WHELP
@ NPC_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
@ DATA_ONYXIA
void GetPosition(float &x, float &y) const
Definition Object.h:333
bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const *, Unit const *, uint32) OVERRIDE
bool SetBossState(uint32 type, EncounterState state) OVERRIDE