TrinityCore
Loading...
Searching...
No Matches
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
41
77
86
87#define SPELL_POWER_FEEDBACK DUNGEON_MODE<uint32>(44233, 47109)
88#define SPELL_GRAVITY_LAPSE_DAMAGE DUNGEON_MODE<uint32>(49887, 44226)
89
120
128
129// 24664 - Kael'thas Sunstrider
131{
136
138 {
140 _firstGravityLapse = true;
141 }
142
153
154 void Reset() override
155 {
156 _Reset();
157 Initialize();
159 }
160
161 void JustDied(Unit* /*killer*/) override
162 {
163 // No _JustDied() here because otherwise we would reset the events which will trigger the death sequence twice.
165 }
166
167 void EnterEvadeMode(EvadeReason /*why*/) override
168 {
173 }
174
175 void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
176 {
177 // Checking for lethal damage first so we trigger the outro phase without triggering phase two in case of oneshot attacks
178 if (damage >= me->GetHealth() && !events.IsInPhase(PHASE_OUTRO))
179 {
180 me->AttackStop();
193 }
194
195 // Phase two checks. Skip phase two if we are in the outro already
197 {
200 }
201
202 // Kael'thas may only kill himself via Quite Suicide
203 if (damage >= me->GetHealth() && attacker != me)
204 damage = me->GetHealth() - 1;
205 }
206
207 void SetData(uint32 type, uint32 /*data*/) override
208 {
209 if (type == DATA_KAELTHAS_INTRO)
210 {
211 // skip the intro if Kael'thas is engaged already
213 return;
214
215 me->SetImmuneToPC(true);
217 }
218 }
219
220 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
221 {
222 Unit* unitTarget = target->ToUnit();
223 if (!unitTarget)
224 return;
225
226 switch (spellInfo->Id)
227 {
229 {
231 uint32 gravityLapseDamageSpell = SPELL_GRAVITY_LAPSE_DAMAGE;
232 target->m_Events.AddEventAtOffset([target, gravityLapseDamageSpell]()
233 {
234 target->CastSpell(target, gravityLapseDamageSpell);
235 target->CastSpell(target, SPELL_GRAVITY_LAPSE_FLY);
236
237 }, 400ms);
239 break;
240 }
244 break;
245 default:
246 break;
247 }
248 }
249
250 void JustSummoned(Creature* summon) override
251 {
252 summons.Summon(summon);
253
254 switch (summon->GetEntry())
255 {
257 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 70.0f, true))
258 summon->GetMotionMaster()->MoveFollow(target, 0.0f, 0.0f);
259 break;
260 case NPC_FLAME_STRIKE:
261 summon->CastSpell(summon, SPELL_FLAME_STRIKE_DUMMY);
262 summon->DespawnOrUnsummon(15s);
263 break;
264 default:
265 break;
266 }
267 }
268
269 void UpdateAI(uint32 diff) override
270 {
272 return;
273
274 events.Update(diff);
275
277 return;
278
279 while (uint32 eventId = events.ExecuteEvent())
280 {
281 switch (eventId)
282 {
288 break;
292 break;
295 break;
298 me->SetImmuneToPC(false);
299 break;
300 case EVENT_FIREBALL:
302 events.Repeat(2s + 500ms);
303 break;
306 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, true))
307 DoCast(target, SPELL_FLAME_STRIKE);
308 events.Repeat(44s);
309 break;
315 events.Repeat(1min);
316 break;
317 case EVENT_PYROBLAST:
318 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, true))
319 DoCast(target, SPELL_PYROBLAST);
320 break;
321 case EVENT_PHOENIX:
324 events.Repeat(45s);
325 break;
328 _firstGravityLapse = false;
330 me->AttackStop();
333 break;
337 break;
344 break;
347 break;
349 for (uint8 i = 0; i < 3; i++)
351 break;
358 break;
361 break;
364 break;
365 case EVENT_EMOTE_ROAR:
367 break;
370 break;
371 default:
372 break;
373 }
374 }
375 }
376
377private:
380};
381
382// 24674 - Phoenix
384{
385 npc_felblood_kaelthas_phoenix(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
386 {
387 Initialize();
388 }
389
391 {
393 _isInEgg = false;
394 }
395
403
404 void JustEngagedWith(Unit* /*who*/) override { }
405
406 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
407 {
408 if (damage >= me->GetHealth())
409 {
410 if (!_isInEgg)
411 {
412 me->AttackStop();
415 me->SetUninteractible(true);
417 // DoCastSelf(SPELL_SUMMON_PHOENIX_EGG); -- We do a manual summon for now. Feel free to move it to spelleffect_dbc
418 if (Creature* egg = DoSummon(NPC_PHOENIX_EGG, me->GetPosition(), 0s))
419 {
421 {
422 kaelthas->AI()->JustSummoned(egg);
423 _eggGUID = egg->GetGUID();
424 }
425 }
426
428 _isInEgg = true;
429 }
430 damage = me->GetHealth() - 1;
431 }
432
433 }
434
435 void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override
436 {
437 // Egg has been destroyed within 15 seconds so we lose the phoenix.
439 }
440
441 void UpdateAI(uint32 diff) override
442 {
443 if (!UpdateVictim())
444 return;
445
446 _events.Update(diff);
447
449 return;
450
451 while (uint32 eventId = _events.ExecuteEvent())
452 {
453 switch (eventId)
454 {
457 break;
460 egg->DespawnOrUnsummon();
463 break;
464 case EVENT_REBIRTH:
467 break;
469 _isInEgg = false;
472 me->SetUninteractible(false);
474 break;
475 default:
476 break;
477 }
478 }
479 }
480private:
485};
486
487// 44191 - Flame Strike
489{
490 bool Validate(SpellInfo const* /*spellInfo*/) override
491 {
493 }
494
495 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
496 {
497 if (Unit* target = GetTarget())
498 target->CastSpell(target, SPELL_FLAME_STRIKE_DAMAGE);
499 }
500
505};
506
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ DONE
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_0
@ 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)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
#define SPELL_POWER_FEEDBACK
@ SAY_GRAVITY_LAPSE_2
@ SAY_ANNOUNCE_PYROBLAST
@ SAY_GRAVITY_LAPSE_1
uint32 gravityLapseTeleportSpells[]
@ SPELL_QUITE_SUICIDE
@ SPELL_FLAME_STRIKE_DAMAGE
@ SPELL_SHOCK_BARRIER
@ SPELL_EMOTE_TALK_EXCLAMATION
@ SPELL_GRAVITY_LAPSE_FRONT_RIGHT_TELEPORT
@ SPELL_GRAVITY_LAPSE_FLY
@ SPELL_SUMMON_ARCANE_SPHERE
@ 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_GRAVITY_LAPSE_CENTER_TELEPORT
@ SPELL_FLAME_STRIKE_DUMMY
void AddSC_boss_felblood_kaelthas()
#define SPELL_GRAVITY_LAPSE_DAMAGE
@ EVENT_EMOTE_TALK_EXCLAMATION
@ EVENT_TALK_NEXT_GRAVITY_LAPSE
@ EVENT_PREPARE_GRAVITY_LAPSE
@ EVENT_PREPARE_REENGAGE
@ EVENT_GRAVITY_LAPSE_BEAM_VISUAL_PERIODIC
@ EVENT_SHOCK_BARRIER
@ EVENT_SUMMON_ARCANE_SPHERE
@ EVENT_GRAVITY_LAPSE_CENTER_TELEPORT
HookList< EffectApplyHandler > AfterEffectRemove
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:169
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
void SetImmuneToPC(bool apply) override
Definition Creature.h:190
void SetReactState(ReactStates st)
Definition Creature.h:180
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:246
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:56
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:32
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
virtual bool SetBossState(uint32 id, EncounterState state)
Creature * GetCreature(uint32 type)
void MoveFollow(Unit *target, float dist, Optional< ChaseAngle > angle={}, Optional< Milliseconds > duration={}, bool ignoreTargetWalk=false, MovementSlot slot=MOTION_SLOT_ACTIVE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 GetEntry() const
Definition Object.h:89
Unit * ToUnit()
Definition Object.h:116
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void DespawnEntry(uint32 entry)
void Summon(Creature const *summon)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3253
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
void SetUninteractible(bool apply)
Definition Unit.cpp:8583
void SetEmoteState(Emote emote)
Definition Unit.h:880
uint64 GetHealth() const
Definition Unit.h:800
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
void RemoveAllAuras()
Definition Unit.cpp:4400
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition Unit.cpp:1662
bool AttackStop()
Definition Unit.cpp:5984
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
EventProcessor m_Events
Definition Object.h:561
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:92
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 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