From 0aaf5214239ebdb0bf491acf4a20aff52b48816a Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Mon, 20 May 2024 05:40:28 -0300 Subject: [PATCH] fix(Scripts/Hyjal): Limit Anetheron sleep to 3 targets (#18929) --- .../rev_1716154650178411700.sql | 4 +++ .../BattleForMountHyjal/boss_anetheron.cpp | 25 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1716154650178411700.sql diff --git a/data/sql/updates/pending_db_world/rev_1716154650178411700.sql b/data/sql/updates/pending_db_world/rev_1716154650178411700.sql new file mode 100644 index 00000000000000..76b37f75cd7caf --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1716154650178411700.sql @@ -0,0 +1,4 @@ +-- +DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_anetheron_sleep'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(31298, 'spell_anetheron_sleep'); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp index a6f6e179110eb0..e814cc6074453a 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp @@ -17,6 +17,8 @@ #include "CreatureScript.h" #include "ScriptedCreature.h" +#include "SpellScript.h" +#include "SpellScriptLoader.h" #include "hyjal.h" enum Spells @@ -58,18 +60,18 @@ struct boss_anetheron : public BossAI scheduler.Schedule(20s, 28s, [this](TaskContext context) { - if (DoCastRandomTarget(SPELL_CARRION_SWARM, 0, 60.f)) + if (DoCastRandomTarget(SPELL_CARRION_SWARM, 0, 60.f) == SPELL_CAST_OK) Talk(SAY_SWARM); context.Repeat(10s, 15s); }).Schedule(25s, 32s, [this](TaskContext context) { - if (DoCastRandomTarget(SPELL_SLEEP)) + if (DoCastRandomTarget(SPELL_SLEEP) == SPELL_CAST_OK) Talk(SAY_SLEEP); context.Repeat(35s, 48s); }).Schedule(30s, 48s, [this](TaskContext context) { - if (DoCastRandomTarget(SPELL_INFERNO)) + if (DoCastRandomTarget(SPELL_INFERNO) == SPELL_CAST_OK) Talk(SAY_INFERNO); context.Repeat(50s, 55s); @@ -138,7 +140,24 @@ struct boss_anetheron : public BossAI }; +class spell_anetheron_sleep : public SpellScript +{ + PrepareSpellScript(spell_anetheron_sleep); + + void FilterTargets(std::list& targets) + { + if (!targets.empty()) + Acore::Containers::RandomResize(targets, 3); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_anetheron_sleep::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + } +}; + void AddSC_boss_anetheron() { RegisterHyjalAI(boss_anetheron); + RegisterSpellScript(spell_anetheron_sleep); }