CSAR - added check smoke/flare distance is valid

This commit is contained in:
Applevangelist 2021-11-27 17:27:58 +01:00
parent 7280ceac32
commit c7ddd6ec35
2 changed files with 5 additions and 5 deletions

View File

@ -1607,7 +1607,7 @@ function CSAR:_SignalFlare(_unitName)
local _closest = self:_GetClosestDownedPilot(_heli) local _closest = self:_GetClosestDownedPilot(_heli)
local smokedist = 8000 local smokedist = 8000
if self.approachdist_far > smokedist then smokedist = self.approachdist_far end if self.approachdist_far > smokedist then smokedist = self.approachdist_far end
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < smokedist then if _closest ~= nil and _closest.pilot ~= nil and _closest.distance > 0 and _closest.distance < smokedist then
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot) local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
local _distance = 0 local _distance = 0
@ -1662,7 +1662,7 @@ function CSAR:_Reqsmoke( _unitName )
local smokedist = 8000 local smokedist = 8000
if smokedist < self.approachdist_far then smokedist = self.approachdist_far end if smokedist < self.approachdist_far then smokedist = self.approachdist_far end
local _closest = self:_GetClosestDownedPilot(_heli) local _closest = self:_GetClosestDownedPilot(_heli)
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < smokedist then if _closest ~= nil and _closest.pilot ~= nil and _closest.distance > 0 and _closest.distance < smokedist then
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot) local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
local _distance = 0 local _distance = 0
if _SETTINGS:IsImperial() then if _SETTINGS:IsImperial() then
@ -1670,7 +1670,7 @@ function CSAR:_Reqsmoke( _unitName )
else else
_distance = string.format("%.1fkm",_closest.distance) _distance = string.format("%.1fkm",_closest.distance)
end end
local _msg = string.format("%s - Popping signal smoke at your %s o\'clock. Distance %s", _unitName, _clockDir, _distance) local _msg = string.format("%s - Popping smoke at your %s o\'clock. Distance %s", _unitName, _clockDir, _distance)
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true) self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true)
local _coord = _closest.pilot:GetCoordinate() local _coord = _closest.pilot:GetCoordinate()
local color = self.smokecolor local color = self.smokecolor

View File

@ -2089,7 +2089,7 @@ end
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems. -- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
-- @param #string Filename The name of the file. -- @param #string Filename The name of the file.
-- @param #boolean Reduce If false, existing loaded groups will not be reduced to fit the saved number. -- @param #boolean Reduce If false, existing loaded groups will not be reduced to fit the saved number.
-- @return #table Table of data objects (tables) containing groupname, size and coordinate. Returns nil when file cannot be read. -- @return #table Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read.
function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce) function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce)
local reduce = Reduce==false and false or true local reduce = Reduce==false and false or true
local filename = Filename or "StateListofGroups" local filename = Filename or "StateListofGroups"
@ -2135,7 +2135,7 @@ end
-- @param #string Filename The name of the file. -- @param #string Filename The name of the file.
-- @param #boolean Spawn If set to false, do not re-spawn the groups loaded in location and reduce to size. -- @param #boolean Spawn If set to false, do not re-spawn the groups loaded in location and reduce to size.
-- @return Core.Set#SET_GROUP Set of GROUP objects. -- @return Core.Set#SET_GROUP Set of GROUP objects.
-- Returns nil when file cannot be read. Returns a table of data entries is Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate }` -- Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate }`
function UTILS.LoadSetOfGroups(Path,Filename,Spawn) function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
local spawn = SPAWN==false and false or true local spawn = SPAWN==false and false or true
local filename = Filename or "SetOfGroups" local filename = Filename or "SetOfGroups"