From 5101026143cd9f50d2244682fa82cd232841b4f1 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 18 Jan 2023 17:28:26 +0100 Subject: [PATCH] Core/Spells: fixed Anti-Magic Zone absorb behavior and amount calculation --- src/server/scripts/Spells/spell_dk.cpp | 34 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 7e3722d110..bfa79b7f8f 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -149,7 +149,14 @@ class spell_dk_anti_magic_zone : public AuraScript { bool Load() override { - absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(GetCaster()); + _absorbAmount = 0; + if (!GetCaster()->IsSummon()) + return true; + + TempSummon* summon = GetCaster()->ToTempSummon(); + if (Unit* summoner = summon->GetSummoner()) + _absorbAmount = sSpellMgr->AssertSpellInfo(SPELL_DK_ANTI_MAGIC_SHELL_TALENT)->Effects[0].CalcValue(summoner) + 2 * summoner->GetTotalAttackPowerValue(BASE_ATTACK); + return true; } @@ -158,26 +165,29 @@ class spell_dk_anti_magic_zone : public AuraScript return ValidateSpellInfo({ SPELL_DK_ANTI_MAGIC_SHELL_TALENT }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + void Absorb(AuraEffect* aurEff, DamageInfo& damageInfo, uint32& /*absorbAmount*/) { - SpellInfo const* talentSpell = sSpellMgr->AssertSpellInfo(SPELL_DK_ANTI_MAGIC_SHELL_TALENT); - amount = talentSpell->Effects[EFFECT_0].CalcValue(GetCaster()); - if (Player* player = GetCaster()->ToPlayer()) - amount += int32(2 * player->GetTotalAttackPowerValue(BASE_ATTACK)); - } + PreventDefaultAction(); - void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) - { - absorbAmount = CalculatePct(dmgInfo.GetDamage(), absorbPct); + int32 currentAbsorb = _absorbAmount; + currentAbsorb = RoundToInterval(currentAbsorb, 0, CalculatePct(damageInfo.GetDamage(), aurEff->GetAmount())); + damageInfo.AbsorbDamage(currentAbsorb); + + if (_absorbAmount >= 0) + { + _absorbAmount -= currentAbsorb; + if (_absorbAmount <= 0) + if (Unit* caster = GetCaster()) + caster->InterruptNonMeleeSpells(true); + } } void Register() override { - DoEffectCalcAmount.Register(&spell_dk_anti_magic_zone::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); OnEffectAbsorb.Register(&spell_dk_anti_magic_zone::Absorb, EFFECT_0); } private: - uint32 absorbPct = 0; + int32 _absorbAmount = 0; }; // 48721 - Blood Boil