From 96ee23487fe2a5fc2cf79e5d2ec4ec38b965e70d Mon Sep 17 00:00:00 2001 From: ariel- Date: Fri, 2 Jun 2017 14:12:53 -0300 Subject: Core/Scripts: moved Wild Growth calculation to script and fixed formula Thanks ccrs for the formula --- src/server/scripts/Spells/spell_druid.cpp | 43 +++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'src/server/scripts/Spells') diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 6e8b3130163..59ccf7a8bda 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -85,7 +85,8 @@ enum DruidSpells SPELL_DRUID_REJUVENATION_T10_PROC = 70691, SPELL_DRUID_BALANCE_T10_BONUS = 70718, SPELL_DRUID_BALANCE_T10_BONUS_PROC = 70721, - SPELL_DRUID_BARKSKIN_01 = 63058 + SPELL_DRUID_BARKSKIN_01 = 63058, + SPELL_DRUID_RESTORATION_T10_2P_BONUS = 70658 }; // 22812 - Barkskin @@ -2264,14 +2265,52 @@ class spell_dru_wild_growth : public SpellScriptLoader OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_wild_growth_SpellScript::SetTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ALLY); } - private: std::list _targets; }; + class spell_dru_wild_growth_AuraScript : public AuraScript + { + PrepareAuraScript(spell_dru_wild_growth_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_DRUID_RESTORATION_T10_2P_BONUS }); + } + + void HandleTickUpdate(AuraEffect* aurEff) + { + Unit* caster = GetCaster(); + if (!caster) + return; + + // calculate from base damage, not from aurEff->GetAmount() (already modified) + float damage = caster->CalculateSpellDamage(GetUnitOwner(), GetSpellInfo(), aurEff->GetEffIndex()); + + // Wild Growth = first tick gains a 6% bonus, reduced by 2% each tick + float reduction = 2.f; + if (AuraEffect* bonus = caster->GetAuraEffect(SPELL_DRUID_RESTORATION_T10_2P_BONUS, EFFECT_0)) + reduction -= CalculatePct(reduction, bonus->GetAmount()); + reduction *= (aurEff->GetTickNumber() - 1); + + AddPct(damage, 6.f - reduction); + aurEff->SetAmount(int32(damage)); + } + + void Register() override + { + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_dru_wild_growth_AuraScript::HandleTickUpdate, EFFECT_0, SPELL_AURA_PERIODIC_HEAL); + } + }; + SpellScript* GetSpellScript() const override { return new spell_dru_wild_growth_SpellScript(); } + + AuraScript* GetAuraScript() const override + { + return new spell_dru_wild_growth_AuraScript(); + } }; void AddSC_druid_spell_scripts() -- cgit v1.2.3