From 4c7b64739ba018a22afbbb4907cd3f05106ece2f Mon Sep 17 00:00:00 2001 From: Sandern Date: Mon, 9 Jun 2014 10:15:28 +0200 Subject: [PATCH 1/2] Base updating blocked status on fraction of max speed instead of a fixed value. --- src/game/server/lambdawars/unit_navigator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/server/lambdawars/unit_navigator.cpp b/src/game/server/lambdawars/unit_navigator.cpp index f48864015..ecd0df396 100644 --- a/src/game/server/lambdawars/unit_navigator.cpp +++ b/src/game/server/lambdawars/unit_navigator.cpp @@ -2031,10 +2031,11 @@ void UnitBaseNavigator::UpdateBlockedStatus( UnitBaseMoveCommand &MoveCommand, c } // Detect low velocity situation (which means the unit is not moving from the current position) + float fWishSpeedThreshold = MoveCommand.maxspeed * 0.35f; float fWishSpeed = m_vLastWishVelocity.Length2DSqr(); float fVelocity2dSqr = GetAbsVelocity().Length2DSqr(); - if( unit_blocked_lowvel_check.GetBool() && fWishSpeed > 100.0f && fVelocity2dSqr < 100.0 ) + if( unit_blocked_lowvel_check.GetBool() && fWishSpeed > fWishSpeedThreshold && fVelocity2dSqr < fWishSpeedThreshold ) { if( !m_bLowVelocityDetectionActive ) { @@ -2061,7 +2062,7 @@ void UnitBaseNavigator::UpdateBlockedStatus( UnitBaseMoveCommand &MoveCommand, c m_vBlockedLastPosition = GetAbsOrigin(); #else // Only perform this check if we have no target or if the target is not moving - if( unit_blocked_longdist_check.GetBool() && fWishSpeed > 100.0f && ( !GetPath()->m_hTarget || GetPath()->m_hTarget->GetAbsVelocity().IsLengthLessThan( 10.0f ) ) ) + if( unit_blocked_longdist_check.GetBool() && fWishSpeed > fWishSpeedThreshold && ( !GetPath()->m_hTarget || GetPath()->m_hTarget->GetAbsVelocity().IsLengthLessThan( 10.0f ) ) ) { if( m_fLastWaypointDistance < 0 ) { From 49274bb5e9916bcd1c9cdd4a0d7c4b439e444917 Mon Sep 17 00:00:00 2001 From: Sandern Date: Mon, 9 Jun 2014 10:30:44 +0200 Subject: [PATCH 2/2] Slightly move unit up when finding a position to get it unstuck, because nav areas might not be perfect. Also test if position is correct. --- src/game/shared/lambdawars/unit_locomotion.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game/shared/lambdawars/unit_locomotion.cpp b/src/game/shared/lambdawars/unit_locomotion.cpp index ff54b2e40..79a101c2c 100644 --- a/src/game/shared/lambdawars/unit_locomotion.cpp +++ b/src/game/shared/lambdawars/unit_locomotion.cpp @@ -1652,11 +1652,13 @@ void UnitBaseLocomotion::DoUnstuck() CNavArea *pArea = TheNavMesh->GetNearestNavArea( mv->origin, true, 10000.0f, false, false ); if( pArea ) { - positioninfo_t info( pArea->GetCenter(), m_vecMins, m_vecMaxs, 0, 1024.0f ); + positioninfo_t info( pArea->GetCenter(), m_vecMins, m_vecMaxs, 0, 1024.0f, 0, 0, NULL, + 8.0f, 256.0f, MASK_NPCSOLID, true ); UTIL_FindPosition( info ); if( info.m_bSuccess ) { mv->origin = info.m_vPosition; + mv->origin.z += 16.0f; bFoundPosition = true; } }