mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 16:36:26 +02:00
Redone dir function, started lock functionality,
This commit is contained in:
26
cl_radar.lua
26
cl_radar.lua
@@ -84,6 +84,8 @@ RADAR.vars =
|
|||||||
[ "front" ] = {
|
[ "front" ] = {
|
||||||
xmit = false, -- Whether the antenna is on or off
|
xmit = false, -- Whether the antenna is on or off
|
||||||
mode = 0, -- Current antenna mode, 0 = none, 1 = same, 2 = opp, 3 = same and opp
|
mode = 0, -- Current antenna mode, 0 = none, 1 = same, 2 = opp, 3 = same and opp
|
||||||
|
speedLocked = false,
|
||||||
|
lockedSpeed = 0,
|
||||||
--[[ speed = 0, -- Speed of the vehicle caught by the front antenna
|
--[[ speed = 0, -- Speed of the vehicle caught by the front antenna
|
||||||
dir = nil, -- Direction the caught vehicle is going, 0 = towards, 1 = away
|
dir = nil, -- Direction the caught vehicle is going, 0 = towards, 1 = away
|
||||||
fastMode = 1, -- Current fast mode, 1 = polling, 2 = lock on at first fast vehicle
|
fastMode = 1, -- Current fast mode, 1 = polling, 2 = lock on at first fast vehicle
|
||||||
@@ -95,6 +97,8 @@ RADAR.vars =
|
|||||||
[ "rear" ] = {
|
[ "rear" ] = {
|
||||||
xmit = false, -- Whether the antenna is on or off
|
xmit = false, -- Whether the antenna is on or off
|
||||||
mode = 0, -- Current antenna mode, 0 = none, 1 = same, 2 = opp, 3 = same and opp
|
mode = 0, -- Current antenna mode, 0 = none, 1 = same, 2 = opp, 3 = same and opp
|
||||||
|
speedLocked = false,
|
||||||
|
lockedSpeed = 0,
|
||||||
--[[ speed = 0, -- Speed of the vehicle caught by the front antenna
|
--[[ speed = 0, -- Speed of the vehicle caught by the front antenna
|
||||||
dir = nil, -- Direction the caught vehicle is going, 0 = towards, 1 = away
|
dir = nil, -- Direction the caught vehicle is going, 0 = towards, 1 = away
|
||||||
fastMode = 1, -- Current fast mode, 1 = polling, 2 = lock on at first fast vehicle
|
fastMode = 1, -- Current fast mode, 1 = polling, 2 = lock on at first fast vehicle
|
||||||
@@ -541,7 +545,15 @@ function RADAR:SetAntennaMode( ant, mode, cb )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function RADAR:SetAntennaSpeed( ant, speed )
|
function RADAR:SetAntennaLockedSpeed( ant, speed )
|
||||||
|
if ( type( speed ) == "number" ) then
|
||||||
|
if ( speed >= 0 and speed <= 999 ) then
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[ function RADAR:SetAntennaSpeed( ant, speed )
|
||||||
if ( type( speed ) == "number" ) then
|
if ( type( speed ) == "number" ) then
|
||||||
if ( speed >= 0 and speed <= 999 ) then
|
if ( speed >= 0 and speed <= 999 ) then
|
||||||
self.vars.antennas[ant].speed = speed
|
self.vars.antennas[ant].speed = speed
|
||||||
@@ -585,7 +597,7 @@ function RADAR:SetAntennaFastLock( ant, state )
|
|||||||
if ( type( state ) == "boolean" ) then
|
if ( type( state ) == "boolean" ) then
|
||||||
self.vars.antennas[ant].fastLocked = state
|
self.vars.antennas[ant].fastLocked = state
|
||||||
end
|
end
|
||||||
end
|
end ]]
|
||||||
|
|
||||||
function RADAR:ResetAntenna( ant )
|
function RADAR:ResetAntenna( ant )
|
||||||
-- Overwrite default behaviour, this is because when the system is turned off, the temporary memory is
|
-- Overwrite default behaviour, this is because when the system is turned off, the temporary memory is
|
||||||
@@ -668,7 +680,7 @@ function RADAR:GetDynamicRadius( veh )
|
|||||||
local min, max = GetModelDimensions( mdl )
|
local min, max = GetModelDimensions( mdl )
|
||||||
local size = max - min
|
local size = max - min
|
||||||
local numericSize = size.x + size.y + size.z
|
local numericSize = size.x + size.y + size.z
|
||||||
local dynamicRadius = UTIL:Clamp( ( numericSize * numericSize ) / 12, 4.0, 10.0 )
|
local dynamicRadius = UTIL:Clamp( ( numericSize * numericSize ) / 12, 5.0, 10.0 )
|
||||||
|
|
||||||
self:InsertDynamicRadiusData( key, dynamicRadius, numericSize )
|
self:InsertDynamicRadiusData( key, dynamicRadius, numericSize )
|
||||||
|
|
||||||
@@ -910,9 +922,9 @@ function RADAR:Main()
|
|||||||
data.antennas[ant][i].speed = UTIL:FormatSpeed( self:GetVehSpeedFormatted( av[ant][i].speed ) )
|
data.antennas[ant][i].speed = UTIL:FormatSpeed( self:GetVehSpeedFormatted( av[ant][i].speed ) )
|
||||||
|
|
||||||
-- Work out if the vehicle is closing or away
|
-- Work out if the vehicle is closing or away
|
||||||
local ownH = GetEntityHeading( PLY.veh )
|
local ownH = UTIL:Round( GetEntityHeading( PLY.veh ), 0 )
|
||||||
local tarH = GetEntityHeading( av[ant][i].veh )
|
local tarH = UTIL:Round( GetEntityHeading( av[ant][i].veh ), 0 )
|
||||||
data.antennas[ant][i].dir = UTIL:GetEntityRelativeDirection( ownH, tarH, 120 )
|
data.antennas[ant][i].dir = UTIL:GetEntityRelativeDirection( ownH, tarH )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1007,6 +1019,8 @@ Citizen.CreateThread( function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UTIL:DrawDebugText( 0.5, 0.2, 0.6, true, tostring( GetEntityHeading( PLY.veh ) ) )
|
||||||
|
|
||||||
Citizen.Wait( 0 )
|
Citizen.Wait( 0 )
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
|
|||||||
18
cl_utils.lua
18
cl_utils.lua
@@ -62,22 +62,12 @@ function UTIL:GetVehicleInDirection( entFrom, coordFrom, coordTo )
|
|||||||
return vehicle
|
return vehicle
|
||||||
end
|
end
|
||||||
|
|
||||||
function UTIL:OppositeAngle( ang )
|
function UTIL:GetEntityRelativeDirection( myAng, tarAng )
|
||||||
return ( ang + 180 ) % 360
|
local angleDiff = math.abs( ( myAng - tarAng + 180 ) % 360 - 180 )
|
||||||
end
|
|
||||||
|
|
||||||
function UTIL:GetEntityRelativeDirection( myAng, tarAng, angToCheck )
|
if ( angleDiff < 45 ) then
|
||||||
local rangeStartFront = myAng - ( angToCheck / 2 )
|
|
||||||
local rangeEndFront = myAng + ( angToCheck / 2 )
|
|
||||||
|
|
||||||
local opp = self:OppositeAngle( myAng )
|
|
||||||
|
|
||||||
local rangeStartBack = opp - ( angToCheck / 2 )
|
|
||||||
local rangeEndBack = opp + ( angToCheck / 2 )
|
|
||||||
|
|
||||||
if ( ( tarAng > rangeStartFront ) and ( tarAng < rangeEndFront ) ) then
|
|
||||||
return 1
|
return 1
|
||||||
elseif ( ( tarAng > rangeStartBack ) and ( tarAng < rangeEndBack ) ) then
|
elseif ( angleDiff > 135 ) then
|
||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user