From 3d820399bbd4892454708f59e6b84d3c47808c0f Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 7 Nov 2019 20:25:13 +0100 Subject: [PATCH] Core/Units: ported additional fixups for taken spell bonus damage from 335 branch and fixed an issue that was causing flag damage bonus values for liquid damage auras not taking provided benefits --- src/server/game/Entities/Unit/Unit.cpp | 88 ++++++++++---------------- 1 file changed, 32 insertions(+), 56 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c387aa8a18..c7dbfa0ec3 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6671,8 +6671,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin // Done fixed damage bonus auras int32 DoneAdvertisedBenefit = SpellBaseDamageBonusDone(spellProto->GetSchoolMask()); - // modify spell power by victim's SPELL_AURA_MOD_DAMAGE_TAKEN auras (eg Amplify/Dampen Magic) - DoneAdvertisedBenefit += victim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_DAMAGE_TAKEN, spellProto->GetSchoolMask()); // Check for table values float coeff = spellProto->Effects[effIndex].BonusMultiplier; @@ -6944,17 +6942,18 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui if (!spellProto || damagetype == DIRECT_DAMAGE) return pdamage; - int32 TakenTotal = 0; float TakenTotalMod = 1.0f; - float TakenTotalCasterMod = 0.0f; + int32 TakenTotalFlat = SpellBaseDamageBonusTaken(SpellSchoolMask(spellProto->SchoolMask)); // Mod damage from spell mechanic if (uint32 mechanicMask = spellProto->GetAllEffectsMechanicMask()) { - AuraEffectList const& mDamageDoneMechanic = GetAuraEffectsByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT); - for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i) - if (mechanicMask & uint32(1 << ((*i)->GetMiscValue()))) - AddPct(TakenTotalMod, (*i)->GetAmount()); + TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT, [mechanicMask](AuraEffect const* aurEff) -> bool + { + if (mechanicMask & uint32(1 << (aurEff->GetMiscValue()))) + return true; + return false; + }); } // from positive and negative SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN @@ -6974,64 +6973,43 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui break; } } + // Spells with SPELL_ATTR4_FIXED_DAMAGE should only benefit from mechanic damage mod auras. if (!spellProto->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) { - // get all auras from caster that allow the spell to ignore resistance (sanctified wrath) - AuraEffectList const& IgnoreResistAuras = caster->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST); - for (AuraEffectList::const_iterator i = IgnoreResistAuras.begin(); i != IgnoreResistAuras.end(); ++i) - { - if ((*i)->GetMiscValue() & spellProto->GetSchoolMask()) - TakenTotalCasterMod += (float((*i)->GetAmount())); - } + // from positive and negative SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN + // multiplicative bonus, for example Dispersion + Shadowform (0.10*0.85=0.085) + TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, spellProto->GetSchoolMask()); // From caster spells - AuraEffectList const& mOwnerTaken = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER); - for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i) - if ((*i)->GetCasterGUID() == caster->GetGUID() && (*i)->IsAffectingSpell(spellProto)) - AddPct(TakenTotalMod, (*i)->GetAmount()); - - int32 TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(spellProto->GetSchoolMask()); - - // Check for table values - float coeff = 0; - if (SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id)) - coeff = (damagetype == DOT) ? bonus->dot_damage : bonus->direct_damage; - - // Default calculation - if (TakenAdvertisedBenefit) + if (caster) { - if (coeff < 0) - coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack); - - // level penalty still applied on Taken bonus - is it blizzlike? - if (Player* modOwner = GetSpellModOwner()) - { - coeff *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); - coeff /= 100.0f; - } - TakenTotal += int32(TakenAdvertisedBenefit * coeff * stack); + TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_DAMAGE_FROM_CASTER, [caster, spellProto](AuraEffect const* aurEff) -> bool + { + if (aurEff->GetCasterGUID() == caster->GetGUID() && aurEff->IsAffectingSpell(spellProto)) + return true; + return false; + }); } } - float tmpDamage = 0.0f; - - if (TakenTotalCasterMod) + // Sanctified Wrath (bypass damage reduction) + if (caster && TakenTotalMod < 1.0f) { - if (TakenTotal < 0) + float damageReduction = 1.0f - TakenTotalMod; + Unit::AuraEffectList const& casterIgnoreResist = caster->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST); + for (AuraEffect const* aurEff : casterIgnoreResist) { - if (TakenTotalMod < 1) - tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenTotal) * TakenTotalMod) + CalculatePct(pdamage, TakenTotalCasterMod)); - else - tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenTotal) + CalculatePct(pdamage, TakenTotalCasterMod)) * TakenTotalMod); - } - else if (TakenTotalMod < 1) - tmpDamage = ((CalculatePct(float(pdamage) + TakenTotal, TakenTotalCasterMod) * TakenTotalMod) + CalculatePct(float(pdamage) + TakenTotal, TakenTotalCasterMod)); - } - if (!tmpDamage) - tmpDamage = (float(pdamage) + TakenTotal) * TakenTotalMod; + if (!(aurEff->GetMiscValue() & spellProto->GetSchoolMask())) + continue; + AddPct(damageReduction, -aurEff->GetAmount()); + } + + TakenTotalMod = 1.0f - damageReduction; + } + + float tmpDamage = (pdamage + TakenTotalFlat) * TakenTotalMod; return uint32(std::max(tmpDamage, 0.0f)); } @@ -7484,8 +7462,6 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui // Done fixed damage bonus auras int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(spellProto->GetSchoolMask()); - // modify spell power by victim's SPELL_AURA_MOD_HEALING auras (eg Amplify/Dampen Magic) - DoneAdvertisedBenefit += victim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_HEALING, spellProto->GetSchoolMask()); // Check for table values float coeff = spellProto->Effects[effIndex].BonusMultiplier;