Show
Ignore:
Timestamp:
11/19/08 13:47:00 (17 years ago)
Author:
yumileroy
Message:

[svn] Fix some aura_interrupt_flag to correctly remove auras.
Add interrupt_flag_unattackable. Source: mangos forum. Adapted by F636y623.
Add function CombatStart?().

Original author: megamage
Date: 2008-11-11 17:49:51-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Unit.cpp

    r186 r213  
    473473 
    474474        //sLog.outDetail("auraflag:%u flag:%u = %u",(*iter)->GetSpellProto()->AuraInterruptFlags,flag,(*iter)->GetSpellProto()->AuraInterruptFlags & flag); 
    475         if(*iter && ((*iter)->GetSpellProto()->AuraInterruptFlags & flag) == flag) 
     475        if(*iter && ((*iter)->GetSpellProto()->AuraInterruptFlags & flag)) 
    476476        { 
    477477            RemoveAurasDueToSpell((*iter)->GetId()); 
     
    489489} 
    490490 
     491/* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ 
     492void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell) 
     493{ 
     494    // The chance to dispel an aura depends on the damage taken with respect to the casters level. 
     495    uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; 
     496    float chance = float(damage) / max_dmg * 100.0f; 
     497 
     498    AuraList::iterator i, next; 
     499    for(i = m_ccAuras.begin(); i != m_ccAuras.end(); i = next) 
     500    { 
     501        next = i; 
     502        ++next; 
     503 
     504        if(*i && (!spell || (*i)->GetId() != spell) && roll_chance_f(chance)) 
     505        { 
     506            RemoveAurasDueToSpell((*i)->GetId()); 
     507            if (!m_ccAuras.empty()) 
     508                next = m_ccAuras.begin(); 
     509            else 
     510                return; 
     511        } 
     512    } 
     513} 
     514 
    491515uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss) 
    492516{ 
     
    510534    if( damagetype != DOT) 
    511535    { 
    512         RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); 
    513  
    514536        if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) 
    515537            pVictim->SetStandState(PLAYER_STATE_NONE); 
     
    889911 
    890912        // TODO: Store auras by interrupt flag to speed this up. 
    891         AuraMap& vAuras = pVictim->GetAuras(); 
     913        /*AuraMap& vAuras = pVictim->GetAuras(); 
    892914        for (AuraMap::iterator i = vAuras.begin(), next; i != vAuras.end(); i = next) 
    893915        { 
     
    909931                } 
    910932            } 
    911             else if ( (se->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) && (!spellProto || se->Id != spellProto->Id) ) 
    912             { 
    913                 uint32 max_dmg = pVictim->getLevel() > 8 ? 25 * pVictim->getLevel() - 150 : 50; 
    914                 float chance = float(damage) / max_dmg * 100.0f; 
    915                 if (roll_chance_f(chance)) 
    916                 { 
    917                     pVictim->RemoveAurasDueToSpell(i->second->GetId()); 
    918                     next = vAuras.begin(); 
    919                 } 
    920             } 
    921         } 
     933            else */ 
     934        RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DAMAGE); 
     935        pVictim->RemoveSpellbyDamageTaken(damage, spellProto ? spellProto->Id : 0); 
    922936 
    923937        if (damagetype != NODAMAGE && damage && pVictim->GetTypeId() == TYPEID_PLAYER) 
     
    21932207        return; 
    21942208 
    2195     if(!pVictim->isInCombat() && pVictim->GetTypeId() != TYPEID_PLAYER && ((Creature*)pVictim)->AI()) 
    2196         ((Creature*)pVictim)->AI()->AttackStart(this); 
    2197  
    2198     SetInCombatWith(pVictim); 
    2199     pVictim->SetInCombatWith(this); 
    2200  
    2201     if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) 
    2202         SetContestedPvP(attackedPlayer); 
     2209    CombatStart(pVictim); 
    22032210 
    22042211    uint32 hitInfo; 
     
    37903797        if(Aur->GetSpellProto()->AuraInterruptFlags) 
    37913798            m_interruptableAuras.push_back(Aur); 
     3799        if(Aur->GetSpellProto()->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) 
     3800        { 
     3801            m_ccAuras.push_back(Aur); 
     3802            RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); 
     3803        } 
    37923804    } 
    37933805 
     
    41534165        if((*i).second->GetSpellProto()->AuraInterruptFlags) 
    41544166            m_interruptableAuras.remove((*i).second); 
     4167        if((*i).second->GetSpellProto()->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) 
     4168            m_ccAuras.remove((*i).second); 
    41554169    } 
    41564170 
     
    83998413        return; 
    84008414 
    8401     RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNTING); 
     8415    RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT); 
    84028416 
    84038417    SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); 
     
    84678481    } 
    84688482    SetInCombatState(false); 
     8483} 
     8484 
     8485void Unit::CombatStart(Unit* target) 
     8486{ 
     8487    if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI()) 
     8488        ((Creature*)target)->AI()->AttackStart(this); 
     8489 
     8490    SetInCombatWith(target); 
     8491    target->SetInCombatWith(this); 
     8492 
     8493    if(Player* attackedPlayer = target->GetCharmerOrOwnerPlayerOrPlayerItself()) 
     8494        SetContestedPvP(attackedPlayer); 
     8495 
     8496    if(!isInCombat()) // remove this? 
     8497        RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ATTACK); 
    84698498} 
    84708499