mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Update CSAR.lua
This commit is contained in:
parent
dd5ca93f26
commit
bb1caa6642
@ -263,6 +263,7 @@ CSAR = {
|
||||
rescuedpilots = 0,
|
||||
limitmaxdownedpilots = true,
|
||||
maxdownedpilots = 10,
|
||||
useFIFOLimitReplacement = false, -- If true, it will remove the oldest downed pilot when a new one is added, if the limit is reached.
|
||||
allheligroupset = nil,
|
||||
topmenuname = "CSAR",
|
||||
ADFRadioPwr = 1000,
|
||||
@ -1144,19 +1145,8 @@ function CSAR:_EventHandler(EventData)
|
||||
self:T("Double Ejection!")
|
||||
return self
|
||||
end
|
||||
|
||||
-- limit no of pilots in the field.
|
||||
if self.limitmaxdownedpilots and self:_ReachedPilotLimit() then
|
||||
self:T("Maxed Downed Pilot!")
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
-- TODO: Over water check --- EVENTS.LandingAfterEjection NOT triggered by DCS, so handle csarUsePara = true case
|
||||
-- might create dual pilots in edge cases
|
||||
|
||||
local wetfeet = false
|
||||
|
||||
|
||||
|
||||
local initdcscoord = nil
|
||||
local initcoord = nil
|
||||
if _event.id == EVENTS.Ejection then
|
||||
@ -1168,6 +1158,36 @@ function CSAR:_EventHandler(EventData)
|
||||
initcoord = COORDINATE:NewFromVec3(initdcscoord)
|
||||
self:T({initdcscoord})
|
||||
end
|
||||
|
||||
-- Remove downed pilot if already exists to replace with new one.
|
||||
if _event.IniPlayerName then
|
||||
local PilotTable = self.downedPilots --#CSAR.DownedPilot
|
||||
local _foundPilot = nil
|
||||
for _,_pilot in pairs(PilotTable) do
|
||||
if _pilot.player == _event.IniPlayerName and _pilot.alive == true then
|
||||
_foundPilot = _pilot
|
||||
break
|
||||
end
|
||||
end
|
||||
if _foundPilot then
|
||||
self:T("Downed pilot already exists!")
|
||||
_foundPilot.group:Destroy(false)
|
||||
self:_RemoveNameFromDownedPilots(_foundPilot.name)
|
||||
self:_CheckDownedPilotTable()
|
||||
end
|
||||
end
|
||||
|
||||
-- limit no of pilots in the field.
|
||||
if self.limitmaxdownedpilots and self:_ReachedPilotLimit() then
|
||||
self:T("Maxed Downed Pilot!")
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
-- TODO: Over water check --- EVENTS.LandingAfterEjection NOT triggered by DCS, so handle csarUsePara = true case
|
||||
-- might create dual pilots in edge cases
|
||||
|
||||
local wetfeet = false
|
||||
|
||||
--local surface = _unit:GetCoordinate():GetSurfaceType()
|
||||
local surface = initcoord:GetSurfaceType()
|
||||
@ -2401,11 +2421,26 @@ function CSAR:_ReachedPilotLimit()
|
||||
local limit = self.maxdownedpilots
|
||||
local islimited = self.limitmaxdownedpilots
|
||||
local count = self:_CountActiveDownedPilots()
|
||||
if islimited and (count >= limit) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
if islimited and (count >= limit) then
|
||||
if self.useFIFOLimitReplacement then
|
||||
local oldIndex = -1
|
||||
local oldDownedPilot = nil
|
||||
for _index, _downedpilot in pairs(self.downedPilots) do
|
||||
oldIndex = _index
|
||||
oldDownedPilot = _downedpilot
|
||||
break
|
||||
end
|
||||
if oldDownedPilot then
|
||||
oldDownedPilot.group:Destroy(false)
|
||||
oldDownedPilot.alive = false
|
||||
self:_CheckDownedPilotTable()
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
--- User - Function to add onw SET_GROUP Set-up for pilot filtering and assignment.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user