mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Additional fix for locking speeds, more comments
This commit is contained in:
29
cl_radar.lua
29
cl_radar.lua
@@ -834,7 +834,7 @@ end
|
|||||||
-- necessary information from the antenna, and then lock it into the display
|
-- necessary information from the antenna, and then lock it into the display
|
||||||
function RADAR:LockAntennaSpeed( ant )
|
function RADAR:LockAntennaSpeed( ant )
|
||||||
-- Only lock a speed if the antenna is on and the UI is displayed
|
-- Only lock a speed if the antenna is on and the UI is displayed
|
||||||
if ( self:IsPowerOn() and self:GetDisplayState() and not self:GetDisplayHidden() ) then
|
if ( self:IsPowerOn() and self:GetDisplayState() and not self:GetDisplayHidden() and self:IsAntennaTransmitting( ant ) ) then
|
||||||
-- Check if the antenna already has a speed locked, if it does then reset the lock, otherwise we lock
|
-- Check if the antenna already has a speed locked, if it does then reset the lock, otherwise we lock
|
||||||
-- a speed
|
-- a speed
|
||||||
if ( self:IsAntennaSpeedLocked( ant ) ) then
|
if ( self:IsAntennaSpeedLocked( ant ) ) then
|
||||||
@@ -847,11 +847,11 @@ function RADAR:LockAntennaSpeed( ant )
|
|||||||
-- As the lock system is based on which speed is displayed, we have to check if there is a speed in the
|
-- As the lock system is based on which speed is displayed, we have to check if there is a speed in the
|
||||||
-- fast box, if there is then we lock in the fast speed, otherwise we lock in the strongest speed
|
-- fast box, if there is then we lock in the fast speed, otherwise we lock in the strongest speed
|
||||||
if ( self:IsFastDisplayEnabled() and self:DoesAntennaHaveValidFastData( ant ) ) then
|
if ( self:IsFastDisplayEnabled() and self:DoesAntennaHaveValidFastData( ant ) ) then
|
||||||
data[1] = self:GetAntennaFastSpeed( ant )
|
data[1] = self:GetAntennaFastSpeed( ant )
|
||||||
data[2] = self:GetAntennaFastDir( ant )
|
data[2] = self:GetAntennaFastDir( ant )
|
||||||
else
|
else
|
||||||
data[1] = self:GetAntennaSpeed( ant )
|
data[1] = self:GetAntennaSpeed( ant )
|
||||||
data[2] = self:GetAntennaDir( ant )
|
data[2] = self:GetAntennaDir( ant )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Lock in the speed data for the antenna
|
-- Lock in the speed data for the antenna
|
||||||
@@ -1012,30 +1012,45 @@ function RADAR:GetVehSpeedFormatted( speed )
|
|||||||
-- Get the speed unit from the settings
|
-- Get the speed unit from the settings
|
||||||
local unit = self:GetSettingValue( "speedType" )
|
local unit = self:GetSettingValue( "speedType" )
|
||||||
|
|
||||||
--
|
-- Return the coverted speed rounded to a whole number
|
||||||
return UTIL:Round( speed * self.speedConversions[unit], 0 )
|
return UTIL:Round( speed * self.speedConversions[unit], 0 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Gathers all of the vehicles in the local area of the player
|
||||||
function RADAR:GetAllVehicles()
|
function RADAR:GetAllVehicles()
|
||||||
|
-- Create a temporary table
|
||||||
local t = {}
|
local t = {}
|
||||||
|
|
||||||
for v in UTIL:EnumerateVehicles() do
|
-- Iterate through vehicles
|
||||||
|
for v in UTIL:EnumerateVehicles() do
|
||||||
|
-- Insert the vehicle id into the temporary table
|
||||||
table.insert( t, v )
|
table.insert( t, v )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Return the table
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Used to check if an antennas mode fits with a ray type from the ray trace system
|
||||||
function RADAR:CheckVehicleDataFitsMode( ant, rt )
|
function RADAR:CheckVehicleDataFitsMode( ant, rt )
|
||||||
|
-- Get the current mode value for the given antenna
|
||||||
local mode = self:GetAntennaMode( ant )
|
local mode = self:GetAntennaMode( ant )
|
||||||
|
|
||||||
|
-- Check that the given ray type matches up with the antenna's current mode
|
||||||
if ( ( mode == 3 ) or ( mode == 1 and rt == "same" ) or ( mode == 2 and rt == "opp" ) ) then return true end
|
if ( ( mode == 3 ) or ( mode == 1 and rt == "same" ) or ( mode == 2 and rt == "opp" ) ) then return true end
|
||||||
|
|
||||||
|
-- Otherwise, return false as a last resort
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- This function is used to filter through the captured vehicles and work out what vehicles should be used for display
|
||||||
|
-- on the radar interface
|
||||||
function RADAR:GetVehiclesForAntenna()
|
function RADAR:GetVehiclesForAntenna()
|
||||||
local vehs = { ["front"] = {}, ["rear"] = {} }
|
-- Create the vehs table to store the split up captured vehicle data
|
||||||
|
local vehs = { ["front"] = {}, ["rear"] = {} }
|
||||||
|
|
||||||
|
-- Create the results table to store the vehicle results, the first index is for the 'strongest' vehicle and the
|
||||||
|
-- second index is for the 'fastest' vehicle
|
||||||
local results = { ["front"] = { nil, nil }, ["rear"] = { nil, nil } }
|
local results = { ["front"] = { nil, nil }, ["rear"] = { nil, nil } }
|
||||||
|
|
||||||
-- Loop through and split up the vehicles based on front and rear, this is simply because the actual system
|
-- Loop through and split up the vehicles based on front and rear, this is simply because the actual system
|
||||||
|
|||||||
Reference in New Issue
Block a user