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);
112 me->SetUninteractible(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);
145 me->SetUninteractible(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
168 void JustReachedHome() override
169 {
171
172 me->SetImmuneToNPC(true);
173 me->SetUninteractible(true);
175
177
179 }
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 }
238
239private:
241};
242
243// 17653 - Shadowmoon Channeler
245{
246 npc_shadowmoon_channeler(Creature* creature) : ScriptedAI(creature), _instance(me->GetInstanceScript()) { }
247
248 void InitializeAI() override
249 {
251 me->SetCorpseDelay(3, true);
252 }
253
254 void JustAppeared() override
255 {
257 }
258
259 void Reset() override
260 {
262 }
263
264 void JustEngagedWith(Unit* /*who*/) override
265 {
267
269
271
272 if (roll_chance(15))
274
276 .SetValidator([this]
277 {
279 })
280 .Schedule(0s, 5s, [this](TaskContext& task)
281 {
283 task.Repeat(10s, 15s);
284 })
285 .Schedule(5s, 15s, [this](TaskContext& task)
286 {
287 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, true, -SPELL_MARK_OF_SHADOW))
289 task.Repeat(5s, 15s);
290 });
291 }
292
294 {
295 _scheduler.Schedule(10s, [this](TaskContext& task)
296 {
297 Creature* channeler = me->FindNearestCreatureWithOptions(100.0f, { .StringId = GetStringIdOfChanneler() });
298 if (!channeler || channeler->IsInEvadeMode())
299 {
300 task.Repeat(1s);
301 return;
302 }
303
304 DoCast(channeler, SPELL_STAR_BEAM);
305 });
306 }
307
308 std::string_view GetStringIdOfChanneler() const
309 {
310 if (me->HasStringId("KelidansShadowmoonChanneler1"))
311 return "KelidansShadowmoonChanneler4";
312 else if (me->HasStringId("KelidansShadowmoonChanneler2"))
313 return "KelidansShadowmoonChanneler3";
314 else if (me->HasStringId("KelidansShadowmoonChanneler3"))
315 return "KelidansShadowmoonChanneler5";
316 else if (me->HasStringId("KelidansShadowmoonChanneler4"))
317 return "KelidansShadowmoonChanneler2";
318 else if (me->HasStringId("KelidansShadowmoonChanneler5"))
319 return "KelidansShadowmoonChanneler1";
320 return "";
321 }
322
323 void JustReachedHome() override
324 {
326
328 kelidan->AI()->DoAction(ACTION_RESET_ENCOUNTER);
329 }
330
331 void JustDied(Unit* /*killer*/) override
332 {
334 kelidan->AI()->DoAction(ACTION_CHANNELER_DIES);
335 }
336
337 void UpdateAI(uint32 diff) override
338 {
339 _scheduler.Update(diff);
340
341 UpdateVictim();
342 }
343
344private:
347};
348
349// 30940 - Burning Nova
376
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
bool roll_chance(float chance, PseudoRandomDistributionState &state)
Definition Random.cpp:131
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ 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_STATE_CASTING
Definition Unit.h:290
#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()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
bool HasStringId(std::string_view id) const
void SetImmuneToNPC(bool apply) override
Definition Creature.h:193
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:118
bool IsInEvadeMode() const
Definition Creature.h:224
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
Creature * GetCreature(uint32 type)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2360
bool IsHeroic() const
Definition Map.cpp:3347
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void InitializeAI()
Definition UnitAI.cpp:35
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 DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
void ApplySpellImmune(uint32 spellId, SpellImmunity op, uint32 type, bool apply)
Definition Unit.cpp:8261
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3253
void SetUninteractible(bool apply)
Definition Unit.cpp:8583
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
Map * GetMap() const
Definition Object.h:411
Creature * FindNearestCreatureWithOptions(float range, FindCreatureOptions const &options) const
Definition Object.cpp:1531
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
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