TrinityCore
Loading...
Searching...
No Matches
boss_kelidan_the_breaker.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/*
19 * Timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "blood_furnace.h"
24#include "InstanceScript.h"
25#include "Map.h"
26#include "ScriptedCreature.h"
27#include "SpellInfo.h"
28#include "SpellScript.h"
29
31{
32 // Keli'dan the Breaker
37
38 // Shadowmoon Channeler
40 SAY_AGGRO_2 = 1
41};
42
44{
45 // Keli'dan the Breaker - Out of Combat
47
48 // Keli'dan the Breaker - Combat
53
54 // Shadowmoon Channeler - Out of Combat
56
57 // Shadowmoon Channeler - Combat
61
62 // Scripts
63 SPELL_VORTEX = 37370,
65 SPELL_FIRE_NOVA_H = 37371
66};
67
78
85
94
103
104// 17377 - Keli'dan the Breaker
106{
108
109 void JustAppeared() override
110 {
111 me->SetImmuneToNPC(true);
114
116
118 me->GetMap()->SpawnGroupSpawn(group, true);
119 }
120
121 void JustEngagedWith(Unit* who) override
122 {
124
125 Talk(SAY_WAKE);
126
128
132 }
133
134 void DoAction(int32 action) override
135 {
136 switch (action)
137 {
139 {
141
143 {
144 me->SetImmuneToNPC(false);
149 }
150 break;
151 }
155 me->GetMap()->SpawnGroupSpawn(group, true);
156 break;
157 default:
158 break;
159 }
160 }
161
162 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
163 {
164 if (spellInfo->Id == SPELL_BURNING_NOVA)
165 Talk(SAY_NOVA);
166 }
167
180
181 void KilledUnit(Unit* /*victim*/) override
182 {
183 Talk(SAY_SLAY);
184 }
185
186 void JustDied(Unit* /*killer*/) override
187 {
188 _JustDied();
190 }
191
192 void UpdateAI(uint32 diff) override
193 {
194 if (!UpdateVictim())
195 {
196 events.Update(diff);
197
198 while (uint32 eventId = events.ExecuteEvent())
199 {
200 if (eventId == EVENT_EVOCATION)
202 }
203
204 return;
205 }
206
207 events.Update(diff);
208
210 return;
211
212 while (uint32 eventId = events.ExecuteEvent())
213 {
214 switch (eventId)
215 {
218 events.Repeat(15s, 25s);
219 break;
220 case EVENT_CORRUPTION:
222 events.Repeat(10s, 15s);
223 break;
228 events.Repeat(25s, 35s);
229 break;
230 default:
231 break;
232 }
233
235 return;
236 }
237
239 }
240
241private:
243};
244
245// 17653 - Shadowmoon Channeler
247{
248 npc_shadowmoon_channeler(Creature* creature) : ScriptedAI(creature), _instance(me->GetInstanceScript()) { }
249
250 void InitializeAI() override
251 {
253 me->SetCorpseDelay(3, true);
254 }
255
256 void JustAppeared() override
257 {
259 }
260
261 void Reset() override
262 {
264 }
265
266 void JustEngagedWith(Unit* /*who*/) override
267 {
269
271
273
274 if (roll_chance_i(15))
276
278 .SetValidator([this]
279 {
281 })
282 .Schedule(0s, 5s, [this](TaskContext task)
283 {
285 task.Repeat(10s, 15s);
286 })
287 .Schedule(5s, 15s, [this](TaskContext task)
288 {
289 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, true, -SPELL_MARK_OF_SHADOW))
291 task.Repeat(5s, 15s);
292 });
293 }
294
296 {
297 _scheduler.Schedule(10s, [this](TaskContext task)
298 {
299 Creature* channeler = me->FindNearestCreatureWithOptions(100.0f, { .StringId = GetStringIdOfChanneler() });
300 if (!channeler || channeler->IsInEvadeMode())
301 {
302 task.Repeat(1s);
303 return;
304 }
305
306 DoCast(channeler, SPELL_STAR_BEAM);
307 });
308 }
309
310 std::string_view GetStringIdOfChanneler() const
311 {
312 if (me->HasStringId("KelidansShadowmoonChanneler1"))
313 return "KelidansShadowmoonChanneler4";
314 else if (me->HasStringId("KelidansShadowmoonChanneler2"))
315 return "KelidansShadowmoonChanneler3";
316 else if (me->HasStringId("KelidansShadowmoonChanneler3"))
317 return "KelidansShadowmoonChanneler5";
318 else if (me->HasStringId("KelidansShadowmoonChanneler4"))
319 return "KelidansShadowmoonChanneler2";
320 else if (me->HasStringId("KelidansShadowmoonChanneler5"))
321 return "KelidansShadowmoonChanneler1";
322 return "";
323 }
324
325 void JustReachedHome() override
326 {
328
330 kelidan->AI()->DoAction(ACTION_RESET_ENCOUNTER);
331 }
332
333 void JustDied(Unit* /*killer*/) override
334 {
336 kelidan->AI()->DoAction(ACTION_CHANNELER_DIES);
337 }
338
339 void UpdateAI(uint32 diff) override
340 {
341 _scheduler.Update(diff);
342
343 if (UpdateVictim())
345 }
346
347private:
350};
351
352// 30940 - Burning Nova
381
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
@ EFFECT_0
@ MECHANIC_BANISH
@ IMMUNITY_MECHANIC
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_MOD_STUN
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_FLAG_UNINTERACTIBLE
@ UNIT_STATE_CASTING
Definition Unit.h:249
#define RegisterBloodFurnaceCreatureAI(ai_name)
@ DATA_KELIDAN
@ EVENT_SHADOW_BOLT_VOLLEY
static constexpr std::array< uint32, 5 > ChannelersSpawnGroupsData
@ SPAWN_GROUP_CHANNELER_3
@ SPAWN_GROUP_CHANNELER_5
@ SPAWN_GROUP_CHANNELER_1
@ SPAWN_GROUP_CHANNELER_2
@ SPAWN_GROUP_CHANNELER_4
@ SPELL_SHADOW_BOLT_VOLLEY
@ SPELL_SHADOW_BOLT_VOLLEY_H
void AddSC_boss_kelidan_the_breaker()
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
void _JustReachedHome()
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:128
bool HasStringId(std::string_view id) const
void SetImmuneToNPC(bool apply) override
Definition Creature.h:141
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:98
bool IsInEvadeMode() const
Definition Creature.h:155
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Creature * GetCreature(uint32 type)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
bool IsHeroic() const
Definition Map.cpp:4251
uint32 Id
Definition SpellInfo.h:289
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
virtual void InitializeAI()
Definition UnitAI.cpp:36
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:783
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3116
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition Unit.cpp:8082
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:968
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:969
Map * GetMap() const
Definition Object.h:451
Creature * FindNearestCreatureWithOptions(float range, FindCreatureOptions const &options) const
Definition Object.cpp:2109
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_kelidan_the_breaker_burning_nova)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
T const & DUNGEON_MODE(T const &normal5, T const &heroic10) const
boss_kelidan_the_breaker(Creature *creature)
void DoAction(int32 action) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
std::string_view GetStringIdOfChanneler() const
npc_shadowmoon_channeler(Creature *creature)
void UpdateAI(uint32 diff) override