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

[svn] Remove isVisible function. Check stealth and invisible in canAttack();
Use new remove aura by interrupt flag function.

Original author: megamage
Date: 2008-11-07 09:36:46-06:00

Files:
1 modified

Legend:

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

    r179 r186  
    464464} 
    465465 
    466 void Unit::RemoveInterruptableAura(uint32 flag) 
     466void Unit::RemoveAurasWithInterruptFlags(uint32 flag) 
    467467{ 
    468468    AuraList::iterator iter, next; 
     
    510510    if( damagetype != DOT) 
    511511    { 
    512         RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); 
     512        RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); 
    513513 
    514514        if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) 
     
    41014101                ++iter; 
    41024102        } 
    4103     } 
    4104 } 
    4105  
    4106 void Unit::RemoveAurasWithInterruptFlags(uint32 flags) 
    4107 { 
    4108     for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) 
    4109     { 
    4110         if (iter->second->GetSpellProto()->AuraInterruptFlags & flags) 
    4111             RemoveAura(iter); 
    4112         else 
    4113             ++iter; 
    41144103    } 
    41154104} 
     
    85078496} 
    85088497 
     8498//TODO: remove this function 
    85098499bool Unit::isTargetableForAttack() const 
    85108500{ 
    8511     if (GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) 
     8501    return isAttackableByAOE() && !hasUnitState(UNIT_STAT_DIED); 
     8502} 
     8503 
     8504bool Unit::canAttack(Unit const* target) const 
     8505{ 
     8506    assert(target); 
     8507 
     8508    if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) 
     8509        return false; 
     8510 
     8511    if((m_invisibilityMask || target->m_invisibilityMask) && !canDetectInvisibilityOf(target)) 
     8512        return false; 
     8513 
     8514    if(target->GetVisibility() == VISIBILITY_GROUP_STEALTH && !canDetectStealthOf(target, GetDistance(target))) 
     8515        return false; 
     8516 
     8517    return true; 
     8518} 
     8519 
     8520bool Unit::isAttackableByAOE() const 
     8521{ 
     8522    if(!isAlive()) 
    85128523        return false; 
    85138524 
     
    85158526        return false; 
    85168527 
    8517     return isAlive() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/; 
     8528    if(GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) 
     8529        return false; 
     8530 
     8531    return !isInFlight(); 
    85188532} 
    85198533 
     
    90679081        for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) 
    90689082        { 
    9069             if( (*itr)->IsInMap(this) && (*itr)->isTargetableForAttack() && (*itr)->isInAccessablePlaceFor((Creature*)this) ) 
     9083            if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccessablePlaceFor((Creature*)this) ) 
    90709084                return false; 
    90719085        }