From 23c407ceb7936f507a61052fd98094b55d9c70f0 Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Mon, 11 Dec 2023 08:02:03 -0300 Subject: [PATCH] refactor(Scripts/Outland): Update Doomwalker to new register model (#17987) --- .../scripts/Outland/boss_doomwalker.cpp | 191 ++++++++---------- 1 file changed, 88 insertions(+), 103 deletions(-) diff --git a/src/server/scripts/Outland/boss_doomwalker.cpp b/src/server/scripts/Outland/boss_doomwalker.cpp index 198e68172..fe3351f75 100644 --- a/src/server/scripts/Outland/boss_doomwalker.cpp +++ b/src/server/scripts/Outland/boss_doomwalker.cpp @@ -38,115 +38,100 @@ enum Spells SPELL_AURA_DEATH = 37131 }; -class boss_doomwalker : public CreatureScript +struct boss_doomwalker : public ScriptedAI { -public: - boss_doomwalker() : CreatureScript("boss_doomwalker") { } + boss_doomwalker(Creature* creature) : ScriptedAI(creature) { } - struct boss_doomwalkerAI : public ScriptedAI + void Reset() override { - boss_doomwalkerAI(Creature* creature) : ScriptedAI(creature) {} - - void Reset() override - { - _inEnrage = false; - scheduler.CancelAll(); - } - - void KilledUnit(Unit* victim) override - { - victim->CastSpell(victim, SPELL_MARK_DEATH, 0); - if (urand(0, 4)) - return; - - if (victim->GetTypeId() == TYPEID_PLAYER) - { - Talk(SAY_SLAY); - } - } - - void JustDied(Unit* /*killer*/) override - { - Talk(SAY_DEATH); - } - - void JustEngagedWith(Unit* /*who*/) override - { - Talk(SAY_AGGRO); - scheduler.Schedule(1ms, [this](TaskContext context) - { - if (!HealthAbovePct(20)) - { - DoCastSelf(SPELL_ENRAGE); - context.Repeat(6s); - _inEnrage = true; - } - }).Schedule(5s, 13s, [this](TaskContext context) - { - DoCastVictim(SPELL_SUNDER_ARMOR); - context.Repeat(10s, 25s); - }).Schedule(10s, 30s, [this](TaskContext context) - { - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true)) - { - DoCast(target, SPELL_CHAIN_LIGHTNING); - } - context.Repeat(7s, 27s); - }).Schedule(25s, 35s, [this](TaskContext context) - { - if (urand(0, 1)) - { - return; - } - Talk(SAY_EARTHQUAKE); - if (_inEnrage) // avoid enrage + earthquake - { - me->RemoveAurasDueToSpell(SPELL_ENRAGE); - } - DoCastAOE(SPELL_EARTHQUAKE); - context.Repeat(30s, 55s); - }).Schedule(30s, 45s, [this](TaskContext context) - { - Talk(SAY_OVERRUN); - DoCastVictim(SPELL_OVERRUN); - context.Repeat(25s, 40s); - }); - } - - void MoveInLineOfSight(Unit* who) override - { - if (who && who->GetTypeId() == TYPEID_PLAYER && me->IsValidAttackTarget(who)) - { - if (who->HasAura(SPELL_MARK_DEATH) && !who->HasAura(27827)) // Spirit of Redemption - { - who->CastSpell(who, SPELL_AURA_DEATH, 1); - } - } - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - scheduler.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - - DoMeleeAttackIfReady(); - } - - private: - bool _inEnrage; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_doomwalkerAI (creature); + _inEnrage = false; + scheduler.CancelAll(); } + + void KilledUnit(Unit* victim) override + { + victim->CastSpell(victim, SPELL_MARK_DEATH, 0); + + if (roll_chance_i(25) && victim->IsPlayer()) + { + Talk(SAY_SLAY); + } + } + + void JustDied(Unit* /*killer*/) override + { + Talk(SAY_DEATH); + } + + void JustEngagedWith(Unit* /*who*/) override + { + Talk(SAY_AGGRO); + scheduler.Schedule(1ms, [this](TaskContext context) + { + if (!HealthAbovePct(20)) + { + DoCastSelf(SPELL_ENRAGE); + context.Repeat(6s); + _inEnrage = true; + } + }).Schedule(5s, 13s, [this](TaskContext context) + { + DoCastVictim(SPELL_SUNDER_ARMOR); + context.Repeat(10s, 25s); + }).Schedule(10s, 30s, [this](TaskContext context) + { + DoCastRandomTarget(SPELL_CHAIN_LIGHTNING, 1); + context.Repeat(7s, 27s); + }).Schedule(25s, 35s, [this](TaskContext context) + { + if (urand(0, 1)) + { + return; + } + Talk(SAY_EARTHQUAKE); + if (_inEnrage) // avoid enrage + earthquake + { + me->RemoveAurasDueToSpell(SPELL_ENRAGE); + } + DoCastAOE(SPELL_EARTHQUAKE); + context.Repeat(30s, 55s); + }).Schedule(30s, 45s, [this](TaskContext context) + { + Talk(SAY_OVERRUN); + DoCastVictim(SPELL_OVERRUN); + context.Repeat(25s, 40s); + }); + } + + void MoveInLineOfSight(Unit* who) override + { + if (who && who->GetTypeId() == TYPEID_PLAYER && me->IsValidAttackTarget(who)) + { + if (who->HasAura(SPELL_MARK_DEATH) && !who->HasAura(27827)) // Spirit of Redemption + { + who->CastSpell(who, SPELL_AURA_DEATH, 1); + } + } + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + scheduler.Update(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + DoMeleeAttackIfReady(); + } + +private: + bool _inEnrage; }; void AddSC_boss_doomwalker() { - new boss_doomwalker(); + RegisterCreatureAI(boss_doomwalker); }