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

[svn] Rewrite canSeeOrDetect function.
Minor change on trigger creatures.
Remove some unused hacks in scripts.

Original author: megamage
Date: 2008-11-06 10:27:58-06:00

Files:
1 modified

Legend:

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

    r174 r178  
    319319    m_spells[2] = GetCreatureInfo()->spell3; 
    320320    m_spells[3] = GetCreatureInfo()->spell4; 
     321 
     322    // HACK: trigger creature is always not selectable 
     323    if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) 
     324        SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); 
    321325 
    322326    return true; 
     
    14881492} 
    14891493 
     1494bool Creature::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const 
     1495{ 
     1496    // not in world 
     1497    if(!IsInWorld() || !u->IsInWorld()) 
     1498        return false; 
     1499 
     1500    // all dead creatures/players not visible for any creatures 
     1501    if(!u->isAlive() || !isAlive()) 
     1502        return false; 
     1503 
     1504    // Always can see self 
     1505    if (u == this) 
     1506        return true; 
     1507 
     1508    // always seen by owner 
     1509    if(GetGUID() == u->GetCharmerOrOwnerGUID()) 
     1510        return true; 
     1511 
     1512    if(u->GetVisibility() == VISIBILITY_OFF) //GM 
     1513        return false; 
     1514 
     1515    // invisible aura 
     1516    if((m_invisibilityMask || u->m_invisibilityMask) && !canDetectInvisibilityOf(u)) 
     1517        return false; 
     1518 
     1519    // unit got in stealth in this moment and must ignore old detected state 
     1520    //if (m_Visibility == VISIBILITY_GROUP_NO_DETECT) 
     1521    //    return false; 
     1522 
     1523    // GM invisibility checks early, invisibility if any detectable, so if not stealth then visible 
     1524    if(u->GetVisibility() == VISIBILITY_GROUP_STEALTH) 
     1525    { 
     1526        //do not know what is the use of this detect 
     1527        if(!detect || !canDetectStealthOf(u, GetDistance(u))) 
     1528            return false; 
     1529    } 
     1530 
     1531    // Now check is target visible with LoS 
     1532    return u->IsWithinLOS(GetPositionX(),GetPositionY(),GetPositionZ()); 
     1533} 
     1534 
    14901535float Creature::GetAttackDistance(Unit const* pl) const 
    14911536{ 
     
    16991744} 
    17001745 
    1701 bool Creature::IsVisibleInGridForPlayer(Player* pl) const 
     1746bool Creature::IsVisibleInGridForPlayer(Player const* pl) const 
    17021747{ 
    17031748    // gamemaster in GM mode see all, including ghosts