[8229] Improve stealth detection code for player case. Author: Ambal
--HG-- branch : trunk
This commit is contained in:
+29
-10
@@ -1329,8 +1329,8 @@ void Player::Update( uint32 p_time )
|
||||
{
|
||||
if (p_time >= m_DetectInvTimer)
|
||||
{
|
||||
m_DetectInvTimer = 3000;
|
||||
HandleStealthedUnitsDetection();
|
||||
m_DetectInvTimer = 3000;
|
||||
}
|
||||
else
|
||||
m_DetectInvTimer -= p_time;
|
||||
@@ -17552,19 +17552,38 @@ void Player::HandleStealthedUnitsDetection()
|
||||
Trinity::UnitListSearcher<Trinity::AnyStealthedCheck > searcher(this, stealthedUnits, u_check);
|
||||
VisitNearbyObject(World::GetMaxVisibleDistance(), searcher);
|
||||
|
||||
for (std::list<Unit*>::iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i)
|
||||
for (std::list<Unit*>::const_iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i)
|
||||
{
|
||||
if (!HaveAtClient(*i) && canSeeOrDetect(*i, true))
|
||||
if((*i)==this)
|
||||
continue;
|
||||
|
||||
bool hasAtClient = HaveAtClient((*i));
|
||||
bool hasDetected = canSeeOrDetect(*i, true);
|
||||
|
||||
if (hasDetected)
|
||||
{
|
||||
(*i)->SendUpdateToPlayer(this);
|
||||
m_clientGUIDs.insert((*i)->GetGUID());
|
||||
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
|
||||
#ifdef MANGOS_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
|
||||
|
||||
SendInitialVisiblePackets(*i);
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -2051,7 +2051,6 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
void UpdateVisibilityOf(T* target, UpdateData& data, std::set<WorldObject*>& visibleNow);
|
||||
|
||||
// Stealth detection system
|
||||
uint32 m_DetectInvTimer;
|
||||
void HandleStealthedUnitsDetection();
|
||||
|
||||
uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
|
||||
@@ -2404,6 +2403,8 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
bool m_bCanDelayTeleport;
|
||||
bool m_bHasDelayedTeleport;
|
||||
|
||||
uint32 m_DetectInvTimer;
|
||||
|
||||
// Temporary removed pet cache
|
||||
uint32 m_temporaryUnsummonedPetNumber;
|
||||
uint32 m_oldpetspell;
|
||||
|
||||
@@ -10905,6 +10905,7 @@ bool Unit::canDetectStealthOf(Unit const* target, float distance) const
|
||||
//-Stealth Mod(positive like Master of Deception) and Stealth Detection(negative like paranoia)
|
||||
//based on wowwiki every 5 mod we have 1 more level diff in calculation
|
||||
visibleDistance += (float)(GetTotalAuraModifier(SPELL_AURA_MOD_DETECT) - target->GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_LEVEL)) / 5.0f;
|
||||
visibleDistance = visibleDistance > MAX_PLAYER_STEALTH_DETECT_RANGE ? MAX_PLAYER_STEALTH_DETECT_RANGE : visibleDistance;
|
||||
|
||||
return distance < visibleDistance;
|
||||
}
|
||||
|
||||
@@ -1012,6 +1012,7 @@ enum ReactiveType
|
||||
|
||||
// delay time next attack to prevent client attack animation problems
|
||||
#define ATTACK_DISPLAY_DELAY 200
|
||||
#define MAX_PLAYER_STEALTH_DETECT_RANGE 45.0f // max distance for detection targets by player
|
||||
|
||||
struct SpellProcEventEntry; // used only privately
|
||||
|
||||
|
||||
Reference in New Issue
Block a user