All pastes #825903 Raw Edit

Chestr

public text v1 · immutable
#825903 ·published 2007-12-20 21:50 UTC
rendered paste body
//handle SPELL_AURA_ADD_TARGET_TRIGGER auras
Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER);
for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i)
{
    const SpellEntry *AuraSpell = (*i)->GetSpellProto();
    uint32 index = (*i)->GetEffIndex();
    if (IsAffectedBy(AuraSpell, index))
    {
        int32 chance = 0;
        // Calculate chance at that moment (can be depend for exampe from combo points)
        m_caster->CalculateSpellDamageAndDuration(&chance, NULL, AuraSpell, (*i)->GetEffIndex(), AuraSpell->EffectBasePoints[index]);
        for(std::list<uint64>::iterator iunit= m_targetUnitGUIDs[index].begin();iunit != m_targetUnitGUIDs[index].end();++iunit)
        {
            // check m_caster->GetGUID() let load auras at login and speedup most often case
            Unit* unit = m_caster->GetGUID()==*iunit ? m_caster : ObjectAccessor::GetUnit(*m_caster,*iunit);
            if (unit && unit->isAlive() && roll_chance_i(chance))
                m_caster->CastSpell(unit, AuraSpell->EffectTriggerSpell[index], true, NULL, (*i));
        }
    }
}


void Player::resetComboPointsIfNeed(const SpellEntry *spellInfo)
{
   bool needClearCombo = false;
   // Check use combo points in damage calculations
   int comboDamage = spellInfo->EffectPointsPerComboPoint[0] + 
                     spellInfo->EffectPointsPerComboPoint[1] + 
                     spellInfo->EffectPointsPerComboPoint[2];
   if(comboDamage != 0 &&  m_attacking && (m_attacking->GetGUID() == GetComboTarget()))
        needClearCombo = true;
   // Check in duration calculations
   int32 minduration = GetDuration(spellInfo);
   int32 maxduration = GetMaxDuration(spellInfo);
   if( minduration != -1 && minduration != maxduration )
        needClearCombo = true;

   // overpower - need reset combopoints
   if(spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellFamilyFlags == 0x4)
        needClearCombo = true;
   // Reset if need
   if (needClearCombo)
       ClearComboPoints();
}