/
instance_blackwing_lair.cpp
299 lines (270 loc) · 11 KB
/
instance_blackwing_lair.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "blackwing_lair.h"
#include "GameObject.h"
#include "InstanceScript.h"
#include "Map.h"
#include "MotionMaster.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "TemporarySummon.h"
DoorData const doorData[] =
{
{ GO_PORTCULLIS_RAZORGORE, DATA_RAZORGORE_THE_UNTAMED, DOOR_TYPE_PASSAGE },
{ GO_PORTCULLIS_VAELASTRASZ, DATA_VAELASTRAZ_THE_CORRUPT, DOOR_TYPE_PASSAGE },
{ GO_PORTCULLIS_BROODLORD, DATA_BROODLORD_LASHLAYER, DOOR_TYPE_PASSAGE },
{ GO_PORTCULLIS_THREEDRAGONS, DATA_FIREMAW, DOOR_TYPE_PASSAGE },
{ GO_PORTCULLIS_THREEDRAGONS, DATA_EBONROC, DOOR_TYPE_PASSAGE },
{ GO_PORTCULLIS_THREEDRAGONS, DATA_FLAMEGOR, DOOR_TYPE_PASSAGE },
{ GO_PORTCULLIS_CHROMAGGUS, DATA_CHROMAGGUS, DOOR_TYPE_PASSAGE },
{ GO_PORTCULLIS_NEFARIAN, DATA_NEFARIAN, DOOR_TYPE_ROOM },
{ 0, 0, DOOR_TYPE_ROOM } // END
};
ObjectData const creatureData[] =
{
{ NPC_RAZORGORE, DATA_RAZORGORE_THE_UNTAMED },
{ NPC_VAELASTRAZ, DATA_VAELASTRAZ_THE_CORRUPT },
{ NPC_BROODLORD, DATA_BROODLORD_LASHLAYER },
{ NPC_FIREMAW, DATA_FIREMAW },
{ NPC_EBONROC, DATA_EBONROC },
{ NPC_FLAMEGOR, DATA_FLAMEGOR },
{ NPC_CHROMAGGUS, DATA_CHROMAGGUS },
{ NPC_NEFARIAN, DATA_NEFARIAN },
{ NPC_VICTOR_NEFARIUS, DATA_LORD_VICTOR_NEFARIUS },
{ 0, 0 } // END
};
ObjectData const gameObjectData[] =
{
{ GO_CHROMAGGUS_DOOR, DATA_GO_CHROMAGGUS_DOOR },
{ 0, 0 } //END
};
Position const SummonPosition[8] =
{
{-7661.207520f, -1043.268188f, 407.199554f, 6.280452f},
{-7644.145020f, -1065.628052f, 407.204956f, 0.501492f},
{-7624.260742f, -1095.196899f, 407.205017f, 0.544694f},
{-7608.501953f, -1116.077271f, 407.199921f, 0.816443f},
{-7531.841797f, -1063.765381f, 407.199615f, 2.874187f},
{-7547.319336f, -1040.971924f, 407.205078f, 3.789175f},
{-7568.547852f, -1013.112488f, 407.204926f, 3.773467f},
{-7584.175781f, -989.6691289f, 407.199585f, 4.527447f},
};
uint32 const Entry[5] = {12422, 12458, 12416, 12420, 12459};
class instance_blackwing_lair : public InstanceMapScript
{
public:
instance_blackwing_lair() : InstanceMapScript(BWLScriptName, 469) { }
struct instance_blackwing_lair_InstanceMapScript : public InstanceScript
{
instance_blackwing_lair_InstanceMapScript(Map* map) : InstanceScript(map)
{
SetHeaders(DataHeader);
SetBossNumber(EncounterCount);
LoadDoorData(doorData);
LoadObjectData(creatureData, gameObjectData);
// Razorgore
EggCount = 0;
EggEvent = 0;
}
void OnCreatureCreate(Creature* creature) override
{
InstanceScript::OnCreatureCreate(creature);
switch (creature->GetEntry())
{
case NPC_BLACKWING_DRAGON:
case NPC_BLACKWING_TASKMASTER:
case NPC_BLACKWING_LEGIONAIRE:
case NPC_BLACKWING_WARLOCK:
if (Creature* razor = GetCreature(DATA_RAZORGORE_THE_UNTAMED))
razor->AI()->JustSummoned(creature);
break;
default:
break;
}
}
void OnGameObjectCreate(GameObject* go) override
{
InstanceScript::OnGameObjectCreate(go);
switch(go->GetEntry())
{
case GO_BLACK_DRAGON_EGG:
if (GetBossState(DATA_FIREMAW) == DONE)
go->SetPhaseMask(2, true);
else
EggList.push_back(go->GetGUID());
break;
default:
break;
}
}
void OnGameObjectRemove(GameObject* go) override
{
InstanceScript::OnGameObjectRemove(go);
if (go->GetEntry() == GO_BLACK_DRAGON_EGG)
EggList.remove(go->GetGUID());
}
bool CheckRequiredBosses(uint32 bossId, Player const* player /*= nullptr*/) const override
{
if (_SkipCheckRequiredBosses(player))
return true;
switch (bossId)
{
case DATA_BROODLORD_LASHLAYER:
if (GetBossState(DATA_VAELASTRAZ_THE_CORRUPT) != DONE)
return false;
break;
case DATA_FIREMAW:
case DATA_EBONROC:
case DATA_FLAMEGOR:
if (GetBossState(DATA_BROODLORD_LASHLAYER) != DONE)
return false;
break;
case DATA_CHROMAGGUS:
if (GetBossState(DATA_FIREMAW) != DONE
|| GetBossState(DATA_EBONROC) != DONE
|| GetBossState(DATA_FLAMEGOR) != DONE)
return false;
break;
default:
break;
}
return true;
}
bool SetBossState(uint32 type, EncounterState state) override
{
if (!InstanceScript::SetBossState(type, state))
return false;
switch (type)
{
case DATA_RAZORGORE_THE_UNTAMED:
if (state == DONE)
{
for (GuidList::const_iterator itr = EggList.begin(); itr != EggList.end(); ++itr)
if (GameObject* egg = instance->GetGameObject(*itr))
egg->SetPhaseMask(2, true);
}
SetData(DATA_EGG_EVENT, NOT_STARTED);
break;
case DATA_NEFARIAN:
switch (state)
{
case NOT_STARTED:
if (Creature* nefarian = GetCreature(DATA_NEFARIAN))
nefarian->DespawnOrUnsummon();
break;
case FAIL:
_events.ScheduleEvent(EVENT_RESPAWN_NEFARIUS, 15 * IN_MILLISECONDS * MINUTE);
SetBossState(DATA_NEFARIAN, NOT_STARTED);
break;
default:
break;
}
break;
}
return true;
}
void SetData(uint32 type, uint32 data) override
{
if (type == DATA_EGG_EVENT)
{
switch (data)
{
case IN_PROGRESS:
_events.ScheduleEvent(EVENT_RAZOR_SPAWN, 45s);
EggEvent = data;
EggCount = 0;
break;
case NOT_STARTED:
_events.CancelEvent(EVENT_RAZOR_SPAWN);
EggEvent = data;
EggCount = 0;
break;
case SPECIAL:
if (++EggCount == 15)
{
if (Creature* razor = GetCreature(DATA_RAZORGORE_THE_UNTAMED))
{
SetData(DATA_EGG_EVENT, DONE);
razor->RemoveAurasDueToSpell(42013); // MindControl
DoRemoveAurasDueToSpellOnPlayers(42013, true, true);
}
_events.ScheduleEvent(EVENT_RAZOR_PHASE_TWO, 1s);
_events.CancelEvent(EVENT_RAZOR_SPAWN);
}
if (EggEvent == NOT_STARTED)
SetData(DATA_EGG_EVENT, IN_PROGRESS);
break;
}
}
}
void OnUnitDeath(Unit* unit) override
{
//! HACK, needed because of buggy CreatureAI after charm
if (unit->GetEntry() == NPC_RAZORGORE && GetBossState(DATA_RAZORGORE_THE_UNTAMED) != DONE)
SetBossState(DATA_RAZORGORE_THE_UNTAMED, DONE);
}
void Update(uint32 diff) override
{
if (_events.Empty())
return;
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_RAZOR_SPAWN:
for (uint8 i = urand(2, 5); i > 0; --i)
if (Creature* summon = instance->SummonCreature(Entry[urand(0, 4)], SummonPosition[urand(0, 7)]))
summon->AI()->DoZoneInCombat();
_events.ScheduleEvent(EVENT_RAZOR_SPAWN, 12s, 17s);
break;
case EVENT_RAZOR_PHASE_TWO:
_events.CancelEvent(EVENT_RAZOR_SPAWN);
if (Creature* razor = GetCreature(DATA_RAZORGORE_THE_UNTAMED))
razor->AI()->DoAction(ACTION_PHASE_TWO);
break;
case EVENT_RESPAWN_NEFARIUS:
if (Creature* nefarius = GetCreature(DATA_LORD_VICTOR_NEFARIUS))
{
nefarius->SetPhaseMask(1, true);
nefarius->setActive(true);
nefarius->SetFarVisible(true);
nefarius->Respawn();
nefarius->GetMotionMaster()->MoveTargetedHome();
}
break;
}
}
}
protected:
// Misc
EventMap _events;
// Razorgore
uint8 EggCount;
uint32 EggEvent;
GuidList EggList;
};
InstanceScript* GetInstanceScript(InstanceMap* map) const override
{
return new instance_blackwing_lair_InstanceMapScript(map);
}
};
void AddSC_instance_blackwing_lair()
{
new instance_blackwing_lair();
}