Example #1
0
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<uint32> const* masterySpells = GetTalentTreeMasterySpells(m_talentsPrimaryTree[m_activeSpec]);
    if (!masterySpells)
        return;

    for (uint32 i = 0; i < masterySpells->size(); ++i)
    {
        SpellAuraHolder* holder = GetSpellAuraHolder(masterySpells->at(i));
        if (!holder)
            continue;

        SpellEntry const* spellEntry = holder->GetSpellProto();

        // calculate mastery scaling coef
        int32 masteryCoef = GetMasteryCoefficient(spellEntry);
        if (!masteryCoef)
            continue;

        // update aura modifiers
        for (uint32 j = 0; j < MAX_EFFECT_INDEX; ++j)
        {
            Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(j));
            if (!aura)
                continue;

            if (spellEntry->CalculateSimpleValue(SpellEffectIndex(j)))
                continue;

            aura->ApplyModifier(false, false);
            aura->GetModifier()->m_amount = int32(masteryValue * masteryCoef / 100.0f);
            aura->ApplyModifier(true, false);
        }
    }
}