TrinityCore
Loading...
Searching...
No Matches
boss_leotheras_the_blind.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 (timers seems to be different in different expansions or patches)
20 * Many parts of this encounter requires sniff verification
21 * Spell SPELL_STUN_SELF is guessed, based on effects received in packets
22 * For some reason Leotheras is transparent until evade is triggered
23 */
24
25#include "ScriptMgr.h"
26#include "Containers.h"
27#include "InstanceScript.h"
28#include "Map.h"
29#include "MotionMaster.h"
30#include "Player.h"
31#include "ScriptedCreature.h"
32#include "serpent_shrine.h"
33#include "SpellAuraEffects.h"
34#include "SpellInfo.h"
35#include "SpellMgr.h"
36#include "SpellScript.h"
37#include "TemporarySummon.h"
38
53
55{
56 // Leotheras the Blind - Initial
57 SPELL_BANISH = 37546,
58
59 // Leotheras the Blind - Combat
65
66 // Leotheras the Blind - Combat - Misc
70
71 // Greyheart Spellbinder
75
76 // Inner Demon
81
82 // Shadow of Leotheras
83 SPELL_SHRINK = 37780,
84
85 // Scripts
94};
95
115
124
135
142
149
150static constexpr std::array<uint32, 5> ForceReactionSpells =
151{
157};
158
167
168// 21215 - Leotheras the Blind
170{
173
174 void Reset() override
175 {
176 _Reset();
177
178 _isStartedTransition = false;
179
183 me->SetCanDualWield(true);
184 SetEquipmentSlots(true);
185 }
186
187 void JustAppeared() override
188 {
190
194
196 me->GetMap()->SpawnGroupSpawn(group, true);
197 }
198
209
210 void AttackStart(Unit* who) override
211 {
213 BossAI::AttackStartCaster(who, 40.0f);
214 else
216 }
217
218 void OnSpellCast(SpellInfo const* spellInfo) override
219 {
220 if (spellInfo->Id == SPELL_INSIDIOUS_WHISPER)
222 }
223
224 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
225 {
226 if (!_isStartedTransition && me->HealthBelowPctDamaged(15, damage))
227 {
230 }
231 }
232
233 void DoAction(int32 action) override
234 {
235 switch (action)
236 {
238 {
240
242 {
247 }
248 break;
249 }
253 me->GetMap()->SpawnGroupSpawn(group, true);
254 break;
260
264 break;
266 SetEquipmentSlots(true);
268
270
271 // Without this AttackStartCaster gets stuck if Leotheras uses Consuming Madness. Investigate this
272 if (Unit* victim = me->GetVictim())
273 me->GetMotionMaster()->MoveChase(victim);
274
278 break;
279 default:
280 break;
281 }
282 }
283
284 void EnterEvadeMode(EvadeReason why) override
285 {
287
289 }
290
303
304 void KilledUnit(Unit* victim) override
305 {
306 if (victim->GetTypeId() != TYPEID_PLAYER)
307 return;
308
310 }
311
312 void JustDied(Unit* /*killer*/) override
313 {
314 _JustDied();
316
318 }
319
320 void UpdateAI(uint32 diff) override
321 {
322 if (!UpdateVictim())
323 {
324 events.Update(diff);
325
326 while (uint32 eventId = events.ExecuteEvent())
327 {
328 if (eventId == EVENT_FORCE_CHANNEL)
329 {
330 std::vector<Creature*> spellbinders;
332 for (Creature* spellbinder : spellbinders)
333 spellbinder->AI()->DoAction(ACTION_START_CHANNELING);
334
335 events.Repeat(15s, 25s);
336 }
337 }
338
339 return;
340 }
341
342 events.Update(diff);
343
345 return;
346
347 while (uint32 eventId = events.ExecuteEvent())
348 {
349 switch (eventId)
350 {
351 // Combat
352 case EVENT_WHIRLWIND:
354 events.Repeat(25s, 35s);
355 break;
358 events.Repeat(120s);
359 break;
362 events.Repeat(2400ms);
363 break;
366 break;
367 case EVENT_BERSERK:
369 break;
370
371 // Transition
377
379
381
382 SetEquipmentSlots(true);
383
388
390 break;
395 break;
399 break;
403 break;
409 break;
410 default:
411 break;
412 }
413
415 return;
416 }
417
419 }
420
421private:
424};
425
426// 21875 - Shadow of Leotheras
428{
430
431 void JustAppeared() override
432 {
433 _scheduler.Schedule(0s, [this](TaskContext task)
434 {
435 switch (task.GetRepeatCounter())
436 {
437 case 0:
438 me->SetReactState(REACT_PASSIVE);
439 DoCastSelf(SPELL_SHRINK);
440 task.Repeat(3s);
441 break;
442 case 1:
443 me->RemoveAurasDueToSpell(SPELL_SHRINK);
444 task.Repeat(2s);
445 break;
446 case 2:
447 Talk(SAY_DEMON_FREE);
448 DoZoneInCombat();
449 me->SetReactState(REACT_AGGRESSIVE);
450 me->RemoveUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
451 break;
452 default:
453 break;
454 }
455 });
456 }
457
458 void Reset() override
459 {
461 }
462
463 void JustEngagedWith(Unit* /*who*/) override
464 {
465 _scheduler.Schedule(0s, [this](TaskContext task)
466 {
468 task.Repeat(2400ms);
469 });
470 }
471
472 void AttackStart(Unit* who) override
473 {
475 }
476
477 void UpdateAI(uint32 diff) override
478 {
479 _scheduler.Update(diff);
480
481 if (!UpdateVictim())
482 return;
483
485 }
486
487private:
489};
490
491// 21806 - Greyheart Spellbinder
493{
494 npc_greyheart_spellbinder(Creature* creature) : ScriptedAI(creature), _instance(me->GetInstanceScript()) { }
495
496 void JustAppeared() override
497 {
499 }
500
501 void Reset() override
502 {
504 }
505
506 void JustEngagedWith(Unit* /*who*/) override
507 {
509
511 .SetValidator([this]
512 {
514 })
515 .Schedule(10s, 20s, [this](TaskContext task)
516 {
517 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 20.0f))
518 DoCast(target, SPELL_MIND_BLAST);
519 task.Repeat(15s, 25s);
520 })
521 .Schedule(5s, 10s, [this](TaskContext task)
522 {
523 std::vector<Player*> playerList;
524 GetPlayerListInGrid(playerList, me, 45.0f);
525 for (Player* player : playerList)
526 {
527 if (player->IsNonMeleeSpellCast(false))
528 {
529 DoCast(player, SPELL_SPELL_SHOCK);
530 break;
531 }
532 }
533 task.Repeat(10s, 15s);
534 });
535 }
536
537 void DoAction(int32 action) override
538 {
539 if (action == ACTION_START_CHANNELING && me->IsAlive() && !me->IsInCombat() && !me->IsInEvadeMode())
541 }
542
543 void EnterEvadeMode(EvadeReason why) override
544 {
546
548 leotheras->AI()->DoAction(ACTION_RESET_ENCOUNTER);
549 }
550
551 void JustReachedHome() override
552 {
554 }
555
556 void JustDied(Unit* /*killer*/) override
557 {
559 leotheras->AI()->DoAction(ACTION_SPELLBINDER_DIES);
560 }
561
562 void UpdateAI(uint32 diff) override
563 {
564 if (!UpdateVictim())
565 return;
566
567 _scheduler.Update(diff, [this]
568 {
570 });
571 }
572
573private:
576};
577
578// 21857 - Inner Demon
580{
582
583 void InitializeAI() override
584 {
586
587 if (TempSummon* summon = me->ToTempSummon())
588 if (Unit* summoner = summon->GetSummonerUnit())
589 for (auto [spellId, factionTemplateId] : DemonFaction)
590 if (summoner->HasAura(spellId))
591 me->SetFaction(factionTemplateId);
592 }
593
594 void JustAppeared() override
595 {
599
600 if (TempSummon* summon = me->ToTempSummon())
601 {
602 if (Unit* summoner = summon->GetSummonerUnit())
603 {
604 AddThreat(summoner, 50000.0f);
605 AttackStart(summoner);
606 }
607 }
608 }
609
610 void Reset() override
611 {
613 }
614
615 void JustEngagedWith(Unit* /*who*/) override
616 {
617 _scheduler.Schedule(5s, 10s, [this](TaskContext task)
618 {
620 task.Repeat(5s, 10s);
621 });
622 }
623
624 void JustDied(Unit* killer) override
625 {
627 }
628
629 void UpdateAI(uint32 diff) override
630 {
631 if (!UpdateVictim())
632 return;
633
634 _scheduler.Update(diff, [this]
635 {
637 });
638 }
639
640private:
642};
643
644// 37640 - Whirlwind
646{
648
650 {
651 Creature* caster = GetCaster()->ToCreature();
652 if (!caster)
653 return;
654
656 if (Unit* target = caster->AI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
657 caster->GetThreatManager().AddThreat(target, 100000.0f);
658 }
659
664};
665
666// 37641 - Whirlwind
668{
670
671 void HandleScript(SpellEffIndex /*effIndex*/)
672 {
673 Creature* caster = GetCaster()->ToCreature();
674 if (!caster)
675 return;
676
677 SpellInfo const* spellInfo = GetTriggeringSpell();
678 if (!spellInfo)
679 return;
680
681 if (AuraEffect const* eff = caster->GetAuraEffect(spellInfo->Id, EFFECT_0))
682 {
683 if (eff->GetTickNumber() != spellInfo->GetMaxTicks())
684 {
685 if (roll_chance_i(50))
686 {
688 if (Unit* target = caster->AI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
689 caster->GetThreatManager().AddThreat(target, 100000.0f);
690 }
691 }
692 else
694 }
695 }
696
701};
702
703// 37673 - Metamorphosis
729
730// 37674 - Chaos Blast
754
755// 37676 - Insidious Whisper
787
816
817/* 37725 - Target 1
818 37726 - Target 2
819 37731 - Target 3
820 37732 - Target 4
821 37733 - Target 5 */
841
842// 37750 - Clear Consuming Madness
863
864// 37716 - Demon Link
866{
868
869 bool Validate(SpellInfo const* spellInfo) override
870 {
871 return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
872 }
873
874 void OnPeriodic(AuraEffect const* aurEff)
875 {
877
878 Unit* target = GetTarget();
879 Unit* victim = target->GetVictim();
880 if (victim)
881 target->CastSpell(victim, aurEff->GetSpellEffectInfo().TriggerSpell, true);
882 }
883
888};
889
@ EQUIP_UNEQUIP
Definition CreatureAI.h:76
@ EQUIP_NO_CHANGE
Definition CreatureAI.h:75
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellAndAuraScriptPair(script_1, script_2)
Definition ScriptMgr.h:1130
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
void GetPlayerListInGrid(Container &container, WorldObject *source, float maxSearchRange, bool alive=true)
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_APPLY_AURA
@ TARGET_UNIT_SRC_AREA_ENEMY
@ MECHANIC_BANISH
@ IMMUNITY_MECHANIC
@ AURA_REMOVE_BY_EXPIRE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_TRANSFORM
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
@ SPELLVALUE_BASE_POINT0
#define sSpellMgr
Definition SpellMgr.h:738
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCastFn(F)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STAND_STATE_KNEEL
Definition UnitDefines.h:42
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:34
@ UNIT_FLAG_UNINTERACTIBLE
@ UNIT_STATE_CASTING
Definition Unit.h:249
DamageEffectType
Definition Unit.h:366
static constexpr std::array< uint32, 5 > ForceReactionSpells
@ SAY_NIGHT_ELF_FINAL_FORM
@ SPELL_CONSUMING_MADNESS
@ SPELL_CHAOS_BLAST_DAMAGE
@ SPELL_DEMONIC_ALIGNMENT
@ SPELL_SUMMON_INNER_DEMON
@ SPELL_CLEAR_CONSUMING_MADNESS
@ SPELL_INSIDIOUS_WHISPER
@ FACTION_LEOTHERAS_DEMON_1
@ FACTION_LEOTHERAS_DEMON_2
@ FACTION_LEOTHERAS_DEMON_3
@ NPC_GREYHEART_SPELLBINDER
@ FACTION_LEOTHERAS_DEMON_4
@ FACTION_LEOTHERAS_DEMON_5
@ ACTION_METAMORPHOSIS_REMOVED
@ ACTION_METAMORPHOSIS_APPLIED
@ SPAWN_GROUP_SPELLBINDER_1
@ SPAWN_GROUP_SPELLBINDER_2
@ SPAWN_GROUP_SPELLBINDER_3
static constexpr std::pair< uint32, uint32 > DemonFaction[5]
static constexpr std::array< uint32, 3 > SpellbindersSpawnGroupsData
void AddSC_boss_leotheras_the_blind()
AuraRemoveMode GetRemoveMode() const
Definition SpellAuras.h:88
SpellEffectInfo const & GetSpellEffectInfo() const
void PreventDefaultAction()
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
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
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
void SetReactState(ReactStates st)
Definition Creature.h:128
void SetCanDualWield(bool value) override
bool IsInEvadeMode() const
Definition Creature.h:155
CreatureAI * AI() const
Definition Creature.h:163
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void CancelEvent(EventId eventId)
Definition EventMap.cpp:151
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
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
static Creature * ToCreature(Object *o)
Definition Object.h:189
TypeID GetTypeId() const
Definition Object.h:93
uint32 TriggerSpell
Definition SpellInfo.h:228
int32 CalcValue(WorldObject const *caster=nullptr, int32 const *basePoints=nullptr) const
uint32 GetMaxTicks() const
uint32 Id
Definition SpellInfo.h:289
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:483
HookList< CastHandler > AfterCast
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
SpellInfo const * GetTriggeringSpell() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler::repeated_t GetRepeatCounter() const
Returns the repeat counter which increases every time the task is repeated.
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 AddThreat(Unit *target, float amount, SpellInfo const *spell=nullptr, bool ignoreModifiers=false, bool ignoreRedirects=false)
== AFFECT MY THREAT LIST ==
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:48
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
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:30
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:783
ThreatManager & GetThreatManager()
Definition Unit.h:1169
void SetFaction(uint32 faction) override
Definition Unit.h:988
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3116
MotionMaster * GetMotionMaster()
Definition Unit.h:1683
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition Unit.cpp:4382
bool IsAlive() const
Definition Unit.h:1247
TempSummon * ToTempSummon()
Definition Unit.h:1810
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4558
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3807
Unit * GetVictim() const
Definition Unit.h:873
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 SetStandState(UnitStandStateType state)
Definition Unit.cpp:10340
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:932
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:968
bool IsInCombat() const
Definition Unit.h:1158
void SetIsCombatDisallowed(bool apply)
Definition Unit.h:1844
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:969
Map * GetMap() const
Definition Object.h:451
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_leotheras_the_blind_chaos_blast)
PrepareSpellScript(spell_leotheras_the_blind_clear_consuming_madness)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_leotheras_the_blind_insidious_whisper_aura)
PrepareSpellScript(spell_leotheras_the_blind_insidious_whisper)
void FilterTargets(std::list< WorldObject * > &targets)
PrepareAuraScript(spell_leotheras_the_blind_metamorphosis)
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
PrepareSpellScript(spell_leotheras_the_blind_summon_inner_demon)
PrepareSpellScript(spell_leotheras_the_blind_whirlwind_effect)
PrepareSpellScript(spell_leotheras_the_blind_whirlwind_init)
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:66
@ BOSS_LEOTHERAS_THE_BLIND
#define RegisterSerpentshrineCavernCreatureAI(ai_name)
void SetEquipmentSlots(bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
void AttackStart(Unit *) override
ScriptedAI(Creature *creature)
void ResetThreatList(Unit *who=nullptr)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void OnSpellCast(SpellInfo const *spellInfo) override
void AttackStart(Unit *who) override
void DoAction(int32 action) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
boss_leotheras_the_blind(Creature *creature)
void EnterEvadeMode(EvadeReason why) override
void KilledUnit(Unit *victim) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void DoAction(int32 action) override
npc_greyheart_spellbinder(Creature *creature)
void UpdateAI(uint32 diff) override
void EnterEvadeMode(EvadeReason why) override
void JustDied(Unit *killer) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void AttackStart(Unit *who) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override