mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Fixed the heading check not working near 0deg
This commit is contained in:
@@ -777,13 +777,15 @@ function RADAR:IsVehicleInTraffic( tgtVeh, relPos )
|
|||||||
local tgtHdg = GetEntityHeading( tgtVeh )
|
local tgtHdg = GetEntityHeading( tgtVeh )
|
||||||
local plyHdg = GetEntityHeading( PLY.veh )
|
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
|
if ( relPos == 1 and hdgDiff > 45 and hdgDiff < 135 ) then
|
||||||
return false
|
return false
|
||||||
elseif ( relPos == -1 and hdgDiff > 45 and ( hdgDiff < 135 or hdgDiff > 215 ) ) then
|
elseif ( relPos == -1 and hdgDiff > 45 and ( hdgDiff < 135 or hdgDiff > 215 ) ) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user