TrinityCore
boss_felblood_kaelthas.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 "InstanceScript.h"
20#include "magisters_terrace.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "ScriptedCreature.h"
24#include "SpellAuraEffects.h"
25#include "SpellScript.h"
26#include "TemporarySummon.h"
27
28enum Says
29{
30 // Kael'thas Sunstrider
39 SAY_DEATH = 8
40};
41
43{
44 // Kael'thas Sunstrider
64 SPELL_QUITE_SUICIDE = 3617, // Serverside spell
65
66 // Flame Strike
69
70 // Phoenix
72 SPELL_BURN = 44197,
74 SPELL_SUMMON_PHOENIX_EGG = 44195, // Serverside spell
75 SPELL_FULL_HEAL = 17683
76};
77
79{
85};
86
87#define SPELL_POWER_FEEDBACK DUNGEON_MODE<uint32>(44233, 47109)
88#define SPELL_GRAVITY_LAPSE_DAMAGE DUNGEON_MODE<uint32>(49887, 44226)
89
91{
92 // Kael'thas Sunstrider
113
114 // Phoenix
120
122{
126 PHASE_OUTRO = 3
128
130{
132 {
133 Initialize();
134 }
135
137 {
139 _firstGravityLapse = true;
140 }
141
142 void JustEngagedWith(Unit* who) override
143 {
149 if (IsHeroic())
151 }
152
153 void Reset() override
154 {
155 _Reset();
156 Initialize();
158 }
159
160 void JustDied(Unit* /*killer*/) override
161 {
162 // No _JustDied() here because otherwise we would reset the events which will trigger the death sequence twice.
164 }
165
166 void EnterEvadeMode(EvadeReason /*why*/) override
167 {
172 }
173
174 void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
175 {
176 // Checking for lethal damage first so we trigger the outro phase without triggering phase two in case of oneshot attacks
177 if (damage >= me->GetHealth() && !events.IsInPhase(PHASE_OUTRO))
178 {
179 me->AttackStop();
192 }
193
194 // Phase two checks. Skip phase two if we are in the outro already
196 {
199 }
200
201 // Kael'thas may only kill himself via Quite Suicide
202 if (damage >= me->GetHealth() && attacker != me)
203 damage = me->GetHealth() - 1;
204 }
205
206 void SetData(uint32 type, uint32 /*data*/) override
207 {
208 if (type == DATA_KAELTHAS_INTRO)
209 {
210 // skip the intro if Kael'thas is engaged already
212 return;
213
214 me->SetImmuneToPC(true);
216 }
217 }
218
219 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
220 {
221 Unit* unitTarget = target->ToUnit();
222 if (!unitTarget)
223 return;
224
225 switch (spellInfo->Id)
226 {
228 {
230 uint32 gravityLapseDamageSpell = SPELL_GRAVITY_LAPSE_DAMAGE;
231 target->m_Events.AddEventAtOffset([target, gravityLapseDamageSpell]()
232 {
233 target->CastSpell(target, gravityLapseDamageSpell);
234 target->CastSpell(target, SPELL_GRAVITY_LAPSE_FLY);
235
236 }, 400ms);
238 break;
239 }
243 break;
244 default:
245 break;
246 }
247 }
248
249 void JustSummoned(Creature* summon) override
250 {
251 summons.Summon(summon);
252
253 switch (summon->GetEntry())
254 {
256 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 70.0f, true))
257 summon->GetMotionMaster()->MoveFollow(target, 0.0f, 0.0f);
258 break;
259 case NPC_FLAME_STRIKE:
260 summon->CastSpell(summon, SPELL_FLAME_STRIKE_DUMMY);
261 summon->DespawnOrUnsummon(15s);
262 break;
263 default:
264 break;
265 }
266 }
267
268 void UpdateAI(uint32 diff) override
269 {
271 return;
272
273 events.Update(diff);
274
276 return;
277
278 while (uint32 eventId = events.ExecuteEvent())
279 {
280 switch (eventId)
281 {
287 break;
291 break;
294 break;
297 me->SetImmuneToPC(false);
298 break;
299 case EVENT_FIREBALL:
301 events.Repeat(2s + 500ms);
302 break;
305 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, true))
306 DoCast(target, SPELL_FLAME_STRIKE);
307 events.Repeat(44s);
308 break;
314 events.Repeat(1min);
315 break;
316 case EVENT_PYROBLAST:
317 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, true))
318 DoCast(target, SPELL_PYROBLAST);
319 break;
320 case EVENT_PHOENIX:
323 events.Repeat(45s);
324 break;
327 _firstGravityLapse = false;
329 me->AttackStop();
332 break;
336 break;
343 break;
346 break;
348 for (uint8 i = 0; i < 3; i++)
350 break;
357 break;
360 break;
363 break;
364 case EVENT_EMOTE_ROAR:
366 break;
369 break;
370 default:
371 break;
372 }
373 }
374 }
375
376private:
379};
380
382{
383 npc_felblood_kaelthas_phoenix(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
384 {
385 Initialize();
386 }
387
389 {
391 _isInEgg = false;
392 }
393
394 void IsSummonedBy(WorldObject* /*summoner*/) override
395 {
400 }
401
402 void JustEngagedWith(Unit* /*who*/) override { }
403
404 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
405 {
406 if (damage >= me->GetHealth())
407 {
408 if (!_isInEgg)
409 {
410 me->AttackStop();
413 me->SetUninteractible(true);
415 // DoCastSelf(SPELL_SUMMON_PHOENIX_EGG); -- We do a manual summon for now. Feel free to move it to spelleffect_dbc
416 if (Creature* egg = DoSummon(NPC_PHOENIX_EGG, me->GetPosition(), 0s))
417 {
419 {
420 kaelthas->AI()->JustSummoned(egg);
421 _eggGUID = egg->GetGUID();
422 }
423 }
424
426 _isInEgg = true;
427 }
428 damage = me->GetHealth() - 1;
429 }
430
431 }
432
433 void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override
434 {
435 // Egg has been destroyed within 15 seconds so we lose the phoenix.
437 }
438
439 void UpdateAI(uint32 diff) override
440 {
441 if (!UpdateVictim())
442 return;
443
444 _events.Update(diff);
445
447 return;
448
449 while (uint32 eventId = _events.ExecuteEvent())
450 {
451 switch (eventId)
452 {
455 break;
458 egg->DespawnOrUnsummon();
461 break;
462 case EVENT_REBIRTH:
465 break;
467 _isInEgg = false;
470 me->SetUninteractible(false);
472 break;
473 default:
474 break;
475 }
476 }
477 }
478private:
483};
484
485// 44191 - Flame Strike
487{
488 bool Validate(SpellInfo const* /*spellInfo*/) override
489 {
491 }
492
493 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
494 {
495 if (Unit* target = GetTarget())
496 target->CastSpell(target, SPELL_FLAME_STRIKE_DAMAGE);
497 }
498
499 void Register() override
500 {
502 }
503};
504
506{
510}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ DONE
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_0
Definition: SharedDefines.h:30
@ EMOTE_ONESHOT_LAUGH_NO_SHEATHE
@ EMOTE_STATE_TALK
@ EMOTE_ONESHOT_NONE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SAY_POWER_FEEDBACK
@ SAY_GRAVITY_LAPSE_2
@ SAY_ANNOUNCE_PYROBLAST
@ SAY_GRAVITY_LAPSE_1
@ SAY_FLAME_STRIKE
@ SAY_SUMMON_PHOENIX
#define SPELL_POWER_FEEDBACK
@ SPELL_QUITE_SUICIDE
@ SPELL_FLAME_STRIKE_DAMAGE
@ SPELL_EMOTE_ROAR
@ SPELL_SHOCK_BARRIER
@ SPELL_EMOTE_TALK_EXCLAMATION
@ SPELL_GRAVITY_LAPSE_FRONT_RIGHT_TELEPORT
@ SPELL_GRAVITY_LAPSE_FLY
@ SPELL_EMOTE_POINT
@ SPELL_SUMMON_ARCANE_SPHERE
@ SPELL_CLEAR_FLIGHT
@ SPELL_GRAVITY_LAPSE_BEAM_VISUAL_PERIODIC
@ SPELL_GRAVITY_LAPSE_FRONT_TELEPORT
@ SPELL_GRAVITY_LAPSE_RIGHT_TELEPORT
@ SPELL_GRAVITY_LAPSE_FRONT_LEFT_TELEPORT
@ SPELL_GRAVITY_LAPSE_LEFT_TELEPORT
@ SPELL_GRAVITY_LAPSE_INITIAL
@ SPELL_SUMMON_PHOENIX_EGG
@ SPELL_FLAME_STRIKE
@ SPELL_EMBER_BLAST
@ SPELL_GRAVITY_LAPSE_CENTER_TELEPORT
@ SPELL_FLAME_STRIKE_DUMMY
uint32 gravityLapseTeleportSpells[]
void AddSC_boss_felblood_kaelthas()
#define SPELL_GRAVITY_LAPSE_DAMAGE
@ EVENT_EMOTE_TALK_EXCLAMATION
@ EVENT_TALK_INTRO_2
@ EVENT_HATCH_FROM_EGG
@ EVENT_GRAVITY_LAPSE
@ EVENT_LAUGH_EMOTE
@ EVENT_TALK_INTRO_1
@ EVENT_TALK_NEXT_GRAVITY_LAPSE
@ EVENT_ATTACK_PLAYERS
@ EVENT_PREPARE_GRAVITY_LAPSE
@ EVENT_PREPARE_REENGAGE
@ EVENT_POWER_FEEDBACK
@ EVENT_QUITE_SUICIDE
@ EVENT_GRAVITY_LAPSE_BEAM_VISUAL_PERIODIC
@ EVENT_FLAME_STRIKE
@ EVENT_SHOCK_BARRIER
@ EVENT_SUMMON_ARCANE_SPHERE
@ EVENT_FINISH_INTRO
@ EVENT_GRAVITY_LAPSE_CENTER_TELEPORT
Says
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
Unit * GetTarget() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat()
Definition: CreatureAI.h:161
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:299
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
Definition: CreatureAI.cpp:464
void SetImmuneToPC(bool apply) override
Definition: Creature.h:170
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:52
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
virtual bool SetBossState(uint32 id, EncounterState state)
Creature * GetCreature(uint32 type)
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
static Unit * ToUnit(Object *o)
Definition: Object.h:225
uint32 GetEntry() const
Definition: Object.h:161
uint32 const Id
Definition: SpellInfo.h:325
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
void DespawnEntry(uint32 entry)
void Summon(Creature const *summon)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
void SetEmoteState(Emote emote)
Definition: Unit.h:852
uint64 GetHealth() const
Definition: Unit.h:776
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
void RemoveAllAuras()
Definition: Unit.cpp:4242
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
bool AttackStop()
Definition: Unit.cpp:5781
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
EventProcessor m_Events
Definition: Object.h:777
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
@ NPC_PHOENIX_EGG
@ NPC_ARCANE_SPHERE
@ NPC_FLAME_STRIKE
#define RegisterMagistersTerraceCreatureAI(ai_name)
@ DATA_KAELTHAS_INTRO
@ DATA_KAELTHAS_SUNSTRIDER
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
bool IsHeroic() const
void JustSummoned(Creature *summon) override
void JustEngagedWith(Unit *who) override
void SetData(uint32 type, uint32) override
void DamageTaken(Unit *attacker, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
void EnterEvadeMode(EvadeReason) override
boss_felblood_kaelthas(Creature *creature)
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
npc_felblood_kaelthas_phoenix(Creature *creature)
void IsSummonedBy(WorldObject *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void SummonedCreatureDies(Creature *, Unit *) override