TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "GameObject.h"
20#include "InstanceScript.h"
21#include "magisters_terrace.h"
22#include "MotionMaster.h"
23#include "ObjectAccessor.h"
24#include "ScriptedCreature.h"
25#include "SpellScript.h"
26#include "SpellAuraEffects.h"
27#include "SpellInfo.h"
28#include "TemporarySummon.h"
29
31{
32 // Kael'thas Sunstrider
41 SAY_DEATH = 8
42};
43
45{
46 // Kael'thas Sunstrider
67 SPELL_QUITE_SUICIDE = 3617, // Serverside spell
68
69 // Flame Strike
72
73 // Phoenix
75 SPELL_BURN = 44197,
77 SPELL_SUMMON_PHOENIX_EGG = 44195, // Serverside spell
78 SPELL_FULL_HEAL = 17683
79};
80
82{
88};
89
90#define SPELL_GRAVITY_LAPSE_DAMAGE RAID_MODE<uint32>(49887, 44226)
91
93{
94 // Kael'thas Sunstrider
115
116 // Phoenix
122
124{
128 PHASE_OUTRO = 3
130
131// 24664 - Kael'thas Sunstrider
133{
135 {
136 Initialize();
137 }
138
140 {
142 _firstGravityLapse = true;
143 }
144
145 void JustEngagedWith(Unit* who) override
146 {
152 if (IsHeroic())
154 }
155
156 void Reset() override
157 {
158 _Reset();
159 Initialize();
161 }
162
163 void JustDied(Unit* /*killer*/) override
164 {
165 // No _JustDied() here because otherwise we would reset the events which will trigger the death sequence twice.
167 }
168
169 void EnterEvadeMode(EvadeReason /*why*/) override
170 {
175 }
176
177 void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
178 {
179 // Checking for lethal damage first so we trigger the outro phase without triggering phase two in case of oneshot attacks
180 if (damage >= me->GetHealth() && !events.IsInPhase(PHASE_OUTRO))
181 {
182 me->AttackStop();
195 }
196
197 // Phase two checks. Skip phase two if we are in the outro already
199 {
202 }
203
204 // Kael'thas may only kill himself via Quite Suicide
205 if (damage >= me->GetHealth() && attacker != me)
206 damage = me->GetHealth() - 1;
207 }
208
209 void SetData(uint32 type, uint32 /*data*/) override
210 {
211 if (type == DATA_KAELTHAS_INTRO)
212 {
213 // skip the intro if Kael'thas is engaged already
215 return;
216
217 me->SetImmuneToPC(true);
219 }
220 }
221
222 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
223 {
224 Unit* unitTarget = target->ToUnit();
225 if (!unitTarget)
226 return;
227
228 switch (spellInfo->Id)
229 {
231 {
233 uint32 gravityLapseDamageSpell = SPELL_GRAVITY_LAPSE_DAMAGE;
234 target->m_Events.AddEventAtOffset([target, gravityLapseDamageSpell]()
235 {
236 target->CastSpell(target, gravityLapseDamageSpell);
237 target->CastSpell(target, SPELL_GRAVITY_LAPSE_FLY);
238
239 }, 400ms);
241 break;
242 }
246 break;
247 default:
248 break;
249 }
250 }
251
252 void JustSummoned(Creature* summon) override
253 {
254 summons.Summon(summon);
255
256 switch (summon->GetEntry())
257 {
259 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 70.0f, true))
260 summon->GetMotionMaster()->MoveFollow(target, 0.0f, 0.0f);
261 break;
262 case NPC_FLAME_STRIKE:
263 summon->CastSpell(summon, SPELL_FLAME_STRIKE_DUMMY);
264 summon->DespawnOrUnsummon(15s);
265 break;
266 default:
267 break;
268 }
269 }
270
271 void UpdateAI(uint32 diff) override
272 {
274 return;
275
276 events.Update(diff);
277
279 return;
280
281 while (uint32 eventId = events.ExecuteEvent())
282 {
283 switch (eventId)
284 {
290 break;
294 break;
297 break;
300 me->SetImmuneToPC(false);
301 break;
302 case EVENT_FIREBALL:
304 events.Repeat(2s + 500ms);
305 break;
308 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, true))
309 DoCast(target, SPELL_FLAME_STRIKE);
310 events.Repeat(44s);
311 break;
317 events.Repeat(1min);
318 break;
319 case EVENT_PYROBLAST:
320 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, true))
321 DoCast(target, SPELL_PYROBLAST);
322 break;
323 case EVENT_PHOENIX:
326 events.Repeat(45s);
327 break;
330 _firstGravityLapse = false;
332 me->AttackStop();
335 break;
339 break;
346 break;
349 break;
351 for (uint8 i = 0; i < 3; i++)
353 break;
360 break;
363 break;
366 break;
367 case EVENT_EMOTE_ROAR:
369 break;
372 break;
373 default:
374 break;
375 }
376 }
377 }
378
379private:
382};
383
384// 24674 - Phoenix
386{
387 npc_felblood_kaelthas_phoenix(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
388 {
389 Initialize();
390 }
391
393 {
395 _isInEgg = false;
396 }
397
398 void IsSummonedBy(WorldObject* /*summoner*/) override
399 {
404 }
405
406 void JustEngagedWith(Unit* /*who*/) override { }
407
408 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
409 {
410 if (damage >= me->GetHealth())
411 {
412 if (!_isInEgg)
413 {
414 me->AttackStop();
419 // DoCastSelf(SPELL_SUMMON_PHOENIX_EGG); -- We do a manual summon for now. Feel free to move it to spelleffect_dbc
420 if (Creature* egg = DoSummon(NPC_PHOENIX_EGG, me->GetPosition(), 0s))
421 {
423 {
424 kaelthas->AI()->JustSummoned(egg);
425 _eggGUID = egg->GetGUID();
426 }
427 }
428
430 _isInEgg = true;
431 }
432 damage = me->GetHealth() - 1;
433 }
434
435 }
436
437 void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override
438 {
439 // Egg has been destroyed within 15 seconds so we lose the phoenix.
441 }
442
443 void UpdateAI(uint32 diff) override
444 {
445 if (!UpdateVictim())
446 return;
447
448 _events.Update(diff);
449
451 return;
452
453 while (uint32 eventId = _events.ExecuteEvent())
454 {
455 switch (eventId)
456 {
459 break;
462 egg->DespawnOrUnsummon();
465 break;
466 case EVENT_REBIRTH:
469 break;
471 _isInEgg = false;
476 break;
477 default:
478 break;
479 }
480 }
481
483 }
484private:
489};
490
491// 44191 - Flame Strike
493{
495
496 bool Validate(SpellInfo const* /*spellInfo*/) override
497 {
499 }
500
501 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
502 {
503 if (Unit* target = GetTarget())
504 target->CastSpell(target, SPELL_FLAME_STRIKE_DAMAGE);
505 }
506
507 void Register() override
508 {
510 }
511};
512
514{
518}
uint8_t uint8
Definition: Define.h:135
uint32_t uint32
Definition: Define.h:133
@ DONE
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1129
@ EFFECT_0
Definition: SharedDefines.h:31
@ 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:809
@ REACT_PASSIVE
Definition: UnitDefines.h:408
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:410
@ UNIT_FLAG_UNINTERACTIBLE
Definition: UnitDefines.h:160
@ UNIT_STATE_CASTING
Definition: Unit.h:235
DamageEffectType
Definition: Unit.h:352
@ SAY_POWER_FEEDBACK
@ SAY_GRAVITY_LAPSE_2
@ SAY_ANNOUNCE_PYROBLAST
@ SAY_GRAVITY_LAPSE_1
@ SAY_FLAME_STRIKE
@ SAY_SUMMON_PHOENIX
uint32 gravityLapseTeleportSpells[]
@ SPELL_QUITE_SUICIDE
@ SPELL_POWER_FEEDBACK
@ 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
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
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:808
Unit * GetTarget() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
bool _EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
Definition: CreatureAI.cpp:294
void DoZoneInCombat(Creature *creature=nullptr)
Definition: CreatureAI.cpp:73
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:48
bool UpdateVictim()
Definition: CreatureAI.cpp:240
Creature *const me
Definition: CreatureAI.h:81
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
Definition: CreatureAI.cpp:437
void SetImmuneToPC(bool apply) override
Definition: Creature.h:129
void SetReactState(ReactStates st)
Definition: Creature.h:119
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2172
void Update(uint32 time)
Definition: EventMap.h:67
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
EventId ExecuteEvent()
Definition: EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition: EventMap.h:236
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition: EventMap.cpp:52
void SetPhase(PhaseIndex phase)
Definition: EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition: EventMap.cpp:36
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, MovementSlot slot=MOTION_SLOT_ACTIVE)
static Unit * ToUnit(Object *o)
Definition: Object.h:191
uint32 GetEntry() const
Definition: Object.h:80
uint32 Id
Definition: SpellInfo.h:293
void DespawnEntry(uint32 entry)
void Summon(Creature const *summon)
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:62
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:174
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:104
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:114
Definition: Unit.h:769
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3093
MotionMaster * GetMotionMaster()
Definition: Unit.h:1667
void SetEmoteState(Emote emote)
Definition: Unit.h:965
uint32 GetHealth() const
Definition: Unit.h:911
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3780
bool HasUnitState(const uint32 f) const
Definition: Unit.h:874
void HandleEmoteCommand(Emote emoteId)
Definition: Unit.cpp:1565
void RemoveAllAuras()
Definition: Unit.cpp:4153
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:916
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:952
bool AttackStop()
Definition: Unit.cpp:5641
void RemoveUnitFlag(UnitFlags flags)
Definition: Unit.h:953
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2831
EventProcessor m_Events
Definition: Object.h:591
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:145
PrepareAuraScript(spell_felblood_kaelthas_flame_strike)
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)
void GetPosition(float &x, float &y) const
Definition: Position.h:84
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