aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-01-13 19:57:20 -0300
committerShauren <shauren.trinity@gmail.com>2021-06-14 01:17:43 +0200
commitbec829df0a51b4597e40d0f8638a4d6bf1788977 (patch)
treed93966a7b67bf006b1d0b3d68371b85c5bd548d9 /src
parent5fbddef85f48f6b9140d025d7f2e14faae0af178 (diff)
Core/Unit: simplified and arranged spell bonus calculation
- Remove duplicated SPELLMOD_BONUS_MULTIPLIER handling (both on done and taken) - Handle properly bonus data, don't apply bonus by default, only player spells should take into account spell power - Moved Earthliving Weapon coefficient to DB - Refactored Avenging Wrath handling Closes #13287 Closes #21230 (cherry picked from commit d570e2af3e7bcb625d8941397d55972d49319a8f)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp110
1 files changed, 47 insertions, 63 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 94dffe2efaf..de95cee92b2 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -6829,7 +6829,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
// Default calculation
float coeff = effect->BonusCoefficient;
- if (DoneAdvertisedBenefit)
+ if (coeff && DoneAdvertisedBenefit)
{
if (Player* modOwner = GetSpellModOwner())
{
@@ -6837,6 +6837,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
modOwner->ApplySpellMod(spellProto, SpellModOp::BonusCoefficient, coeff);
coeff /= 100.0f;
}
+
DoneTotal += int32(DoneAdvertisedBenefit * coeff * stack);
}
@@ -6937,7 +6938,6 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
int32 TakenTotal = 0;
float TakenTotalMod = 1.0f;
- float TakenTotalCasterMod = 0.0f;
// Mod damage from spell mechanic
if (uint32 mechanicMask = spellProto->GetAllEffectsMechanicMask())
@@ -6957,9 +6957,6 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
// 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)
- TakenTotalCasterMod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_IGNORE_TARGET_RESIST, spellProto->GetSchoolMask());
-
// Versatility
if (Player* modOwner = GetSpellModOwner())
{
@@ -6973,15 +6970,18 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, spellProto->GetSchoolMask());
// From caster spells
- TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_SCHOOL_MASK_DAMAGE_FROM_CASTER, [caster, spellProto](AuraEffect const* aurEff) -> bool
+ if (caster)
{
- return aurEff->GetCasterGUID() == caster->GetGUID() && (aurEff->GetMiscValue() & spellProto->GetSchoolMask());
- });
+ TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_SCHOOL_MASK_DAMAGE_FROM_CASTER, [caster, spellProto](AuraEffect const* aurEff) -> bool
+ {
+ return aurEff->GetCasterGUID() == caster->GetGUID() && (aurEff->GetMiscValue() & spellProto->GetSchoolMask());
+ });
- TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_SPELL_DAMAGE_FROM_CASTER, [caster, spellProto](AuraEffect const* aurEff) -> bool
- {
- return aurEff->GetCasterGUID() == caster->GetGUID() && aurEff->IsAffectingSpell(spellProto);
- });
+ TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_SPELL_DAMAGE_FROM_CASTER, [caster, spellProto](AuraEffect const* aurEff) -> bool
+ {
+ return aurEff->GetCasterGUID() == caster->GetGUID() && aurEff->IsAffectingSpell(spellProto);
+ });
+ }
if (damagetype == DOT)
{
@@ -6999,34 +6999,27 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
// Default calculation
if (TakenAdvertisedBenefit)
{
- // level penalty still applied on Taken bonus - is it blizzlike?
- if (Player* modOwner = GetSpellModOwner())
- {
- coeff *= 100.0f;
- modOwner->ApplySpellMod(spellProto, SpellModOp::BonusCoefficient, coeff);
- coeff /= 100.0f;
- }
TakenTotal += int32(TakenAdvertisedBenefit * coeff * stack);
}
}
- 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);
+ if (!(aurEff->GetMiscValue() & spellProto->GetSchoolMask()))
+ continue;
+
+ ApplyPct(damageReduction, aurEff->GetAmount());
}
- else if (TakenTotalMod < 1)
- tmpDamage = ((CalculatePct(float(pdamage) + TakenTotal, TakenTotalCasterMod) * TakenTotalMod) + CalculatePct(float(pdamage) + TakenTotal, TakenTotalCasterMod));
+
+ TakenTotalMod = 1.0f - damageReduction;
}
- if (!tmpDamage)
- tmpDamage = (float(pdamage) + TakenTotal) * TakenTotalMod;
+ float tmpDamage = float(pdamage + TakenTotal) * TakenTotalMod;
return uint32(std::max(tmpDamage, 0.0f));
}
@@ -7328,7 +7321,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
}
// Default calculation
- if (DoneAdvertisedBenefit)
+ if (coeff && DoneAdvertisedBenefit)
{
if (Player* modOwner = GetSpellModOwner())
{
@@ -7463,13 +7456,6 @@ uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, u
// Default calculation
if (TakenAdvertisedBenefit)
{
- if (Player* modOwner = GetSpellModOwner())
- {
- coeff *= 100.0f;
- modOwner->ApplySpellMod(spellProto, SpellModOp::BonusCoefficient, coeff);
- coeff /= 100.0f;
- }
-
TakenTotal += int32(TakenAdvertisedBenefit * coeff * stack);
}
@@ -7485,12 +7471,15 @@ uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, u
AddPct(TakenTotalMod, maxval_hot);
}
- TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_RECEIVED, [caster, spellProto](AuraEffect const* aurEff) -> bool
+ if (caster)
{
- if (caster->GetGUID() == aurEff->GetCasterGUID() && aurEff->IsAffectingSpell(spellProto))
- return true;
- return false;
- });
+ TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_RECEIVED, [caster, spellProto](AuraEffect const* aurEff) -> bool
+ {
+ if (caster->GetGUID() == aurEff->GetCasterGUID() && aurEff->IsAffectingSpell(spellProto))
+ return true;
+ return false;
+ });
+ }
for (SpellEffectInfo const* effect : spellProto->GetEffects())
{
@@ -7859,11 +7848,6 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT
return 0;
int32 TakenFlatBenefit = 0;
- float TakenTotalCasterMod = 0.0f;
-
- // get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
- SpellSchoolMask const attackSchoolMask = spellProto ? spellProto->GetSchoolMask() : SPELL_SCHOOL_MASK_NORMAL;
- TakenTotalCasterMod += attacker->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_IGNORE_TARGET_RESIST, attackSchoolMask);
// ..taken
TakenFlatBenefit += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_DAMAGE_TAKEN, attacker->GetMeleeDamageSchoolMask());
@@ -7935,24 +7919,25 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT
AddPct(TakenTotalMod, -(modOwner->GetRatingBonusValue(CR_VERSATILITY_DAMAGE_TAKEN) + versaBonus));
}
- float tmpDamage = 0.0f;
-
- if (TakenTotalCasterMod)
+ // Sanctified Wrath (bypass damage reduction)
+ if (attacker && TakenTotalMod < 1.0f)
{
- if (TakenFlatBenefit < 0)
+ SpellSchoolMask const attackSchoolMask = spellProto ? spellProto->GetSchoolMask() : SPELL_SCHOOL_MASK_NORMAL;
+
+ float damageReduction = 1.0f - TakenTotalMod;
+ Unit::AuraEffectList const& casterIgnoreResist = attacker->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
+ for (AuraEffect const* aurEff : casterIgnoreResist)
{
- if (TakenTotalMod < 1)
- tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenFlatBenefit) * TakenTotalMod) + CalculatePct(pdamage, TakenTotalCasterMod));
- else
- tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenFlatBenefit) + CalculatePct(pdamage, TakenTotalCasterMod)) * TakenTotalMod);
+ if (!(aurEff->GetMiscValue() & attackSchoolMask))
+ continue;
+
+ ApplyPct(damageReduction, aurEff->GetAmount());
}
- else if (TakenTotalMod < 1)
- tmpDamage = ((CalculatePct(float(pdamage) + TakenFlatBenefit, TakenTotalCasterMod) * TakenTotalMod) + CalculatePct(float(pdamage) + TakenFlatBenefit, TakenTotalCasterMod));
+
+ TakenTotalMod = 1.0f - damageReduction;
}
- if (!tmpDamage)
- tmpDamage = (float(pdamage) + TakenFlatBenefit) * TakenTotalMod;
- // bonus result can be negative
+ float tmpDamage = float(pdamage + TakenFlatBenefit) * TakenTotalMod;
return uint32(std::max(tmpDamage, 0.0f));
}
@@ -11168,7 +11153,6 @@ float Unit::CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffect
float DotFactor = 1.0f;
if (damagetype == DOT)
{
-
int32 DotDuration = spellInfo->GetDuration();
if (!spellInfo->IsChanneled() && DotDuration > 0)
DotFactor = DotDuration / 15000.0f;