diff --git a/Source/Game/Entities/StatSystem.cs b/Source/Game/Entities/StatSystem.cs index 33b2c0e48..12682cd49 100644 --- a/Source/Game/Entities/StatSystem.cs +++ b/Source/Game/Entities/StatSystem.cs @@ -1640,19 +1640,13 @@ namespace Game.Entities if (chrSpec == null) return; - foreach (uint masterySpellId in chrSpec.MasterySpellID) + foreach (var (_, aura) in GetOwnedAuras()) { - Aura aura = GetAura(masterySpellId); - if (aura != null) + if (aura.GetCasterGUID() == GetGUID() && aura.GetSpellInfo().HasAttribute(SpellAttr8.MasteryAffectsPoints)) { - foreach (var spellEffectInfo in aura.GetSpellInfo().GetEffects()) - { - float mult = spellEffectInfo.BonusCoefficient; - if (MathFunctions.fuzzyEq(mult, 0.0f)) - continue; - - aura.GetEffect(spellEffectInfo.EffectIndex).ChangeAmount((int)(value * mult)); - } + foreach (var auraEff in aura.GetAuraEffects()) + if (MathFunctions.fuzzyEq(auraEff.GetSpellEffectInfo().BonusCoefficient, 0.0f)) + auraEff.RecalculateAmount(this); } } } diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 1766c487e..8d09ae9f2 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -58,13 +58,10 @@ namespace Game.Spells public int CalculateAmount(Unit caster) { - // default amount calculation - int amount = 0; + Unit unitOwner = GetBase().GetOwner().ToUnit(); - if (!m_spellInfo.HasAttribute(SpellAttr8.MasteryAffectsPoints) || MathFunctions.fuzzyEq(GetSpellEffectInfo().BonusCoefficient, 0.0f)) - amount = GetSpellEffectInfo().CalcValue(caster, m_baseAmount, GetBase().GetOwner().ToUnit(), GetBase().GetCastItemId(), GetBase().GetCastItemLevel()); - else if (caster != null && caster.IsTypeId(TypeId.Player)) - amount = (int)(caster.ToPlayer().m_activePlayerData.Mastery * GetSpellEffectInfo().BonusCoefficient); + // default amount calculation + int amount = GetSpellEffectInfo().CalcValue(caster, m_baseAmount, unitOwner, GetBase().GetCastItemId(), GetBase().GetCastItemLevel()); // custom amount calculations go here switch (GetAuraType()) @@ -79,7 +76,7 @@ namespace Game.Spells m_canBeRecalculated = false; if (m_spellInfo.ProcFlags == null) break; - amount = (int)(GetBase().GetUnitOwner().CountPctFromMaxHealth(10)); + amount = (int)unitOwner.CountPctFromMaxHealth(10); break; case AuraType.SchoolAbsorb: case AuraType.ManaShield: @@ -91,7 +88,7 @@ namespace Game.Spells if (mountEntry != null) mountType = mountEntry.MountTypeID; - var mountCapability = GetBase().GetUnitOwner().GetMountCapability(mountType); + var mountCapability = unitOwner.GetMountCapability(mountType); if (mountCapability != null) amount = (int)mountCapability.Id; break; @@ -106,7 +103,7 @@ namespace Game.Spells if (GetSpellInfo().HasAttribute(SpellAttr10.RollingPeriodic)) { - var periodicAuras = GetBase().GetUnitOwner().GetAuraEffectsByType(GetAuraType()); + var periodicAuras = unitOwner.GetAuraEffectsByType(GetAuraType()); uint totalTicks = GetTotalTicks(); if (totalTicks != 0) { diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index 6243b222a..46e7c6566 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -4123,6 +4123,7 @@ namespace Game.Spells value += level * basePointsPerLevel; } } + // random damage if (casterUnit != null) { @@ -4133,11 +4134,19 @@ namespace Game.Spells if (comboPoints != 0) value += comboDamage * comboPoints; } - - if (caster != null) - value = caster.ApplyEffectModifiers(_spellInfo, EffectIndex, value); } + if (_spellInfo.HasAttribute(SpellAttr8.MasteryAffectsPoints)) + { + Player playerCaster = caster?.ToPlayer(); + if (playerCaster != null) + value += playerCaster.m_activePlayerData.Mastery * BonusCoefficient; + } + + if (caster != null) + value = caster.ApplyEffectModifiers(_spellInfo, EffectIndex, value); + + return (int)Math.Round(value); }