From 74d97cc220c238332f7bde4188396a3bfa66e6c1 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 2 Dec 2018 23:48:39 +0100 Subject: [PATCH] AIRBOSS v0.4.3 --- Moose Development/Moose/Ops/Airboss.lua | 511 ++++++++++++++---------- 1 file changed, 306 insertions(+), 205 deletions(-) diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index 87cc8a3bb..4fc8def7b 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -20,13 +20,14 @@ -- **PLEASE NOTE** that his class is work in progress and in an **alpha** stage and very much work in progress. -- -- At the moment, parameters are optimized for F/A-18C Hornet as aircraft and USS John C. Stennis as carrier. --- The community mod A-4E is also supported in priciple but needs further tweaking of parameters suche as on speed AoA values. +-- The community A-4E-C mod is also supported in priciple but needs further tweaking of parameters suche as on speed AoA values. +-- -- Other aircraft and carriers **might** be possible in future but would need a different set of optimized parameters. -- -- === -- -- ### Author: **funkyfranky** --- ### Co-author: **Bankler** (Carrier trainer idea and script) +-- ### Special Thanks To: **Bankler** (Carrier trainer idea and script) -- -- @module Ops.Airboss -- @image MOOSE.JPG @@ -47,7 +48,6 @@ -- @field #number ICLSchannel ICLS channel. -- @field Core.Radio#RADIO LSOradio Radio for LSO calls. -- @field Core.Radio#RADIO Carrierradio Radio for carrier calls. --- @field #AIRBOSS.RadioCalls radiocall LSO and Airboss call sound files and texts. -- @field Core.Scheduler#SCHEDULER radiotimer Radio queue scheduler. -- @field Core.Zone#ZONE_UNIT zoneCCA Carrier controlled area (CCA), i.e. a zone of 50 NM radius around the carrier. -- @field Core.Zone#ZONE_UNIT zoneCCZ Carrier controlled zone (CCZ), i.e. a zone of 5 NM radius around the carrier. @@ -132,7 +132,6 @@ AIRBOSS = { LSOfreq = nil, Carrierradio = nil, Carrierfreq = nil, - radiocall = {}, radiotimer = nil, zoneCCA = nil, zoneCCZ = nil, @@ -258,99 +257,194 @@ AIRBOSS.PatternStep={ --- Radio sound file and subtitle. -- @type AIRBOSS.RadioSound --- @field #string normal Sound file normal. --- @field #string louder Sound file loud. +-- @field #string file Sound file name without suffix. +-- @field #string suffix File suffix/extention, e.g. "ogg". +-- @field #boolean loud Loud version of sound file available. -- @field #string subtitle Subtitle displayed during transmission. --- @field #number duration Duration in seconds the subtitle is displayed. +-- @field #number duration Duration of the sound in seconds. This is also the duration the subtitle is displayed. ---- LSO and Airboss radio calls. --- @type AIRBOSS.RadioCalls +--- LSO radio calls. +-- @type AIRBOSS.LSOCall -- @field #AIRBOSS.RadioSound RIGHTFORLINEUP "Right for line up!" call. -- @field #AIRBOSS.RadioSound COMELEFT "Come left!" call. -- @field #AIRBOSS.RadioSound HIGH "You're high!" call. --- @field #AIRBOSS.RadioSound POWER Sound file "Power!" call. --- @field #AIRBOSS.RadioSound SLOW Sound file "You're slow!" call. --- @field #AIRBOSS.RadioSound FAST Sound file "You're fast!" call. --- @field #AIRBOSS.RadioSound CALLTHEBALL Sound file "Call the ball." call. --- @field #AIRBOSS.RadioSound ROGERBALL "Roger, ball." call. --- @field #AIRBOSS.RadioSound WAVEOFF "Wave off!" call. --- @field #AIRBOSS.RadioSound BOLTER "Bolter, bolter!" call. +-- @field #AIRBOSS.RadioSound POWER "Power!" call. +-- @field #AIRBOSS.RadioSound CALLTHEBALL "Call the Ball" +-- @field #AIRBOSS.RadioSound ROGERBALL "Roger ball" call (actually from pilot). +-- @field #AIRBOSS.RadioSound WAVEOFF "Wafe off" call +-- @field #AIRBOSS.RadioSound BOLTER "Bolter, Bolter" call -- @field #AIRBOSS.RadioSound LONGINGROOVE "You're long in the groove. Depart and re-enter." call. - ---- Default radio call sound files. --- @type AIRBOSS.Soundfile --- @field #AIRBOSS.RadioSound RIGHTFORLINEUP --- @field #AIRBOSS.RadioSound COMELEFT --- @field #AIRBOSS.RadioSound HIGH --- @field #AIRBOSS.RadioSound POWER --- @field #AIRBOSS.RadioSound CALLTHEBALL --- @field #AIRBOSS.RadioSound ROGERBALL --- @field #AIRBOSS.RadioSound WAVEOFF --- @field #AIRBOSS.RadioSound BOLTER --- @field #AIRBOSS.RadioSound LONGINGROOVE -AIRBOSS.Soundfile={ +-- @field #AIRBOSS.RadioSound N1 "One" call. +-- @field #AIRBOSS.RadioSound N2 "Two" call. +-- @field #AIRBOSS.RadioSound N9 "Nine" call. +AIRBOSS.LSOCall={ RIGHTFORLINEUP={ - normal="LSO - RightLineUp(S).ogg", - louder="LSO - RightLineUp(L).ogg", - subtitle="Right for line up.", - duration=1.5, + file="LSO-RightForLineup", + suffix="ogg", + loud=true, + subtitle="Right for line up", + duration=1.0, }, COMELEFT={ - normal="LSO - ComeLeft(S).ogg", - louder="LSO - ComeLeft(L).ogg", - subtitle="Come left.", - duration=1, + file="LSO-ComeLeft", + suffix="ogg", + loud=true, + subtitle="Come left", + duration=0.8, }, HIGH={ - normal="LSO - High(S).ogg", - louder="LSO - High(L).ogg", - subtitle="You're high.", - duration=1, + file="LSO-High", + loud=true, + subtitle="You're high", + duration=0.9, + }, + LOW={ + file="LSO-Low", + loud=true, + subtitle="You're low", + duration=0.6, }, POWER={ - normal="LSO - Power(S).ogg", - louder="LSO - Power(L).ogg", - subtitle="Power.", - duration=1, + file="LSO-Power", + suffix="ogg", + loud=true, + subtitle="Power", + duration=0.6, }, SLOW={ - normal="LSO-Slow-Normal.ogg", - louder="LSO-Slow-Loud.ogg", - subtitle="You're slow.", - duration=1, + file="LSO-Slow", + suffix="ogg", + loud=true, + subtitle="You're slow", + duration=0.9, }, FAST={ - normal="LSO-Fast-Normal.ogg", - louder="LSO-Fast-Loud.ogg", - subtitle="You're fast.", - duration=1, + file="LSO-Fast", + suffix="ogg", + loud=true, + subtitle="You're fast", + duration=0.9, }, CALLTHEBALL={ - normal="LSO - Call the Ball.ogg", - louder="LSO - Call the Ball.ogg", - subtitle="Call the ball.", - duration=3, + file="LSO-CallTheBall", + suffix="ogg", + louder=false, + subtitle="Call the ball", + duration=0.7, }, ROGERBALL={ - normal="LSO - Roger.ogg", - subtitle="Roger ball!", - duration=1.2, + file="LSO-RogerBall", + suffix="ogg", + louder=false, + subtitle="Roger ball", + duration=0.7, }, WAVEOFF={ - normal="LSO - WaveOff.ogg", - subtitle="Wave off!", - duration=1, + file="LSO-WaveOff", + suffix="ogg", + louder=false, + subtitle="Wave off", + duration=0.7, }, BOLTER={ - normal="LSO - Bolter.ogg", + file="LSO-BolterBolter", + suffix="ogg", + louder=false, subtitle="Bolter, Bolter!", - duration=1.5, + duration=1.0, }, LONGINGROOVE={ - normal="LSO - Long in Groove.ogg", - subtitle="You're long in the groove. Depart and re-enter.", - duration=3, - } + file="LSO-LonInTheGroove", + suffix="ogg", + louder=false, + subtitle="You're long in the groove", + duration=1.3, + }, + DEPARTANDREENTER={ + file="LSO-DepartAndReenter", + suffix="ogg", + louder=false, + subtitle="Depart and re-enter", + duration=1.3, + }, + PADDLESCONTACT={ + file="LSO-PaddlesContact", + suffix="ogg", + louder=false, + subtitle="Paddles, contact", + duration=1.0, + }, + N1={ + file="LSO-N1", + suffix="ogg", + louder=false, + subtitle="", + duration=0.3, + }, + N2={ + file="LSO-N2", + suffix="ogg", + louder=false, + subtitle="", + duration=0.3, + }, + N3={ + file="LSO-N3", + suffix="ogg", + louder=false, + subtitle="", + duration=0.4, + }, + N4={ + file="LSO-N4", + suffix="ogg", + louder=false, + subtitle="", + duration=0.4, + }, + N5={ + file="LSO-N5", + suffix="ogg", + louder=false, + subtitle="", + duration=0.4, + }, + N6={ + file="LSO-N6", + suffix="ogg", + louder=false, + subtitle="", + duration=0.6, + }, + N7={ + file="LSO-N7", + suffix="ogg", + louder=false, + subtitle="", + duration=0.6, + }, + N8={ + file="LSO-N8", + suffix="ogg", + louder=false, + subtitle="", + duration=0.4, + }, + N9={ + file="LSO-N9", + suffix="ogg", + louder=false, + subtitle="", + duration=0.5, + }, + N0={ + file="LSO-N0", + suffix="ogg", + louder=false, + subtitle="", + duration=0.4, + }, + } --- Difficulty level. @@ -366,8 +460,8 @@ AIRBOSS.Difficulty={ --- Recovery time. -- @type AIRBOSS.Recovery --- @field #number START Start of recovery. --- @field #number STOP End of recovery. +-- @field #number START Start of recovery in seconds of abs time. +-- @field #number STOP End of recovery in seconds of abs time. -- @field #number CASE Recovery case (1-3) of that time slot. --- Groove position. @@ -438,7 +532,7 @@ AIRBOSS.GroovePos={ -- @field #boolean player If true, flight is a human player. -- @field #string actype Aircraft type name. -- @field #table onboardnumbers Onboard numbers of aircraft in the group. --- @field #number onboard Onboard number of player or fist unit in group. +-- @field #string onboard Onboard number of player or first unit in group. -- @field #number case Recovery case of flight. -- @field #string seclead Name of section lead. -- @field #table section Other human flight groups belonging to this flight. This flight is the lead. @@ -473,7 +567,7 @@ AIRBOSS.MenuF10={} --- Airboss class version. -- @field #string version -AIRBOSS.version="0.4.2" +AIRBOSS.version="0.4.3" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -620,11 +714,14 @@ function AIRBOSS:New(carriername, alias) self:_GetZoneCorridor(case):SmokeZone(SMOKECOLOR.Green, 45) end - +--[[ -- Init default sound files. - for _name,_sound in pairs(AIRBOSS.Soundfile) do + for _name,_sound in pairs(AIRBOSS.LSOCall) do local sound=_sound --#AIRBOSS.RadioSound - self.radiocall[_name]=sound + local text=string.format() + sound.subtitle=1 + sound.louder=1 + --self.radiocall[_name]=sound end -- Debug: @@ -632,6 +729,7 @@ function AIRBOSS:New(carriername, alias) for _name,_sound in pairs(self.radiocall) do self:T{name=_name,sound=_sound} end +]] ----------------------- --- FSM Transitions --- @@ -1071,75 +1169,7 @@ function AIRBOSS:_CheckRecoveryTimes() end -- Debug output. - self:I(self.lid..text) - - --[[ - - -- Check if a recovery time was set. - if #self.recoverytime==0 then - - -- If no recovery times have been specified, we assume any time is okay. - self:I("FF Start recovery. No recovery time set!") - if not self:IsRecovering() then - -- Give command to recover! - return true - else - -- Do nothing. - return nil - end - - else - - -- Selected recovery event if any. - local recovery=nil --#AIRBOSS.Recovery - - for i,_rtime in pairs(self.recoverytime) do - local rtime=_rtime --#AIRBOSS.Recovery - - if abstime>=rtime.START and abstime<=rtime.STOP then - - -- This is a valid time slot. Do not touch recovery again! - recovery=rtime - - elseif abstime>rtime.STOP then - -- Stop time has already passed. - -- We do not remove the time sind the above #recovery check would fail by automatically setting case 1 always! - --table.insert(remove, i) - elseif abstime1 then -- "You're high!" - self:RadioTransmission(self.LSOradio, self.radiocall.HIGH, true, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.HIGH, true) elseif glideslopeError>0.5 then -- "You're a little high." - self:RadioTransmission(self.LSOradio, self.radiocall.HIGH, false, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.HIGH, false) elseif glideslopeError<-1.0 then -- "Power!" - self:RadioTransmission(self.LSOradio, self.radiocall.POWER, true, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.POWER, true) elseif glideslopeError<-0.5 then -- "You're a little low." - self:RadioTransmission(self.LSOradio, self.radiocall.POWER, false, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.POWER, false) else text="Good altitude." end @@ -4498,20 +4528,16 @@ function AIRBOSS:_LSOadvice(playerData, glideslopeError, lineupError) -- Lineup left/right calls. if lineupError<-3 then -- "Come left!" - self:RadioTransmission(self.LSOradio, self.radiocall.COMELEFT, true, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.COMELEFT, true) elseif lineupError<-1 then -- "Come left." - self:RadioTransmission(self.LSOradio, self.radiocall.COMELEFT, false, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.COMELEFT, false) elseif lineupError>3 then -- "Right for lineup!" - self:RadioTransmission(self.LSOradio, self.radiocall.RIGHTFORLINEUP, true, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.RIGHTFORLINEUP, true) elseif lineupError>1 then -- "Right for lineup." - self:RadioTransmission(self.LSOradio, self.radiocall.RIGHTFORLINEUP, false, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.RIGHTFORLINEUP, false) else text=text.."Good lineup." end @@ -4527,22 +4553,18 @@ function AIRBOSS:_LSOadvice(playerData, glideslopeError, lineupError) -- Rate aoa. if aoa>=aircraftaoa.Slow then -- "Your're slow!" - self:RadioTransmission(self.LSOradio, self.radiocall.SLOW, true, delay) - --delay=delay+1.5 + self:RadioTransmission(self.LSOradio, AIRBOSS.LSOCall.SLOW, true) elseif aoa>=aircraftaoa.OnSpeedMax and aoa=aircraftaoa.OnSpeedMin and aoa=aircraftaoa.Fast and aoa0 then SCHEDULER:New(nil, self.MessageToPlayer, {self, playerData, message, sender, receiver, duration, clear}, delay) @@ -5652,6 +5690,69 @@ function AIRBOSS:MessageToAll(message, sender, receiver, duration, clear, delay) end +--- Convert a number (as string) into a radio message. +-- E.g. for board number or headings. +-- @param #AIRBOSS self +-- @param Core.Radio#RADIO radio Radio used for transmission. +-- @param #string number Number string, e.g. "032" or "183". +-- @param #number delay Delay before transmission in seconds. +function AIRBOSS:_Number2Sound(radio, number, delay) + + --- Split string into characters. + local function _split(str) + local chars={} + for i=1,#str do + local c=str:sub(i,i) + table.insert(chars, c) + end + return chars + end + + local alias=radio:GetAlias() + local sender="" + if alias=="LSO" then + sender="LSOCall" + elseif alias=="MARSHAL" then + sender="MarshalCall" + elseif alias=="AIRBOSS" then + sender="AirbossCall" + end + + -- Split string into characters. + local numbers=_split(number) + + for i=1,#numbers do + + -- Current number + local n=numbers[i] + + if n=="0" then + self:RadioTransmission(radio, AIRBOSS[sender].N0, false, delay) + elseif n=="1" then + self:RadioTransmission(radio, AIRBOSS[sender].N1, false, delay) + elseif n=="2" then + self:RadioTransmission(radio, AIRBOSS[sender].N2, false, delay) + elseif n=="3" then + self:RadioTransmission(radio, AIRBOSS[sender].N3, false, delay) + elseif n=="4" then + self:RadioTransmission(radio, AIRBOSS[sender].N4, false, delay) + elseif n=="5" then + self:RadioTransmission(radio, AIRBOSS[sender].N5, false, delay) + elseif n=="6" then + self:RadioTransmission(radio, AIRBOSS[sender].N6, false, delay) + elseif n=="7" then + self:RadioTransmission(radio, AIRBOSS[sender].N7, false, delay) + elseif n=="8" then + self:RadioTransmission(radio, AIRBOSS[sender].N8, false, delay) + elseif n=="9" then + self:RadioTransmission(radio, AIRBOSS[sender].N9, false, delay) + else + self:E(self.lid..string.format("ERROR: Unknown number %s", tostring(n))) + end + end + +end + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- RADIO MENU Functions ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -6539,25 +6640,25 @@ function AIRBOSS:_MarkCase23Zones(_unitName, flare) else -- Case I/II: Initial - if case==1 or case==2 or self.Debug then + if case==1 or case==2 then text=text.."* initial with WHITE smoke\n" self.zoneInitial:SmokeZone(SMOKECOLOR.White, 45) end -- Case II/III: Approach Corridor - if case==2 or case==3 or self.Debug then + if case==2 or case==3 then text=text.."* approach corridor with GREEN smoke\n" self:_GetZoneCorridor(case):SmokeZone(SMOKECOLOR.Green, 45) end -- Case II/III: platform - if case==2 or case==3 or self.Debug then + if case==2 or case==3 then text=text.."* platform with RED smoke\n" self:_GetZonePlatform(case):SmokeZone(SMOKECOLOR.Red, 45) end -- Case II/III: arc in/out if offset>0. - if case==2 or case==3 or self.Debug then + if case==2 or case==3 then if math.abs(self.holdingoffset)>0 then self:_GetZoneArcIn(case):SmokeZone(SMOKECOLOR.Red, 45) text=text.."* arc turn in with YELLOW flares\n" @@ -6567,13 +6668,13 @@ function AIRBOSS:_MarkCase23Zones(_unitName, flare) end -- Case III: dirty up - if case==3 or self.Debug then + if case==3 then text=text.."* dirty up with ORANGE flares\n" self:_GetZoneDirtyUp(case):SmokeZone(SMOKECOLOR.Orange, 45) end -- Case III: dirty up - if case==3 or self.Debug then + if case==3 then text=text.."* bullseye with BLUE smoke\n" self:_GetZoneBullseye(case):SmokeZone(SMOKECOLOR.Blue, 45) end