mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
CSAR: Align to Dev changes
This commit is contained in:
parent
a49f4eaa21
commit
a844a5d697
@ -22,7 +22,7 @@
|
|||||||
-- @module Ops.CSAR
|
-- @module Ops.CSAR
|
||||||
-- @image OPS_CSAR.jpg
|
-- @image OPS_CSAR.jpg
|
||||||
|
|
||||||
-- Date: Aug 2021
|
-- Date: Sep 2021
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
||||||
@ -233,7 +233,7 @@ CSAR.AircraftType["Mi-24V"] = 8
|
|||||||
|
|
||||||
--- CSAR class version.
|
--- CSAR class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CSAR.version="0.1.10r3"
|
CSAR.version="0.1.10r5"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -349,7 +349,7 @@ function CSAR:New(Coalition, Template, Alias)
|
|||||||
self.csarPrefix = { "helicargo", "MEDEVAC"} -- prefixes used for useprefix=true - DON\'T use # in names!
|
self.csarPrefix = { "helicargo", "MEDEVAC"} -- prefixes used for useprefix=true - DON\'T use # in names!
|
||||||
self.template = Template or "generic" -- template for downed pilot
|
self.template = Template or "generic" -- template for downed pilot
|
||||||
self.mashprefix = {"MASH"} -- prefixes used to find MASHes
|
self.mashprefix = {"MASH"} -- prefixes used to find MASHes
|
||||||
self.mash = SET_GROUP:New():FilterCoalitions(self.coalition):FilterPrefixes(self.mashprefix):FilterOnce() -- currently only GROUP objects, maybe support STATICs also?
|
|
||||||
self.autosmoke = false -- automatically smoke location when heli is near
|
self.autosmoke = false -- automatically smoke location when heli is near
|
||||||
self.autosmokedistance = 2000 -- distance for autosmoke
|
self.autosmokedistance = 2000 -- distance for autosmoke
|
||||||
-- added 0.1.4
|
-- added 0.1.4
|
||||||
@ -718,7 +718,6 @@ function CSAR:SpawnCSARAtZone(Zone, Coalition, Description, RandomPoint, Nomessa
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: Split in functions per Event type
|
|
||||||
--- (Internal) Event handler.
|
--- (Internal) Event handler.
|
||||||
-- @param #CSAR self
|
-- @param #CSAR self
|
||||||
function CSAR:_EventHandler(EventData)
|
function CSAR:_EventHandler(EventData)
|
||||||
@ -790,7 +789,7 @@ function CSAR:_EventHandler(EventData)
|
|||||||
if self:_DoubleEjection(_unitname) then
|
if self:_DoubleEjection(_unitname) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self:_DisplayToAllSAR("MAYDAY MAYDAY! " .. _unit:GetTypeName() .. " shot down. No Chute!", self.coalition, self.messageTime)
|
|
||||||
else
|
else
|
||||||
self:T(self.lid .. " Pilot has not taken off, ignore")
|
self:T(self.lid .. " Pilot has not taken off, ignore")
|
||||||
end
|
end
|
||||||
@ -878,13 +877,6 @@ function CSAR:_EventHandler(EventData)
|
|||||||
|
|
||||||
if _place:GetCoalition() == self.coalition or _place:GetCoalition() == coalition.side.NEUTRAL then
|
if _place:GetCoalition() == self.coalition or _place:GetCoalition() == coalition.side.NEUTRAL then
|
||||||
self:_ScheduledSARFlight(_event.IniUnitName,_event.IniGroupName,true)
|
self:_ScheduledSARFlight(_event.IniUnitName,_event.IniGroupName,true)
|
||||||
--[[
|
|
||||||
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_event.IniUnitName) then
|
|
||||||
self:_DisplayMessageToSAR(_unit, "Open the door to let me out!", self.messageTime, true)
|
|
||||||
else
|
|
||||||
self:_RescuePilots(_unit)
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
else
|
else
|
||||||
self:T(string.format("Airfield %d, Unit %d", _place:GetCoalition(), _unit:GetCoalition()))
|
self:T(string.format("Airfield %d, Unit %d", _place:GetCoalition(), _unit:GetCoalition()))
|
||||||
end
|
end
|
||||||
@ -904,7 +896,6 @@ end
|
|||||||
function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
||||||
self:T(self.lid .. " _InitSARForPilot")
|
self:T(self.lid .. " _InitSARForPilot")
|
||||||
local _leader = _downedGroup:GetUnit(1)
|
local _leader = _downedGroup:GetUnit(1)
|
||||||
--local _groupName = _downedGroup:GetName()
|
|
||||||
local _groupName = _GroupName
|
local _groupName = _GroupName
|
||||||
local _freqk = _freq / 1000
|
local _freqk = _freq / 1000
|
||||||
local _coordinatesText = self:_GetPositionOfWounded(_downedGroup)
|
local _coordinatesText = self:_GetPositionOfWounded(_downedGroup)
|
||||||
@ -920,7 +911,7 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- trigger FSM event
|
-- trigger FSM event
|
||||||
self:__PilotDown(2,_downedGroup, _freqk, _leadername, _coordinatesText)
|
self:__PilotDown(2,_downedGroup, _freqk, _groupName, _coordinatesText)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1090,7 +1081,6 @@ function CSAR:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupNam
|
|||||||
local grouptable = downedgrouptable --#CSAR.DownedPilot
|
local grouptable = downedgrouptable --#CSAR.DownedPilot
|
||||||
self.inTransitGroups[_heliName][_woundedGroupName] =
|
self.inTransitGroups[_heliName][_woundedGroupName] =
|
||||||
{
|
{
|
||||||
-- DONE: Fix with #CSAR.DownedPilot
|
|
||||||
originalUnit = grouptable.originalUnit,
|
originalUnit = grouptable.originalUnit,
|
||||||
woundedGroup = _woundedGroupName,
|
woundedGroup = _woundedGroupName,
|
||||||
side = self.coalition,
|
side = self.coalition,
|
||||||
@ -1129,40 +1119,6 @@ end
|
|||||||
-- @return #boolean outcome The outcome.
|
-- @return #boolean outcome The outcome.
|
||||||
function CSAR:_IsLoadingDoorOpen( unit_name )
|
function CSAR:_IsLoadingDoorOpen( unit_name )
|
||||||
self:T(self.lid .. " _IsLoadingDoorOpen")
|
self:T(self.lid .. " _IsLoadingDoorOpen")
|
||||||
|
|
||||||
--[[
|
|
||||||
local ret_val = false
|
|
||||||
local unit = Unit.getByName(unit_name)
|
|
||||||
if unit ~= nil then
|
|
||||||
local type_name = unit:getTypeName()
|
|
||||||
|
|
||||||
if type_name == "Mi-8MT" and unit:getDrawArgumentValue(86) == 1 or unit:getDrawArgumentValue(250) == 1 then
|
|
||||||
self:T(unit_name .. " Cargo doors are open or cargo door not present")
|
|
||||||
ret_val = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if type_name == "Mi-24P" and unit:getDrawArgumentValue(38) == 1 or unit:getDrawArgumentValue(86) == 1 then
|
|
||||||
self:T(unit_name .. " a side door is open")
|
|
||||||
ret_val = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if type_name == "UH-1H" and unit:getDrawArgumentValue(43) == 1 or unit:getDrawArgumentValue(44) == 1 then
|
|
||||||
self:T(unit_name .. " a side door is open ")
|
|
||||||
ret_val = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if string.find(type_name, "SA342" ) and unit:getDrawArgumentValue(34) == 1 or unit:getDrawArgumentValue(38) == 1 then
|
|
||||||
self:T(unit_name .. " front door(s) are open")
|
|
||||||
ret_val = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ret_val == false then
|
|
||||||
self:T(unit_name .. " all doors are closed")
|
|
||||||
end
|
|
||||||
return ret_val
|
|
||||||
|
|
||||||
end -- nil
|
|
||||||
--]]
|
|
||||||
return UTILS.IsLoadingDoorOpen(unit_name)
|
return UTILS.IsLoadingDoorOpen(unit_name)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1195,14 +1151,12 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
|||||||
else
|
else
|
||||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land in a safe place, I will go there ", _heliName, _pilotName), self.messageTime,false,true)
|
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land in a safe place, I will go there ", _heliName, _pilotName), self.messageTime,false,true)
|
||||||
end
|
end
|
||||||
--mark as shown for THIS heli and THIS group
|
|
||||||
self.heliCloseMessage[_lookupKeyHeli] = true
|
self.heliCloseMessage[_lookupKeyHeli] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- have we landed close enough?
|
-- have we landed close enough?
|
||||||
if not _heliUnit:InAir() then
|
if not _heliUnit:InAir() then
|
||||||
|
|
||||||
-- if you land on them, doesnt matter if they were heading to someone else as you\'re closer, you win! :)
|
|
||||||
if self.pilotRuntoExtractPoint == true then
|
if self.pilotRuntoExtractPoint == true then
|
||||||
if (_distance < self.extractDistance) then
|
if (_distance < self.extractDistance) then
|
||||||
local _time = self.landedStatus[_lookupKeyHeli]
|
local _time = self.landedStatus[_lookupKeyHeli]
|
||||||
@ -1353,8 +1307,7 @@ function CSAR:_RescuePilots(_heliUnit)
|
|||||||
-- Groups already rescued
|
-- Groups already rescued
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- DONE: count saved units?
|
|
||||||
local PilotsSaved = self:_PilotsOnboard(_heliName)
|
local PilotsSaved = self:_PilotsOnboard(_heliName)
|
||||||
|
|
||||||
self.inTransitGroups[_heliName] = nil
|
self.inTransitGroups[_heliName] = nil
|
||||||
@ -1450,7 +1403,6 @@ function CSAR:_DisplayActiveSAR(_unitName)
|
|||||||
local _groupName = _value.name
|
local _groupName = _value.name
|
||||||
self:T(string.format("Display Active Pilot: %s", tostring(_groupName)))
|
self:T(string.format("Display Active Pilot: %s", tostring(_groupName)))
|
||||||
self:T({Table=_value})
|
self:T({Table=_value})
|
||||||
--local _woundedGroup = GROUP:FindByName(_groupName)
|
|
||||||
local _woundedGroup = _value.group
|
local _woundedGroup = _value.group
|
||||||
if _woundedGroup and _value.alive then
|
if _woundedGroup and _value.alive then
|
||||||
local _coordinatesText = self:_GetPositionOfWounded(_woundedGroup)
|
local _coordinatesText = self:_GetPositionOfWounded(_woundedGroup)
|
||||||
@ -1747,7 +1699,6 @@ function CSAR:_GetDistance(_point1, _point2)
|
|||||||
if _point1 and _point2 then
|
if _point1 and _point2 then
|
||||||
local distance1 = _point1:Get2DDistance(_point2)
|
local distance1 = _point1:Get2DDistance(_point2)
|
||||||
local distance2 = _point1:DistanceFromPointVec2(_point2)
|
local distance2 = _point1:DistanceFromPointVec2(_point2)
|
||||||
--self:I({dist1=distance1, dist2=distance2})
|
|
||||||
if distance1 and type(distance1) == "number" then
|
if distance1 and type(distance1) == "number" then
|
||||||
return distance1
|
return distance1
|
||||||
elseif distance2 and type(distance2) == "number" then
|
elseif distance2 and type(distance2) == "number" then
|
||||||
@ -1768,7 +1719,6 @@ end
|
|||||||
-- @param #CSAR self
|
-- @param #CSAR self
|
||||||
function CSAR:_GenerateVHFrequencies()
|
function CSAR:_GenerateVHFrequencies()
|
||||||
self:T(self.lid .. " _GenerateVHFrequencies")
|
self:T(self.lid .. " _GenerateVHFrequencies")
|
||||||
--local _skipFrequencies = self.SkipFrequencies
|
|
||||||
|
|
||||||
local FreeVHFFrequencies = {}
|
local FreeVHFFrequencies = {}
|
||||||
FreeVHFFrequencies = UTILS.GenerateVHFrequencies()
|
FreeVHFFrequencies = UTILS.GenerateVHFrequencies()
|
||||||
@ -1808,7 +1758,6 @@ function CSAR:_GetClockDirection(_heli, _group)
|
|||||||
if _heading then
|
if _heading then
|
||||||
local Aspect = Angle - _heading
|
local Aspect = Angle - _heading
|
||||||
if Aspect == 0 then Aspect = 360 end
|
if Aspect == 0 then Aspect = 360 end
|
||||||
--clock = math.floor(Aspect / 30)
|
|
||||||
clock = math.abs(UTILS.Round((Aspect / 30),0))
|
clock = math.abs(UTILS.Round((Aspect / 30),0))
|
||||||
if clock == 0 then clock = 12 end
|
if clock == 0 then clock = 12 end
|
||||||
end
|
end
|
||||||
@ -1917,6 +1866,7 @@ function CSAR:onafterStart(From, Event, To)
|
|||||||
else
|
else
|
||||||
self.allheligroupset = SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterCategoryHelicopter():FilterStart()
|
self.allheligroupset = SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterCategoryHelicopter():FilterStart()
|
||||||
end
|
end
|
||||||
|
self.mash = SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterPrefixes(self.mashprefix):FilterStart() -- currently only GROUP objects, maybe support STATICs also?
|
||||||
self:__Status(-10)
|
self:__Status(-10)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user