From db851b483e952dff225d0a636cd342a0aa120e62 Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Wed, 15 Nov 2023 20:41:56 -0300 Subject: [PATCH] refactor(Scripts/RuinsOfAhnQiraj): Clean up script files (#17723) --- .../Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp | 64 ++++++------------- .../RuinsOfAhnQiraj/boss_kurinnaxx.cpp | 5 -- .../RuinsOfAhnQiraj/ruins_of_ahnqiraj.cpp | 27 +++----- 3 files changed, 29 insertions(+), 67 deletions(-) diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp index 545f3080b..f0af04f5f 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp @@ -56,17 +56,16 @@ enum Misc ACTION_SWARMER_SWARM = 1, }; +enum TaskGroups +{ + GROUP_AIR = 1 +}; + enum Emotes { EMOTE_FRENZY = 0 }; -enum Phases -{ - PHASE_AIR = 0, - PHASE_GROUND = 1 -}; - enum Points { POINT_AIR = 0, @@ -84,11 +83,23 @@ struct boss_ayamiss : public BossAI void Reset() override { BossAI::Reset(); - _phase = PHASE_AIR; - _enraged = false; SetCombatMovement(false); - scheduler.CancelAll(); me->SetReactState(REACT_AGGRESSIVE); + + ScheduleHealthCheckEvent(70, [&] { + me->ClearUnitState(UNIT_STATE_ROOT); + me->SetReactState(REACT_PASSIVE); + me->SetCanFly(false); + me->SetDisableGravity(false); + me->GetMotionMaster()->MovePath(me->GetEntry() * 10, false); + DoResetThreatList(); + scheduler.CancelGroup(GROUP_AIR); + }); + + ScheduleHealthCheckEvent(20, [&] { + DoCastSelf(SPELL_FRENZY); + Talk(EMOTE_FRENZY); + }); } void JustSummoned(Creature* who) override @@ -145,9 +156,8 @@ struct boss_ayamiss : public BossAI { DoCastSelf(SPELL_STINGER_SPRAY); context.Repeat(15s, 20s); - }).Schedule(5s, [this](TaskContext context) { + }).Schedule(5s, GROUP_AIR, [this](TaskContext context) { DoCastVictim(SPELL_POISON_STINGER); - context.SetGroup(PHASE_AIR); context.Repeat(2s, 3s); }).Schedule(5s, [this](TaskContext context) { DoCastAOE(SPELL_SUMMON_HIVEZARA_SWARMER, true); @@ -210,40 +220,8 @@ struct boss_ayamiss : public BossAI ScheduleTasks(); } - void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType, SpellSchoolMask) override - { - if (_phase == PHASE_AIR && me->HealthBelowPctDamaged(70, damage)) - { - _phase = PHASE_GROUND; - me->ClearUnitState(UNIT_STATE_ROOT); - me->SetReactState(REACT_PASSIVE); - me->SetCanFly(false); - me->SetDisableGravity(false); - me->GetMotionMaster()->MovePath(me->GetEntry() * 10, false); - DoResetThreatList(); - scheduler.CancelGroup(PHASE_AIR); - } - - if (!_enraged && me->HealthBelowPctDamaged(20, damage)) - { - DoCastSelf(SPELL_FRENZY); - Talk(EMOTE_FRENZY); - _enraged = true; - } - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - scheduler.Update(diff, - std::bind(&BossAI::DoMeleeAttackIfReady, this)); - } private: GuidList _swarmers; - uint8 _phase; - bool _enraged; Position homePos; }; diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp index 572c67791..8e7f79777 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp @@ -44,11 +44,6 @@ struct boss_kurinnaxx : public BossAI void InitializeAI() override { me->m_CombatDistance = 50.0f; - - scheduler.SetValidator([this] - { - return !me->HasUnitState(UNIT_STATE_CASTING); - }); } void JustEngagedWith(Unit* who) override diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.cpp index 8cd2c6e94..13d2f47d6 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.cpp @@ -19,7 +19,6 @@ #include "ScriptedCreature.h" #include "SpellScript.h" #include "ruins_of_ahnqiraj.h" -#include "TaskScheduler.h" enum Spells { @@ -37,20 +36,18 @@ enum Spells struct npc_hivezara_stinger : public ScriptedAI { - npc_hivezara_stinger(Creature* creature) : ScriptedAI(creature) - { - } + npc_hivezara_stinger(Creature* creature) : ScriptedAI(creature) { } void Reset() override { - _scheduler.CancelAll(); + scheduler.CancelAll(); } void JustEngagedWith(Unit* who) override { DoCast(who ,who->HasAura(SPELL_HIVEZARA_CATALYST) ? SPELL_STINGER_CHARGE_BUFFED : SPELL_STINGER_CHARGE_NORMAL, true); - _scheduler.Schedule(5s, [this](TaskContext context) + scheduler.Schedule(5s, [this](TaskContext context) { Unit* target = SelectTarget(SelectTargetMethod::Random, 1, [&](Unit* u) { @@ -80,29 +77,24 @@ struct npc_hivezara_stinger : public ScriptedAI return; } - _scheduler.Update(diff, + scheduler.Update(diff, std::bind(&ScriptedAI::DoMeleeAttackIfReady, this)); } - -private: - TaskScheduler _scheduler; }; struct npc_obsidian_destroyer : public ScriptedAI { - npc_obsidian_destroyer(Creature* creature) : ScriptedAI(creature) - { - } + npc_obsidian_destroyer(Creature* creature) : ScriptedAI(creature) { } void Reset() override { - _scheduler.CancelAll(); + scheduler.CancelAll(); me->SetPower(POWER_MANA, 0); } void JustEngagedWith(Unit* /*who*/) override { - _scheduler.Schedule(6s, [this](TaskContext context) + scheduler.Schedule(6s, [this](TaskContext context) { std::list targets; SelectTargetList(targets, 6, SelectTargetMethod::Random, 1, [&](Unit* target) @@ -136,12 +128,9 @@ struct npc_obsidian_destroyer : public ScriptedAI return; } - _scheduler.Update(diff, + scheduler.Update(diff, std::bind(&ScriptedAI::DoMeleeAttackIfReady, this)); } - -private: - TaskScheduler _scheduler; }; class spell_drain_mana : public SpellScript