/
boss_anzu.cpp
281 lines (235 loc) · 7.5 KB
/
boss_anzu.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
/*
* Copyright (C) 2008-2014 Hellground <http://hellground.net/>
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "precompiled.h"
#include "def_sethekk_halls.h"
#define SPELL_SPELL_BOMB 40303
#define SPELL_CYCLONE_OF_FEATHERS 40321
#define SPELL_PARALYZING_SCREECH 40184
#define SPELL_BANISH 42354 // probably completly wrong spell
#define SPELL_PROTECTION_OF_THE_HAWK 40237
#define SPELL_SPITE_OF_THE_EAGLE 40240
#define SPELL_SPEED_OF_THE_FALCON 40241
#define NPC_HAWK_SPIRIT 23134
#define NPC_EAGLE_SPIRIT 23136
#define NPC_FALCON_SPIRIT 23135
#define NPC_BROOD_OF_ANZU 23132
#define GO_RAVENS_CLAW 185554
uint32 AnzuSpirits[] = {NPC_HAWK_SPIRIT, NPC_EAGLE_SPIRIT, NPC_FALCON_SPIRIT};
float AnzuSpiritLoc[][3] = {
{ -113, 293, 27 },
{ -77, 315, 27 },
{ -62, 288, 27 }
};
struct boss_anzuAI : public ScriptedAI
{
boss_anzuAI(Creature* c) : ScriptedAI(c), summons(c)
{
pInstance = c->GetInstanceData();
}
SummonList summons;
ScriptedInstance* pInstance;
bool Banished;
uint32 Banish_Timer;
uint32 SpellBomb_Timer;
uint32 CycloneOfFeathers_Timer;
uint32 ParalyzingScreech_Timer;
uint8 BanishedTimes;
uint8 BroodCount;
void Reset()
{
ClearCastQueue();
summons.DespawnAll();
Banished = false;
Banish_Timer = 0;
SpellBomb_Timer = 22000;
CycloneOfFeathers_Timer = 5000;
ParalyzingScreech_Timer = 14000;
BanishedTimes = 2;
if(pInstance)
pInstance->SetData(DATA_ANZUEVENT, NOT_STARTED);
}
void IsSummonedBy(Unit *summoner)
{
GameObject* go = FindGameObject(GO_RAVENS_CLAW, 20, me);
if(go)
{
go->Delete();
}
}
void JustSummoned(Creature *summon)
{
if(summon->GetEntry() == NPC_BROOD_OF_ANZU)
{
summon->AI()->AttackStart(me->getVictim());
BroodCount++;
}
summons.Summon(summon);
}
void SummonedCreatureDespawn(Creature *summon)
{
if(summon->GetEntry() == NPC_BROOD_OF_ANZU)
BroodCount--;
summons.Despawn(summon);
}
void SummonSpirits()
{
for(uint8 i = 0; i < 3; i++)
me->SummonCreature(AnzuSpirits[i], AnzuSpiritLoc[i][0], AnzuSpiritLoc[i][1], AnzuSpiritLoc[i][2], 0, TEMPSUMMON_MANUAL_DESPAWN, 0);
}
void SummonBrood()
{
for(uint8 i = 0; i < 5; i++)
DoSummon(NPC_BROOD_OF_ANZU, me, 5, 0, TEMPSUMMON_CORPSE_DESPAWN);
}
void EnterCombat(Unit *who)
{
if(pInstance)
pInstance->SetData(DATA_ANZUEVENT, IN_PROGRESS);
SummonSpirits();
}
void JustDied(Unit* Killer)
{
if (pInstance)
pInstance->SetData(DATA_ANZUEVENT, DONE);
summons.DespawnAll();
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
if(Banished)
{
if(BroodCount == 0 || Banish_Timer < diff)
{
Banished = false;
me->RemoveAurasDueToSpell(SPELL_BANISH);
} else
Banish_Timer -= diff;
} else {
if(ParalyzingScreech_Timer < diff)
{
AddSpellToCast(me, SPELL_PARALYZING_SCREECH);
ParalyzingScreech_Timer = 26000;
} else
ParalyzingScreech_Timer -= diff;
if(SpellBomb_Timer < diff)
{
if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
AddSpellToCast(target, SPELL_SPELL_BOMB);
SpellBomb_Timer = 30000;
} else
SpellBomb_Timer -= diff;
if(CycloneOfFeathers_Timer < diff)
{
if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1, 45.0f, true))
AddSpellToCast(target, SPELL_CYCLONE_OF_FEATHERS);
CycloneOfFeathers_Timer = 21000;
} else
CycloneOfFeathers_Timer -= diff;
if(HealthBelowPct(33*BanishedTimes))
{
BanishedTimes--;
Banished = true;
Banish_Timer = 45000;
ForceSpellCast(me, SPELL_BANISH, INTERRUPT_AND_CAST_INSTANTLY, true);
SummonBrood();
}
}
CastNextSpellIfAnyAndReady();
if(!Banished)
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_boss_anzu(Creature *_Creature)
{
return new boss_anzuAI (_Creature);
}
struct npc_anzu_spiritAI : public Scripted_NoMovementAI
{
npc_anzu_spiritAI(Creature* c, uint32 spell) : Scripted_NoMovementAI(c)
{
Spell = spell;
}
uint32 Spell;
uint32 Timer;
void Reset() {
Timer = 5000;
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_PL_SPELL_TARGET);
}
bool isDruidHotSpell(const SpellEntry *spellProto)
{
return spellProto->SpellFamilyName == SPELLFAMILY_DRUID && (spellProto->SpellFamilyFlags & 0x1000000050LL);
}
void OnAuraApply(Aura *aur, Unit *caster, bool stackApply)
{
if(isDruidHotSpell(aur->GetSpellProto()))
{
DoCast(me, Spell);
Timer = 5000;
}
}
void UpdateAI(const uint32 diff)
{
if(Timer < diff)
{
const Unit::AuraList& auras = me->GetAurasByType(SPELL_AURA_PERIODIC_HEAL);
for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
{
if(isDruidHotSpell((*i)->GetSpellProto()))
{
DoCast(me, Spell);
break;
}
}
Timer = 5000;
} else
Timer -= diff;
}
};
CreatureAI* GetAI_npc_eagle_spirit(Creature *_Creature)
{
return new npc_anzu_spiritAI (_Creature, SPELL_SPITE_OF_THE_EAGLE);
}
CreatureAI* GetAI_npc_hawk_spirit(Creature *_Creature)
{
return new npc_anzu_spiritAI (_Creature, SPELL_PROTECTION_OF_THE_HAWK);
}
CreatureAI* GetAI_npc_falcon_spirit(Creature *_Creature)
{
return new npc_anzu_spiritAI (_Creature, SPELL_SPEED_OF_THE_FALCON);
}
void AddSC_boss_anzu()
{
Script *newscript;
newscript = new Script;
newscript->Name="boss_anzu";
newscript->GetAI = &GetAI_boss_anzu;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name="npc_eagle_spirit";
newscript->GetAI = &GetAI_npc_eagle_spirit;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name="npc_falcon_spirit";
newscript->GetAI = &GetAI_npc_falcon_spirit;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name="npc_hawk_spirit";
newscript->GetAI = &GetAI_npc_hawk_spirit;
newscript->RegisterSelf();
}