From 8bb3bfb29de4a6d664a253d5249827900261e2a1 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Sun, 19 Mar 2023 19:52:24 -0300 Subject: [PATCH] refactor(Scripts/Mechanar): Modernize Gatewatchers script (#15492) --- .../Mechanar/boss_gatewatcher_gyrokill.cpp | 101 ++++++------------ .../Mechanar/boss_gatewatcher_ironhand.cpp | 94 ++++++---------- 2 files changed, 64 insertions(+), 131 deletions(-) diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_gyrokill.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_gyrokill.cpp index 4a30cad15..be106c502 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_gyrokill.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_gyrokill.cpp @@ -34,81 +34,48 @@ enum Spells SPELL_SHADOW_POWER = 35322 }; -enum Events +struct boss_gatewatcher_gyrokill : public BossAI { - EVENT_STREAM_OF_MACHINE_FLUID = 1, - EVENT_SAW_BLADE = 2, - EVENT_SHADOW_POWER = 3 -}; + boss_gatewatcher_gyrokill(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_GYROKILL) { } -class boss_gatewatcher_gyrokill : public CreatureScript -{ -public: - boss_gatewatcher_gyrokill() : CreatureScript("boss_gatewatcher_gyrokill") { } - - struct boss_gatewatcher_gyrokillAI : public BossAI + void JustDied(Unit* /*killer*/) override { - boss_gatewatcher_gyrokillAI(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_GYROKILL) { } + _JustDied(); + Talk(SAY_DEATH); + } - void JustDied(Unit* /*killer*/) override - { - _JustDied(); - Talk(SAY_DEATH); - } - - void JustEngagedWith(Unit* /*who*/) override - { - _JustEngagedWith(); - events.ScheduleEvent(EVENT_STREAM_OF_MACHINE_FLUID, 10000); - events.ScheduleEvent(EVENT_SAW_BLADE, 20000); - events.ScheduleEvent(EVENT_SHADOW_POWER, 30000); - Talk(SAY_AGGRO); - } - - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - Talk(SAY_SLAY); - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - - switch (events.ExecuteEvent()) - { - case EVENT_STREAM_OF_MACHINE_FLUID: - me->CastSpell(me->GetVictim(), SPELL_STREAM_OF_MACHINE_FLUID, false); - events.ScheduleEvent(EVENT_STREAM_OF_MACHINE_FLUID, urand(12000, 14000)); - break; - case EVENT_SAW_BLADE: - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 50.0f)) - me->CastSpell(target, SPELL_SAW_BLADE, false); - Talk(SAY_SAW_BLADE); - events.ScheduleEvent(EVENT_SAW_BLADE, 25000); - break; - case EVENT_SHADOW_POWER: - me->CastSpell(me, SPELL_SHADOW_POWER, false); - events.ScheduleEvent(EVENT_SAW_BLADE, 25000); - break; - } - - DoMeleeAttackIfReady(); - } - }; - - CreatureAI* GetAI(Creature* creature) const override + void JustEngagedWith(Unit* /*who*/) override { - return GetMechanarAI(creature); + _JustEngagedWith(); + + scheduler.Schedule(10s, [this](TaskContext context) + { + DoCastVictim(SPELL_STREAM_OF_MACHINE_FLUID); + context.Repeat(12s, 14s); + }).Schedule(20s, [this](TaskContext context) + { + DoCastRandomTarget(SPELL_SAW_BLADE, 0, 50.0f); + Talk(SAY_SAW_BLADE); + context.Repeat(25s); + }).Schedule(30s, [this](TaskContext context) + { + me->CastSpell(me, SPELL_SHADOW_POWER, false); + context.Repeat(25s); + }); + + Talk(SAY_AGGRO); + } + + void KilledUnit(Unit* victim) override + { + if (victim->IsPlayer()) + { + Talk(SAY_SLAY); + } } }; void AddSC_boss_gatewatcher_gyrokill() { - new boss_gatewatcher_gyrokill(); + RegisterMechanarCreatureAI(boss_gatewatcher_gyrokill); } diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_ironhand.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_ironhand.cpp index fc2483722..2b93adb58 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_ironhand.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_gatewatcher_ironhand.cpp @@ -35,83 +35,49 @@ enum Spells SPELL_STREAM_OF_MACHINE_FLUID = 35311 }; -enum Events +struct boss_gatewatcher_iron_hand : public BossAI { - EVENT_STREAM_OF_MACHINE_FLUID = 1, - EVENT_JACKHAMMER = 2, - EVENT_SHADOW_POWER = 3 -}; + boss_gatewatcher_iron_hand(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_IRON_HAND) { } -class boss_gatewatcher_iron_hand : public CreatureScript -{ -public: - boss_gatewatcher_iron_hand(): CreatureScript("boss_gatewatcher_iron_hand") { } - - struct boss_gatewatcher_iron_handAI : public BossAI + void JustEngagedWith(Unit* /*who*/) override { - boss_gatewatcher_iron_handAI(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_IRON_HAND) { } + _JustEngagedWith(); - void JustEngagedWith(Unit* /*who*/) override + scheduler.Schedule(15s, [this](TaskContext context) { - _JustEngagedWith(); - events.ScheduleEvent(EVENT_STREAM_OF_MACHINE_FLUID, 15000); - events.ScheduleEvent(EVENT_JACKHAMMER, 35000); - events.ScheduleEvent(EVENT_SHADOW_POWER, 25000); - Talk(SAY_AGGRO); - } - - void KilledUnit(Unit* victim) override + DoCastVictim(SPELL_STREAM_OF_MACHINE_FLUID); + context.Repeat(20s); + }).Schedule(35s, [this](TaskContext context) { - if (victim->GetTypeId() == TYPEID_PLAYER) - Talk(SAY_SLAY); - } - - void JustDied(Unit* /*killer*/) override + Talk(EMOTE_HAMMER); + Talk(SAY_HAMMER); + DoCastSelf(SPELL_JACKHAMMER); + context.Repeat(40s); + }).Schedule(25s, [this](TaskContext context) { - _JustDied(); - Talk(SAY_DEATH); - } + DoCastSelf(SPELL_SHADOW_POWER); + context.Repeat(25s); + }); - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + Talk(SAY_AGGRO); + } - events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - - switch (events.ExecuteEvent()) - { - case EVENT_STREAM_OF_MACHINE_FLUID: - me->CastSpell(me->GetVictim(), SPELL_STREAM_OF_MACHINE_FLUID, false); - events.ScheduleEvent(EVENT_STREAM_OF_MACHINE_FLUID, 20000); - break; - case EVENT_JACKHAMMER: - Talk(EMOTE_HAMMER); - Talk(SAY_HAMMER); - me->CastSpell(me, SPELL_JACKHAMMER, false); - events.ScheduleEvent(EVENT_JACKHAMMER, 40000); - break; - case EVENT_SHADOW_POWER: - me->CastSpell(me, SPELL_SHADOW_POWER, false); - events.ScheduleEvent(EVENT_SHADOW_POWER, 25000); - break; - default: - break; - } - - DoMeleeAttackIfReady(); - } - }; - - CreatureAI* GetAI(Creature* creature) const override + void KilledUnit(Unit* victim) override { - return GetMechanarAI(creature); + if (victim->IsPlayer()) + { + Talk(SAY_SLAY); + } + } + + void JustDied(Unit* /*killer*/) override + { + _JustDied(); + Talk(SAY_DEATH); } }; void AddSC_boss_gatewatcher_iron_hand() { - new boss_gatewatcher_iron_hand(); + RegisterMechanarCreatureAI(boss_gatewatcher_iron_hand); }