TrinityCore
Loading...
Searching...
No Matches
boss_the_candle_king.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 "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "Creature.h"
21#include "GridNotifiersImpl.h"
22#include "InstanceScript.h"
23#include "Map.h"
24#include "ObjectAccessor.h"
25#include "ScriptMgr.h"
26#include "ScriptedCreature.h"
27#include "SpellAuras.h"
28#include "SpellHistory.h"
29#include "SpellMgr.h"
30#include "SpellScript.h"
31#include "darkflame_cleft.h"
32
57
67
75
77{
79 NPC_WAX_CHUNK = 209791,
80};
81
82// 208745 - The Candle King
84{
86
96
108
110 {
111 std::list<Creature*> waxStatues;
113 GetCreatureListWithEntryInGrid(waxStatues, me, NPC_WAX_CHUNK, 200.0f);
114
115 for (Creature* waxStatue : waxStatues)
116 waxStatue->DespawnOrUnsummon();
117 }
118
119 void KilledUnit(Unit* victim) override
120 {
121 if (!victim->IsPlayer())
122 return;
123
124 Talk(SAY_KILL);
125 }
126
127 void OnSpellStart(SpellInfo const* spellInfo) override
128 {
129 if (spellInfo->Id == SPELL_EERIE_MOLDS_SELECTOR)
131 }
132
133 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
134 {
135 if (!target->IsPlayer())
136 return;
137
138 if (spellInfo->Id == SPELL_DARKFLAME_PICKAXE_SELECTOR)
139 Talk(SAY_PICKAXE_WARNING, target);
140 }
141
157
159 {
160 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, GetDifficulty());
161 if (!spellInfo)
162 return 0ms;
163
164 return me->GetSpellHistory()->GetRemainingCooldown(spellInfo);
165 }
166
168 {
169 Milliseconds cd = GetCooldownOfSpell(spellId);
170 if (cd == 0ms)
171 {
172 DoCastSelf(spellId);
173 return true;
174 }
175
176 events.Repeat(cd);
177 return false;
178 }
179
180 void UpdateAI(uint32 diff) override
181 {
182 if (!UpdateVictim())
183 return;
184
185 events.Update(diff);
186
188 return;
189
190 while (uint32 eventId = events.ExecuteEvent())
191 {
192 switch (eventId)
193 {
195 {
197 events.Repeat(IsMythic() ? 23100ms : 31500ms);
198 break;
199 }
201 {
203 events.Repeat(IsMythic() ? 10900ms : 20600ms);
204 break;
205 }
207 {
209 events.Repeat(IsMythic() ? 23100ms : 17s);
210 break;
211 }
213 {
215 events.Repeat(IsMythic() ? 24300ms : 17s);
216 break;
217 }
218 default:
219 break;
220 }
221 }
222 }
223};
224
225// 420677 - Eerie Molds
243
244// 420659 - Eerie Molds
266
267// 420696 - Throw Darkflame
288
289// 421250 - Throw Darkflame
291{
292 bool Validate(SpellInfo const* /*spellInfo*/) override
293 {
295 }
296
297 void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) const
298 {
299 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
300 return;
301
302 if (Unit* caster = GetCaster())
305 .TriggeringAura = aurEff
306 });
307 }
308
313};
314
315// 422079 - Cursed Wax
317{
318 bool Validate(SpellInfo const* /*spellInfo*/) override
319 {
321 }
322
323 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
324 {
325 Unit* target = GetHitUnit();
328 .TriggeringSpell = GetSpell()
329 });
330 }
331
336};
337
338// 421274 - Darkflame Pickaxe
364
366{
367public:
368 explicit DarkflamePickaxeDamageEvent(Unit* caster, ObjectGuid const& targetGUID, ObjectGuid const& originalCastId) : _caster(caster), _targetGUID(targetGUID), _originalCastId(originalCastId) { }
369
370 bool Execute(uint64 /*time*/, uint32 /*diff*/) override
371 {
373 {
376 .OriginalCastId = _originalCastId
377 });
378 }
379 return true;
380 }
381
382private:
386};
387
388// 421277 - Darkflame Pickaxe
390{
391 bool Validate(SpellInfo const* /*spellInfo*/) override
392 {
394 }
395
397 {
398 target = nullptr;
399 }
400
401 void FilterTargets(std::list<WorldObject*>& targets)
402 {
403 static constexpr uint8 MAX_TARGETS = 1;
404
405 if (targets.size() <= MAX_TARGETS)
406 return;
407
408 targets.remove_if([](WorldObject* target) -> bool
409 {
410 Unit* unit = target->ToUnit();
411 if (!unit)
412 return true;
413
414 return (!unit->IsPlayer() && unit->GetEntry() != NPC_WAX_STATUE) || !unit->HasAura(SPELL_MOLTEN_WAX_AT);
415 });
416
417 auto closestTargetItr = std::ranges::min_element(targets, std::ranges::less(), [caster = GetCaster()](WorldObject const* obj)
418 {
419 return caster->GetExactDist2dSq(obj->GetPosition());
420 });
421
422 if (closestTargetItr == targets.end())
423 return;
424
425 WorldObject* closestTarget = *closestTargetItr;
426 targets.clear();
427 targets.push_back(closestTarget);
428 }
429
445
452};
453
454// 421648 - Cursed Wax
455// Id - 29999
457{
459
460 void OnUnitEnter(Unit* unit) override
461 {
462 if (!unit->IsPlayer())
463 return;
464
465 Unit* caster = at->GetCaster();
466 if (!caster)
467 return;
468
471 }
472};
473
474// 420691 - Molten Wax and 420963 - Molten Wax
475// Ids: 29904, 29906
477{
479
480 void OnUnitEnter(Unit* unit) override
481 {
482 if (!unit->IsPlayer())
483 return;
484
486 }
487
488 void OnUnitExit(Unit* unit, AreaTriggerExitReason /*reason*/) override
489 {
491 }
492};
493
494// Id - XXXX (change on merge)
496{
498
499 void OnUnitEnter(Unit* unit) override
500 {
501 if (!unit->IsPlayer())
502 return;
503
506 }
507
508 void OnUnitExit(Unit* unit, AreaTriggerExitReason /*reason*/) override
509 {
511 }
512};
513
AreaTriggerExitReason
Definition AreaTrigger.h:69
uint8_t uint8
Definition Define.h:156
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ IN_PROGRESS
@ FAIL
@ DONE
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
@ EFFECT_0
@ TARGET_UNIT_TARGET_ENEMY
@ TARGET_UNIT_RECT_CASTER
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_APPLY_AURA
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_EXPIRE
@ SPELL_AURA_DUMMY
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will not check if a current cast is in progress.
@ TRIGGERED_DONT_REPORT_CAST_ERROR
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
#define sSpellMgr
Definition SpellMgr.h:812
#define SpellObjectTargetSelectFn(F, I, N)
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ EVENT_EERIE_MOLDS
@ EVENT_THROW_DARKFLAME
@ EVENT_PARANOID_MIND
@ EVENT_DARKFLAME_PICKAXE
@ SAY_PICKAXE_WARNING
@ SAY_EERIE_MOLDS
void AddSC_boss_the_candle_king()
@ SPELL_THROW_DARKFLAME_MARKER
@ SPELL_DARKFLAME_PICKAXE_DAMAGE
@ SPELL_MOLTEN_WAX_AT
@ SPELL_EERIE_MOLDS_SUMMON
@ SPELL_DARKLIGHT_DEBUFF
@ SPELL_CURSED_WAX_VISUAL
@ SPELL_PARANOID_MIND
@ SPELL_CURSED_WAX_DUMMY
@ SPELL_THROW_DARKFLAME_MISSILE
@ SPELL_MOLTEN_WAX_DAMAGE
@ SPELL_DARKFLAME_PICKAXE_VISUAL
@ SPELL_THROW_DARKFLAME_SELECTOR
@ SPELL_CANDLELIGHT
@ SPELL_CURSED_WAX
@ SPELL_DARKLIGHT
@ SPELL_EERIE_MOLDS_SELECTOR
@ SPELL_CURSED_WAX_STUN
@ SPELL_DARKFLAME_PICKAXE_MARKER
@ SPELL_EERIE_MOLDS_CLONE_SUMMONER
@ SPELL_DARKFLAME_PICKAXE_SELECTOR
@ SPELL_DARKFLAME_PICKAXE_CAST
AreaTrigger *const at
AreaTriggerAI(AreaTrigger *a, uint32 scriptId={}) noexcept
Unit * GetCaster() const
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
Unit * GetCaster() const
Unit * GetTarget() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
EventMap events
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
DarkflamePickaxeDamageEvent(Unit *caster, ObjectGuid const &targetGUID, ObjectGuid const &originalCastId)
bool Execute(uint64, uint32) override
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
virtual bool SetBossState(uint32 id, EncounterState state)
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
uint32 GetEntry() const
Definition Object.h:89
Unit * ToUnit()
Definition Object.h:116
Duration GetRemainingCooldown(SpellInfo const *spellInfo) const
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
Spell * GetSpell() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
Definition Unit.h:635
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
SpellHistory * GetSpellHistory()
Definition Unit.h:1498
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
EventProcessor m_Events
Definition Object.h:561
bool Validate(SpellInfo const *) override
void HandleHitTarget(SpellEffIndex) const
void FilterTargets(std::list< WorldObject * > &targets)
void OnRemove(AuraEffect const *aurEff, AuraEffectHandleModes) const
@ DATA_THE_CANDLE_KING
#define RegisterDarkflameCleftCreatureAI(ai_name)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TriggerCastFlags TriggerFlags
CastSpellExtraArgs & SetTriggeringSpell(Spell const *triggeringSpell)
Definition Spell.cpp:9707
CastSpellExtraArgs & SetTriggerFlags(TriggerCastFlags flag)
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
bool IsMythic() const
Difficulty GetDifficulty() const
void OnUnitExit(Unit *unit, AreaTriggerExitReason) override
void OnUnitEnter(Unit *unit) override
void OnUnitEnter(Unit *unit) override
void OnUnitExit(Unit *unit, AreaTriggerExitReason) override
void OnUnitEnter(Unit *unit) override
void KilledUnit(Unit *victim) override
bool TryCastSpellIfReady(uint32 spellId)
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void EnterEvadeMode(EvadeReason) override
boss_the_candle_king(Creature *creature)
void OnSpellStart(SpellInfo const *spellInfo) override
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
Milliseconds GetCooldownOfSpell(uint32 spellId)