From dcc1991490de5a056d3d73af33fbaa21913e5bab Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 28 Mar 2020 21:48:58 +0000 Subject: [PATCH] Fixed the heading check not working near 0deg --- cl_radar.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cl_radar.lua b/cl_radar.lua index f6f66c7..ff5a11e 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -777,13 +777,15 @@ function RADAR:IsVehicleInTraffic( tgtVeh, relPos ) local tgtHdg = GetEntityHeading( tgtVeh ) local plyHdg = GetEntityHeading( PLY.veh ) - local hdgDiff = math.abs(tgtHdg - plyHdg) + -- Work out the heading difference, but also take into account extreme opposites (e.g. 5deg and 350deg) + local hdgDiff = math.abs( ( plyHdg - tgtHdg + 180 ) % 360 - 180 ) if ( relPos == 1 and hdgDiff > 45 and hdgDiff < 135 ) then return false elseif ( relPos == -1 and hdgDiff > 45 and ( hdgDiff < 135 or hdgDiff > 215 ) ) then return false end + return true end