| 1494 | bool 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 | |