TrinityCore
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 "CreatureAI.h"
29#include "GridNotifiersImpl.h"
30#include "InstanceScript.h"
31#include "Map.h"
32#include "onyxias_lair.h"
33#include "TemporarySummon.h"
34#include <queue>
35
37{
38 { DATA_ONYXIA, new CircleBoundary(Position(-34.3697f, -212.3296f), 100.0) }
39};
40
42{
43 { DATA_ONYXIA, {{ 1084 }} }
44};
45
47{
48public:
50
52 {
54 }
55
57 {
59 {
64
67 eruptTimer = 0;
68
71 }
72
73 //Eruption is a BFS graph problem
74 //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
75
76 void OnCreatureCreate(Creature* creature) override
77 {
78 switch (creature->GetEntry())
79 {
80 case NPC_ONYXIA:
81 onyxiaGUID = creature->GetGUID();
82 break;
83 }
84 }
85
86 void OnGameObjectCreate(GameObject* go) override
87 {
88 if ((go->GetGOInfo()->displayId == 4392 || go->GetGOInfo()->displayId == 4472) && go->GetGOInfo()->trap.spell == 17731)
89 {
90 FloorEruptionGUID[0].insert(std::make_pair(go->GetGUID(), 0));
91 return;
92 }
93
94 switch (go->GetEntry())
95 {
97 Position goPos = go->GetPosition();
99 {
100 temp->AI()->DoZoneInCombat();
102 }
103 break;
104 }
105 }
106
108 {
109 if ((go->GetGOInfo()->displayId == 4392 || go->GetGOInfo()->displayId == 4472) && go->GetGOInfo()->trap.spell == 17731)
110 {
111 FloorEruptionGUID[0].erase(go->GetGUID());
112 return;
113 }
114 }
115
116 void FloorEruption(ObjectGuid floorEruptedGUID)
117 {
118 if (GameObject* floorEruption = instance->GetGameObject(floorEruptedGUID))
119 {
120 //THIS GOB IS A TRAP - What shall i do? =(
121 //Cast it spell? Copyed Heigan method
122 floorEruption->SendCustomAnim(floorEruption->GetGoAnimProgress());
125 floorEruption->CastSpell(floorEruption, floorEruption->GetGOInfo()->trap.spell, args);
126
127 //Get all immediatly nearby floors
128 std::list<GameObject*> nearFloorList;
129 Trinity::GameObjectInRangeCheck check(floorEruption->GetPositionX(), floorEruption->GetPositionY(), floorEruption->GetPositionZ(), 15);
130 Trinity::GameObjectListSearcher<Trinity::GameObjectInRangeCheck> searcher(floorEruption, nearFloorList, check);
131 Cell::VisitGridObjects(floorEruption, searcher, SIZE_OF_GRIDS);
132 //remove all that are not present on FloorEruptionGUID[1] and update treeLen on each GUID
133 for (std::list<GameObject*>::const_iterator itr = nearFloorList.begin(); itr != nearFloorList.end(); ++itr)
134 {
135 if (((*itr)->GetGOInfo()->displayId == 4392 || (*itr)->GetGOInfo()->displayId == 4472) && (*itr)->GetGOInfo()->trap.spell == 17731)
136 {
137 ObjectGuid nearFloorGUID = (*itr)->GetGUID();
138 if (FloorEruptionGUID[1].find(nearFloorGUID) != FloorEruptionGUID[1].end() && (*FloorEruptionGUID[1].find(nearFloorGUID)).second == 0)
139 {
140 (*FloorEruptionGUID[1].find(nearFloorGUID)).second = (*FloorEruptionGUID[1].find(floorEruptedGUID)).second+1;
141 FloorEruptionGUIDQueue.push(nearFloorGUID);
142 }
143 }
144 }
145 }
146 FloorEruptionGUID[1].erase(floorEruptedGUID);
147 }
148
149 bool SetBossState(uint32 type, EncounterState state) override
150 {
151 if (!InstanceScript::SetBossState(type, state))
152 return false;
153
154 switch (type)
155 {
156 case DATA_ONYXIA:
157 if (state == IN_PROGRESS)
159 break;
160 }
161 return true;
162 }
163
164 void SetData(uint32 type, uint32 data) override
165 {
166 switch (type)
167 {
169 if (data == PHASE_BREATH) //Used to mark the liftoff phase
170 {
173 onyxiaLiftoffTimer = 10000;
174 }
175 break;
177 if (data == IN_PROGRESS)
178 {
180 }
181 else if (data == FAIL)
182 {
184 }
185 break;
186 }
187 }
188
189 void SetGuidData(uint32 type, ObjectGuid data) override
190 {
191 switch (type)
192 {
195 FloorEruptionGUIDQueue.push(data);
196 eruptTimer = 2500;
197 break;
198 }
199 }
200
201 ObjectGuid GetGuidData(uint32 data) const override
202 {
203 switch (data)
204 {
205 case NPC_ONYXIA:
206 return onyxiaGUID;
207 }
208
209 return ObjectGuid::Empty;
210 }
211
212 void Update(uint32 diff) override
213 {
215 {
217 {
219 if (manyWhelpsCounter >= 50)
221 } else onyxiaLiftoffTimer -= diff;
222 }
223
224 if (!FloorEruptionGUIDQueue.empty())
225 {
226 if (eruptTimer <= diff)
227 {
228 ObjectGuid frontGuid = FloorEruptionGUIDQueue.front();
229 std::map<ObjectGuid, uint32>::iterator itr = FloorEruptionGUID[1].find(frontGuid);
230 if (itr != FloorEruptionGUID[1].end())
231 {
232 uint32 treeHeight = itr->second;
233
234 do
235 {
236 FloorEruption(frontGuid);
238 if (FloorEruptionGUIDQueue.empty())
239 break;
240
241 frontGuid = FloorEruptionGUIDQueue.front();
242 itr = FloorEruptionGUID[1].find(frontGuid);
243 } while (itr != FloorEruptionGUID[1].end() && itr->second == treeHeight);
244 }
245
246 eruptTimer = 1000;
247 }
248 else
249 eruptTimer -= diff;
250 }
251 }
252
253 bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* /*source*/, Unit const* /*target = nullptr*/, uint32 /*miscValue1 = 0*/) override
254 {
255 switch (criteriaId)
256 {
257 case ACHIEV_CRITERIA_MANY_WHELPS_10_PLAYER: // Criteria for achievement 4403: Many Whelps! Handle It! (10 player) Hatch 50 eggs in 10s
258 case ACHIEV_CRITERIA_MANY_WHELPS_25_PLAYER: // Criteria for achievement 4406: Many Whelps! Handle It! (25 player) Hatch 50 eggs in 10s
260 case ACHIEV_CRITERIA_DEEP_BREATH_10_PLAYER: // Criteria for achievement 4404: She Deep Breaths More (10 player) Everybody evade Deep Breath
261 case ACHIEV_CRITERIA_DEEP_BREATH_25_PLAYER: // Criteria for achievement 4407: She Deep Breaths More (25 player) Everybody evade Deep Breath
263 }
264 return false;
265 }
266
267 protected:
268 std::map<ObjectGuid, uint32> FloorEruptionGUID[2];
269 std::queue<ObjectGuid> FloorEruptionGUIDQueue;
276 };
277};
278
280{
282}
uint32_t uint32
Definition: Define.h:142
#define SIZE_OF_GRIDS
Definition: GridDefines.h:40
EncounterState
@ IN_PROGRESS
@ FAIL
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: ObjectDefines.h:67
#define DataHeader
uint32 const EncounterCount
@ GO_WHELP_SPAWNER
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:202
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)
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3489
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Definition: Unit.h:627
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:2025
InstanceScript * GetInstanceScript(InstanceMap *map) const override
void AddSC_instance_onyxias_lair()
BossBoundaryData const boundaries
DungeonEncounterData const encounters[]
@ DATA_SHE_DEEP_BREATH_MORE
Definition: onyxias_lair.h:36
@ DATA_ONYXIA_PHASE
Definition: onyxias_lair.h:35
@ PHASE_BREATH
Definition: onyxias_lair.h:49
@ NPC_WHELP
Definition: onyxias_lair.h:55
@ NPC_ONYXIA
Definition: onyxias_lair.h:57
@ DATA_FLOOR_ERUPTION_GUID
Definition: onyxias_lair.h:43
@ DATA_ONYXIA
Definition: onyxias_lair.h:30
@ ACHIEV_CRITERIA_MANY_WHELPS_10_PLAYER
Definition: onyxias_lair.h:69
@ ACHIEV_CRITERIA_DEEP_BREATH_25_PLAYER
Definition: onyxias_lair.h:72
@ ACHIEV_CRITERIA_DEEP_BREATH_10_PLAYER
Definition: onyxias_lair.h:71
@ ACHIEV_CRITERIA_MANY_WHELPS_25_PLAYER
Definition: onyxias_lair.h:70
#define OnyxiaScriptName
Definition: onyxias_lair.h:23
ObjectGuid OriginalCaster
Definition: SpellDefines.h:482
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
struct GameObjectTemplate::@213::@221 trap
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
bool SetBossState(uint32 type, EncounterState state) override
bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const *, Unit const *, uint32) override