Reflect DEVELOP changes in MASTER

This commit is contained in:
Applevangelist
2021-07-14 08:41:14 +02:00
parent 6fbf050b72
commit 2fb0ab1aed
3 changed files with 524 additions and 265 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -609,7 +609,8 @@ end
-- @param #number _freq Frequency -- @param #number _freq Frequency
-- @param #boolean noMessage -- @param #boolean noMessage
-- @param #string _description Description -- @param #string _description Description
function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _playerName, _freq, noMessage, _description ) -- @param #boolean forcedesc Use the description only for the pilot track entry
function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _playerName, _freq, noMessage, _description, forcedesc )
self:T(self.lid .. " _AddCsar") self:T(self.lid .. " _AddCsar")
self:T({_coalition , _country, _point, _typeName, _unitName, _playerName, _freq, noMessage, _description}) self:T({_coalition , _country, _point, _typeName, _unitName, _playerName, _freq, noMessage, _description})
@@ -622,11 +623,10 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
local _spawnedGroup, _alias = self:_SpawnPilotInField(_country,_point,_freq) local _spawnedGroup, _alias = self:_SpawnPilotInField(_country,_point,_freq)
local _typeName = _typeName or "PoW" local _typeName = _typeName or "Pilot"
if not noMessage then if not noMessage then
self:_DisplayToAllSAR("MAYDAY MAYDAY! " .. _typeName .. " is down. ", self.coalition, 10) self:_DisplayToAllSAR("MAYDAY MAYDAY! " .. _typeName .. " is down. ", self.coalition, 10)
--local m = MESSAGE:New("MAYDAY MAYDAY! " .. _typeName .. " is down. ",10,"INFO"):ToCoalition(self.coalition)
end end
if _freq then if _freq then
@@ -635,15 +635,14 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
self:_AddSpecialOptions(_spawnedGroup) self:_AddSpecialOptions(_spawnedGroup)
local _text = " " local _text = _description
if _playerName ~= nil then if not forcedesc then
_text = "Pilot " .. _playerName .. " of " .. _unitName .. " - " .. _typeName if _playerName ~= nil then
elseif _typeName ~= nil then _text = "Pilot " .. _playerName
_text = "AI Pilot of " .. _unitName .. " - " .. _typeName elseif _unitName ~= nil then
else _text = "AI Pilot of " .. _unitName
_text = _description end
end end
self:T({_spawnedGroup, _alias}) self:T({_spawnedGroup, _alias})
local _GroupName = _spawnedGroup:GetName() or _alias local _GroupName = _spawnedGroup:GetName() or _alias
@@ -662,7 +661,10 @@ end
-- @param #string _description (optional) Description. -- @param #string _description (optional) Description.
-- @param #boolean _randomPoint (optional) Random yes or no. -- @param #boolean _randomPoint (optional) Random yes or no.
-- @param #boolean _nomessage (optional) If true, don\'t send a message to SAR. -- @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.
-- @param #boolean forcedesc (optional) Force to use the description passed only for the pilot track entry. Use to have fully custom names.
function CSAR:_SpawnCsarAtZone( _zone, _coalition, _description, _randomPoint, _nomessage, unitname, typename, forcedesc)
self:T(self.lid .. " _SpawnCsarAtZone") self:T(self.lid .. " _SpawnCsarAtZone")
local freq = self:_GenerateADFFrequency() local freq = self:_GenerateADFFrequency()
local _triggerZone = ZONE:New(_zone) -- trigger to use as reference position local _triggerZone = ZONE:New(_zone) -- trigger to use as reference position
@@ -671,7 +673,9 @@ function CSAR:_SpawnCsarAtZone( _zone, _coalition, _description, _randomPoint, _
return return
end 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 = {} local pos = {}
if _randomPoint then if _randomPoint then
@@ -690,7 +694,7 @@ function CSAR:_SpawnCsarAtZone( _zone, _coalition, _description, _randomPoint, _
_country = country.id.UN_PEACEKEEPERS _country = country.id.UN_PEACEKEEPERS
end end
self:_AddCsar(_coalition, _country, pos, "PoW", _description, nil, freq, _nomessage, _description) self:_AddCsar(_coalition, _country, pos, typename, unitname, _description, freq, _nomessage, _description, forcedesc)
return self return self
end end
@@ -702,12 +706,15 @@ end
-- @param #string Description (optional) Description. -- @param #string Description (optional) Description.
-- @param #boolean RandomPoint (optional) Random yes or no. -- @param #boolean RandomPoint (optional) Random yes or no.
-- @param #boolean Nomessage (optional) If true, don\'t send a message to SAR. -- @param #boolean Nomessage (optional) If true, don\'t send a message to SAR.
-- @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: -- @param #string Unitname (optional) Name of the lost unit.
-- @param #string Typename (optional) Type of plane.
-- @param #boolean Forcedesc (optional) Force to use the **description passed only** for the pilot track entry. Use to have fully custom names.
-- @usage If missions designers want to spawn downed pilots into the field, e.g. at mission begin, to give the helicopter guys work, they can do this like so:
-- --
-- -- Create downed "Pilot Wagner" in #ZONE "CSAR_Start_1" at a random point for the blue coalition -- -- 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 ) -- my_csar:SpawnCSARAtZone( "CSAR_Start_1", coalition.side.BLUE, "Wagner", true, false, "Charly-1-1", "F5E" )
function CSAR:SpawnCSARAtZone(Zone, Coalition, Description, RandomPoint, Nomessage) function CSAR:SpawnCSARAtZone(Zone, Coalition, Description, RandomPoint, Nomessage, Unitname, Typename, Forcedesc)
self:_SpawnCsarAtZone(Zone, Coalition, Description, RandomPoint, Nomessage) self:_SpawnCsarAtZone(Zone, Coalition, Description, RandomPoint, Nomessage, Unitname, Typename, Forcedesc)
return self return self
end end
@@ -1199,7 +1206,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
end end
if _time <= 0 or _distance < self.loadDistance then if _time <= 0 or _distance < self.loadDistance then
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_heliName) 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 return true
else else
self.landedStatus[_lookupKeyHeli] = nil self.landedStatus[_lookupKeyHeli] = nil
@@ -1211,7 +1218,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
else else
if (_distance < self.loadDistance) then if (_distance < self.loadDistance) then
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_heliName) 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 return true
else else
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName) self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
@@ -1252,7 +1259,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) 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 else
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_heliName) then 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 return true
else else
self.hoverStatus[_lookupKeyHeli] = nil self.hoverStatus[_lookupKeyHeli] = nil
@@ -1377,7 +1384,7 @@ end
--- (Internal) Check and return Wrappe.Unit#UNIT based on the name if alive. --- (Internal) Check and return Wrappe.Unit#UNIT based on the name if alive.
-- @param #CSAR self -- @param #CSAR self
-- @param #string _unitname Name of Unit -- @param #string _unitname Name of Unit
-- @return #UNIT or nil -- @return Wrapper.Unit#UNIT The unit or nil
function CSAR:_GetSARHeli(_unitName) function CSAR:_GetSARHeli(_unitName)
self:T(self.lid .. " _GetSARHeli") self:T(self.lid .. " _GetSARHeli")
local unit = UNIT:FindByName(_unitName) local unit = UNIT:FindByName(_unitName)
@@ -1428,12 +1435,8 @@ function CSAR:_GetPositionOfWounded(_woundedGroup)
_coordinatesText = _coordinate:ToStringLLDMS() _coordinatesText = _coordinate:ToStringLLDMS()
elseif self.coordtype == 2 then -- MGRS elseif self.coordtype == 2 then -- MGRS
_coordinatesText = _coordinate:ToStringMGRS() _coordinatesText = _coordinate:ToStringMGRS()
elseif self.coordtype == 3 then -- Bullseye Imperial else -- Bullseye Metric --(medevac.coordtype == 4 or 3)
local Settings = _SETTINGS:SetImperial() _coordinatesText = _coordinate:ToStringBULLS(self.coalition)
_coordinatesText = _coordinate:ToStringBULLS(self.coalition,Settings)
else -- Bullseye Metric --(medevac.coordtype == 4)
local Settings = _SETTINGS:SetMetric()
_coordinatesText = _coordinate:ToStringBULLS(self.coalition,Settings)
end end
end end
return _coordinatesText return _coordinatesText
@@ -1467,12 +1470,11 @@ function CSAR:_DisplayActiveSAR(_unitName)
local _woundcoord = _woundedGroup:GetCoordinate() local _woundcoord = _woundedGroup:GetCoordinate()
local _distance = self:_GetDistance(_helicoord, _woundcoord) local _distance = self:_GetDistance(_helicoord, _woundcoord)
self:T({_distance = _distance}) self:T({_distance = _distance})
-- change distance to miles if self.coordtype < 4
local distancetext = "" local distancetext = ""
if self.coordtype < 4 then if _SETTINGS:IsImperial() then
distancetext = string.format("%.3fnm",UTILS.MetersToNM(_distance)) distancetext = string.format("%.1fnm",UTILS.MetersToNM(_distance))
else else
distancetext = string.format("%.3fkm", _distance/1000.0) distancetext = string.format("%.1fkm", _distance/1000.0)
end end
table.insert(_csarList, { dist = _distance, msg = string.format("%s at %s - %.2f KHz ADF - %s ", _value.desc, _coordinatesText, _value.frequency / 1000, distancetext) }) table.insert(_csarList, { dist = _distance, msg = string.format("%s at %s - %.2f KHz ADF - %s ", _value.desc, _coordinatesText, _value.frequency / 1000, distancetext) })
end end
@@ -1542,10 +1544,10 @@ function CSAR:_SignalFlare(_unitName)
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot) local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
local _distance = 0 local _distance = 0
if self.coordtype < 4 then if _SETTINGS:IsImperial() then
_distance = string.format("%.3fnm",UTILS.MetersToNM(_closest.distance)) _distance = string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
else else
_distance = string.format("%.3fkm",_closest.distance) _distance = string.format("%.1fkm",_closest.distance)
end end
local _msg = string.format("%s - Popping signal flare at your %s o\'clock. Distance %s", _unitName, _clockDir, _distance) local _msg = string.format("%s - Popping signal flare 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)
@@ -1554,7 +1556,7 @@ function CSAR:_SignalFlare(_unitName)
_coord:FlareRed(_clockDir) _coord:FlareRed(_clockDir)
else else
local disttext = "4.3nm" local disttext = "4.3nm"
if self.coordtype == 4 then if _SETTINGS:IsMetric() then
disttext = "8km" disttext = "8km"
end end
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",disttext), self.messageTime) self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",disttext), self.messageTime)
@@ -1593,10 +1595,10 @@ function CSAR:_Reqsmoke( _unitName )
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < 8000.0 then if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < 8000.0 then
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot) local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
local _distance = 0 local _distance = 0
if self.coordtype < 4 then if _SETTINGS:IsImperial() then
_distance = string.format("%.3fnm",UTILS.MetersToNM(_closest.distance)) _distance = string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
else else
_distance = string.format("%.3fkm",_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 signal 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)
@@ -1605,7 +1607,7 @@ function CSAR:_Reqsmoke( _unitName )
_coord:Smoke(color) _coord:Smoke(color)
else else
local disttext = "4.3nm" local disttext = "4.3nm"
if self.coordtype == 4 then if _SETTINGS:IsMetric() then
disttext = "8km" disttext = "8km"
end end
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",disttext), self.messageTime) self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",disttext), self.messageTime)

View File

@@ -81,8 +81,8 @@ CTLD_CARGO = {
self.Name = Name or "none" -- #string self.Name = Name or "none" -- #string
self.Templates = Templates or {} -- #table self.Templates = Templates or {} -- #table
self.CargoType = Sorte or "type" -- #CTLD_CARGO.Enum self.CargoType = Sorte or "type" -- #CTLD_CARGO.Enum
self.HasBeenMoved = HasBeenMoved or false -- #booolean self.HasBeenMoved = HasBeenMoved or false -- #boolean
self.LoadDirectly = LoadDirectly or false -- #booolean self.LoadDirectly = LoadDirectly or false -- #boolean
self.CratesNeeded = CratesNeeded or 0 -- #number self.CratesNeeded = CratesNeeded or 0 -- #number
self.Positionable = Positionable or nil -- Wrapper.Positionable#POSITIONABLE self.Positionable = Positionable or nil -- Wrapper.Positionable#POSITIONABLE
self.HasBeenDropped = Dropped or false --#boolean self.HasBeenDropped = Dropped or false --#boolean
@@ -410,6 +410,7 @@ do
-- my_ctld.enableHercules = true -- my_ctld.enableHercules = true
-- my_ctld.HercMinAngels = 155 -- for troop/cargo drop via chute in meters, ca 470 ft -- 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.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`: -- Also, the following options need to be set to `true`:
-- --
@@ -478,7 +479,7 @@ CTLD = {
-- @field #table vhfbeacon Beacon info as #CTLD.ZoneBeacon -- @field #table vhfbeacon Beacon info as #CTLD.ZoneBeacon
--- Zone Type Info. --- Zone Type Info.
-- @type CTLD. -- @type CTLD.CargoZoneType
CTLD.CargoZoneType = { CTLD.CargoZoneType = {
LOAD = "load", LOAD = "load",
DROP = "drop", DROP = "drop",
@@ -651,6 +652,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
self.enableHercules = false self.enableHercules = false
self.HercMinAngels = 165 -- for troop/cargo drop via chute self.HercMinAngels = 165 -- for troop/cargo drop via chute
self.HercMaxAngels = 2000 -- 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 -- message suppression
self.suppressmessages = false self.suppressmessages = false
@@ -803,16 +805,10 @@ function CTLD:_GenerateUHFrequencies()
end end
--- (Internal) Function to generate valid FM Frequencies --- (Internal) Function to generate valid FM Frequencies
-- @param #CTLD sel -- @param #CTLD self
function CTLD:_GenerateFMFrequencies() function CTLD:_GenerateFMFrequencies()
self:T(self.lid .. " _GenerateFMrequencies") self:T(self.lid .. " _GenerateFMrequencies")
self.FreeFMFrequencies = {} self.FreeFMFrequencies = {}
local _start = 220000000
while _start < 399000000 do
_start = _start + 500000
end
for _first = 3, 7 do for _first = 3, 7 do
for _second = 0, 5 do for _second = 0, 5 do
@@ -2289,10 +2285,12 @@ end
local aheight = uheight - gheight -- height above ground local aheight = uheight - gheight -- height above ground
local maxh = self.HercMinAngels-- 1500m local maxh = self.HercMinAngels-- 1500m
local minh = self.HercMaxAngels -- 5000m local minh = self.HercMaxAngels -- 5000m
local mspeed = 2 -- 2 m/s local maxspeed = self.HercMaxSpeed -- 77 mps
-- TODO:Add speed test for Herc, should not be above 280kph/150kn -- TODO: TEST - 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)) local kmspeed = uspeed * 3.6
if (aheight <= maxh) and (aheight >= minh) then 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 -- yep within parameters
outcome = true outcome = true
end end
@@ -2308,7 +2306,14 @@ end
local inhover = self:IsCorrectHover(Unit) local inhover = self:IsCorrectHover(Unit)
local htxt = "true" local htxt = "true"
if not inhover then htxt = "false" end 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) self:_SendMessage(text, 10, false, Group)
--local m = MESSAGE:New(text,10,"CTLD",false):ToGroup(Group) --local m = MESSAGE:New(text,10,"CTLD",false):ToGroup(Group)
return self return self
@@ -2322,9 +2327,16 @@ end
local inhover = self:IsCorrectFlightParameters(Unit) local inhover = self:IsCorrectFlightParameters(Unit)
local htxt = "true" local htxt = "true"
if not inhover then htxt = "false" end if not inhover then htxt = "false" end
local minheight = UTILS.MetersToFeet(self.HercMinAngels) local text = ""
local maxheight = UTILS.MetersToFeet(self.HercMaxAngels) if _SETTINGS:IsImperial() then
local text = string.format("Flight parameters (airdrop):\n - Min height %dft \n - Max height %dft \n - In parameter: %s", minheight, maxheight, htxt) 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) self:_SendMessage(text, 10, false, Group)
--local m = MESSAGE:New(text,15,"CTLD",false):ToGroup(Group) --local m = MESSAGE:New(text,15,"CTLD",false):ToGroup(Group)
return self return self