From b9772a93550076d6174cf84840aeb5e90ff823c2 Mon Sep 17 00:00:00 2001 From: Yaki Khadafi Date: Wed, 5 Sep 2012 18:02:46 +0300 Subject: [PATCH] [12184] Implement mastery scaling Signed-off-by: Yaki Khadafi --- src/game/Player.cpp | 3 ++ src/game/Player.h | 1 + src/game/StatSystem.cpp | 64 ++++++++++++++++++++++++++++++++++++++++ src/game/Unit.h | 2 +- src/shared/revision_nr.h | 2 +- 5 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 834e4cbc3..ff074edf8 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -5382,6 +5382,9 @@ void Player::UpdateRating(CombatRating cr) if (affectStats) UpdateArmorPenetration(); break; + case CR_MASTERY: + UpdateMasteryAuras(); + break; // deprecated case CR_HIT_TAKEN_MELEE: case CR_HIT_TAKEN_RANGED: diff --git a/src/game/Player.h b/src/game/Player.h index c0830ba41..cd5078005 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1847,6 +1847,7 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateArmorPenetration(); void ApplyManaRegenBonus(int32 amount, bool apply); void UpdateManaRegen(); + void UpdateMasteryAuras(); ObjectGuid const& GetLootGuid() const { return m_lootGuid; } void SetLootGuid(ObjectGuid const& guid) { m_lootGuid = guid; } diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index a35d90f89..c77cff0eb 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -781,6 +781,70 @@ void Player::UpdateManaRegen() SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, power_regen_mp5 + power_regen); } +void Player::UpdateMasteryAuras() +{ + if (!HasAuraType(SPELL_AURA_MASTERY)) + { + SetFloatValue(PLAYER_MASTERY, 0.0f); + return; + } + + float masteryValue = GetTotalAuraModifier(SPELL_AURA_MASTERY) + GetRatingBonusValue(CR_MASTERY); + SetFloatValue(PLAYER_MASTERY, masteryValue); + + std::vector const* masterySpells = GetTalentTreeMasterySpells(m_talentsPrimaryTree[m_activeSpec]); + if (!masterySpells) + return; + + for (int i = 0; i < masterySpells->size(); ++i) + { + SpellAuraHolder* holder = GetSpellAuraHolder(masterySpells->at(i)); + if (!holder) + continue; + + SpellEntry const* spellEntry = holder->GetSpellProto(); + + // Find mastery scaling coef + int32 masteryBonus = 0; + for (uint32 j = 0; j < MAX_EFFECT_INDEX; ++j) + { + SpellEffectEntry const * effectEntry = spellEntry->GetSpellEffect(SpellEffectIndex(j)); + if (!effectEntry) + continue; + + // mastery scaling coef is stored in dummy aura, except 77215 (Potent Afflictions, zero effect) + // and 76808 (Executioner, not stored at all) + uint32 bp = effectEntry->CalculateSimpleValue(); + if (holder->GetId() == 76808) + bp = 250; + + if (!bp) + continue; + + masteryBonus = bp; + break; + } + + if (!masteryBonus) + continue; + + // update aura modifiers + for (uint32 j = 0; j < MAX_EFFECT_INDEX; ++j) + { + Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(j)); + if (!aura) + continue; + + if (aura->GetSpellProto()->CalculateSimpleValue(SpellEffectIndex(j))) + continue; + + aura->ApplyModifier(false, false); + aura->GetModifier()->m_amount = int32(masteryValue * masteryBonus / 100.0f); + aura->ApplyModifier(true, false); + } + } +} + void Player::_ApplyAllStatBonuses() { SetCanModifyStats(false); diff --git a/src/game/Unit.h b/src/game/Unit.h index fad4034b3..cb484ffe0 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -335,7 +335,7 @@ enum UnitMods UNIT_MOD_STAT_INTELLECT, UNIT_MOD_STAT_SPIRIT, UNIT_MOD_HEALTH, - UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_RUNIC_POWER must be in existing order, it's accessed by index values of Powers enum. + UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_ALTERNATIVE must be in existing order, it's accessed by index values of Powers enum. UNIT_MOD_RAGE, UNIT_MOD_FOCUS, UNIT_MOD_ENERGY, diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 0b9afddb7..98ec24abd 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12183" + #define REVISION_NR "12184" #endif // __REVISION_NR_H__