17191 | | bool Player::IsVisibleInGridForPlayer( Player* pl ) const |
| 17190 | bool Player::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const |
| 17191 | { |
| 17192 | // Always can see self |
| 17193 | if (u == this) |
| 17194 | return true; |
| 17195 | |
| 17196 | // player visible for other player if not logout and at same transport |
| 17197 | // including case when player is out of world |
| 17198 | bool at_same_transport = |
| 17199 | GetTransport() && u->GetTypeId() == TYPEID_PLAYER |
| 17200 | && !GetSession()->PlayerLogout() && !((Player*)u)->GetSession()->PlayerLogout() |
| 17201 | && !GetSession()->PlayerLoading() && !((Player*)u)->GetSession()->PlayerLoading() |
| 17202 | && GetTransport() == ((Player*)u)->GetTransport(); |
| 17203 | |
| 17204 | // not in world |
| 17205 | if(!at_same_transport && (!IsInWorld() || !u->IsInWorld())) |
| 17206 | return false; |
| 17207 | |
| 17208 | // forbidden to seen (at GM respawn command) |
| 17209 | if(u->GetVisibility() == VISIBILITY_RESPAWN) |
| 17210 | return false; |
| 17211 | |
| 17212 | // always seen by owner |
| 17213 | if(GetGUID() == u->GetCharmerOrOwnerGUID()) |
| 17214 | return true; |
| 17215 | |
| 17216 | // Grid dead/alive checks |
| 17217 | // non visible at grid for any stealth state |
| 17218 | if(!u->IsVisibleInGridForPlayer(this)) |
| 17219 | return false; |
| 17220 | |
| 17221 | // If the player is currently possessing, update visibility from the possessed unit's location |
| 17222 | const Unit* target = isPossessing() ? GetCharm() : this; |
| 17223 | |
| 17224 | // different visible distance checks |
| 17225 | if(isInFlight()) // what see player in flight |
| 17226 | { |
| 17227 | if (!target->IsWithinDistInMap(u,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) |
| 17228 | return false; |
| 17229 | } |
| 17230 | else if(!u->isAlive()) // distance for show body |
| 17231 | { |
| 17232 | if (!target->IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) |
| 17233 | return false; |
| 17234 | } |
| 17235 | else if(u->GetTypeId()==TYPEID_PLAYER) // distance for show player |
| 17236 | { |
| 17237 | // Players far than max visible distance for player or not in our map are not visible too |
| 17238 | if (!at_same_transport && !target->IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) |
| 17239 | return false; |
| 17240 | } |
| 17241 | else if(u->GetCharmerOrOwnerGUID()) // distance for show pet/charmed |
| 17242 | { |
| 17243 | // Pet/charmed far than max visible distance for player or not in our map are not visible too |
| 17244 | if (!target->IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) |
| 17245 | return false; |
| 17246 | } |
| 17247 | else // distance for show creature |
| 17248 | { |
| 17249 | // Units far than max visible distance for creature or not in our map are not visible too |
| 17250 | if (!target->IsWithinDistInMap(u, target->isActive() |
| 17251 | ? (MAX_VISIBILITY_DISTANCE - (inVisibleList ? 0.0f : World::GetVisibleUnitGreyDistance())) |
| 17252 | : (World::GetMaxVisibleDistanceForCreature() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))) |
| 17253 | return false; |
| 17254 | } |
| 17255 | |
| 17256 | // GMs see any players, not higher GMs and all units |
| 17257 | if(isGameMaster()) |
| 17258 | { |
| 17259 | if(u->GetTypeId() == TYPEID_PLAYER) |
| 17260 | return ((Player *)u)->GetSession()->GetSecurity() <= GetSession()->GetSecurity(); |
| 17261 | else |
| 17262 | return true; |
| 17263 | } |
| 17264 | |
| 17265 | if(u->GetVisibility() == VISIBILITY_OFF) |
| 17266 | return false; |
| 17267 | |
| 17268 | // player see other player with stealth/invisibility only if he in same group or raid or same team (raid/team case dependent from conf setting) |
| 17269 | if((m_invisibilityMask || u->m_invisibilityMask) && !canDetectInvisibilityOf(u)) |
| 17270 | if(!(u->GetTypeId()==TYPEID_PLAYER && !IsHostileTo(u) && IsGroupVisibleFor(((Player*)u)))) |
| 17271 | return false; |
| 17272 | |
| 17273 | // GM invisibility checks early, invisibility if any detectable, so if not stealth then visible |
| 17274 | if(u->GetVisibility() == VISIBILITY_GROUP_STEALTH) |
| 17275 | { |
| 17276 | // if player is dead then he can't detect anyone in anycases |
| 17277 | //do not know what is the use of this detect |
| 17278 | // stealth and detected and visible for some seconds |
| 17279 | if(!isAlive()) |
| 17280 | detect = false; |
| 17281 | if(m_DetectInvTimer < 300 || !HaveAtClient(u)) |
| 17282 | if(!(u->GetTypeId()==TYPEID_PLAYER && !IsHostileTo(u) && IsGroupVisibleFor(((Player*)u)))) |
| 17283 | if(!detect || !canDetectStealthOf(u, GetDistance(u))) |
| 17284 | return false; |
| 17285 | } |
| 17286 | |
| 17287 | // Now check is target visible with LoS |
| 17288 | return u->IsWithinLOS(GetPositionX(),GetPositionY(),GetPositionZ()); |
| 17289 | } |
| 17290 | |
| 17291 | bool Player::IsVisibleInGridForPlayer( Player const * pl ) const |