From b0ff954322c588fd045ffee576ad2d691d6ac00e Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Mon, 23 Jan 2023 09:45:34 +0100 Subject: [PATCH] Core/Spells: fixed Entangling Root's proc number calculation The number of procs before the roots break depend on the level difference between caster and target --- .../world/4.3.4/2023_01_23_00_world.sql | 7 ++++ src/server/scripts/Spells/spell_druid.cpp | 40 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 sql/updates/world/4.3.4/2023_01_23_00_world.sql diff --git a/sql/updates/world/4.3.4/2023_01_23_00_world.sql b/sql/updates/world/4.3.4/2023_01_23_00_world.sql new file mode 100644 index 0000000000..2029e65a69 --- /dev/null +++ b/sql/updates/world/4.3.4/2023_01_23_00_world.sql @@ -0,0 +1,7 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`= 'spell_dru_entangling_roots'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(339, 'spell_dru_entangling_roots'); + +DELETE FROM `spell_proc` WHERE `SpellId`= 339; +INSERT INTO `spell_proc` (`SpellId`, `SpellTypeMask`, `Charges`) VALUES +(339, 0x1, 1); diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index c3da49297a..8fda4af536 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -2080,6 +2080,45 @@ private: bool _bountyActive = false; }; +// 339 - Entangling Roots +class spell_dru_entangling_roots : public AuraScript +{ + static constexpr uint8 DEFAULT_PROCS = 4; // The number of allowed procs for a target of the same level as the caster + static constexpr uint8 MINIMUM_PROCS = 2; // The minimum amount of procs + + void CalculateProcAmount(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* caster = GetCaster(); + if (!caster) + return; + + // Every two level difference increase or reduce the chance of breaking. Tree of Life enhances this effect + int16 offset = (caster->getLevel() - GetTarget()->getLevel()) / 2; + _allowedProcs = std::max(MINIMUM_PROCS, DEFAULT_PROCS + offset); + if (caster->GetShapeshiftForm() == FORM_TREE) + ++_allowedProcs; + } + + bool CheckProc(ProcEventInfo& /*eventInfo*/) + { + if (_allowedProcs != 0) + --_allowedProcs; + + if (_allowedProcs == 0) + return true; + + return false; + } + + void Register() override + { + AfterEffectApply.Register(&spell_dru_entangling_roots::CalculateProcAmount, EFFECT_0, SPELL_AURA_MOD_ROOT, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + DoCheckProc.Register(&spell_dru_entangling_roots::CheckProc); + } +private: + uint8 _allowedProcs = 0; +}; + void AddSC_druid_spell_scripts() { RegisterSpellScript(spell_dru_astral_alignment); @@ -2095,6 +2134,7 @@ void AddSC_druid_spell_scripts() RegisterSpellScript(spell_dru_empowered_touch); RegisterSpellScript(spell_dru_empowered_touch_script); RegisterSpellScript(spell_dru_enrage); + RegisterSpellScript(spell_dru_entangling_roots); RegisterSpellScript(spell_dru_ferocious_bite); RegisterSpellScript(spell_dru_firebloom); RegisterSpellScript(spell_dru_frenzied_regeneration);