-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathbosses_emerald_dragons.cpp
More file actions
554 lines (448 loc) · 16.2 KB
/
bosses_emerald_dragons.cpp
File metadata and controls
554 lines (448 loc) · 16.2 KB
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/* This file is part of the ScriptDev2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: bosses_emerald_dragons
SD%Complete: 95
SDComment: Missing correct behaviour of used trigger NPCs, some spell issues, summon player NYI
SDCategory: Emerald Dragon Bosses
EndScriptData */
/* ContentData
boss_emerald_dragon -- Superclass for the four dragons
boss_emeriss
boss_lethon
npc_spirit_shade
boss_taerar
boss_ysondre
EndContentData */
#include "precompiled.h"
/*######
## boss_emerald_dragon -- Superclass for the four dragons
######*/
enum
{
SPELL_MARK_OF_NATURE_PLAYER = 25040,
SPELL_MARK_OF_NATURE_AURA = 25041,
SPELL_SEEPING_FOG_R = 24813, // Summons 15224 'Dream Fog'
SPELL_SEEPING_FOG_L = 24814,
SPELL_DREAM_FOG = 24777, // Used by summoned Adds
SPELL_NOXIOUS_BREATH = 24818,
SPELL_TAILSWEEP = 15847,
SPELL_SUMMON_PLAYER = 24776, // NYI
NPC_DREAM_FOG = 15224,
};
struct boss_emerald_dragonAI : public ScriptedAI
{
boss_emerald_dragonAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); }
uint32 m_uiEventCounter;
uint32 m_uiSeepingFogTimer;
uint32 m_uiNoxiousBreathTimer;
uint32 m_uiTailsweepTimer;
void Reset() override
{
m_uiEventCounter = 1;
m_uiSeepingFogTimer = urand(15000, 20000);
m_uiNoxiousBreathTimer = 8000;
m_uiTailsweepTimer = 4000;
}
void EnterCombat(Unit* pEnemy) override
{
DoCastSpellIfCan(m_creature, SPELL_MARK_OF_NATURE_AURA, CAST_TRIGGERED);
ScriptedAI::EnterCombat(pEnemy);
}
void KilledUnit(Unit* pVictim) override
{
// Mark killed players with Mark of Nature
if (pVictim->GetTypeId() == TYPEID_PLAYER)
pVictim->CastSpell(pVictim, SPELL_MARK_OF_NATURE_PLAYER, true, NULL, NULL, m_creature->GetObjectGuid());
}
void JustSummoned(Creature* pSummoned) override
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
pSummoned->AI()->AttackStart(pTarget);
if (pSummoned->GetEntry() == NPC_DREAM_FOG)
pSummoned->CastSpell(pSummoned, SPELL_DREAM_FOG, true, NULL, NULL, m_creature->GetObjectGuid());
}
// Return true, if succeeded
virtual bool DoSpecialDragonAbility() = 0;
// Return true to handle shared timers and MeleeAttack
virtual bool UpdateDragonAI(const uint32 /*uiDiff*/) { return true; }
void UpdateAI(const uint32 uiDiff) override
{
// Return since we have no target
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
// Trigger special ability function at 75, 50 and 25% health
if (m_creature->GetHealthPercent() < 100.0f - m_uiEventCounter * 25.0f && DoSpecialDragonAbility())
++m_uiEventCounter;
// Call dragon specific virtual function
if (!UpdateDragonAI(uiDiff))
return;
if (m_uiSeepingFogTimer < uiDiff)
{
DoCastSpellIfCan(m_creature, SPELL_SEEPING_FOG_R, CAST_TRIGGERED);
DoCastSpellIfCan(m_creature, SPELL_SEEPING_FOG_L, CAST_TRIGGERED);
m_uiSeepingFogTimer = urand(120000, 150000); // Rather Guesswork, but one Fog has 2min duration, hence a bit longer
}
else
m_uiSeepingFogTimer -= uiDiff;
if (m_uiNoxiousBreathTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_NOXIOUS_BREATH) == CAST_OK)
m_uiNoxiousBreathTimer = urand(14000, 20000);
}
else
m_uiNoxiousBreathTimer -= uiDiff;
if (m_uiTailsweepTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_TAILSWEEP) == CAST_OK)
m_uiTailsweepTimer = 2000;
}
else
m_uiTailsweepTimer -= uiDiff;
DoMeleeAttackIfReady();
}
};
/*######
## boss_emeriss
######*/
enum
{
SAY_EMERISS_AGGRO = -1000401,
SAY_CAST_CORRUPTION = -1000402,
SPELL_VOLATILE_INFECTION = 24928,
SPELL_CORRUPTION_OF_EARTH = 24910,
SPELL_PUTRID_MUSHROOM = 24904, // Summons a mushroom on killing a player
};
struct boss_emerissAI : public boss_emerald_dragonAI
{
boss_emerissAI(Creature* pCreature) : boss_emerald_dragonAI(pCreature) { Reset(); }
uint32 m_uiVolatileInfectionTimer;
void Reset() override
{
boss_emerald_dragonAI::Reset();
m_uiVolatileInfectionTimer = 12000;
}
void Aggro(Unit* /*pWho*/) override
{
DoScriptText(SAY_EMERISS_AGGRO, m_creature);
}
void KilledUnit(Unit* pVictim) override
{
// summon a mushroom on the spot the player dies
if (pVictim->GetTypeId() == TYPEID_PLAYER)
pVictim->CastSpell(pVictim, SPELL_PUTRID_MUSHROOM, true, NULL, NULL, m_creature->GetObjectGuid());
boss_emerald_dragonAI::KilledUnit(pVictim);
}
// Corruption of Earth at 75%, 50% and 25%
bool DoSpecialDragonAbility()
{
if (DoCastSpellIfCan(m_creature, SPELL_CORRUPTION_OF_EARTH) == CAST_OK)
{
DoScriptText(SAY_CAST_CORRUPTION, m_creature);
// Successfull cast
return true;
}
return false;
}
bool UpdateDragonAI(const uint32 uiDiff)
{
// Volatile Infection Timer
if (m_uiVolatileInfectionTimer < uiDiff)
{
Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
if (pTarget && DoCastSpellIfCan(pTarget, SPELL_VOLATILE_INFECTION) == CAST_OK)
m_uiVolatileInfectionTimer = urand(7000, 12000);
}
else
m_uiVolatileInfectionTimer -= uiDiff;
return true;
}
};
CreatureAI* GetAI_boss_emeriss(Creature* pCreature)
{
return new boss_emerissAI(pCreature);
}
/*######
## boss_lethon
######*/
enum
{
SAY_LETHON_AGGRO = -1000666,
SAY_DRAW_SPIRIT = -1000667,
SPELL_SHADOW_BOLT_WIRL = 24834, // Periodic aura
SPELL_DRAW_SPIRIT = 24811,
SPELL_SUMMON_SPIRIT_SHADE = 24810, // Summon spell was removed, was SPELL_EFFECT_SUMMON_DEMON
NPC_LETHON = 14888,
NPC_SPIRIT_SHADE = 15261, // Add summoned by Lethon
SPELL_DARK_OFFERING = 24804,
SPELL_SPIRIT_SHAPE_VISUAL = 24809,
};
struct boss_lethonAI : public boss_emerald_dragonAI
{
boss_lethonAI(Creature* pCreature) : boss_emerald_dragonAI(pCreature) {}
void Aggro(Unit* /*pWho*/) override
{
DoScriptText(SAY_LETHON_AGGRO, m_creature);
// Shadow bolt wirl is a periodic aura which triggers a set of shadowbolts every 2 secs; may need some core tunning
DoCastSpellIfCan(m_creature, SPELL_SHADOW_BOLT_WIRL, CAST_TRIGGERED);
}
// Summon a spirit which moves toward the boss and heals him for each player hit by the spell; used at 75%, 50% and 25%
bool DoSpecialDragonAbility()
{
if (DoCastSpellIfCan(m_creature, SPELL_DRAW_SPIRIT) == CAST_OK)
{
DoScriptText(SAY_DRAW_SPIRIT, m_creature);
return true;
}
return false;
}
// Need this code here, as SPELL_DRAW_SPIRIT has no Script- or Dummyeffect
void SpellHitTarget(Unit* pTarget, const SpellEntry* pSpell) override
{
// Summon a shade for each player hit
if (pTarget->GetTypeId() == TYPEID_PLAYER && pSpell->Id == SPELL_DRAW_SPIRIT)
{
// Summon this way, to be able to cast the shade visual spell with player as original caster
// This might not be supported currently by core, but this spell's visual should be dependend on the player
// Also possible that this was no problem due to the special way these NPCs had been summoned in classic times
if (Creature* pSummoned = pTarget->SummonCreature(NPC_SPIRIT_SHADE, 0.0f, 0.0f, 0.0f, pTarget->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0))
pSummoned->CastSpell(pSummoned, SPELL_SPIRIT_SHAPE_VISUAL, true, NULL, NULL, pTarget->GetObjectGuid());
}
}
void JustSummoned(Creature* pSummoned) override
{
// Move the shade to lethon
if (pSummoned->GetEntry() == NPC_SPIRIT_SHADE)
pSummoned->GetMotionMaster()->MoveFollow(m_creature, 0.0f, 0.0f);
else
boss_emerald_dragonAI::JustSummoned(pSummoned);
}
};
struct npc_spirit_shadeAI : public ScriptedAI
{
npc_spirit_shadeAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); }
bool m_bHasHealed;
void Reset() override
{
m_bHasHealed = false;
}
void MoveInLineOfSight(Unit* pWho) override
{
if (!m_bHasHealed && pWho->GetEntry() == NPC_LETHON && pWho->IsWithinDistInMap(m_creature, 3.0f))
{
if (DoCastSpellIfCan(pWho, SPELL_DARK_OFFERING) == CAST_OK)
{
m_bHasHealed = true;
m_creature->ForcedDespawn(1000);
}
}
}
void AttackStart(Unit* /*pWho*/) override { }
void UpdateAI(const uint32 /*uiDiff*/) override { }
};
CreatureAI* GetAI_boss_lethon(Creature* pCreature)
{
return new boss_lethonAI(pCreature);
}
CreatureAI* GetAI_npc_spirit_shade(Creature* pCreature)
{
return new npc_spirit_shadeAI(pCreature);
}
/*######
## boss_taerar
######*/
enum
{
SAY_TAERAR_AGGRO = -1000399,
SAY_SUMMONSHADE = -1000400,
SPELL_ARCANE_BLAST = 24857,
SPELL_BELLOWING_ROAR = 22686,
SPELL_SUMMON_SHADE_1 = 24841,
SPELL_SUMMON_SHADE_2 = 24842,
SPELL_SUMMON_SHADE_3 = 24843,
SPELL_SELF_STUN = 24883, // Stunns the main boss until the shades are dead or timer expires
NPC_SHADE_OF_TAERAR = 15302,
SPELL_POSIONCLOUD = 24840,
SPELL_POSIONBREATH = 20667
};
struct boss_taerarAI : public boss_emerald_dragonAI
{
boss_taerarAI(Creature* pCreature) : boss_emerald_dragonAI(pCreature) { Reset(); }
uint32 m_uiArcaneBlastTimer;
uint32 m_uiBellowingRoarTimer;
uint32 m_uiShadesTimeoutTimer;
uint8 m_uiShadesDead;
void Reset() override
{
boss_emerald_dragonAI::Reset();
m_uiArcaneBlastTimer = 12000;
m_uiBellowingRoarTimer = 30000;
m_uiShadesTimeoutTimer = 0; // The time that Taerar is banished
m_uiShadesDead = 0;
// Remove Unselectable if needed
if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
}
void Aggro(Unit* /*pWho*/) override
{
DoScriptText(SAY_TAERAR_AGGRO, m_creature);
}
// Summon 3 Shades at 75%, 50% and 25% and Banish Self
bool DoSpecialDragonAbility()
{
if (DoCastSpellIfCan(m_creature, SPELL_SELF_STUN) == CAST_OK)
{
// Summon the shades at boss position
DoCastSpellIfCan(m_creature, SPELL_SUMMON_SHADE_1, CAST_TRIGGERED);
DoCastSpellIfCan(m_creature, SPELL_SUMMON_SHADE_2, CAST_TRIGGERED);
DoCastSpellIfCan(m_creature, SPELL_SUMMON_SHADE_3, CAST_TRIGGERED);
// Make boss not selectable when banished
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
DoScriptText(SAY_SUMMONSHADE, m_creature);
m_uiShadesTimeoutTimer = 60000;
return true;
}
return false;
}
void SummonedCreatureJustDied(Creature* pSummoned) override
{
if (pSummoned->GetEntry() == NPC_SHADE_OF_TAERAR)
{
++m_uiShadesDead;
// If all shades are dead then unbanish the boss
if (m_uiShadesDead == 3)
DoUnbanishBoss();
}
}
void DoUnbanishBoss()
{
m_creature->RemoveAurasDueToSpell(SPELL_SELF_STUN);
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
m_uiShadesTimeoutTimer = 0;
m_uiShadesDead = 0;
}
bool UpdateDragonAI(const uint32 uiDiff)
{
// Timer to unbanish the boss
if (m_uiShadesTimeoutTimer)
{
if (m_uiShadesTimeoutTimer <= uiDiff)
DoUnbanishBoss();
else
m_uiShadesTimeoutTimer -= uiDiff;
// Prevent further spells or timer handling while banished
return false;
}
// Arcane Blast Timer
if (m_uiArcaneBlastTimer < uiDiff)
{
Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
if (pTarget && DoCastSpellIfCan(pTarget, SPELL_ARCANE_BLAST) == CAST_OK)
m_uiArcaneBlastTimer = urand(7000, 12000);
}
else
m_uiArcaneBlastTimer -= uiDiff;
// Bellowing Roar Timer
if (m_uiBellowingRoarTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_BELLOWING_ROAR) == CAST_OK)
m_uiBellowingRoarTimer = urand(20000, 30000);
}
else
m_uiBellowingRoarTimer -= uiDiff;
return true;
}
};
CreatureAI* GetAI_boss_taerar(Creature* pCreature)
{
return new boss_taerarAI(pCreature);
}
/*######
## boss_ysondre
######*/
enum
{
SAY_YSONDRE_AGGRO = -1000360,
SAY_SUMMON_DRUIDS = -1000361,
SPELL_LIGHTNING_WAVE = 24819,
SPELL_SUMMON_DRUIDS = 24795,
// druid spells
SPELL_MOONFIRE = 21669
};
// Ysondre script
struct boss_ysondreAI : public boss_emerald_dragonAI
{
boss_ysondreAI(Creature* pCreature) : boss_emerald_dragonAI(pCreature) { Reset(); }
uint32 m_uiLightningWaveTimer;
void Reset() override
{
boss_emerald_dragonAI::Reset();
m_uiLightningWaveTimer = 12000;
}
void Aggro(Unit* /*pWho*/) override
{
DoScriptText(SAY_YSONDRE_AGGRO, m_creature);
}
// Summon Druids - TODO FIXME (spell not understood)
bool DoSpecialDragonAbility()
{
DoScriptText(SAY_SUMMON_DRUIDS, m_creature);
for (int i = 0; i < 10; ++i)
DoCastSpellIfCan(m_creature, SPELL_SUMMON_DRUIDS, CAST_TRIGGERED);
return true;
}
bool UpdateDragonAI(const uint32 uiDiff)
{
// Lightning Wave Timer
if (m_uiLightningWaveTimer < uiDiff)
{
Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
if (pTarget && DoCastSpellIfCan(pTarget, SPELL_LIGHTNING_WAVE) == CAST_OK)
m_uiLightningWaveTimer = urand(7000, 12000);
}
else
m_uiLightningWaveTimer -= uiDiff;
return true;
}
};
CreatureAI* GetAI_boss_ysondre(Creature* pCreature)
{
return new boss_ysondreAI(pCreature);
}
void AddSC_bosses_emerald_dragons()
{
Script* pNewScript;
pNewScript = new Script;
pNewScript->Name = "boss_emeriss";
pNewScript->GetAI = &GetAI_boss_emeriss;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "boss_lethon";
pNewScript->GetAI = &GetAI_boss_lethon;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "npc_spirit_shade";
pNewScript->GetAI = &GetAI_npc_spirit_shade;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "boss_taerar";
pNewScript->GetAI = &GetAI_boss_taerar;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "boss_ysondre";
pNewScript->GetAI = &GetAI_boss_ysondre;
pNewScript->RegisterSelf();
}