TrinityCore
Loading...
Searching...
No Matches
instance_blackwing_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#include "ScriptMgr.h"
19#include "blackwing_lair.h"
20#include "Containers.h"
21#include "GameObject.h"
22#include "InstanceScript.h"
23#include "Map.h"
24#include "MotionMaster.h"
25#include "Player.h"
26#include "ScriptedCreature.h"
27#include "TemporarySummon.h"
28
40
53
58
59static constexpr DungeonEncounterData encounters[] =
60{
61 { DATA_RAZORGORE_THE_UNTAMED, {{ 610 }} },
62 { DATA_VAELASTRAZ_THE_CORRUPT, {{ 611 }} },
63 { DATA_BROODLORD_LASHLAYER, {{ 612 }} },
64 { DATA_FIREMAW, {{ 613 }} },
65 { DATA_EBONROC, {{ 614 }} },
66 { DATA_FLAMEGOR, {{ 615 }} },
67 { DATA_CHROMAGGUS, {{ 616 }} },
68 { DATA_NEFARIAN, {{ 617 }} }
69};
70
71static constexpr Position SummonPosition[8] =
72{
73 { -7661.207520f, -1043.268188f, 407.199554f, 6.280452f },
74 { -7644.145020f, -1065.628052f, 407.204956f, 0.501492f },
75 { -7624.260742f, -1095.196899f, 407.205017f, 0.544694f },
76 { -7608.501953f, -1116.077271f, 407.199921f, 0.816443f },
77 { -7531.841797f, -1063.765381f, 407.199615f, 2.874187f },
78 { -7547.319336f, -1040.971924f, 407.205078f, 3.789175f },
79 { -7568.547852f, -1013.112488f, 407.204926f, 3.773467f },
80 { -7584.175781f, -989.6691289f, 407.199585f, 4.527447f },
81};
82
83static constexpr uint32 Entry[5] = {12422, 12458, 12416, 12420, 12459};
84
86{
87public:
89
91 {
104
105 void OnCreatureCreate(Creature* creature) override
106 {
108
109 switch (creature->GetEntry())
110 {
116 if (CreatureAI* razorAI = razor->AI())
117 razorAI->JustSummoned(creature);
118 break;
119 default:
120 break;
121 }
122 }
123
125 {
127 return 0;
128 return entry;
129 }
130
132 {
134
135 switch(go->GetEntry())
136 {
138 _eggList.push_back(go->GetGUID());
139 break;
141 _drakonicBonesList.push_back(go->GetGUID());
142 break;
143 default:
144 break;
145 }
146 }
147
149 {
151
152 if (go->GetEntry() == GO_BLACK_DRAGON_EGG)
153 _eggList.remove(go->GetGUID());
154 }
155
156 bool CheckRequiredBosses(uint32 bossId, Player const* player /*= nullptr*/) const override
157 {
158 if (_SkipCheckRequiredBosses(player))
159 return true;
160
161 switch (bossId)
162 {
165 return false;
166 break;
167 case DATA_FIREMAW:
168 case DATA_EBONROC:
169 case DATA_FLAMEGOR:
171 return false;
172 break;
173 case DATA_CHROMAGGUS:
177 return false;
178 break;
179 default:
180 break;
181 }
182
183 return true;
184 }
185
186 bool SetBossState(uint32 type, EncounterState state) override
187 {
188 if (!InstanceScript::SetBossState(type, state))
189 return false;
190
191 switch (type)
192 {
194 if (state == DONE)
195 {
196 for (GuidList::const_iterator itr = _eggList.begin(); itr != _eggList.end(); ++itr)
197 if (GameObject* egg = instance->GetGameObject(*itr))
198 egg->SetLootState(GO_JUST_DEACTIVATED);
199 }
201 break;
202 case DATA_NEFARIAN:
203 switch (state)
204 {
205 case NOT_STARTED:
206 if (Creature* nefarian = GetCreature(DATA_NEFARIAN))
207 nefarian->DespawnOrUnsummon();
208 break;
209 case FAIL:
212 break;
213 default:
214 break;
215 }
216 break;
217 }
218 return true;
219 }
220
221 void SetData(uint32 type, uint32 data) override
222 {
223 if (type == DATA_EGG_EVENT)
224 {
225 switch (data)
226 {
227 case IN_PROGRESS:
229 _eggEvent = data;
230 _eggCount = 0;
231 break;
232 case NOT_STARTED:
234 _eggEvent = data;
235 _eggCount = 0;
236 break;
237 case SPECIAL:
238 if (++_eggCount == 15)
239 {
241 {
243 razor->RemoveAurasDueToSpell(42013); // MindControl
244 DoRemoveAurasDueToSpellOnPlayers(42013, true, true);
245 }
248 }
249 if (_eggEvent == NOT_STARTED)
251 break;
252 }
253 }
254 else if (type == DATA_DRAKONID_BONES)
255 {
256 for (ObjectGuid const& guid : _drakonicBonesList)
257 if (GameObject* go = instance->GetGameObject(guid))
258 go->DespawnOrUnsummon();
259 _drakonicBonesList.clear();
260 }
261 }
262
269
270 void Update(uint32 diff) override
271 {
272 if (_events.Empty())
273 return;
274
275 _events.Update(diff);
276
277 while (uint32 eventId = _events.ExecuteEvent())
278 {
279 switch (eventId)
280 {
282 for (uint8 i = urand(2, 5); i > 0; --i)
284 summon->AI()->DoZoneInCombat();
286 break;
290 razor->AI()->DoAction(ACTION_PHASE_TWO);
291 break;
294 {
295 nefarius->setActive(true);
296 nefarius->SetFarVisible(true);
297 nefarius->Respawn();
298 nefarius->GetMotionMaster()->MoveTargetedHome();
299 }
300 break;
301 }
302 }
303 }
304
305 protected:
306 // Misc
308
309 // Razorgore
313
314 // Nefarian
316 };
317
319 {
321 }
322};
323
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ GO_JUST_DEACTIVATED
Definition GameObject.h:165
EncounterState
@ IN_PROGRESS
@ FAIL
@ DONE
@ SPECIAL
@ NOT_STARTED
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:433
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:43
#define DataHeader
uint32 const EncounterCount
@ NPC_NEFARIAN
@ EVENT_RAZOR_PHASE_TWO
@ EVENT_RAZOR_SPAWN
@ EVENT_RESPAWN_NEFARIUS
@ DATA_DRAKONID_BONES
@ DATA_EGG_EVENT
@ ACTION_PHASE_TWO
@ GO_PORTCULLIS_CHROMAGGUS
@ GO_PORTCULLIS_BROODLORD
@ GO_PORTCULLIS_NEFARIAN
@ GO_CHROMAGGUS_DOOR
@ GO_BLACK_DRAGON_EGG
@ GO_PORTCULLIS_VAELASTRASZ
@ GO_PORTCULLIS_THREEDRAGONS
@ GO_DRAKONID_BONES
@ GO_PORTCULLIS_RAZORGORE
#define BWLScriptName
@ DATA_VAELASTRAZ_THE_CORRUPT
@ DATA_FLAMEGOR
@ DATA_LORD_VICTOR_NEFARIUS
@ DATA_CHROMAGGUS
@ DATA_NEFARIAN
@ DATA_GO_CHROMAGGUS_DOOR
@ DATA_EBONROC
@ DATA_BROODLORD_LASHLAYER
@ DATA_FIREMAW
@ DATA_RAZORGORE_THE_UNTAMED
@ NPC_BROODLORD
@ NPC_VICTOR_NEFARIUS
@ NPC_BLACKWING_DRAGON
@ NPC_CHROMAGGUS
@ NPC_EBONROC
@ NPC_BLACKWING_TASKMASTER
@ NPC_FIREMAW
@ NPC_RAZORGORE
@ NPC_BLACKWING_LEGIONAIRE
@ NPC_BLACKWING_WARLOCK
@ NPC_VAELASTRAZ
@ NPC_FLAMEGOR
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void Update(uint32 time)
Definition EventMap.h:77
bool Empty() const
Definition EventMap.h:105
EventId ExecuteEvent()
Definition EventMap.cpp:77
void CancelEvent(EventId eventId)
Definition EventMap.cpp:156
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
Creature * GetCreature(uint32 type)
virtual void OnGameObjectRemove(GameObject *go) override
void LoadObjectData(std::span< ObjectData const > creatureData, std::span< ObjectData const > gameObjectData)
InstanceMap * instance
void SetHeaders(std::string_view dataHeaders)
void LoadDungeonEncounterData(std::span< DungeonEncounterData const > encounters)
EncounterState GetBossState(uint32 id) const
virtual void OnGameObjectCreate(GameObject *go) override
void LoadDoorData(std::span< DoorData const > data)
bool _SkipCheckRequiredBosses(Player const *player=nullptr) const
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition Object.cpp:1191
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3588
uint64 LowType
Definition ObjectGuid.h:321
uint32 GetEntry() const
Definition Object.h:89
Definition Unit.h:647
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
static constexpr Position SummonPosition[8]
static constexpr uint32 Entry[5]
static constexpr DoorData doorData[]
void AddSC_instance_blackwing_lair()
static constexpr ObjectData gameObjectData[]
static constexpr DungeonEncounterData encounters[]
auto SelectRandomContainerElement(C const &container) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
Definition Containers.h:110
bool CheckRequiredBosses(uint32 bossId, Player const *player) const override
uint32 GetGameObjectEntry(ObjectGuid::LowType, uint32 entry) override