MANTIS - Change logic to FSM, added functions

CSAR - advanced options to name injected AI downed pilots
CTLD - added Herc speed check
This commit is contained in:
Applevangelist 2021-07-13 17:50:44 +02:00
parent e33de03522
commit 433d1bbf57
3 changed files with 493 additions and 224 deletions

File diff suppressed because it is too large Load Diff

View File

@ -662,7 +662,9 @@ end
-- @param #string _description (optional) Description.
-- @param #boolean _randomPoint (optional) Random yes or no.
-- @param #boolean _nomessage (optional) If true, don\'t send a message to SAR.
function CSAR:_SpawnCsarAtZone( _zone, _coalition, _description, _randomPoint, _nomessage)
-- @param #string unitname (optional) Name of the lost unit.
-- @param #string typename (optional) Type of plane.
function CSAR:_SpawnCsarAtZone( _zone, _coalition, _description, _randomPoint, _nomessage, unitname, typename)
self:T(self.lid .. " _SpawnCsarAtZone")
local freq = self:_GenerateADFFrequency()
local _triggerZone = ZONE:New(_zone) -- trigger to use as reference position
@ -671,7 +673,9 @@ function CSAR:_SpawnCsarAtZone( _zone, _coalition, _description, _randomPoint, _
return
end
local _description = _description or "Unknown"
local _description = _description or "PoW"
local unitname = unitname or "Old Rusty"
local typename = typename or "Phantom II"
local pos = {}
if _randomPoint then
@ -690,7 +694,7 @@ function CSAR:_SpawnCsarAtZone( _zone, _coalition, _description, _randomPoint, _
_country = country.id.UN_PEACEKEEPERS
end
self:_AddCsar(_coalition, _country, pos, "PoW", _description, nil, freq, _nomessage, _description)
self:_AddCsar(_coalition, _country, pos, typename, unitname, _description, freq, _nomessage, _description)
return self
end
@ -702,12 +706,14 @@ end
-- @param #string Description (optional) Description.
-- @param #boolean RandomPoint (optional) Random yes or no.
-- @param #boolean Nomessage (optional) If true, don\'t send a message to SAR.
-- @param #string unitname (optional) Name of the lost unit.
-- @param #string typename (optional) Type of plane.
-- @usage If missions designers want to spawn downed pilots into the field, e.g. at mission begin, to give the helicopter guys works, they can do this like so:
--
-- -- Create downed "Pilot Wagner" in #ZONE "CSAR_Start_1" at a random point for the blue coalition
-- my_csar:SpawnCSARAtZone( "CSAR_Start_1", coalition.side.BLUE, "Pilot Wagner", true )
function CSAR:SpawnCSARAtZone(Zone, Coalition, Description, RandomPoint, Nomessage)
self:_SpawnCsarAtZone(Zone, Coalition, Description, RandomPoint, Nomessage)
-- my_csar:SpawnCSARAtZone( "CSAR_Start_1", coalition.side.BLUE, "Wagner", true, false, "Charly-1-1", "F5E" )
function CSAR:SpawnCSARAtZone(Zone, Coalition, Description, RandomPoint, Nomessage, Unitname, Typename)
self:_SpawnCsarAtZone(Zone, Coalition, Description, RandomPoint, Nomessage, Unitname, Typename)
return self
end
@ -1199,7 +1205,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
end
if _time <= 0 or _distance < self.loadDistance then
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_heliName) then
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in, bugger!", self.messageTime, true)
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true)
return true
else
self.landedStatus[_lookupKeyHeli] = nil
@ -1211,7 +1217,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
else
if (_distance < self.loadDistance) then
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_heliName) then
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in, honk!", self.messageTime, true)
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true)
return true
else
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
@ -1252,7 +1258,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
self:_DisplayMessageToSAR(_heliUnit, "Hovering above " .. _pilotName .. ". \n\nHold hover for " .. _time .. " seconds to winch them up. \n\nIf the countdown stops you\'re too far away!", self.messageTime, true)
else
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_heliName) then
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in, noob!", self.messageTime, true)
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true)
return true
else
self.hoverStatus[_lookupKeyHeli] = nil

View File

@ -410,6 +410,7 @@ do
-- my_ctld.enableHercules = true
-- my_ctld.HercMinAngels = 155 -- for troop/cargo drop via chute in meters, ca 470 ft
-- my_ctld.HercMaxAngels = 2000 -- for troop/cargo drop via chute in meters, ca 6000 ft
-- my_ctld.HercMaxSpeed = 77 -- 77mps or 270 kph or 150 kn
--
-- Also, the following options need to be set to `true`:
--
@ -478,7 +479,7 @@ CTLD = {
-- @field #table vhfbeacon Beacon info as #CTLD.ZoneBeacon
--- Zone Type Info.
-- @type CTLD.
-- @type CTLD.CargoZoneType
CTLD.CargoZoneType = {
LOAD = "load",
DROP = "drop",
@ -651,6 +652,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
self.enableHercules = false
self.HercMinAngels = 165 -- for troop/cargo drop via chute
self.HercMaxAngels = 2000 -- for troop/cargo drop via chute
self.HercMaxSpeed = 77 -- 280 kph or 150kn eq 77 mps
-- message suppression
self.suppressmessages = false
@ -2283,10 +2285,12 @@ end
local aheight = uheight - gheight -- height above ground
local maxh = self.HercMinAngels-- 1500m
local minh = self.HercMaxAngels -- 5000m
local mspeed = 2 -- 2 m/s
-- TODO:Add speed test for Herc, should not be above 280kph/150kn
--self:Tstring.format("%s Unit parameters: at %dm AGL with %dmps",self.lid,aheight,uspeed))
if (aheight <= maxh) and (aheight >= minh) then
local maxspeed = self.HercMaxSpeed -- 77 mps
-- TODO: TEST - Speed test for Herc, should not be above 280kph/150kn
local kmspeed = uspeed * 3.6
local knspeed = kmspeed / 1.86
self:T(string.format("%s Unit parameters: at %dm AGL with %dmps | %dkph | %dkn",self.lid,aheight,uspeed,kmspeed,knspeed))
if (aheight <= maxh) and (aheight >= minh) and (uspeed <= maxspeed) then
-- yep within parameters
outcome = true
end
@ -2302,7 +2306,14 @@ end
local inhover = self:IsCorrectHover(Unit)
local htxt = "true"
if not inhover then htxt = "false" end
local text = string.format("Hover parameters (autoload/drop):\n - Min height %dm \n - Max height %dm \n - Max speed 2mps \n - In parameter: %s", self.minimumHoverHeight, self.maximumHoverHeight, htxt)
local text = ""
if _SETTINGS:IsMetric() then
text = string.format("Hover parameters (autoload/drop):\n - Min height %dm \n - Max height %dm \n - Max speed 2mps \n - In parameter: %s", self.minimumHoverHeight, self.maximumHoverHeight, htxt)
else
local minheight = UTILS.MetersToFeet(self.minimumHoverHeight)
local maxheight = UTILS.MetersToFeet(self.maximumHoverHeight)
text = string.format("Hover parameters (autoload/drop):\n - Min height %dm \n - Max height %dm \n - Max speed 6fts \n - In parameter: %s", minheight, maxheight, htxt)
end
self:_SendMessage(text, 10, false, Group)
--local m = MESSAGE:New(text,10,"CTLD",false):ToGroup(Group)
return self
@ -2316,9 +2327,16 @@ end
local inhover = self:IsCorrectFlightParameters(Unit)
local htxt = "true"
if not inhover then htxt = "false" end
local minheight = UTILS.MetersToFeet(self.HercMinAngels)
local maxheight = UTILS.MetersToFeet(self.HercMaxAngels)
local text = string.format("Flight parameters (airdrop):\n - Min height %dft \n - Max height %dft \n - In parameter: %s", minheight, maxheight, htxt)
local text = ""
if _SETTINGS:IsImperial() then
local minheight = UTILS.MetersToFeet(self.HercMinAngels)
local maxheight = UTILS.MetersToFeet(self.HercMaxAngels)
text = string.format("Flight parameters (airdrop):\n - Min height %dft \n - Max height %dft \n - In parameter: %s", minheight, maxheight, htxt)
else
local minheight = self.HercMinAngels
local maxheight = self.HercMaxAngels
text = string.format("Flight parameters (airdrop):\n - Min height %dm \n - Max height %dm \n - In parameter: %s", minheight, maxheight, htxt)
end
self:_SendMessage(text, 10, false, Group)
--local m = MESSAGE:New(text,15,"CTLD",false):ToGroup(Group)
return self