mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Couple of changes to make finding the distance to nearest pilot more stable
This commit is contained in:
parent
8b45067226
commit
63431bb54b
@ -232,7 +232,7 @@ CSAR.AircraftType["Mi-24V"] = 8
|
|||||||
|
|
||||||
--- CSAR class version.
|
--- CSAR class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CSAR.version="0.1.9r1"
|
CSAR.version="0.1.10r1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -1487,10 +1487,17 @@ function CSAR:_GetClosestDownedPilot(_heli)
|
|||||||
local _shortestDistance = -1
|
local _shortestDistance = -1
|
||||||
local _distance = 0
|
local _distance = 0
|
||||||
local _closestGroupInfo = nil
|
local _closestGroupInfo = nil
|
||||||
local _heliCoord = _heli:GetCoordinate()
|
local _heliCoord = _heli:GetCoordinate() or _heli:GetCoordinate()
|
||||||
|
|
||||||
|
if _heliCoord == nil then
|
||||||
|
self:E("****Error obtaining coordinate!")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
local DownedPilotsTable = self.downedPilots
|
local DownedPilotsTable = self.downedPilots
|
||||||
for _, _groupInfo in pairs(DownedPilotsTable) do
|
|
||||||
|
for _, _groupInfo in UTILS.spairs(DownedPilotsTable) do
|
||||||
|
--for _, _groupInfo in pairs(DownedPilotsTable) do
|
||||||
local _woundedName = _groupInfo.name
|
local _woundedName = _groupInfo.name
|
||||||
local _tempWounded = _groupInfo.group
|
local _tempWounded = _groupInfo.group
|
||||||
|
|
||||||
@ -1732,9 +1739,21 @@ end
|
|||||||
function CSAR:_GetDistance(_point1, _point2)
|
function CSAR:_GetDistance(_point1, _point2)
|
||||||
self:T(self.lid .. " _GetDistance")
|
self:T(self.lid .. " _GetDistance")
|
||||||
if _point1 and _point2 then
|
if _point1 and _point2 then
|
||||||
local distance = _point1:DistanceFromPointVec2(_point2)
|
local distance1 = _point1:Get2DDistance(_point2)
|
||||||
return distance
|
local distance2 = _point1:DistanceFromPointVec2(_point2)
|
||||||
|
self:I({dist1=distance1, dist2=distance2})
|
||||||
|
if distance1 and type(distance1) == "number" then
|
||||||
|
return distance1
|
||||||
|
elseif distance2 and type(distance2) == "number" then
|
||||||
|
return distance2
|
||||||
|
else
|
||||||
|
self:E("*****Cannot calculate distance!")
|
||||||
|
self:E({_point1,_point2})
|
||||||
|
return -1
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
self:E("******Cannot calculate distance!")
|
||||||
|
self:E({_point1,_point2})
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1900,19 +1919,19 @@ end
|
|||||||
-- @param #CSAR self
|
-- @param #CSAR self
|
||||||
function CSAR:_CheckDownedPilotTable()
|
function CSAR:_CheckDownedPilotTable()
|
||||||
local pilots = self.downedPilots
|
local pilots = self.downedPilots
|
||||||
for _,_entry in pairs (pilots) do
|
local npilots = {}
|
||||||
self:T("Checking for " .. _entry.name)
|
|
||||||
self:T({entry=_entry})
|
for _ind,_entry in pairs(pilots) do
|
||||||
local group = _entry.group
|
local _group = _entry.group
|
||||||
if not group:IsAlive() then
|
if _group:IsAlive() then
|
||||||
self:T("Group is dead")
|
npilots[_ind] = _entry
|
||||||
if _entry.alive == true then
|
else
|
||||||
self:T("Switching .alive to false")
|
if _entry.alive then
|
||||||
self:__KIA(1,_entry.desc)
|
self:__KIA(1,_entry.desc)
|
||||||
self:_RemoveNameFromDownedPilots(_entry.name,true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.downedPilots = npilots
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user