- Redesigned stealth and invisibility handling
  - Implemented the handling of multiple stealth types
- Implemented fake inebriation
- The message deliverer no longer sends packets from a non-visible source
  - The server won't send that much garbage which just takes bandwith
  - It won't be possible to use cheats to detect invisible objects
- Removed a lot of checks for the Z-coord
  - Fixes visibility problems happening while flying
- Limited the grid activation range of creatures to use less resources
- Implemented Shroud of Death
- Implemented increased visibility range for active objects
- Removed visibility check at spellhit (only sanctuary effects should prevent it)
(And a lot of other changes...)

Closes issue 4208
Closes issue 3049
Closes issue 2097
Closes issue 2198
Closes issue 2384
Closes issue 2197
Closes issue 2319

--HG--
branch : trunk
This commit is contained in:
linencloth committed 2010-11-13 17:18:09 +01:00
1 parent 995408f0a9
commit bf888285aa
36 files changed
+780 -791

No files matched your search

+47 -247
View File
@@ -485,8 +485,6 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_swingErrorMsg = 0;
m_DetectInvTimer = 1*IN_MILLISECONDS;
for (uint8 j = 0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; ++j)
{
m_bgBattlegroundQueueID[j].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
@@ -1216,16 +1214,19 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId)
{
uint32 oldDrunkenState = Player::GetDrunkenstateByValue(m_drunk);
if (!newDrunkenValue && !HasAuraType(SPELL_AURA_MOD_FAKE_INEBRIATE))
m_invisibilityDetect.AddFlag(INVISIBILITY_DRUNK);
else
m_invisibilityDetect.DelFlag(INVISIBILITY_DRUNK);
m_invisibilityDetect.AddValue(INVISIBILITY_DRUNK, int32(newDrunkenValue - m_drunk) / 256);
m_drunk = newDrunkenValue;
SetUInt32Value(PLAYER_BYTES_3,(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFF0001) | (m_drunk & 0xFFFE));
uint32 newDrunkenState = Player::GetDrunkenstateByValue(m_drunk);
// special drunk invisibility detection
if (newDrunkenState >= DRUNKEN_DRUNK)
m_detectInvisibilityMask |= (1<<6);
else
m_detectInvisibilityMask &= ~(1<<6);
UpdateObjectVisibility();
if (newDrunkenState == oldDrunkenState)
return;
@@ -1477,18 +1478,6 @@ void Player::Update(uint32 p_time)
//Handle Water/drowning
HandleDrowning(p_time);
//Handle detect stealth players
if (m_DetectInvTimer > 0)
{
if (p_time >= m_DetectInvTimer)
{
HandleStealthedUnitsDetection();
m_DetectInvTimer = 3000;
}
else
m_DetectInvTimer -= p_time;
}
// Played time
if (now > m_Last_tick)
{
@@ -1526,7 +1515,7 @@ void Player::Update(uint32 p_time)
SendUpdateToOutOfRangeGroupMembers();
Pet* pet = GetPet();
if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && !pet->isPossessed())
if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityRange()) && !pet->isPossessed())
//if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID())))
RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true);
@@ -1907,7 +1896,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
{
//same map, only remove pet if out of range for new position
if (pet && !pet->IsWithinDist3d(x,y,z, GetMap()->GetVisibilityDistance()))
if (pet && !pet->IsWithinDist3d(x,y,z, GetMap()->GetVisibilityRange()))
UnsummonPetTemporaryIfAny();
}
@@ -2508,6 +2497,7 @@ void Player::SetGameMaster(bool on)
CombatStopWithPets();
SetPhaseMask(PHASEMASK_ANYWHERE,false); // see and visible in all phases
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GM, GetSession()->GetSecurity());
}
else
{
@@ -2537,6 +2527,7 @@ void Player::SetGameMaster(bool on)
UpdateArea(m_areaUpdateId);
getHostileRefManager().setOnlineOfflineState(true);
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER);
}
UpdateObjectVisibility();
@@ -2548,13 +2539,7 @@ void Player::SetGMVisible(bool on)
{
m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag
// Reapply stealth/invisibility if active or show if not any
if (HasAuraType(SPELL_AURA_MOD_STEALTH))
SetVisibility(VISIBILITY_GROUP_STEALTH);
//else if (HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
// SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
else
SetVisibility(VISIBILITY_ON);
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER);
}
else
{
@@ -2563,11 +2548,11 @@ void Player::SetGMVisible(bool on)
SetAcceptWhispers(false);
SetGameMaster(true);
SetVisibility(VISIBILITY_OFF);
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, GetSession()->GetSecurity());
}
}
bool Player::IsGroupVisibleFor(Player* p) const
bool Player::IsGroupVisibleFor(Player const* p) const
{
switch(sWorld.getIntConfig(CONFIG_GROUP_VISIBILITY))
{
@@ -6423,17 +6408,6 @@ void Player::SaveRecallPosition()
m_recallO = GetOrientation();
}
void Player::SendMessageToSet(WorldPacket *data, bool self)
{
if (self)
GetSession()->SendPacket(data);
// we use World::GetMaxVisibleDistance() because i cannot see why not use a distance
// update: replaced by GetMap()->GetVisibilityDistance()
Trinity::MessageDistDeliverer notifier(this, data, GetMap()->GetVisibilityDistance());
VisitNearbyWorldObject(GetMap()->GetVisibilityDistance(), notifier);
}
void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
{
if (self)
@@ -6459,8 +6433,8 @@ void Player::SendMessageToSet(WorldPacket *data, Player const* skipped_rcvr)
// we use World::GetMaxVisibleDistance() because i cannot see why not use a distance
// update: replaced by GetMap()->GetVisibilityDistance()
Trinity::MessageDistDeliverer notifier(this, data, GetMap()->GetVisibilityDistance(), false, skipped_rcvr);
VisitNearbyWorldObject(GetMap()->GetVisibilityDistance(), notifier);
Trinity::MessageDistDeliverer notifier(this, data, GetVisibilityRange(), false, skipped_rcvr);
VisitNearbyWorldObject(GetVisibilityRange(), notifier);
}
void Player::SendDirectMessage(WorldPacket *data)
@@ -19373,49 +19347,6 @@ void Player::SetRestBonus (float rest_bonus_new)
SetUInt32Value(PLAYER_REST_STATE_EXPERIENCE, uint32(m_rest_bonus));
}
void Player::HandleStealthedUnitsDetection()
{
std::list<Unit*> stealthedUnits;
Trinity::AnyStealthedCheck u_check;
Trinity::UnitListSearcher<Trinity::AnyStealthedCheck > searcher(this, stealthedUnits, u_check);
VisitNearbyObject(GetMap()->GetVisibilityDistance(), searcher);
for (std::list<Unit*>::const_iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i)
{
if ((*i) == this)
continue;
bool hasAtClient = HaveAtClient((*i));
bool hasDetected = canSeeOrDetect(*i, true);
if (hasDetected)
{
if (!hasAtClient)
{
(*i)->SendUpdateToPlayer(this);
m_clientGUIDs.insert((*i)->GetGUID());
#ifdef TRINITY_DEBUG
if ((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES) == 0)
sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i));
#endif
// target aura duration for caster show only if target exist at caster client
// send data at target visibility change (adding to client)
SendInitialVisiblePackets(*i);
}
}
else
{
if (hasAtClient)
{
(*i)->DestroyForPlayer(this);
m_clientGUIDs.erase((*i)->GetGUID());
}
}
}
}
bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc /*= NULL*/, uint32 spellid /*= 0*/)
{
if (nodes.size() < 2)
@@ -20540,178 +20471,45 @@ WorldLocation Player::GetStartPosition() const
return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0);
}
bool Player::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool is3dDistance) const
bool Player::isValid() const
{
// Always can see self
if (m_mover == u || this == u)
return true;
// Arena visibility before arena start
if (InArena() && GetBattleground()->GetStatus() == STATUS_WAIT_JOIN)
if (const Player* target = u->GetCharmerOrOwnerPlayerOrPlayerItself())
return GetBGTeam() == target->GetBGTeam() && target->isGMVisible();
// phased visibility (both must phased in same way)
if (!InSamePhase(u))
if (!Unit::isValid())
return false;
// player visible for other player if not logout and at same transport
// including case when player is out of world
bool at_same_transport =
GetTransport() && u->GetTypeId() == TYPEID_PLAYER
&& !GetSession()->PlayerLogout() && !u->ToPlayer()->GetSession()->PlayerLogout()
&& !GetSession()->PlayerLoading() && !u->ToPlayer()->GetSession()->PlayerLoading()
&& GetTransport() == u->ToPlayer()->GetTransport();
// not in world
if (!at_same_transport && (!IsInWorld() || !u->IsInWorld()))
if (GetSession()->PlayerLogout() || GetSession()->PlayerLoading())
return false;
// forbidden to seen (at GM respawn command)
//if (u->GetVisibility() == VISIBILITY_RESPAWN)
// return false;
Map& _map = *u->GetMap();
// Grid dead/alive checks
// non visible at grid for any stealth state
if (!u->IsVisibleInGridForPlayer(this))
return false;
// always seen by owner
if (uint64 guid = u->GetCharmerOrOwnerGUID())
if (GetGUID() == guid)
return true;
if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT))
if (u->GetGUID() == guid)
return true;
// different visible distance checks
if (isInFlight()) // what see player in flight
{
if (!m_seer->IsWithinDistInMap(u, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance))
return false;
}
else if (!u->isAlive()) // distance for show body
{
if (!m_seer->IsWithinDistInMap(u, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance))
return false;
}
else if (u->GetTypeId() == TYPEID_PLAYER) // distance for show player
{
// Players far than max visible distance for player or not in our map are not visible too
if (!at_same_transport && !m_seer->IsWithinDistInMap(u, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance))
return false;
}
else if (u->GetCharmerOrOwnerGUID()) // distance for show pet/charmed
{
// Pet/charmed far than max visible distance for player or not in our map are not visible too
if (!m_seer->IsWithinDistInMap(u, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance))
return false;
}
else // distance for show creature
{
// Units farther than max visible distance for creature or not in our map are not visible too
if (!m_seer->IsWithinDistInMap(u
, u->isActiveObject() ? (MAX_VISIBILITY_DISTANCE - (inVisibleList ? 0.0f : World::GetVisibleUnitGreyDistance()))
: (_map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))
, is3dDistance))
return false;
}
if (Unit* owner = u->GetCharmerOrOwnerOrSelf())
{
if (owner->GetVisibility() == VISIBILITY_OFF)
{
// GMs see any players, not higher GMs and all units
if (isGameMaster())
{
if (owner->GetTypeId() == TYPEID_PLAYER)
return owner->ToPlayer()->GetSession()->GetSecurity() <= GetSession()->GetSecurity();
else
return true;
}
return false;
}
}
// GM's can see everyone with invisibilitymask with less or equal security level
if (m_mover->m_invisibilityMask || u->m_invisibilityMask)
{
if (isGameMaster())
{
if (u->GetTypeId() == TYPEID_PLAYER)
return u->ToPlayer()->GetSession()->GetSecurity() <= GetSession()->GetSecurity();
else
return true;
}
// 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)
if (!m_mover->canDetectInvisibilityOf(u))
if (!(u->GetTypeId() == TYPEID_PLAYER && !IsHostileTo(u) && IsGroupVisibleFor(const_cast<Player*>(u->ToPlayer()))))
return false;
}
// GM invisibility checks early, invisibility if any detectable, so if not stealth then visible
if (u->GetVisibility() == VISIBILITY_GROUP_STEALTH && !isGameMaster())
{
// if player is dead then he can't detect anyone in any cases
//do not know what is the use of this detect
// stealth and detected and visible for some seconds
if (!isAlive())
detect = false;
if (m_DetectInvTimer < 300 || !HaveAtClient(u))
if (!(u->GetTypeId() == TYPEID_PLAYER && !IsHostileTo(u) && IsGroupVisibleFor(const_cast<Player*>(u->ToPlayer()))))
if (!detect || !m_mover->canDetectStealthOf(u, GetDistance(u)))
return false;
}
// If use this server will be too laggy
// Now check is target visible with LoS
//return u->IsWithinLOS(GetPositionX(),GetPositionY(),GetPositionZ());
return true;
}
bool Player::IsVisibleInGridForPlayer(Player const * pl) const
bool Player::canSeeAlways(WorldObject const* obj) const
{
// gamemaster in GM mode see all, including ghosts
if (pl->isGameMaster() && GetSession()->GetSecurity() <= pl->GetSession()->GetSecurity())
if (Unit::canSeeAlways(obj))
return true;
// It seems in battleground everyone sees everyone, except the enemy-faction ghosts
if (InBattleground())
{
if (!(isAlive() || m_deathTimer > 0) && !IsFriendlyTo(pl))
return false;
return true;
}
// Live player see live player or dead player with not realized corpse
if (pl->isAlive() || pl->m_deathTimer > 0)
{
return isAlive() || m_deathTimer > 0;
}
// Ghost see other friendly ghosts, that's for sure
if (!(isAlive() || m_deathTimer > 0) && IsFriendlyTo(pl))
// Always can see self
if (m_mover == obj)
return true;
// Dead player see live players near own corpse
if (isAlive())
{
Corpse *corpse = pl->GetCorpse();
if (corpse)
{
// 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level
if (corpse->IsWithinDistInMap(this,(20+25)*sWorld.getRate(RATE_CREATURE_AGGRO)))
return true;
}
}
if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT))
if (obj->GetGUID() == guid)
return true;
// and not see any other
return false;
}
bool Player::isAlwaysDetectableFor(WorldObject const* seer) const
{
if (Unit::isAlwaysDetectableFor(seer))
return true;
if (const Player* seerPlayer = seer->ToPlayer())
if (IsGroupVisibleFor(seerPlayer))
return true;
return false;
}
bool Player::IsVisibleGloballyFor(Player* u) const
{
if (!u)
@@ -20780,7 +20578,7 @@ void Player::UpdateVisibilityOf(WorldObject* target)
{
if (HaveAtClient(target))
{
if (!target->isVisibleForInState(this, true))
if (!canSeeOrDetect(target, false, true))
{
if (target->GetTypeId() == TYPEID_UNIT)
BeforeVisibilityDestroy<Creature>(target->ToCreature(),this);
@@ -20796,7 +20594,7 @@ void Player::UpdateVisibilityOf(WorldObject* target)
}
else
{
if (target->isVisibleForInState(this,false))
if (canSeeOrDetect(target, false, true))
{
//if (target->isType(TYPEMASK_UNIT) && ((Unit*)target)->m_Vehicle)
// UpdateVisibilityOf(((Unit*)target)->m_Vehicle);
@@ -20856,7 +20654,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& vi
{
if (HaveAtClient(target))
{
if (!target->isVisibleForInState(this,true))
if (!canSeeOrDetect(target, false, true))
{
BeforeVisibilityDestroy<T>(target,this);
@@ -20871,7 +20669,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& vi
}
else //if (visibleNow.size() < 30 || target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsVehicle())
{
if (target->isVisibleForInState(this,false))
if (canSeeOrDetect(target, false, true))
{
//if (target->isType(TYPEMASK_UNIT) && ((Unit*)target)->m_Vehicle)
// UpdateVisibilityOf(((Unit*)target)->m_Vehicle, data, visibleNow);
@@ -20902,7 +20700,7 @@ void Player::UpdateObjectVisibility(bool forced)
Unit::UpdateObjectVisibility(true);
// updates visibility of all objects around point of view for current player
Trinity::VisibleNotifier notifier(*this);
m_seer->VisitNearbyObject(GetMap()->GetVisibilityDistance(), notifier);
m_seer->VisitNearbyObject(GetVisibilityRange(), notifier);
notifier.SendToSelf(); // send gathered data
}
}
@@ -20910,7 +20708,7 @@ void Player::UpdateObjectVisibility(bool forced)
void Player::UpdateVisibilityForPlayer()
{
Trinity::VisibleNotifier notifier(*this);
m_seer->VisitNearbyObject(GetMap()->GetVisibilityDistance(), notifier);
m_seer->VisitNearbyObject(GetVisibilityRange(), notifier);
notifier.SendToSelf(); // send gathered data
}
@@ -21052,6 +20850,8 @@ void Player::SetGroup(Group *group, int8 subgroup)
m_group.link(group, this);
m_group.setSubGroup((uint8)subgroup);
}
UpdateObjectVisibility();
}
void Player::SendInitialPacketsBeforeAddToMap()