From 895ee5b02c98e3cf0ce2e740e10f9fa370649561 Mon Sep 17 00:00:00 2001 From: Khral Steelforge Date: Wed, 22 Aug 2018 15:33:51 +0700 Subject: [PATCH] Spells/Druid Fix Shred damage (#81) --- .../world/2018_08_20_01_world_spell_shred.sql | 3 + src/server/scripts/Spells/spell_druid.cpp | 62 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 sql/ashamane/world/2018_08_20_01_world_spell_shred.sql diff --git a/sql/ashamane/world/2018_08_20_01_world_spell_shred.sql b/sql/ashamane/world/2018_08_20_01_world_spell_shred.sql new file mode 100644 index 0000000000000..0e4edb272976c --- /dev/null +++ b/sql/ashamane/world/2018_08_20_01_world_spell_shred.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `spell_id` = '5221'; +INSERT INTO `spell_script_names` VALUE +(5221, "spell_dru_shred"); diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 1651d8cb81104..80df8e60a60e5 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -2402,6 +2402,67 @@ class spell_dru_thrash_cat : public SpellScript bool m_awardComboPoint = true; }; +// Shred - 5221 +class spell_dru_shred : public SpellScript +{ + PrepareSpellScript(spell_dru_shred); + + bool Load() override + { + Unit* caster = GetCaster(); + + if (caster->HasAuraType(SPELL_AURA_MOD_STEALTH)) + m_stealthed = true; + + if (caster->HasAura(SPELL_DRUID_INCARNATION_KING_OF_JUNGLE)) + m_incarnation = true; + + m_casterLevel = caster->GetLevelForTarget(caster); + + return true; + } + + void HandleCritChance(Unit* /*victim*/, float& chance) + { + // If caster is level >= 56, While stealthed or have Incarnation: King of the Jungle aura, + // Double the chance to critically strike + if ((m_casterLevel >= 56) && (m_stealthed || m_incarnation)) + chance *= 2.0f; + } + + void HandleOnEffectHitTarget(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + Unit* target = GetHitUnit(); + if (!caster || !target) + return; + + int32 damage = GetHitDamage(); + + // If caster is level >= 56, While stealthed or have Incarnation: King of the Jungle aura, + // deals 50% increased damage (get value from the spell data) + if ((m_casterLevel >= 56) && (m_stealthed || m_incarnation)) + AddPct(damage, sSpellMgr->GetSpellInfo(SPELL_DRUID_SHRED)->GetEffect(EFFECT_3)->BasePoints); + + // If caster is level >= 44 and the target is bleeding, deals 20% increased damage (get value from the spell data) + if ((m_casterLevel >= 44) && target->HasAuraState(AURA_STATE_BLEEDING)) + AddPct(damage, sSpellMgr->GetSpellInfo(SPELL_DRUID_SHRED)->GetEffect(EFFECT_4)->BasePoints); + + SetHitDamage(damage); + } + + void Register() override + { + OnCalcCritChance += SpellOnCalcCritChanceFn(spell_dru_shred::HandleCritChance); + OnEffectHitTarget += SpellEffectFn(spell_dru_shred::HandleOnEffectHitTarget, EFFECT_4, SPELL_EFFECT_DUMMY); + } + +private: + bool m_stealthed = false; + bool m_incarnation = false; + int32 m_casterLevel; +}; + void AddSC_druid_spell_scripts() { // Spells Scripts @@ -2447,6 +2508,7 @@ void AddSC_druid_spell_scripts() RegisterSpellScript(spell_dru_swipe); RegisterSpellScript(spell_dru_brutal_slash); RegisterSpellScript(spell_dru_thrash_cat); + RegisterSpellScript(spell_dru_shred); RegisterSpellScript(spell_dru_thrash_bear); RegisterAuraScript(aura_dru_thrash_bear);