Merge branch 'master' into FF/MasterDevel

This commit is contained in:
Frank
2022-11-19 11:44:46 +01:00
120 changed files with 3644 additions and 1748 deletions

View File

@@ -46,7 +46,7 @@
--
-- ### Author: **funkyfranky**
--
-- @module Ops.Atis
-- @module Ops.ATIS
-- @image OPS_ATIS.png
--- ATIS class.
@@ -91,6 +91,8 @@
-- @field #boolean useSRS If true, use SRS for transmission.
-- @field Sound.SRS#MSRS msrs Moose SRS object.
-- @field #number dTQueueCheck Time interval to check the radio queue. Default 5 sec or 90 sec if SRS is used.
-- @field #boolean ReportmBar Report mBar/hpa even if not metric, i.e. for Mirage flights
-- @field #boolean TransmitOnlyWithPlayers For SRS - If true, only transmit if there are alive Players.
-- @extends Core.Fsm#FSM
--- *It is a very sad thing that nowadays there is so little useless information.* - Oscar Wilde
@@ -120,7 +122,7 @@
-- The @{#ATIS.New}(*airbasename*, *frequency*) creates a new ATIS object. The parameter *airbasename* is the name of the airbase or airport. Note that this has to be spelled exactly as in the DCS mission editor.
-- The parameter *frequency* is the frequency the ATIS broadcasts in MHz.
--
-- Broadcasting is started via the @{#ATIS.Start}() function. The start can be delayed by useing @{#ATIS.__Start}(*delay*), where *delay* is the delay in seconds.
-- Broadcasting is started via the @{#ATIS.Start}() function. The start can be delayed by using @{#ATIS.__Start}(*delay*), where *delay* is the delay in seconds.
--
-- ## Subtitles
--
@@ -344,6 +346,8 @@ ATIS = {
usemarker = nil,
markerid = nil,
relHumidity = nil,
ReportmBar = false,
TransmitOnlyWithPlayers = false,
}
--- NATO alphabet.
@@ -586,15 +590,18 @@ _ATIS = {}
--- ATIS class version.
-- @field #string version
ATIS.version = "0.9.8"
ATIS.version = "0.9.11"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Add new Normany airfields.
-- TODO: Add new Normandy airfields.
-- TODO: Zulu time --> Zulu in output.
-- TODO: Correct fog for elevation.
-- DONE: Use new AIRBASE system to set start/landing runway
-- DONE: SetILS doesn't work
-- DONE: Visibility reported twice over SRS
-- DONE: Add text report for output.
-- DONE: Add stop FMS functions.
-- NOGO: Use local time. Not realisitc!
@@ -651,6 +658,7 @@ function ATIS:New(AirbaseName, Frequency, Modulation)
self:SetMapMarks( false )
self:SetRelativeHumidity()
self:SetQueueUpdateTime()
self:SetReportmBar(false)
-- Start State.
self:SetStartState( "Stopped" )
@@ -774,13 +782,52 @@ function ATIS:SetTowerFrequencies( freqs )
return self
end
--- Set active runway. This can be used if the automatic runway determination via the wind direction gives incorrect results.
--- For SRS - Switch to only transmit if there are players on the server.
-- @param #ATIS self
-- @param #boolean Switch If true, only send SRS if there are alive Players.
-- @return #ATIS self
function ATIS:SetTransmitOnlyWithPlayers(Switch)
self.TransmitOnlyWithPlayers = Switch
if self.msrsQ then
self.msrsQ:SetTransmitOnlyWithPlayers(Switch)
end
return self
end
--- Set active runway for **landing** operations. This can be used if the automatic runway determination via the wind direction gives incorrect results.
-- For example, use this if there are two runways with the same directions.
-- @param #ATIS self
-- @param #string runway Active runway, *e.g.* "31L".
-- @return #ATIS self
function ATIS:SetActiveRunway( runway )
self.activerunway = tostring( runway )
local prefer = nil
if string.find(string.lower(runway),"l") then
prefer = true
elseif string.find(string.lower(runway),"r") then
prefer = false
end
self.airbase:SetActiveRunway(runway,prefer)
return self
end
--- Set the active runway for landing.
-- @param #ATIS self
-- @param #string runway : Name of the runway, e.g. "31" or "02L" or "90R". If not given, the runway is determined from the wind direction.
-- @param #boolean preferleft : If true, perfer the left runway. If false, prefer the right runway. If nil (default), do not care about left or right.
-- @return #ATIS self
function ATIS:SetActiveRunwayLanding(runway, preferleft)
self.airbase:SetActiveRunwayLanding(runway,preferleft)
return self
end
--- Set the active runway for take-off.
-- @param #ATIS self
-- @param #string runway : Name of the runway, e.g. "31" or "02L" or "90R". If not given, the runway is determined from the wind direction.
-- @param #boolean preferleft : If true, perfer the left runway. If false, prefer the right runway. If nil (default), do not care about left or right.
-- @return #ATIS self
function ATIS:SetActiveRunwayTakeoff(runway,preferleft)
self.airbase:SetActiveRunwayTakeoff(runway,preferleft)
return self
end
@@ -947,6 +994,28 @@ function ATIS:SetAltimeterQNH( switch )
return self
end
--- Additionally report altimeter QNH/QFE in hPa, even if not set to metric.
-- @param #ATIS self
-- @param #boolean switch If true or nil, report mBar/hPa in addition.
-- @return #ATIS self
function ATIS:SetReportmBar(switch)
if switch == true or switch == nil then
self.ReportmBar = true
else
self.ReportmBar = false
end
return self
end
--- Additionally report free text, only working with SRS(!)
-- @param #ATIS self
-- @param #string text The text to report at the end of the ATIS message, e.g. runway closure, warnings, etc.
-- @return #ATIS self
function ATIS:SetAdditionalInformation(text)
self.AdditionalInformation = text
return self
end
--- Suppresses QFE readout. Default is to report both QNH and QFE.
-- @param #ATIS self
-- @return #ATIS self
@@ -978,7 +1047,7 @@ end
-- Or you make your life simple and just include the sign so you don't have to bother about East/West.
--
-- @param #ATIS self
-- @param #number magvar Magnetic variation in degrees. Positive for easterly and negative for westerly variation. Default is magnatic declinaton of the used map, c.f. @{Utilities.UTils#UTILS.GetMagneticDeclination}.
-- @param #number magvar Magnetic variation in degrees. Positive for easterly and negative for westerly variation. Default is magnatic declinaton of the used map, c.f. @{Utilities.Utils#UTILS.GetMagneticDeclination}.
-- @return #ATIS self
function ATIS:SetMagneticDeclination( magvar )
self.magvar = magvar or UTILS.GetMagneticDeclination()
@@ -1140,6 +1209,7 @@ function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port, GoogleKey)
self.msrs:SetLabel("ATIS")
self.msrs:SetGoogle(GoogleKey)
self.msrsQ = MSRSQUEUE:New("ATIS")
self.msrsQ:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers)
if self.dTQueueCheck<=10 then
self:SetQueueUpdateTime(90)
end
@@ -1188,16 +1258,16 @@ function ATIS:onafterStart( From, Event, To )
-- Start radio queue.
if not self.useSRS then
self.radioqueue = RADIOQUEUE:New( self.frequency, self.modulation, string.format( "ATIS %s", self.airbasename ) )
-- Send coordinate is airbase coord.
self.radioqueue:SetSenderCoordinate( self.airbase:GetCoordinate() )
-- Set relay unit if we have one.
self.radioqueue:SetSenderUnitName( self.relayunitname )
-- Set radio power.
self.radioqueue:SetRadioPower( self.power )
-- Init numbers.
self.radioqueue:SetDigit( 0, ATIS.Sound.N0.filename, ATIS.Sound.N0.duration, self.soundpath )
self.radioqueue:SetDigit( 1, ATIS.Sound.N1.filename, ATIS.Sound.N1.duration, self.soundpath )
@@ -1209,11 +1279,11 @@ function ATIS:onafterStart( From, Event, To )
self.radioqueue:SetDigit( 7, ATIS.Sound.N7.filename, ATIS.Sound.N7.duration, self.soundpath )
self.radioqueue:SetDigit( 8, ATIS.Sound.N8.filename, ATIS.Sound.N8.duration, self.soundpath )
self.radioqueue:SetDigit( 9, ATIS.Sound.N9.filename, ATIS.Sound.N9.duration, self.soundpath )
-- Start radio queue.
self.radioqueue:Start( 1, 0.1 )
end
-- Handle airbase capture
-- Handle events.
self:HandleEvent( EVENTS.BaseCaptured )
@@ -1249,8 +1319,10 @@ function ATIS:onafterStatus( From, Event, To )
text = text .. string.format( ", Relay unit=%s (alive=%s)", tostring( self.relayunitname ), relayunitstatus )
end
self:T( self.lid .. text )
self:__Status( -60 )
if not self:Is("Stopped") then
self:__Status( -60 )
end
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -1278,9 +1350,11 @@ function ATIS:onafterCheckQueue( From, Event, To )
end
end
-- Check back in 5 seconds.
self:__CheckQueue( -math.abs( self.dTQueueCheck ) )
if not self:Is("Stopped") then
-- Check back in 5 seconds.
self:__CheckQueue( -math.abs( self.dTQueueCheck ) )
end
end
--- Broadcast ATIS radio message.
@@ -1328,6 +1402,9 @@ function ATIS:onafterBroadcast( From, Event, To )
end
local mBarqnh = qnh
local mBarqfe = qfe
-- Convert to inHg.
if self.PmmHg then
qfe = UTILS.hPa2mmHg( qfe )
@@ -1778,7 +1855,9 @@ function ATIS:onafterBroadcast( From, Event, To )
end
end
alltext = alltext .. ";\n" .. subtitle
--self:I("Line 1811")
--self:I(alltext)
-- Visibility
if self.metric then
subtitle = string.format( "Visibility %s km", VISIBILITY )
@@ -1795,7 +1874,10 @@ function ATIS:onafterBroadcast( From, Event, To )
end
end
alltext = alltext .. ";\n" .. subtitle
--self:I("Line 1830")
--self:I(alltext)
subtitle = ""
-- Weather phenomena
local wp = false
local wpsub = ""
@@ -1895,8 +1977,11 @@ function ATIS:onafterBroadcast( From, Event, To )
end
end
end
alltext = alltext .. ";\n" .. subtitle
--self:I("Line 1932")
alltext = alltext .. ";\n" .. subtitle
--self:I(alltext)
subtitle = ""
-- Temperature
if self.TDegF then
if temperature < 0 then
@@ -1924,8 +2009,10 @@ function ATIS:onafterBroadcast( From, Event, To )
self:Transmission( ATIS.Sound.DegreesCelsius, 0.2 )
end
end
--self:I("Line 1962")
alltext = alltext .. ";\n" .. subtitle
--self:I(alltext)
-- Dew point
if self.TDegF then
if dewpoint < 0 then
@@ -1953,6 +2040,8 @@ function ATIS:onafterBroadcast( From, Event, To )
self:Transmission( ATIS.Sound.DegreesCelsius, 0.2 )
end
end
--self:I("Line 1992")
--self:I(alltext)
alltext = alltext .. ";\n" .. subtitle
-- Altimeter QNH/QFE.
@@ -1977,6 +2066,15 @@ function ATIS:onafterBroadcast( From, Event, To )
end
end
end
if self.ReportmBar and not self.metric then
if self.qnhonly then
subtitle = string.format( "%s;\nAltimeter %d hPa", subtitle, mBarqnh )
else
subtitle = string.format( "%s;\nAltimeter: QNH %d, QFE %d hPa", subtitle, mBarqnh, mBarqfe)
end
end
local _ALTIMETER = subtitle
if not self.useSRS then
self:Transmission( ATIS.Sound.Altimeter, 1.0, subtitle )
@@ -2009,6 +2107,8 @@ function ATIS:onafterBroadcast( From, Event, To )
end
end
end
--self:I("Line 2049")
--self:I(alltext)
alltext = alltext .. ";\n" .. subtitle
-- Active runway.
@@ -2136,7 +2236,9 @@ function ATIS:onafterBroadcast( From, Event, To )
end
-- ILS
--self:I({ils=self.ils})
local ils=self:GetNavPoint(self.ils, runwayLanding, rwyLandingLeft)
--self:I({ils=ils,runwayLanding=runwayLanding, rwyLandingLeft=rwyLandingLeft})
if ils then
subtitle = string.format( "ILS frequency %.2f MHz", ils.frequency )
if not self.useSRS then
@@ -2151,6 +2253,7 @@ function ATIS:onafterBroadcast( From, Event, To )
self:Transmission( ATIS.Sound.MegaHertz, 0.2 )
end
alltext = alltext .. ";\n" .. subtitle
--self:I(alltext)
end
-- Outer NDB
@@ -2240,7 +2343,12 @@ function ATIS:onafterBroadcast( From, Event, To )
end
alltext = alltext .. ";\n" .. subtitle
end
-- additional info, if any
if self.useSRS and self.AdditionalInformation then
alltext = alltext .. ";\n"..self.AdditionalInformation
end
-- Advice on initial...
subtitle = string.format( "Advise on initial contact, you have information %s", NATO )
if not self.useSRS then

View File

@@ -27,17 +27,17 @@
-- **Supported Carriers:**
--
-- * [USS John C. Stennis](https://en.wikipedia.org/wiki/USS_John_C._Stennis) (CVN-74)
-- * [USS Theodore Roosevelt](https://en.wikipedia.org/wiki/USS_Theodore_Roosevelt_(CVN-71)) (CVN-71) [Super Carrier Module]
-- * [USS Abraham Lincoln](https://en.wikipedia.org/wiki/USS_Abraham_Lincoln_(CVN-72)) (CVN-72) [Super Carrier Module]
-- * [USS George Washington](https://en.wikipedia.org/wiki/USS_George_Washington_(CVN-73)) (CVN-73) [Super Carrier Module]
-- * [USS Theodore Roosevelt](https://en.wikipedia.org/wiki/USS_Theodore_Roosevelt_(CVN-71\)) (CVN-71) [Super Carrier Module]
-- * [USS Abraham Lincoln](https://en.wikipedia.org/wiki/USS_Abraham_Lincoln_(CVN-72\)) (CVN-72) [Super Carrier Module]
-- * [USS George Washington](https://en.wikipedia.org/wiki/USS_George_Washington_(CVN-73\)) (CVN-73) [Super Carrier Module]
-- * [USS Harry S. Truman](https://en.wikipedia.org/wiki/USS_Harry_S._Truman) (CVN-75) [Super Carrier Module]
-- * [USS Forrestal](https://en.wikipedia.org/wiki/USS_Forrestal_(CV-59)) (CV-59) [Heatblur Carrier Module]
-- * [HMS Hermes](https://en.wikipedia.org/wiki/HMS_Hermes_(R12)) (R12) [**WIP**]
-- * [HMS Invincible](https://en.wikipedia.org/wiki/HMS_Invincible_(R05) (R05) [**WIP**]
-- * [USS Tarawa](https://en.wikipedia.org/wiki/USS_Tarawa_(LHA-1)) (LHA-1) [**WIP**]
-- * [USS America](https://en.wikipedia.org/wiki/USS_America_(LHA-6)) (LHA-6) [**WIP**]
-- * [USS Forrestal](https://en.wikipedia.org/wiki/USS_Forrestal_(CV-59\)) (CV-59) [Heatblur Carrier Module]
-- * [HMS Hermes](https://en.wikipedia.org/wiki/HMS_Hermes_(R12\)) (R12) [**WIP**]
-- * [HMS Invincible](https://en.wikipedia.org/wiki/HMS_Invincible_(R05\)) (R05) [**WIP**]
-- * [USS Tarawa](https://en.wikipedia.org/wiki/USS_Tarawa_(LHA-1\)) (LHA-1) [**WIP**]
-- * [USS America](https://en.wikipedia.org/wiki/USS_America_(LHA-6\)) (LHA-6) [**WIP**]
-- * [Juan Carlos I](https://en.wikipedia.org/wiki/Spanish_amphibious_assault_ship_Juan_Carlos_I) (L61) [**WIP**]
-- * [HMAS Canberra](https://en.wikipedia.org/wiki/HMAS_Canberra_(L02)) (L02) [**WIP**]
-- * [HMAS Canberra](https://en.wikipedia.org/wiki/HMAS_Canberra_(L02\)) (L02) [**WIP**]
--
-- **Supported Aircraft:**
--
@@ -117,6 +117,7 @@
-- * [Updated Airboss V/STOL Features USS Tarawa](https://youtu.be/K7I4pU6j718)
-- * [Harrier Practice pattern USS America](https://youtu.be/99NigITYmcI)
-- * [Harrier CASE III TACAN Approach USS Tarawa](https://www.youtube.com/watch?v=bTgJXZ9Mhdc&t=1s)
-- * [Harrier CASE III TACAN Approach USS Tarawa](https://www.youtube.com/watch?v=wWHag5WpNZ0)
--
-- ===
--
@@ -142,7 +143,7 @@
-- @field Wrapper.Airbase#AIRBASE airbase Carrier airbase object.
-- @field #table waypoints Waypoint coordinates of carrier.
-- @field #number currentwp Current waypoint, i.e. the one that has been passed last.
-- @field Core.Radio#BEACON beacon Carrier beacon for TACAN and ICLS.
-- @field Core.Beacon#BEACON beacon Carrier beacon for TACAN and ICLS.
-- @field #boolean TACANon Automatic TACAN is activated.
-- @field #number TACANchannel TACAN channel.
-- @field #string TACANmode TACAN mode, i.e. "X" or "Y".
@@ -296,7 +297,7 @@
--
-- The flight that transitions form the holding pattern to the landing approach, it should leave the Marshal stack at the 3 position and make a left hand turn to the *Initial*
-- position, which is 3 NM astern of the boat. Note that you need to be below 1300 feet to be registered in the initial zone.
-- The altitude can be set via the function @{AIRBOSS.SetInitialMaxAlt}(*altitude*) function.
-- The altitude can be set via the function @{#AIRBOSS.SetInitialMaxAlt}(*altitude*) function.
-- As described below, the initial zone can be smoked or flared via the AIRBOSS F10 Help radio menu.
--
-- ### Landing Pattern
@@ -761,7 +762,7 @@
--
-- ## Save Results
--
-- Saving asset data to file is achieved by the @{AIRBOSS.Save}(*path*, *filename*) function.
-- Saving asset data to file is achieved by the @{#AIRBOSS.Save}(*path*, *filename*) function.
--
-- The parameter *path* specifies the path on the file system where the
-- player grades are saved. If you do not specify a path, the file is saved your the DCS installation root directory if the **lfs** module is *not* desanizied or
@@ -782,7 +783,7 @@
--
-- ### Automatic Saving
--
-- The player grades can be saved automatically after each graded player pass via the @{AIRBOSS.SetAutoSave}(*path*, *filename*) function. Again the parameters *path* and *filename* are optional.
-- The player grades can be saved automatically after each graded player pass via the @{#AIRBOSS.SetAutoSave}(*path*, *filename*) function. Again the parameters *path* and *filename* are optional.
-- In the simplest case, you desanitize the **lfs** module and just add
--
-- airbossStennis:SetAutoSave()
@@ -820,7 +821,7 @@
--
-- ## Load Results
--
-- Loading player grades from file is achieved by the @{AIRBOSS.Load}(*path*, *filename*) function. The parameter *path* specifies the path on the file system where the
-- Loading player grades from file is achieved by the @{#AIRBOSS.Load}(*path*, *filename*) function. The parameter *path* specifies the path on the file system where the
-- data is loaded from. If you do not specify a path, the file is loaded from your the DCS installation root directory or, if **lfs** was desanitized from you "Saved Games\DCS" directory.
-- The parameter *filename* is optional and defines the name of the file to load. By default this is automatically generated from the AIBOSS carrier name/alias, for example
-- "Airboss-USS Stennis_LSOgrades.csv".
@@ -1040,7 +1041,7 @@
--
-- AI groups that enter the CCA are usually guided to Marshal stack. However, due to DCS limitations they might not obey the landing task if they have another airfield as departure and/or destination in
-- their mission task. Therefore, AI groups can be respawned when detected in the CCA. This should clear all other airfields and allow the aircraft to land on the carrier.
-- This is achieved by the @{AIRBOSS.SetRespawnAI}() function.
-- This is achieved by the @{#AIRBOSS.SetRespawnAI}() function.
--
-- ## Known Issues
--
@@ -1202,6 +1203,8 @@ AIRBOSS = {
NmaxSection = nil,
NmaxStack = nil,
handleai = nil,
xtVoiceOvers = nil,
xtVoiceOversAI = nil,
tanker = nil,
Corientation = nil,
Corientlast = nil,
@@ -1333,6 +1336,7 @@ AIRBOSS.CarrierType = {
-- @field #number wire2 Distance in meters from carrier position to second wire.
-- @field #number wire3 Distance in meters from carrier position to third wire.
-- @field #number wire4 Distance in meters from carrier position to fourth wire.
-- @field #number landingdist Distance in meeters to the landing position.
-- @field #number rwylength Length of the landing runway in meters.
-- @field #number rwywidth Width of the landing runway in meters.
-- @field #number totlength Total length of carrier.
@@ -1732,8 +1736,7 @@ AIRBOSS.MenuF10Root = nil
--- Airboss class version.
-- @field #string version
AIRBOSS.version = "1.2.1"
AIRBOSS.version = "1.3.0"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -1903,6 +1906,12 @@ function AIRBOSS:New( carriername, alias )
-- Set AI handling On.
self:SetHandleAION()
-- No extra voiceover/calls from player by default
self:SetExtraVoiceOvers(false)
-- No extra voiceover/calls from AI by default
self:SetExtraVoiceOversAI(false)
-- Airboss is a nice guy.
self:SetAirbossNiceGuy()
@@ -1974,7 +1983,8 @@ function AIRBOSS:New( carriername, alias )
-- Init carrier parameters.
if self.carriertype == AIRBOSS.CarrierType.STENNIS then
self:_InitStennis()
-- Stennis parameters were updated to match the other Super Carriers.
self:_InitNimitz()
elseif self.carriertype == AIRBOSS.CarrierType.ROOSEVELT then
self:_InitNimitz()
elseif self.carriertype == AIRBOSS.CarrierType.LINCOLN then
@@ -1986,7 +1996,7 @@ function AIRBOSS:New( carriername, alias )
elseif self.carriertype == AIRBOSS.CarrierType.FORRESTAL then
self:_InitForrestal()
elseif self.carriertype == AIRBOSS.CarrierType.VINSON then
-- TODO: Carl Vinson parameters.
-- Carl Vinson is legacy now.
self:_InitStennis()
elseif self.carriertype == AIRBOSS.CarrierType.HERMES then
-- Hermes parameters.
@@ -2004,8 +2014,8 @@ function AIRBOSS:New( carriername, alias )
-- Use Juan Carlos parameters.
self:_InitJcarlos()
elseif self.carriertype == AIRBOSS.CarrierType.CANBERRA then
-- Use Juan Carlos parameters at this stage --TODO Check primary Landing spot.
self:_InitJcarlos()
-- Use Juan Carlos parameters at this stage.
self:_InitCanberra()
elseif self.carriertype == AIRBOSS.CarrierType.KUZNETSOV then
-- Kusnetsov parameters - maybe...
self:_InitStennis()
@@ -3234,6 +3244,24 @@ function AIRBOSS:SetHandleAION()
return self
end
--- Will play the inbound calls, commencing, initial, etc. from the player when requesteing marshal
-- @param #AIRBOSS self
-- @param #AIRBOSS status Boolean to activate (true) / deactivate (false) the radio inbound calls (default is ON)
-- @return #AIRBOSS self
function AIRBOSS:SetExtraVoiceOvers(status)
self.xtVoiceOvers=status
return self
end
--- Will simulate the inbound call, commencing, initial, etc from the AI when requested by Airboss
-- @param #AIRBOSS self
-- @param #AIRBOSS status Boolean to activate (true) / deactivate (false) the radio inbound calls (default is ON)
-- @return #AIRBOSS self
function AIRBOSS:SetExtraVoiceOversAI(status)
self.xtVoiceOversAI=status
return self
end
--- Do not handle AI aircraft.
-- @param #AIRBOSS self
-- @return #AIRBOSS self
@@ -3340,6 +3368,20 @@ function AIRBOSS:SetDebugModeOFF()
return self
end
--- Set FunkMan socket. LSO grades and trap sheets will be send to your Discord bot.
-- **Requires running FunkMan program**.
-- @param #AIRBOSS self
-- @param #number Port Port. Default `10042`.
-- @param #string Host Host. Default `"127.0.0.1"`.
-- @return #AIRBOSS self
function AIRBOSS:SetFunkManOn(Port, Host)
self.funkmanSocket=SOCKET:New(Port, Host)
return self
end
--- Get next time the carrier will start recovering aircraft.
-- @param #AIRBOSS self
-- @param #boolean InSeconds If true, abs. mission time seconds is returned. Default is a clock #string.
@@ -4251,6 +4293,9 @@ function AIRBOSS:_InitStennis()
self.carrierparam.wire3 = 46 + 24
self.carrierparam.wire4 = 46 + 35 -- Last wire is strangely one meter closer.
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.wire3
-- Platform at 5k. Reduce descent rate to 2000 ft/min to 1200 dirty up level flight.
self.Platform.name = "Platform 5k"
self.Platform.Xmin = -UTILS.NMToMeters( 22 ) -- Not more than 22 NM behind the boat. Last check was at 21 NM.
@@ -4401,6 +4446,9 @@ function AIRBOSS:_InitNimitz()
self.carrierparam.wire3 = 79
self.carrierparam.wire4 = 92
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.wire3
end
--- Init parameters for Forrestal class super carriers.
@@ -4430,6 +4478,9 @@ function AIRBOSS:_InitForrestal()
self.carrierparam.wire3 = 64 -- 62
self.carrierparam.wire4 = 74 -- 72.5
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.wire3
end
--- Init parameters for R12 HMS Hermes carrier.
@@ -4459,6 +4510,12 @@ function AIRBOSS:_InitHermes()
self.carrierparam.wire3 = nil
self.carrierparam.wire4 = nil
-- Distance to landing spot.
self.carrierparam.landingspot=69
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot
-- Late break.
self.BreakLate.name = "Late Break"
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
@@ -4499,6 +4556,12 @@ function AIRBOSS:_InitInvincible()
self.carrierparam.wire3 = nil
self.carrierparam.wire4 = nil
-- Distance to landing spot.
self.carrierparam.landingspot=69
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot
-- Late break.
self.BreakLate.name = "Late Break"
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
@@ -4539,6 +4602,12 @@ function AIRBOSS:_InitTarawa()
self.carrierparam.wire3 = nil
self.carrierparam.wire4 = nil
-- Distance to landing spot.
self.carrierparam.landingspot=57
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot
-- Late break.
self.BreakLate.name = "Late Break"
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
@@ -4579,6 +4648,12 @@ function AIRBOSS:_InitAmerica()
self.carrierparam.wire3 = nil
self.carrierparam.wire4 = nil
-- Distance to landing spot.
self.carrierparam.landingspot=59
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot
-- Late break.
self.BreakLate.name = "Late Break"
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
@@ -4619,6 +4694,12 @@ function AIRBOSS:_InitJcarlos()
self.carrierparam.wire3 = nil
self.carrierparam.wire4 = nil
-- Distance to landing spot.
self.carrierparam.landingspot=89
-- Landing distance.
self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot
-- Late break.
self.BreakLate.name = "Late Break"
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
@@ -4631,6 +4712,16 @@ function AIRBOSS:_InitJcarlos()
self.BreakLate.LimitZmax = nil
end
--- Init parameters for L02 Canberra carrier.
-- @param #AIRBOSS self
function AIRBOSS:_InitCanberra()
-- Init Juan Carlos as default.
self:_InitJcarlos()
end
--- Init parameters for Marshal Voice overs *Gabriella* by HighwaymanEd.
-- @param #AIRBOSS self
-- @param #string mizfolder (Optional) Folder within miz file where the sound files are located.
@@ -5353,16 +5444,12 @@ function AIRBOSS:_GetAircraftParameters( playerData, step )
aoa = aoaac.OnSpeed
if harrier then
-- 0.8 to 1.0 NM
dist = UTILS.NMToMeters( 0.9 )
else
dist = UTILS.NMToMeters( 1.2 )
end
if goshawk then
-- 0.9 to 1.1 NM per natops ch.4 page 48
dist = UTILS.NMToMeters( 0.9 )
elseif harrier then
-- 0.8 to 1.0 NM
dist = UTILS.NMToMeters( 0.9 )
else
dist = UTILS.NMToMeters( 1.1 )
end
@@ -5404,7 +5491,6 @@ function AIRBOSS:_GetAircraftParameters( playerData, step )
alt = UTILS.FeetToMeters( 300 ) -- ?
elseif harrier then
alt=UTILS.FeetToMeters(312)-- 300-325 ft
end
aoa = aoaac.OnSpeed
@@ -5622,6 +5708,12 @@ function AIRBOSS:_ClearForLanding( flight )
-- Cleared for Case X recovery.
self:_MarshalCallClearedForRecovery( flight.onboard, flight.case )
-- Voice over of the commencing simulated call from AI
if self.xtVoiceOversAI then
local leader = flight.group:GetUnits()[1]
self:_CommencingCall(leader, flight.onboard)
end
else
-- Cleared for Case X recovery.
@@ -5721,12 +5813,12 @@ function AIRBOSS:_ScanCarrierZone()
if knownflight then
-- Check if flight is AI and if we want to handle it at all.
if knownflight.ai and knownflight.flag == -100 and self.handleai then
if knownflight.ai and knownflight.flag == -100 and self.handleai and false then --Disabled AI handling because of incorrect OPSGROUP reference!
local putintomarshal = false
-- Get flight group.
local flight = _DATABASE:GetFlightGroup( groupname )
local flight = _DATABASE:GetOpsGroup( groupname )
if flight and flight:IsInbound() and flight.destbase:GetName() == self.carrier:GetName() then
if flight.ishelo then
@@ -5772,7 +5864,6 @@ function AIRBOSS:_ScanCarrierZone()
if not self:_IsHuman( group ) then
self:_CreateFlightGroup( group )
end
end
end
@@ -5986,7 +6077,12 @@ function AIRBOSS:_MarshalAI( flight, nstack, respawn )
end
-- Check if flight is already in Marshal queue.
if not self:_InQueue( self.Qmarshal, flight.group ) then
if not self:_InQueue(self.Qmarshal,flight.group) then
-- Simulate inbound call
if self.xtVoiceOversAI then
local leader = flight.group:GetUnits()[1]
self:_MarshallInboundCall(leader, flight.onboard)
end
-- Add group to marshal stack queue.
self:_AddMarshalGroup( flight, nstack )
end
@@ -6068,7 +6164,7 @@ function AIRBOSS:_MarshalAI( flight, nstack, respawn )
local radial = self:GetRadial( case, false, true )
-- Point in the middle of the race track and a 5 NM more port perpendicular.
p0 = p2:Translate( UTILS.NMToMeters( 5 ), radial + 90 ):Translate( UTILS.NMToMeters( 5 ), radial, true )
p0 = p2:Translate( UTILS.NMToMeters( 5 ), radial + 90, true ):Translate( UTILS.NMToMeters( 5 ), radial, true )
-- Entering Case II/III marshal pattern waypoint.
wp[#wp + 1] = p0:WaypointAirTurningPoint( nil, speedTransit, { TaskArrivedHolding }, "Entering Case II/III Marshal Pattern" )
@@ -10129,7 +10225,7 @@ function AIRBOSS:_GetWirePos( Lcoord, dc )
if self.Debug and false then
-- Wire position coodinates.
-- Wire position coordinates.
local wp1 = Scoord:Translate( w1, FB )
local wp2 = Scoord:Translate( w2, FB )
local wp3 = Scoord:Translate( w3, FB )
@@ -10854,7 +10950,6 @@ function AIRBOSS:_GetZoneCommence( case, stack )
local Three = self:GetCoordinate():Translate( D, hdg + 275 )
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
local Dx = UTILS.NMToMeters( 2.25 )
local Dz = UTILS.NMToMeters( 2.25 )
@@ -11152,28 +11247,31 @@ function AIRBOSS:_GetOptLandingCoordinate()
-- Start with stern coordiante.
self.landingcoord:UpdateFromCoordinate( self:_GetSternCoord() )
-- Stern coordinate.
-- local stern=self:_GetSternCoord()
-- Final bearing.
local FB=self:GetFinalBearing(false)
-- Cse
local case=self.case
-- set Case III V/STOL abeam landing spot over deck -- Pene Testing
if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then
if case==3 then
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate())
-- Altitude 120ft -- is this corect for Case III?
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
-- Landing coordinate.
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate())
-- Altitude 120ft -- is this corect for Case III?
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
elseif case==2 or case==1 then
-- Landing 100 ft abeam, 120 ft alt.
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35, FB-90, true, true)
--stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
-- Landing 100 ft abeam, 120 ft alt.
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35, FB-90, true, true)
-- Alitude 120 ft.
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
-- Atlitude 120 ft.
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
end
else
@@ -11181,8 +11279,7 @@ function AIRBOSS:_GetOptLandingCoordinate()
-- Ideally we want to land between 2nd and 3rd wire.
if self.carrierparam.wire3 then
-- We take the position of the 3rd wire to approximately account for the length of the aircraft.
local w3 = self.carrierparam.wire3
self.landingcoord:Translate( w3, FB, true, true )
self.landingcoord:Translate( self.carrierparam.wire3, FB, true, true )
end
-- Add 2 meters to account for aircraft height.
@@ -11193,61 +11290,19 @@ function AIRBOSS:_GetOptLandingCoordinate()
return self.landingcoord
end
--- Get landing spot on Tarawa.
--- Get landing spot on Tarawa and others.
-- @param #AIRBOSS self
-- @return Core.Point#COORDINATE Primary landing spot coordinate.
function AIRBOSS:_GetLandingSpotCoordinate()
-- Start at stern coordinate.
self.landingspotcoord:UpdateFromCoordinate( self:_GetSternCoord() )
-- Stern coordinate.
-- local stern=self:_GetSternCoord()
-- Landing 100 ft abeam, 100 alt.
local hdg = self:GetHeading()
if self.carriertype==AIRBOSS.CarrierType.HERMES then
-- Landing 100 ft abeam, 100 alt.
local hdg = self:GetHeading()
-- Primary landing spot 5
self.landingspotcoord:Translate( 69, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
elseif self.carriertype == AIRBOSS.CarrierType.INVINCIBLE then
-- Using spot 3 as the default
local hdg = self:GetHeading()
self.landingspotcoord:Translate( 69, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
-- This location looks good.
elseif self.carriertype == AIRBOSS.CarrierType.TARAWA then
-- Landing 100 ft abeam, 120 alt.
local hdg = self:GetHeading()
-- Primary landing spot 7.5
self.landingspotcoord:Translate( 57, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
elseif self.carriertype == AIRBOSS.CarrierType.AMERICA then
-- Landing 100 ft abeam, 120 alt.
local hdg = self:GetHeading()
-- Primary landing spot 7.5 a little further forwad on the America
self.landingspotcoord:Translate( 59, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
elseif self.carriertype == AIRBOSS.CarrierType.JCARLOS then
-- Landing 100 ft abeam, 120 alt.
local hdg = self:GetHeading()
-- Primary landing spot 5.0 -- Done voice for different landing Spots.
self.landingspotcoord:Translate( 89, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
elseif self.carriertype == AIRBOSS.CarrierType.CANBERRA then
-- Landing 100 ft abeam, 120 alt.
local hdg = self:GetHeading()
-- Primary landing spot 5.0 -- Done voice for different landing Spots.
self.landingspotcoord:Translate( 89, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
end
-- Primary landing spot. Different carriers handled via carrier parameter landingspot now.
self.landingspotcoord:Translate( self.carrierparam.landingspot, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
return self.landingspotcoord
end
@@ -11295,8 +11350,8 @@ function AIRBOSS:GetWind( alt, magnetic, coord )
-- Current position of the carrier or input.
local cv = coord or self:GetCoordinate()
-- Wind direction and speed. By default at 15 meters ASL.
local Wdir, Wspeed = cv:GetWind( alt or 15 )
-- Wind direction and speed. By default at 18 meters ASL.
local Wdir, Wspeed = cv:GetWind( alt or 18 )
-- Include magnetic declination.
if magnetic then
@@ -11312,7 +11367,7 @@ end
--- Get wind speed on carrier deck parallel and perpendicular to runway.
-- @param #AIRBOSS self
-- @param #number alt Altitude in meters. Default 15 m. (change made from 50m from Discord discussion from Sickdog)
-- @param #number alt Altitude in meters. Default 18 m.
-- @return #number Wind component parallel to runway im m/s.
-- @return #number Wind component perpendicular to runway in m/s.
-- @return #number Total wind strength in m/s.
@@ -11335,7 +11390,7 @@ function AIRBOSS:GetWindOnDeck( alt )
zc = UTILS.Rotate2D( zc, -self.carrierparam.rwyangle )
-- Wind (from) vector
local vw = cv:GetWindWithTurbulenceVec3( alt or 15 )
local vw = cv:GetWindWithTurbulenceVec3( alt or 18 ) --(change made from 50m to 15m from Discord discussion from Sickdog, next change to 18m due to SC higher deck discord)
-- Total wind velocity vector.
-- Carrier velocity has to be negative. If carrier drives in the direction the wind is blowing from, we have less wind in total.
@@ -11358,7 +11413,7 @@ end
--- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway.
-- @param #AIRBOSS self
-- @param #boolean magnetic If true, calculate magnetic heading. By default true heading is returned.
-- @param Core.Point#COORDINATE coord (Optional) Coodinate from which heading is calculated. Default is current carrier position.
-- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position.
-- @return #number Carrier heading in degrees.
function AIRBOSS:GetHeadingIntoWind( magnetic, coord )
@@ -11821,7 +11876,7 @@ function AIRBOSS:_LSOgrade( playerData )
local grade
local points
if N == 0 and (TgrooveUnicorn or TgrooveVstolUnicorn) then
if N == 0 and (TgrooveUnicorn or TgrooveVstolUnicorn or playerData.case==3) then
-- No deviations, should be REALLY RARE!
grade = "_OK_"
points = 5.0
@@ -12820,19 +12875,23 @@ function AIRBOSS:_Debrief( playerData )
end
mygrade.case = playerData.case
local windondeck = self:GetWindOnDeck()
mygrade.wind = tostring( UTILS.Round( UTILS.MpsToKnots( windondeck ), 1 ) )
mygrade.wind = UTILS.Round( UTILS.MpsToKnots( windondeck ), 1 )
mygrade.modex = playerData.onboard
mygrade.airframe = playerData.actype
mygrade.carriertype = self.carriertype
mygrade.carriername = self.alias
mygrade.carrierrwy = self.carrierparam.rwyangle
mygrade.theatre = self.theatre
mygrade.mitime = UTILS.SecondsToClock( timer.getAbsTime() )
mygrade.mitime = UTILS.SecondsToClock( timer.getAbsTime(), true )
mygrade.midate = UTILS.GetDCSMissionDate()
mygrade.osdate = "n/a"
if os then
mygrade.osdate = os.date() -- os.date("%d.%m.%Y")
end
-- Add last grade to playerdata for FunkMan.
playerData.grade=mygrade
-- Save trap sheet.
if playerData.trapon and self.trapsheet then
self:_SaveTrapSheet( playerData, mygrade )
@@ -15143,6 +15202,86 @@ function AIRBOSS:_Number2Radio( radio, number, delay, interval, pilotcall )
return wait
end
--- Aircraft request marshal (Inbound call both for players and AI).
-- @param #AIRBOSS self
-- @return Wrapper.Unit#UNIT Unit of player or nil.
-- @param #string modex Tail number.
function AIRBOSS:_MarshallInboundCall(unit, modex)
-- Calculate
local vectorCarrier = self:GetCoordinate():GetDirectionVec3(unit:GetCoordinate())
local bearing = UTILS.Round(unit:GetCoordinate():GetAngleDegrees( vectorCarrier ), 0)
local distance = UTILS.Round(UTILS.MetersToNM(unit:GetCoordinate():Get2DDistance(self:GetCoordinate())),0)
local angels = UTILS.Round(UTILS.MetersToFeet(unit:GetHeight()/1000),0)
local state = UTILS.Round(self:_GetFuelState(unit)/1000,1)
-- Pilot: "Marshall, [modex], marking mom's [bearing] for [distance], angels [XX], state [X.X]"
local text=string.format("Marshal, %s, marking mom's %d for %d, angels %d, state %.1f", modex, bearing, distance, angels, state)
-- Debug message.
self:T(self.lid..text)
-- Fuel state.
local FS=UTILS.Split(string.format("%.1f", state), ".")
-- Create new call to display complete subtitle.
local inboundcall=self:_NewRadioCall(self.MarshalCall.CLICK, unit.UnitName:upper() , text, self.Tmessage, nil, unit.UnitName:upper())
-- CLICK!
self:RadioTransmission(self.MarshalRadio, inboundcall)
-- Marshal ..
self:RadioTransmission(self.MarshalRadio, self.PilotCall.MARSHAL, nil, nil, nil, nil, true)
-- Modex..
self:_Number2Radio(self.MarshalRadio, modex, nil, nil, true)
-- Marking Mom's,
self:RadioTransmission(self.MarshalRadio, self.PilotCall.MARKINGMOMS, nil, nil, nil, nil, true)
-- Bearing ..
self:_Number2Radio(self.MarshalRadio, tostring(bearing), nil, nil, true)
-- For ..
self:RadioTransmission(self.MarshalRadio, self.PilotCall.FOR, nil, nil, nil, nil, true)
-- Distance ..
self:_Number2Radio(self.MarshalRadio, tostring(distance), nil, nil, true)
-- Angels ..
self:RadioTransmission(self.MarshalRadio, self.PilotCall.ANGELS, nil, nil, nil, nil, true)
-- Angels Number ..
self:_Number2Radio(self.MarshalRadio, tostring(angels), nil, nil, true)
-- State ..
self:RadioTransmission(self.MarshalRadio, self.PilotCall.STATE, nil, nil, nil, nil, true)
-- X..
self:_Number2Radio(self.MarshalRadio, FS[1], nil, nil, true)
-- Point..
self:RadioTransmission(self.MarshalRadio, self.PilotCall.POINT, nil, nil, nil, nil, true)
-- Y.
self:_Number2Radio(self.MarshalRadio, FS[2], nil, nil, true)
-- CLICK!
self:RadioTransmission(self.MarshalRadio, self.MarshalRadio.CLICK, nil, nil, nil, nil, true)
end
--- Aircraft commencing call (both for players and AI).
-- @param #AIRBOSS self
-- @return Wrapper.Unit#UNIT Unit of player or nil.
-- @param #string modex Tail number.
function AIRBOSS:_CommencingCall(unit, modex)
-- Pilot: "[modex], commencing"
local text=string.format("%s, commencing", modex)
-- Debug message.
self:T(self.lid..text)
-- Create new call to display complete subtitle.
local commencingCall=self:_NewRadioCall(self.MarshalCall.CLICK, unit.UnitName:upper() , text, self.Tmessage, nil, unit.UnitName:upper())
-- Click
self:RadioTransmission(self.MarshalRadio, commencingCall)
-- Modex..
self:_Number2Radio(self.MarshalRadio, modex, nil, nil, true)
-- Commencing
self:RadioTransmission(self.MarshalRadio, self.PilotCall.COMMENCING, nil, nil, nil, nil, true)
-- CLICK!
self:RadioTransmission(self.MarshalRadio, self.MarshalRadio.CLICK, nil, nil, nil, nil, true)
end
--- AI aircraft calls the ball.
-- @param #AIRBOSS self
-- @param #string modex Tail number.
@@ -15192,6 +15331,7 @@ function AIRBOSS:_MarshalCallGasAtTanker( modex )
-- Debug message.
self:I( self.lid .. text )
-- Create new call to display complete subtitle.
local call = self:_NewRadioCall( self.PilotCall.BINGOFUEL, modex, text, self.Tmessage, nil, modex )
@@ -15898,6 +16038,11 @@ function AIRBOSS:_RequestMarshal( _unitName )
if playerData then
-- Voice over of inbound call (regardless of airboss rejecting it or not)
if self.xtVoiceOvers then
self:_MarshallInboundCall(_unit, playerData.onboard)
end
-- Check if player is in CCA
local inCCA = playerData.unit:IsInZone( self.zoneCCA )
@@ -16145,7 +16290,12 @@ function AIRBOSS:_RequestCommence( _unitName )
local playerData = self.players[_playername] -- #AIRBOSS.PlayerData
if playerData then
-- Voice over of Commencing call (regardless of Airboss will rejected or not)
if self.xtVoiceOvers then
self:_CommencingCall(_unit, playerData.onboard)
end
-- Check if unit is in CCA.
local text = ""
local cleared = false
@@ -17857,6 +18007,59 @@ function AIRBOSS:onafterLoad( From, Event, To, path, filename )
end
--- On after "LSOGrade" event.
-- @param #AIRBOSS self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
-- @param #AIRBOSS.PlayerData playerData Player Data.
-- @param #AIRBOSS.LSOgrade grade LSO grade.
function AIRBOSS:onafterLSOGrade(From, Event, To, playerData, grade)
if self.funkmanSocket then
-- Extract used info for FunkMan. We need to be careful with the amount of data send via UDP socket.
local trapsheet={} ; trapsheet.X={} ; trapsheet.Z={} ; trapsheet.AoA={} ; trapsheet.Alt={}
-- Loop over trapsheet and extract used values.
for i = 1, #playerData.trapsheet do
local ts=playerData.trapsheet[i] --#AIRBOSS.GrooveData
table.insert(trapsheet.X, UTILS.Round(ts.X, 1))
table.insert(trapsheet.Z, UTILS.Round(ts.Z, 1))
table.insert(trapsheet.AoA, UTILS.Round(ts.AoA, 2))
table.insert(trapsheet.Alt, UTILS.Round(ts.Alt, 1))
end
local result={}
result.command=SOCKET.DataType.LSOGRADE
result.name=playerData.name
result.trapsheet=trapsheet
result.airframe=grade.airframe
result.mitime=grade.mitime
result.midate=grade.midate
result.wind=grade.wind
result.carriertype=grade.carriertype
result.carriername=grade.carriername
result.carrierrwy=grade.carrierrwy
result.landingdist=self.carrierparam.landingdist
result.theatre=grade.theatre
result.case=playerData.case
result.Tgroove=grade.Tgroove
result.wire=grade.wire
result.grade=grade.grade
result.points=grade.points
result.details=grade.details
-- Debug info.
self:T(self.lid.."Result onafterLSOGrade")
self:T(result)
-- Send result.
self.funkmanSocket:SendTable(result)
end
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@@ -1,4 +1,4 @@
--- **Ops** -- Combat Search and Rescue.
--- **Ops** - Combat Search and Rescue.
--
-- ===
--
@@ -30,7 +30,7 @@
-- @module Ops.CSAR
-- @image OPS_CSAR.jpg
-- Date: June 2022
-- Date: November 2022
-------------------------------------------------------------------------
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
@@ -114,6 +114,7 @@
-- mycsar.countryneutral = country.id.UN_PEACEKEEPERS
-- mycsar.topmenuname = "CSAR" -- set the menu entry name
-- mycsar.ADFRadioPwr = 1000 -- ADF Beacons sending with 1KW as default
-- mycsar.PilotWeight = 80 -- Loaded pilots weigh 80kgs each
--
-- ## 2.1 Experimental Features
--
@@ -233,6 +234,7 @@ CSAR = {
allheligroupset = nil,
topmenuname = "CSAR",
ADFRadioPwr = 1000,
PilotWeight = 80,
}
--- Downed pilots info.
@@ -270,7 +272,7 @@ CSAR.AircraftType["Bronco-OV-10A"] = 2
--- CSAR class version.
-- @field #string version
CSAR.version="1.0.11"
CSAR.version="1.0.16"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ToDo list
@@ -278,7 +280,7 @@ CSAR.version="1.0.11"
-- DONE: SRS Integration (to be tested)
-- TODO: Maybe - add option to smoke/flare closest MASH
-- TODO: shagrat Add cargoWeight to helicopter when pilot boarded
-- DONE: shagrat Add cargoWeight to helicopter when pilot boarded
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Constructor
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -418,10 +420,13 @@ function CSAR:New(Coalition, Template, Alias)
self.wetfeettemplate = nil
self.usewetfeet = false
-- added 0.1.8
-- added 1.0.15
self.allowbronco = false -- set to true to use the Bronco mod as a CSAR plane
self.ADFRadioPwr = 1000
-- added 1.0.16
self.PilotWeight = 80
-- WARNING - here\'ll be dragons
-- for this to work you need to de-sanitize your mission environment in <DCS root>\Scripts\MissionScripting.lua
@@ -613,6 +618,19 @@ function CSAR:_DoubleEjection(_unitname)
return false
end
--- (User) Add a PLAYERTASK - FSM events will check success
-- @param #CSAR self
-- @param Ops.PlayerTask#PLAYERTASK PlayerTask
-- @return #CSAR self
function CSAR:AddPlayerTask(PlayerTask)
self:T(self.lid .. " AddPlayerTask")
if not self.PlayerTaskQueue then
self.PlayerTaskQueue = FIFO:New()
end
self.PlayerTaskQueue:Push(PlayerTask,PlayerTask.PlayerTaskNr)
return self
end
--- (Internal) Spawn a downed pilot
-- @param #CSAR self
-- @param #number country Country for template.
@@ -1197,6 +1215,38 @@ function CSAR:_RemoveNameFromDownedPilots(name,force)
return found
end
--- [User] Set callsign options for TTS output. See @{Wrapper.Group#GROUP.GetCustomCallSign}() on how to set customized callsigns.
-- @param #CSAR self
-- @param #boolean ShortCallsign If true, only call out the major flight number
-- @param #boolean Keepnumber If true, keep the **customized callsign** in the #GROUP name for players as-is, no amendments or numbers.
-- @param #table CallsignTranslations (optional) Table to translate between DCS standard callsigns and bespoke ones. Does not apply if using customized
-- callsigns from playername or group name.
-- @return #CSAR self
function CSAR:SetCallSignOptions(ShortCallsign,Keepnumber,CallsignTranslations)
if not ShortCallsign or ShortCallsign == false then
self.ShortCallsign = false
else
self.ShortCallsign = true
end
self.Keepnumber = Keepnumber or false
self.CallsignTranslations = CallsignTranslations
return self
end
--- (Internal) Check if a name is in downed pilot table and remove it.
-- @param #CSAR self
-- @param #string UnitName
-- @return #string CallSign
function CSAR:_GetCustomCallSign(UnitName)
local callsign = Unitname
local unit = UNIT:FindByName(UnitName)
if unit and unit:IsAlive() then
local group = unit:GetGroup()
callsign = group:GetCustomCallSign(self.ShortCallsign,self.Keepnumber,self.CallsignTranslations)
end
return callsign
end
--- (Internal) Check state of wounded group.
-- @param #CSAR self
-- @param #string heliname heliname
@@ -1253,9 +1303,9 @@ function CSAR:_CheckWoundedGroupStatus(heliname,woundedgroupname)
local dist = UTILS.MetersToNM(self.autosmokedistance)
disttext = string.format("%.0fnm",dist)
end
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Finally, that is music in my ears!\nI'll pop a smoke when you are %s away.\nLand or hover by the smoke.", _heliName, _pilotName, disttext), self.messageTime,false,true)
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Finally, that is music in my ears!\nI'll pop a smoke when you are %s away.\nLand or hover by the smoke.", self:_GetCustomCallSign(_heliName), _pilotName, disttext), self.messageTime,false,true)
else
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Finally, that is music in my ears!\nRequest a flare or smoke if you need.", _heliName, _pilotName), self.messageTime,false,true)
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Finally, that is music in my ears!\nRequest a flare or smoke if you need.", self:_GetCustomCallSign(_heliName), _pilotName), self.messageTime,false,true)
end
--mark as shown for THIS heli and THIS group
self.heliVisibleMessage[_lookupKeyHeli] = true
@@ -1319,7 +1369,7 @@ function CSAR:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupNam
_maxUnits = self.max_units
end
if _unitsInHelicopter + 1 > _maxUnits then
self:_DisplayMessageToSAR(_heliUnit, string.format("%s, %s. We\'re already crammed with %d guys! Sorry!", _pilotName, _heliName, _unitsInHelicopter, _unitsInHelicopter), self.messageTime,false,false,true)
self:_DisplayMessageToSAR(_heliUnit, string.format("%s, %s. We\'re already crammed with %d guys! Sorry!", _pilotName, self:_GetCustomCallSign(_heliName), _unitsInHelicopter, _unitsInHelicopter), self.messageTime,false,false,true)
return self
end
@@ -1337,13 +1387,29 @@ function CSAR:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupNam
_woundedGroup:Destroy(false)
self:_RemoveNameFromDownedPilots(_woundedGroupName,true)
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s I\'m in! Get to the MASH ASAP! ", _heliName, _pilotName), self.messageTime,true,true)
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s I\'m in! Get to the MASH ASAP! ", self:_GetCustomCallSign(_heliName), _pilotName), self.messageTime,true,true)
self:_UpdateUnitCargoMass(_heliName)
self:__Boarded(5,_heliName,_woundedGroupName,grouptable.desc)
return self
end
--- (Internal) Function to calculate and set Unit internal cargo mass
-- @param #CSAR self
-- @param #string _heliName Unit name
-- @return #CSAR self
function CSAR:_UpdateUnitCargoMass(_heliName)
self:T(self.lid .. " _UpdateUnitCargoMass")
local calculatedMass = self:_PilotsOnboard(_heliName)*(self.PilotWeight or 80)
local Unit = UNIT:FindByName(_heliName)
if Unit then
Unit:SetUnitInternalCargo(calculatedMass)
end
return self
end
--- (Internal) Move group to destination.
-- @param #CSAR self
-- @param Wrapper.Group#GROUP _leader
@@ -1358,7 +1424,6 @@ function CSAR:_OrderGroupToMoveToPoint(_leader, _destination)
return self
end
--- (internal) Function to check if the heli door(s) are open. Thanks to Shadowze.
-- @param #CSAR self
-- @param #string unit_name Name of unit.
@@ -1392,9 +1457,9 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
if self.heliCloseMessage[_lookupKeyHeli] == nil then
if self.autosmoke == true then
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land or hover at the smoke.", _heliName, _pilotName), self.messageTime,false,true)
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land or hover at the smoke.", self:_GetCustomCallSign(_heliName), _pilotName), self.messageTime,false,true)
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 ", self:_GetCustomCallSign(_heliName), _pilotName), self.messageTime,false,true)
end
self.heliCloseMessage[_lookupKeyHeli] = true
end
@@ -1447,7 +1512,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
end
if _heliUnit:InAir() and _unitsInHelicopter + 1 <= _maxUnits then
-- TODO - make variable
-- DONE - make variable
if _distance < self.rescuehoverdistance then
--check height!
@@ -1455,7 +1520,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
if leaderheight < 0 then leaderheight = 0 end
local _height = _heliUnit:GetHeight() - leaderheight
-- TODO - make variable
-- DONE - make variable
if _height <= self.rescuehoverheight then
local _time = self.hoverStatus[_lookupKeyHeli]
@@ -1561,9 +1626,12 @@ function CSAR:_RescuePilots(_heliUnit)
self.inTransitGroups[_heliName] = nil
local _txt = string.format("%s: The %d pilot(s) have been taken to the\nmedical clinic. Good job!", _heliName, PilotsSaved)
local _txt = string.format("%s: The %d pilot(s) have been taken to the\nmedical clinic. Good job!", self:_GetCustomCallSign(_heliName), PilotsSaved)
self:_DisplayMessageToSAR(_heliUnit, _txt, self.messageTime)
self:_UpdateUnitCargoMass(_heliName)
-- trigger event
self:__Rescued(-1,_heliUnit,_heliName, PilotsSaved)
return self
@@ -1597,7 +1665,7 @@ function CSAR:_DisplayMessageToSAR(_unit, _text, _time, _clear, _speak, _overrid
local _clear = _clear or nil
local _time = _time or self.messageTime
if _override or not self.suppressmessages then
local m = MESSAGE:New(_text,_time,"Info",_clear):ToGroup(group)
local m = MESSAGE:New(_text,_time,"CSAR",_clear):ToGroup(group)
end
-- integrate SRS
if _speak and self.useSRS then
@@ -1746,7 +1814,7 @@ function CSAR:_SignalFlare(_unitName)
else
_distance = string.format("%.1fkm",_closest.distance)
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", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true, true)
local _coord = _closest.pilot:GetCoordinate()
@@ -1800,7 +1868,7 @@ function CSAR:_Reqsmoke( _unitName )
else
_distance = string.format("%.1fkm",_closest.distance/1000)
end
local _msg = string.format("%s - Popping smoke at your %s o\'clock. Distance %s", _unitName, _clockDir, _distance)
local _msg = string.format("%s - Popping smoke at your %s o\'clock. Distance %s", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true, true)
local _coord = _closest.pilot:GetCoordinate()
local color = self.smokecolor
@@ -1851,7 +1919,7 @@ function CSAR:_GetClosestMASH(_heli)
if self.allowFARPRescue then
local position = _heli:GetCoordinate()
local afb,distance = position:GetClosestAirbase2(nil,self.coalition)
local afb,distance = position:GetClosestAirbase(nil,self.coalition)
_shortestDistance = distance
end
@@ -2004,13 +2072,17 @@ function CSAR:_GetClockDirection(_heli, _group)
local DirectionVec3 = _playerPosition:GetDirectionVec3( _targetpostions )
local Angle = _playerPosition:GetAngleDegrees( DirectionVec3 )
self:T(self.lid .. " _GetClockDirection"..tostring(Angle).." "..tostring(_heading))
local clock = 12
if _heading then
local Aspect = Angle - _heading
if Aspect == 0 then Aspect = 360 end
clock = math.abs(UTILS.Round((Aspect / 30),0))
if clock == 0 then clock = 12 end
end
local hours = 0
local clock = 12
if _heading and Angle then
clock = 12
--if angle == 0 then angle = 360 end
clock = _heading-Angle
hours = (clock/30)*-1
clock = 12+hours
clock = UTILS.Round(clock,0)
if clock > 12 then clock = clock-12 end
end
return clock
end
@@ -2282,6 +2354,29 @@ end
function CSAR:onbeforeBoarded(From, Event, To, Heliname, Woundedgroupname)
self:T({From, Event, To, Heliname, Woundedgroupname})
self:_ScheduledSARFlight(Heliname,Woundedgroupname)
local Unit = UNIT:FindByName(Heliname)
if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then
local playername = Unit:GetPlayerName()
local dropcoord = Unit:GetCoordinate() or COORDINATE:New(0,0,0)
local dropvec2 = dropcoord:GetVec2()
self.PlayerTaskQueue:ForEach(
function (Task)
local task = Task -- Ops.PlayerTask#PLAYERTASK
local subtype = task:GetSubType()
-- right subtype?
if Event == subtype and not task:IsDone() then
local targetzone = task.Target:GetObject() -- Core.Zone#ZONE should be a zone in this case ....
if (targetzone and targetzone.ClassName and string.match(targetzone.ClassName,"ZONE") and targetzone:IsVec2InZone(dropvec2))
or (string.find(task.CSARPilotName,Woundedgroupname)) then
if task.Clients:HasUniqueID(playername) then
-- success
task:__Success(-1)
end
end
end
end
)
end
return self
end
@@ -2311,6 +2406,23 @@ function CSAR:onbeforeRescued(From, Event, To, HeliUnit, HeliName, PilotsSaved)
self:T({From, Event, To, HeliName, HeliUnit})
self.rescues = self.rescues + 1
self.rescuedpilots = self.rescuedpilots + PilotsSaved
local Unit = HeliUnit or UNIT:FindByName(HeliName)
if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then
local playername = Unit:GetPlayerName()
self.PlayerTaskQueue:ForEach(
function (Task)
local task = Task -- Ops.PlayerTask#PLAYERTASK
local subtype = task:GetSubType()
-- right subtype?
if Event == subtype and not task:IsDone() then
if task.Clients:HasUniqueID(playername) then
-- success
task:__Success(-1)
end
end
end
)
end
return self
end

View File

@@ -1,4 +1,4 @@
--- **Ops** -- Combat Troops & Logistics Department.
--- **Ops** - Combat Troops & Logistics Department.
--
-- ===
--
@@ -22,8 +22,7 @@
-- @module Ops.CTLD
-- @image OPS_CTLD.jpg
-- Date: Feb 2022
-- Last Update Sep 2022
-- Last Update October 2022
do
@@ -288,8 +287,8 @@ CTLD_ENGINEERING = {
end
do
do
------------------------------------------------------
--- **CTLD_CARGO** class, extends Core.Base#BASE
-- @type CTLD_CARGO
@@ -308,9 +307,8 @@ do
-- @field #string Subcategory Sub-category name.
-- @extends Core.Base#BASE
---
-- @field CTLD_CARGO
-- @field #CTLD_CARGO CTLD_CARGO
CTLD_CARGO = {
ClassName = "CTLD_CARGO",
ID = 0,
@@ -343,7 +341,7 @@ CTLD_CARGO = {
CRATE = "Crate", -- #string crate
REPAIR = "Repair", -- #string repair
ENGINEERS = "Engineers", -- #string engineers
STATIC = "Static", -- #string engineers
STATIC = "Static", -- #string statics
}
--- Function to create new CTLD_CARGO object.
@@ -574,6 +572,10 @@ CTLD_CARGO = {
end
do
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO CTLD
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------
--- **CTLD** class, extends Core.Base#BASE, Core.Fsm#FSM
-- @type CTLD
@@ -581,6 +583,7 @@ do
-- @field #number verbose Verbosity level.
-- @field #string lid Class id string for output to DCS log file.
-- @field #number coalition Coalition side number, e.g. `coalition.side.RED`.
-- @field #boolean debug
-- @extends Core.Fsm#FSM
--- *Combat Troop & Logistics Deployment (CTLD): Everyone wants to be a POG, until there\'s POG stuff to be done.* (Mil Saying)
@@ -697,6 +700,7 @@ do
-- my_ctld.smokedistance = 2000 -- Only smoke or flare zones if requesting player unit is this far away (in meters)
-- my_ctld.suppressmessages = false -- Set to true if you want to script your own messages.
-- my_ctld.repairtime = 300 -- Number of seconds it takes to repair a unit.
-- my_ctld.buildtime = 300 -- Number of seconds it takes to build a unit. Set to zero or nil to build instantly.
-- my_ctld.cratecountry = country.id.GERMANY -- ID of crates. Will default to country.id.RUSSIA for RED coalition setups.
-- my_ctld.allowcratepickupagain = true -- allow re-pickup crates that were dropped.
-- my_ctld.enableslingload = false -- allow cargos to be slingloaded - might not work for all cargo types
@@ -706,6 +710,7 @@ do
-- my_ctld.basetype = "container_cargo" -- default shape of the cargo container
-- my_ctld.droppedbeacontimeout = 600 -- dropped beacon lasts 10 minutes
-- my_ctld.usesubcats = false -- use sub-category names for crates, adds an extra menu layer in "Get Crates", useful if you have > 10 crate types.
-- my_ctld.placeCratesAhead = false -- place crates straight ahead of the helicopter, in a random way. If true, crates are more neatly sorted.
--
-- ## 2.1 User functions
--
@@ -824,6 +829,8 @@ do
--
-- To award player with points, using the SCORING Class (SCORING: my_Scoring, CTLD: CTLD_Cargotransport)
--
-- my_scoring = SCORING:New("Combat Transport")
--
-- function CTLD_Cargotransport:OnAfterCratesDropped(From, Event, To, Group, Unit, Cargotable)
-- local points = 10
-- if Unit then
@@ -901,7 +908,7 @@ do
--
-- my_ctld.useprefix = true -- this is true by default and MUST BE ON.
--
-- ### 5.2 Integrate Hercules ground crew (F8 Menu) loadable objects (alternative method)
-- ### 5.2 Integrate Hercules ground crew (F8 Menu) loadable objects (alternative method, use either the above OR this method, NOT both!)
--
-- Integrate to your CTLD instance like so, where `my_ctld` is a previously created CTLD instance:
--
@@ -928,6 +935,8 @@ do
-- The script works on the EVENTS.Shot trigger, which is used by the mod when you **drop cargo from the Hercules while flying**. Unloading on the ground does
-- not achieve anything here. If you just want to unload on the ground, use the normal Moose CTLD (see 5.1).
--
-- DO NOT use the "splash damage" script together with this method! Your cargo will explode on the ground!
--
-- There are two ways of airdropping:
--
-- 1) Very low and very slow (>5m and <10m AGL) - here you can drop stuff which has "Skid" at the end of the cargo name (loaded via F8 Ground Crew menu)
@@ -1064,11 +1073,12 @@ CTLD.UnitTypes = {
--Actually it's longer, but the center coord is off-center of the model.
["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo
["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
}
--- CTLD class version.
-- @field #string version
CTLD.version="1.0.11"
CTLD.version="1.0.19"
--- Instantiate a new CTLD.
-- @param #CTLD self
@@ -1206,8 +1216,9 @@ function CTLD:New(Coalition, Prefixes, Alias)
-- message suppression
self.suppressmessages = false
-- time to repair a unit/group
-- time to repairor build a unit/group
self.repairtime = 300
self.buildtime = 300
-- place spawned crates in front of aircraft
self.placeCratesAhead = false
@@ -1302,6 +1313,92 @@ function CTLD:New(Coalition, Prefixes, Alias)
-- @param #CTLD self
-- @param #number delay Delay in seconds.
--- FSM Function OnBeforeTroopsPickedUp.
-- @function [parent=#CTLD] OnBeforeTroopsPickedUp
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param #CTLD_CARGO Cargo Cargo troops.
-- @return #CTLD self
--- FSM Function OnBeforeTroopsExtracted.
-- @function [parent=#CTLD] OnBeforeTroopsExtracted
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param #CTLD_CARGO Cargo Cargo troops.
-- @return #CTLD self
--- FSM Function OnBeforeCratesPickedUp.
-- @function [parent=#CTLD] OnBeforeCratesPickedUp
-- @param #CTLD self
-- @param #string From State .
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param #CTLD_CARGO Cargo Cargo crate.
-- @return #CTLD self
--- FSM Function OnBeforeTroopsDeployed.
-- @function [parent=#CTLD] OnBeforeTroopsDeployed
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param Wrapper.Group#GROUP Troops Troops #GROUP Object.
-- @return #CTLD self
--- FSM Function OnBeforeCratesDropped.
-- @function [parent=#CTLD] OnBeforeCratesDropped
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param #table Cargotable Table of #CTLD_CARGO objects dropped.
-- @return #CTLD self
--- FSM Function OnBeforeCratesBuild.
-- @function [parent=#CTLD] OnBeforeCratesBuild
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
-- @return #CTLD self
--- FSM Function OnBeforeCratesRepaired.
-- @function [parent=#CTLD] OnBeforeCratesRepaired
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB repaired.
-- @return #CTLD self
--- FSM Function OnBeforeTroopsRTB.
-- @function [parent=#CTLD] OnBeforeTroopsRTB
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
--- FSM Function OnAfterTroopsPickedUp.
-- @function [parent=#CTLD] OnAfterTroopsPickedUp
-- @param #CTLD self
@@ -1476,6 +1573,19 @@ function CTLD:SetTroopDropZoneRadius(Radius)
return self
end
--- (User) Add a PLAYERTASK - FSM events will check success
-- @param #CTLD self
-- @param Ops.PlayerTask#PLAYERTASK PlayerTask
-- @return #CTLD self
function CTLD:AddPlayerTask(PlayerTask)
self:T(self.lid .. " AddPlayerTask")
if not self.PlayerTaskQueue then
self.PlayerTaskQueue = FIFO:New()
end
self.PlayerTaskQueue:Push(PlayerTask,PlayerTask.PlayerTaskNr)
return self
end
--- (Internal) Event handler function
-- @param #CTLD self
-- @param Core.Event#EVENTDATA EventData
@@ -1496,7 +1606,7 @@ function CTLD:_EventHandler(EventData)
self:_RefreshF10Menus()
end
-- Herc support
if _unit:GetTypeName() == "Hercules" and self.enableHercules then
if self:IsHercules(_unit) and self.enableHercules then
local unitname = event.IniUnitName or "none"
self.Loaded_Cargo[unitname] = nil
self:_RefreshF10Menus()
@@ -2501,7 +2611,7 @@ end
-- @param Wrapper.Unit#UNIT Unit
-- @return #boolean Outcome
function CTLD:IsHercules(Unit)
if Unit:GetTypeName() == "Hercules" then
if Unit:GetTypeName() == "Hercules" or string.find(Unit:GetTypeName(),"Bronco") then
return true
else
return false
@@ -2567,9 +2677,7 @@ function CTLD:_UnloadTroops(Group, Unit)
:InitRandomizeUnits(true,20,2)
:InitDelayOff()
:SpawnFromVec2(randomcoord)
if self.movetroopstowpzone and type ~= CTLD_CARGO.Enum.ENGINEERS then
self:_MoveGroupToZone(self.DroppedTroops[self.TroopCounter])
end
self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter],type)
end -- template loop
cargo:SetWasDropped(true)
-- engineering group?
@@ -2581,7 +2689,6 @@ function CTLD:_UnloadTroops(Group, Unit)
else
self:_SendMessage(string.format("Dropped Troops %s into action!",name), 10, false, Group)
end
self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter])
end -- if type end
end -- cargotable loop
else -- droppingatbase
@@ -2710,8 +2817,7 @@ end
function CTLD:_BuildCrates(Group, Unit,Engineering)
self:T(self.lid .. " _BuildCrates")
-- avoid users trying to build from flying Hercs
local type = Unit:GetTypeName()
if type == "Hercules" and self.enableHercules and not Engineering then
if self:IsHercules(Unit) and self.enableHercules and not Engineering then
local speed = Unit:GetVelocityKMH()
if speed > 1 then
self:_SendMessage("You need to land / stop to build something, Pilot!", 10, false, Group)
@@ -2788,7 +2894,13 @@ function CTLD:_BuildCrates(Group, Unit,Engineering)
local build = _build -- #CTLD.Buildable
if build.CanBuild then
self:_CleanUpCrates(crates,build,number)
self:_BuildObjectFromCrates(Group,Unit,build)
if self.buildtime and self.buildtime > 0 then
local buildtimer = TIMER:New(self._BuildObjectFromCrates,self,Group,Unit,build,false,Group:GetCoordinate())
buildtimer:Start(self.buildtime)
self:_SendMessage(string.format("Build started, ready in %d seconds!",self.buildtime),15,false,Group)
else
self:_BuildObjectFromCrates(Group,Unit,build)
end
end
end
end
@@ -2887,13 +2999,13 @@ end
-- @param Wrapper.Group#UNIT Unit
-- @param #CTLD.Buildable Build
-- @param #boolean Repair If true this is a repair and not a new build
-- @param Core.Point#COORDINATE Coordinate Location for repair (e.g. where the destroyed unit was)
-- @param Core.Point#COORDINATE RepairLocation Location for repair (e.g. where the destroyed unit was)
function CTLD:_BuildObjectFromCrates(Group,Unit,Build,Repair,RepairLocation)
self:T(self.lid .. " _BuildObjectFromCrates")
-- Spawn-a-crate-content
if Group and Group:IsAlive() then
local position = Unit:GetCoordinate() or Group:GetCoordinate()
local unitname = Unit:GetName() or Group:GetName()
if Group and Group:IsAlive() or (RepairLocation and not Repair) then
--local position = Unit:GetCoordinate() or Group:GetCoordinate()
--local unitname = Unit:GetName() or Group:GetName() or "Unknown"
local name = Build.Name
local ctype = Build.Type -- #CTLD_CARGO.Enum
local canmove = false
@@ -2905,7 +3017,13 @@ function CTLD:_BuildObjectFromCrates(Group,Unit,Build,Repair,RepairLocation)
if type(temptable) == "string" then
temptable = {temptable}
end
local zone = ZONE_GROUP:New(string.format("Unload zone-%s",unitname),Group,100)
local zone = nil
if RepairLocation and not Repair then
-- timed build
zone = ZONE_RADIUS:New(string.format("Build zone-%d",math.random(1,10000)),RepairLocation:GetVec2(),100)
else
zone = ZONE_GROUP:New(string.format("Unload zone-%d",math.random(1,10000)),Group,100)
end
--local randomcoord = zone:GetRandomCoordinate(35):GetVec2()
local randomcoord = Build.Coord or zone:GetRandomCoordinate(35):GetVec2()
if Repair then
@@ -2924,9 +3042,6 @@ function CTLD:_BuildObjectFromCrates(Group,Unit,Build,Repair,RepairLocation)
:InitDelayOff()
:SpawnFromVec2(randomcoord)
end
if self.movetroopstowpzone and canmove then
self:_MoveGroupToZone(self.DroppedTroops[self.TroopCounter])
end
if Repair then
self:__CratesRepaired(1,Group,Unit,self.DroppedTroops[self.TroopCounter])
else
@@ -3012,7 +3127,7 @@ function CTLD:_RefreshF10Menus()
local _unit = _group:GetUnit(1) -- Wrapper.Unit#UNIT Asume that there is only one unit in the flight for players
if _unit then
if _unit:IsAlive() and _unit:IsPlayer() then
if _unit:IsHelicopter() or (_unit:GetTypeName() == "Hercules" and self.enableHercules) then --ensure no stupid unit entries here
if _unit:IsHelicopter() or (self:IsHercules(_unit) and self.enableHercules) then --ensure no stupid unit entries here
local unitName = _unit:GetName()
_UnitList[unitName] = unitName
end
@@ -3111,7 +3226,7 @@ function CTLD:_RefreshF10Menus()
local buildmenu = MENU_GROUP_COMMAND:New(_group,"Build crates",topcrates, self._BuildCrates, self, _group, _unit)
local repairmenu = MENU_GROUP_COMMAND:New(_group,"Repair",topcrates, self._RepairCrates, self, _group, _unit):Refresh()
end
if unittype == "Hercules" then
if self:IsHercules(_unit) then
local hoverpars = MENU_GROUP_COMMAND:New(_group,"Show flight parameters",topmenu, self._ShowFlightParams, self, _group, _unit):Refresh()
else
local hoverpars = MENU_GROUP_COMMAND:New(_group,"Show hover parameters",topmenu, self._ShowHoverParams, self, _group, _unit):Refresh()
@@ -3386,7 +3501,21 @@ end
-- @return #CTLD self
function CTLD:AddCTLDZone(Name, Type, Color, Active, HasBeacon, Shiplength, Shipwidth)
self:T(self.lid .. " AddCTLDZone")
local zone = ZONE:FindByName(Name)
if not zone and Type ~= CTLD.CargoZoneType.SHIP then
self:E(self.lid.."**** Zone does not exist: "..Name)
return self
end
if Type == CTLD.CargoZoneType.SHIP then
local Ship = UNIT:FindByName(Name)
if not Ship then
self:E(self.lid.."**** Ship does not exist: "..Name)
return self
end
end
local ctldzone = {} -- #CTLD.CargoZone
ctldzone.active = Active or false
ctldzone.color = Color or SMOKECOLOR.Red
@@ -3632,9 +3761,10 @@ function CTLD:IsUnitInZone(Unit,Zonetype)
local zoneret = nil
local zonewret = nil
local zonenameret = nil
local unitcoord = Unit:GetCoordinate()
local unitVec2 = unitcoord:GetVec2()
for _,_cargozone in pairs(zonetable) do
local czone = _cargozone -- #CTLD.CargoZone
local unitcoord = Unit:GetCoordinate()
local zonename = czone.name
local active = czone.active
local color = czone.color
@@ -3643,25 +3773,26 @@ function CTLD:IsUnitInZone(Unit,Zonetype)
local zonewidth = 20
if Zonetype == CTLD.CargoZoneType.SHIP then
self:T("Checking Type Ship: "..zonename)
zone = UNIT:FindByName(zonename)
zonecoord = zone:GetCoordinate()
local ZoneUNIT = UNIT:FindByName(zonename)
zonecoord = ZoneUNIT:GetCoordinate()
zoneradius = czone.shiplength
zonewidth = czone.shipwidth
zone = ZONE_UNIT:New( ZoneUNIT:GetName(), ZoneUNIT, zoneradius/2)
elseif ZONE:FindByName(zonename) then
zone = ZONE:FindByName(zonename)
self:T("Checking Zone: "..zonename)
zonecoord = zone:GetCoordinate()
zoneradius = zone:GetRadius()
--zoneradius = 1500
zonewidth = zoneradius
elseif AIRBASE:FindByName(zonename) then
zone = AIRBASE:FindByName(zonename):GetZone()
self:T("Checking Zone: "..zonename)
zonecoord = zone:GetCoordinate()
zoneradius = zone:GetRadius()
zoneradius = 2000
zonewidth = zoneradius
end
local distance = self:_GetDistance(zonecoord,unitcoord)
if distance <= zoneradius and active then
if zone:IsVec2InZone(unitVec2) and active then
outcome = true
end
if maxdist > distance then
@@ -3915,7 +4046,7 @@ end
function CTLD:IsUnitInAir(Unit)
-- get speed and height
local minheight = self.minimumHoverHeight
if self.enableHercules and Unit:GetTypeName() == "Hercules" then
if self.enableHercules and self:IsHercules(Unit) then
minheight = 5.1 -- herc is 5m AGL on the ground
end
local uheight = Unit:GetHeight()
@@ -4165,7 +4296,7 @@ end
self.EngineersInField[self.Engineers] = CTLD_ENGINEERING:New(name, grpname)
end
if self.eventoninject then
self:__TroopsDeployed(1,nil,nil,self.DroppedTroops[self.TroopCounter])
self:__TroopsDeployed(1,nil,nil,self.DroppedTroops[self.TroopCounter],type)
end
end -- if type end
return self
@@ -4232,9 +4363,6 @@ end
:InitDelayOff()
:SpawnFromVec2(randomcoord)
end
if self.movetroopstowpzone and canmove then
self:_MoveGroupToZone(self.DroppedTroops[self.TroopCounter])
end
if self.eventoninject then
self:__CratesBuild(1,nil,nil,self.DroppedTroops[self.TroopCounter])
end
@@ -4244,7 +4372,7 @@ end
end
-------------------------------------------------------------------
-- FSM functions
-- TODO FSM functions
-------------------------------------------------------------------
--- (Internal) FSM Function onafterStart.
@@ -4417,6 +4545,45 @@ end
-- @return #CTLD self
function CTLD:onbeforeTroopsDeployed(From, Event, To, Group, Unit, Troops)
self:T({From, Event, To})
if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then
local playername = Unit:GetPlayerName()
local dropcoord = Troops:GetCoordinate() or COORDINATE:New(0,0,0)
local dropvec2 = dropcoord:GetVec2()
self.PlayerTaskQueue:ForEach(
function (Task)
local task = Task -- Ops.PlayerTask#PLAYERTASK
local subtype = task:GetSubType()
-- right subtype?
if Event == subtype and not task:IsDone() then
local targetzone = task.Target:GetObject() -- Core.Zone#ZONE should be a zone in this case ....
if targetzone and targetzone.ClassName and string.match(targetzone.ClassName,"ZONE") and targetzone:IsVec2InZone(dropvec2) then
if task.Clients:HasUniqueID(playername) then
-- success
task:__Success(-1)
end
end
end
end
)
end
return self
end
--- (Internal) FSM Function onafterTroopsDeployed.
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param Wrapper.Group#GROUP Troops Troops #GROUP Object.
-- @param #CTLD.CargoZoneType Type Type of Cargo deployed
-- @return #CTLD self
function CTLD:onafterTroopsDeployed(From, Event, To, Group, Unit, Troops, Type)
self:T({From, Event, To})
if self.movetroopstowpzone and Type ~= CTLD_CARGO.Enum.ENGINEERS then
self:_MoveGroupToZone(Troops)
end
return self
end
@@ -4444,7 +4611,45 @@ end
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
-- @return #CTLD self
function CTLD:onbeforeCratesBuild(From, Event, To, Group, Unit, Vehicle)
self:I({From, Event, To})
if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then
local playername = Unit:GetPlayerName()
local dropcoord = Vehicle:GetCoordinate() or COORDINATE:New(0,0,0)
local dropvec2 = dropcoord:GetVec2()
self.PlayerTaskQueue:ForEach(
function (Task)
local task = Task -- Ops.PlayerTask#PLAYERTASK
local subtype = task:GetSubType()
-- right subtype?
if Event == subtype and not task:IsDone() then
local targetzone = task.Target:GetObject() -- Core.Zone#ZONE should be a zone in this case ....
if targetzone and targetzone.ClassName and string.match(targetzone.ClassName,"ZONE") and targetzone:IsVec2InZone(dropvec2) then
if task.Clients:HasUniqueID(playername) then
-- success
task:__Success(-1)
end
end
end
end
)
end
return self
end
--- (Internal) FSM Function onafterCratesBuild.
-- @param #CTLD self
-- @param #string From State.
-- @param #string Event Trigger.
-- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
-- @return #CTLD self
function CTLD:onafterCratesBuild(From, Event, To, Group, Unit, Vehicle)
self:T({From, Event, To})
if self.movetroopstowpzone then
self:_MoveGroupToZone(Vehicle)
end
return self
end
@@ -4802,7 +5007,9 @@ end -- end do
do
--- **Hercules Cargo AIR Drop Events** by Anubis Yinepu
-- Moose CTLD OO refactoring by Applevangelist
--
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO CTLD_HERCULES
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- This script will only work for the Herculus mod by Anubis, and only for **Air Dropping** cargo from the Hercules.
-- Use the standard Moose CTLD if you want to unload on the ground.
-- Payloads carried by pylons 11, 12 and 13 need to be declared in the Herculus_Loadout.lua file
@@ -4825,7 +5032,7 @@ CTLD_HERCULES = {
ClassName = "CTLD_HERCULES",
lid = "",
Name = "",
Version = "0.0.1",
Version = "0.0.2",
}
--- Define cargo types.
@@ -4932,13 +5139,21 @@ CTLD_HERCULES.Types = {
--
-- Expected template names are the ones in the rounded brackets.
--
-- HINTS
-- ### HINTS
--
-- The script works on the EVENTS.Shot trigger, which is used by the mod when you **drop cargo from the Hercules while flying**. Unloading on the ground does
-- not achieve anything here. If you just want to unload on the ground, use the normal Moose CTLD.
-- **Do not use** the **splash damage** script together with this, your cargo will just explode when reaching the ground!
--
-- ### Airdrops
--
-- There are two ways of airdropping:
-- 1) Very low and very slow (>5m and <10m AGL) - here you can drop stuff which has "Skid" at the end of the cargo name (loaded via F8 Ground Crew menu)
-- 2) Higher up and slow (>100m AGL) - here you can drop paratroopers and cargo which has "Air" at the end of the cargo name (loaded via F8 Ground Crew menu)
--
-- ### General
--
-- Use either this method to integrate the Hercules **or** the one from the "normal" CTLD. Never both!
function CTLD_HERCULES:New(Coalition, Alias, CtldObject)
-- Inherit everything from FSM class.
local self=BASE:Inherit(self, FSM:New()) -- #CTLD_HERCULES
@@ -5228,7 +5443,7 @@ function CTLD_HERCULES:Cargo_Track(cargo, initiator)
if self:Check_SurfaceType(cargo.Cargo_Contents) == 2 or self:Check_SurfaceType(cargo.Cargo_Contents) == 3 then
cargo.Cargo_over_water = true--pallets gets destroyed in water
end
local dcsvec3 = self.ObjectTracker[cargo.Cargo_Contents.id_] -- last known position
local dcsvec3 = self.ObjectTracker[cargo.Cargo_Contents.id_] or initiator:GetVec3() -- last known position
self:T("SPAWNPOSITION: ")
self:T({dcsvec3})
local Vec2 = {
@@ -5331,7 +5546,7 @@ function CTLD_HERCULES:Cargo_Initialize(Initiator, Cargo_Contents, Cargo_Type_na
local timer = TIMER:New(self.Cargo_Track,self,self.Cargo[self.j],Initiator)
self.Cargo[self.j].scheduleFunctionID = timer
timer:Start(5,2,600)
timer:Start(1,1,600)
else
-- no paras
@@ -5356,7 +5571,7 @@ function CTLD_HERCULES:Cargo_Initialize(Initiator, Cargo_Contents, Cargo_Type_na
local timer = TIMER:New(self.Cargo_Track,self,self.Cargo[self.j],Initiator)
self.Cargo[self.j].scheduleFunctionID = timer
timer:Start(5,2,600)
timer:Start(1,1,600)
end
end
return self