From 2043e50d512ac052432f9ef1f6381ab23c895a62 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sun, 1 Dec 2019 20:54:19 +0100 Subject: [PATCH] Core/Spells: fixed Whirlwind cooldown reduction when hitting 4 or more targets --- .../custom/custom_2019_12_01_01_world.sql | 3 ++ src/server/scripts/Spells/spell_warrior.cpp | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 sql/updates/world/custom/custom_2019_12_01_01_world.sql diff --git a/sql/updates/world/custom/custom_2019_12_01_01_world.sql b/sql/updates/world/custom/custom_2019_12_01_01_world.sql new file mode 100644 index 0000000000..534b14db19 --- /dev/null +++ b/sql/updates/world/custom/custom_2019_12_01_01_world.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`= 'spell_warr_whirlwind'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(1680, 'spell_warr_whirlwind'); diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index 88d442e262..acf663aa9b 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -1173,6 +1173,33 @@ class spell_warr_devastate : public SpellScript } }; +class spell_warr_whirlwind : public SpellScript +{ + PrepareSpellScript(spell_warr_whirlwind); + + void CountTargets(SpellEffIndex /*effIndex*/) + { + _hitTargets++; + } + + void HandleCooldownReduction() + { + Unit* caster = GetCaster(); + if (!caster || _hitTargets < 4) + return; + + caster->GetSpellHistory()->ModifyCooldown(GetSpellInfo()->Id, ((GetSpellInfo()->Effects[EFFECT_2].CalcValue(caster) * IN_MILLISECONDS) * -1)); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_warr_whirlwind::CountTargets, EFFECT_0, SPELL_EFFECT_NORMALIZED_WEAPON_DMG); + AfterCast += SpellCastFn(spell_warr_whirlwind::HandleCooldownReduction); + } +private: + uint8 _hitTargets = 0; +}; + void AddSC_warrior_spell_scripts() { RegisterAuraScript(spell_warr_blood_craze); @@ -1205,4 +1232,5 @@ void AddSC_warrior_spell_scripts() RegisterSpellScript(spell_warr_victory_rush); new spell_warr_vigilance(); new spell_warr_vigilance_trigger(); + RegisterSpellScript(spell_warr_whirlwind); }