Exemple #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);
        }
    }
}
Exemple #2
0
bool BSWScriptedAI::_doAura(uint32 SpellID, Unit* pTarget, SpellEffectIndex index, int32 basepoint, bool isStack)
{
    if (!pTarget || !pTarget->IsInMap(m_creature) || !pTarget->isAlive())
    {
        error_log("BSW: FAILED adding aura of spell number %u - no target or target not in map or target is dead",SpellID);
        return false;
    }

    if (_hasAura(SpellID,pTarget))
         debug_log("BSW: adding aura stack from spell %u index %u",SpellID, index);
    else debug_log("BSW: adding new aura from spell %u index %u",SpellID, index);

    SpellEntry const *spell = (SpellEntry *)GetSpellStore()->LookupEntry(SpellID);

    if (spell)
    {
        if (IsSpellAppliesAura(spell, (1 << EFFECT_INDEX_0) | (1 << EFFECT_INDEX_1) | (1 << EFFECT_INDEX_2)) || IsSpellHaveEffect(spell, SPELL_EFFECT_PERSISTENT_AREA_AURA))
        {
            int32 _basepoint = basepoint ?  basepoint - 1 : spell->EffectBasePoints[index] + 1;

            bool addedToExisting = true;

            SpellAuraHolderPtr holder = pTarget->GetSpellAuraHolder(SpellID, pTarget->GetObjectGuid());

            Aura* aura = NULL;

            if (!holder)
            {
                holder = CreateSpellAuraHolder(spell, pTarget, pTarget);
                addedToExisting = false;
            }


            if (aura = holder->GetAuraByEffectIndex(index))
            {
                if (isStack)
                    holder->ModStackAmount(1);
            }
            else
            {
                aura = holder->CreateAura(spell, index, &_basepoint, holder, pTarget, m_creature, NULL);
                holder->SetAuraDuration(aura->GetAuraMaxDuration());
            }

            if (addedToExisting)
            {
                pTarget->AddAuraToModList(aura);
                holder->SetInUse(true);
                aura->ApplyModifier(true,true);
                holder->SetInUse(false);
            }
            else
                pTarget->AddSpellAuraHolder(holder);

            return true;
        }
    }

    error_log("BSW: FAILED adding aura from spell %u index %u",SpellID, index);

    return false;
};