aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp17
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp15
-rw-r--r--src/server/game/Spells/SpellInfo.cpp4
3 files changed, 14 insertions, 22 deletions
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index bedb30bf968..451d40f25b7 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -550,20 +550,11 @@ void Player::UpdateMastery()
if (!chrSpec)
return;
- for (int32 masterySpellId : chrSpec->MasterySpellID)
- {
- if (Aura* aura = GetAura(masterySpellId))
- {
+ for (auto const& [_, aura] : GetOwnedAuras())
+ if (aura->GetCasterGUID() == GetGUID() && aura->GetSpellInfo()->HasAttribute(SPELL_ATTR8_MASTERY_AFFECTS_POINTS))
for (AuraEffect* auraEff : aura->GetAuraEffects())
- {
- float mult = auraEff->GetSpellEffectInfo().BonusCoefficient;
- if (G3D::fuzzyEq(mult, 0.0f))
- continue;
-
- auraEff->ChangeAmount(int32(value * mult));
- }
- }
- }
+ if (G3D::fuzzyNe(auraEff->GetSpellEffectInfo().BonusCoefficient, 0.0f))
+ auraEff->RecalculateAmount(this);
}
void Player::UpdateVersatilityDamageDone()
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 7b1ef3d960a..4d2749f28e3 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -758,13 +758,10 @@ void AuraEffect::GetApplicationList(Container& applicationContainer) const
int32 AuraEffect::CalculateAmount(Unit* caster)
{
- // default amount calculation
- int32 amount = 0;
+ Unit* unitOwner = GetBase()->GetOwner()->ToUnit();
- if (!m_spellInfo->HasAttribute(SPELL_ATTR8_MASTERY_AFFECTS_POINTS) || G3D::fuzzyEq(GetSpellEffectInfo().BonusCoefficient, 0.0f))
- amount = GetSpellEffectInfo().CalcValue(caster, &m_baseAmount, GetBase()->GetOwner()->ToUnit(), nullptr, GetBase()->GetCastItemId(), GetBase()->GetCastItemLevel());
- else if (caster && caster->GetTypeId() == TYPEID_PLAYER)
- amount = int32(caster->ToPlayer()->m_activePlayerData->Mastery * GetSpellEffectInfo().BonusCoefficient);
+ // default amount calculation
+ int32 amount = GetSpellEffectInfo().CalcValue(caster, &m_baseAmount, unitOwner, nullptr, GetBase()->GetCastItemId(), GetBase()->GetCastItemLevel());
// custom amount calculations go here
switch (GetAuraType())
@@ -779,7 +776,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
m_canBeRecalculated = false;
if (!m_spellInfo->ProcFlags)
break;
- amount = int32(GetBase()->GetUnitOwner()->CountPctFromMaxHealth(10));
+ amount = int32(unitOwner->CountPctFromMaxHealth(10));
break;
case SPELL_AURA_SCHOOL_ABSORB:
case SPELL_AURA_MANA_SHIELD:
@@ -791,7 +788,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
if (MountEntry const* mountEntry = sDB2Manager.GetMount(GetId()))
mountType = mountEntry->MountTypeID;
- if (MountCapabilityEntry const* mountCapability = GetBase()->GetUnitOwner()->GetMountCapability(mountType))
+ if (MountCapabilityEntry const* mountCapability = unitOwner->GetMountCapability(mountType))
amount = mountCapability->ID;
break;
}
@@ -806,7 +803,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
if (GetSpellInfo()->HasAttribute(SPELL_ATTR10_ROLLING_PERIODIC))
{
- Unit::AuraEffectList const& periodicAuras = GetBase()->GetUnitOwner()->GetAuraEffectsByType(GetAuraType());
+ Unit::AuraEffectList const& periodicAuras = unitOwner->GetAuraEffectsByType(GetAuraType());
if (uint32 totalTicks = GetTotalTicks())
{
amount = std::accumulate(std::begin(periodicAuras), std::end(periodicAuras), amount, [&](int32 val, AuraEffect const* aurEff)
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index ff1c34de729..5cadd602089 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -545,6 +545,10 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
value += comboDamage * comboPoints;
}
+ if (_spellInfo->HasAttribute(SPELL_ATTR8_MASTERY_AFFECTS_POINTS))
+ if (Player const* playerCaster = Object::ToPlayer(caster))
+ value += *playerCaster->m_activePlayerData->Mastery * BonusCoefficient;
+
if (caster)
value = caster->ApplyEffectModifiers(_spellInfo, EffectIndex, value);