mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AIRBOSS v0.4.0
This commit is contained in:
parent
99c2e76e53
commit
21f0094d7c
@ -1719,12 +1719,14 @@ WAREHOUSE.Quantity = {
|
|||||||
--- Warehouse database. Note that this is a global array to have easier exchange between warehouses.
|
--- Warehouse database. Note that this is a global array to have easier exchange between warehouses.
|
||||||
-- @type WAREHOUSE.db
|
-- @type WAREHOUSE.db
|
||||||
-- @field #number AssetID Unique ID of each asset. This is a running number, which is increased each time a new asset is added.
|
-- @field #number AssetID Unique ID of each asset. This is a running number, which is increased each time a new asset is added.
|
||||||
-- @field #table Assets Table holding registered assets, which are of type @{Functional.Warehouse#WAREHOUSE.Assetitem}.
|
-- @field #table Assets Table holding registered assets, which are of type @{Functional.Warehouse#WAREHOUSE.Assetitem}.#
|
||||||
|
-- @field #number WarehouseID Unique ID of the warehouse. Running number.
|
||||||
-- @field #table Warehouses Table holding all defined @{#WAREHOUSE} objects by their unique ids.
|
-- @field #table Warehouses Table holding all defined @{#WAREHOUSE} objects by their unique ids.
|
||||||
WAREHOUSE.db = {
|
WAREHOUSE.db = {
|
||||||
AssetID = 0,
|
AssetID = 0,
|
||||||
Assets = {},
|
Assets = {},
|
||||||
Warehouses = {}
|
WarehouseID = 0,
|
||||||
|
Warehouses = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Warehouse class version.
|
--- Warehouse class version.
|
||||||
@ -1825,7 +1827,13 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
|
|
||||||
-- Set some variables.
|
-- Set some variables.
|
||||||
self.warehouse=warehouse
|
self.warehouse=warehouse
|
||||||
self.uid=tonumber(warehouse:GetID())
|
|
||||||
|
-- Increase global warehouse counter.
|
||||||
|
WAREHOUSE.db.WarehouseID=WAREHOUSE.db.WarehouseID+1
|
||||||
|
|
||||||
|
-- Set unique ID for this warehouse.
|
||||||
|
self.uid=WAREHOUSE.db.WarehouseID
|
||||||
|
--self.uid=tonumber(warehouse:GetID())
|
||||||
|
|
||||||
-- Closest of the same coalition but within a certain range.
|
-- Closest of the same coalition but within a certain range.
|
||||||
local _airbase=self:GetCoordinate():GetClosestAirbase(nil, self:GetCoalition())
|
local _airbase=self:GetCoordinate():GetClosestAirbase(nil, self:GetCoalition())
|
||||||
|
|||||||
@ -287,37 +287,37 @@ AIRBOSS.Soundfile={
|
|||||||
normal="LSO - RightLineUp(S).ogg",
|
normal="LSO - RightLineUp(S).ogg",
|
||||||
louder="LSO - RightLineUp(L).ogg",
|
louder="LSO - RightLineUp(L).ogg",
|
||||||
subtitle="Right for line up.",
|
subtitle="Right for line up.",
|
||||||
duration=3,
|
duration=1.5,
|
||||||
},
|
},
|
||||||
COMELEFT={
|
COMELEFT={
|
||||||
normal="LSO - ComeLeft(S).ogg",
|
normal="LSO - ComeLeft(S).ogg",
|
||||||
louder="LSO - ComeLeft(L).ogg",
|
louder="LSO - ComeLeft(L).ogg",
|
||||||
subtitle="Come left.",
|
subtitle="Come left.",
|
||||||
duration=3,
|
duration=1,
|
||||||
},
|
},
|
||||||
HIGH={
|
HIGH={
|
||||||
normal="LSO - High(S).ogg",
|
normal="LSO - High(S).ogg",
|
||||||
louder="LSO - High(L).ogg",
|
louder="LSO - High(L).ogg",
|
||||||
subtitle="You're high.",
|
subtitle="You're high.",
|
||||||
duration=3,
|
duration=1,
|
||||||
},
|
},
|
||||||
POWER={
|
POWER={
|
||||||
normal="LSO - Power(S).ogg",
|
normal="LSO - Power(S).ogg",
|
||||||
louder="LSO - Power(L).ogg",
|
louder="LSO - Power(L).ogg",
|
||||||
subtitle="Power.",
|
subtitle="Power.",
|
||||||
duration=3,
|
duration=1,
|
||||||
},
|
},
|
||||||
SLOW={
|
SLOW={
|
||||||
normal="LSO-Slow-Normal.ogg",
|
normal="LSO-Slow-Normal.ogg",
|
||||||
louder="LSO-Slow-Loud.ogg",
|
louder="LSO-Slow-Loud.ogg",
|
||||||
subtitle="You're slow.",
|
subtitle="You're slow.",
|
||||||
duration=3,
|
duration=1,
|
||||||
},
|
},
|
||||||
FAST={
|
FAST={
|
||||||
normal="LSO-Fast-Normal.ogg",
|
normal="LSO-Fast-Normal.ogg",
|
||||||
louder="LSO-Fast-Loud.ogg",
|
louder="LSO-Fast-Loud.ogg",
|
||||||
subtitle="You're fast.",
|
subtitle="You're fast.",
|
||||||
duration=3,
|
duration=1,
|
||||||
},
|
},
|
||||||
CALLTHEBALL={
|
CALLTHEBALL={
|
||||||
normal="LSO - Call the Ball.ogg",
|
normal="LSO - Call the Ball.ogg",
|
||||||
@ -328,17 +328,17 @@ AIRBOSS.Soundfile={
|
|||||||
ROGERBALL={
|
ROGERBALL={
|
||||||
normal="LSO - Roger.ogg",
|
normal="LSO - Roger.ogg",
|
||||||
subtitle="Roger ball!",
|
subtitle="Roger ball!",
|
||||||
duration=3,
|
duration=1.2,
|
||||||
},
|
},
|
||||||
WAVEOFF={
|
WAVEOFF={
|
||||||
normal="LSO - WaveOff.ogg",
|
normal="LSO - WaveOff.ogg",
|
||||||
subtitle="Wave off!",
|
subtitle="Wave off!",
|
||||||
duration=3,
|
duration=1,
|
||||||
},
|
},
|
||||||
BOLTER={
|
BOLTER={
|
||||||
normal="LSO - Bolter.ogg",
|
normal="LSO - Bolter.ogg",
|
||||||
subtitle="Bolter, Bolter!",
|
subtitle="Bolter, Bolter!",
|
||||||
duration=3,
|
duration=1.5,
|
||||||
},
|
},
|
||||||
LONGINGROOVE={
|
LONGINGROOVE={
|
||||||
normal="LSO - Long in Groove.ogg",
|
normal="LSO - Long in Groove.ogg",
|
||||||
@ -469,25 +469,25 @@ AIRBOSS.MenuF10={}
|
|||||||
|
|
||||||
--- Airboss class version.
|
--- Airboss class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRBOSS.version="0.3.9w"
|
AIRBOSS.version="0.4.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- TODO: Set case II and III times.
|
|
||||||
-- TODO: Add radio transmission queue for LSO and airboss.
|
|
||||||
-- TODO: Get correct wire when trapped.
|
-- TODO: Get correct wire when trapped.
|
||||||
|
-- TODO: Set case II and III times.
|
||||||
-- TODO: Add radio check (LSO, AIRBOSS) to F10 radio menu.
|
-- TODO: Add radio check (LSO, AIRBOSS) to F10 radio menu.
|
||||||
-- TODO: Add user functions.
|
-- TODO: Add user functions.
|
||||||
-- TODO: Generalize parameters for other carriers.
|
-- TODO: Generalize parameters for other carriers.
|
||||||
-- TODO: Generalize parameters for other aircraft.
|
-- TODO: Generalize parameters for other aircraft.
|
||||||
-- TODO: Foul deck check.
|
-- TODO: Foul deck check.
|
||||||
-- TODO: Persistence of results.
|
-- TODO: Persistence of results.
|
||||||
-- NOPE: Strike group with helo bringing cargo etc.
|
|
||||||
-- TODO: Right pattern step after bolter/wo/patternWO?
|
-- TODO: Right pattern step after bolter/wo/patternWO?
|
||||||
-- TODO: CASE II.
|
-- DONE: Add radio transmission queue for LSO and airboss.
|
||||||
-- TODO: CASE III.
|
-- TONE: CASE II.
|
||||||
|
-- DONE: CASE III.
|
||||||
|
-- NOPE: Strike group with helo bringing cargo etc. Not yet.
|
||||||
-- DONE: Handle crash event. Delete A/C from queue, send rescue helo.
|
-- DONE: Handle crash event. Delete A/C from queue, send rescue helo.
|
||||||
-- DONE: Get fuel state in pounds. (working for the hornet, did not check others)
|
-- DONE: Get fuel state in pounds. (working for the hornet, did not check others)
|
||||||
-- DONE: Add aircraft numbers in queue to carrier info F10 radio output.
|
-- DONE: Add aircraft numbers in queue to carrier info F10 radio output.
|
||||||
@ -920,8 +920,8 @@ function AIRBOSS:onafterStart(From, Event, To)
|
|||||||
|
|
||||||
-- Schedule radio queue checks.
|
-- Schedule radio queue checks.
|
||||||
-- TODO: id's to self to be able to stop the scheduler.
|
-- TODO: id's to self to be able to stop the scheduler.
|
||||||
local RQLid=self.radiotimer:Schedule(self, self._CheckRadioQueue, {self, self.RQLSO}, 1, 0.1)
|
local RQLid=self.radiotimer:Schedule(self, self._CheckRadioQueue, {self.RQLSO, "LSO"}, 1, 0.1)
|
||||||
local RQMid=self.radiotimer:Schedule(self, self._CheckRadioQueue, {self, self.RQMarshal}, 1, 0.1)
|
local RQMid=self.radiotimer:Schedule(self, self._CheckRadioQueue, {self.RQMarshal, "MARSHAL"}, 1, 0.1)
|
||||||
|
|
||||||
-- Start status check in 1 second.
|
-- Start status check in 1 second.
|
||||||
self:__Status(1)
|
self:__Status(1)
|
||||||
@ -1766,7 +1766,7 @@ function AIRBOSS:_GetMarshalAltitude(stack, case)
|
|||||||
angels0=6
|
angels0=6
|
||||||
|
|
||||||
-- Distance: d=n*angles0+15 NM, so first stack is at 15+6=21 NM
|
-- Distance: d=n*angles0+15 NM, so first stack is at 15+6=21 NM
|
||||||
Dist=UTILS.NMToMeters((stack-1)*angels0+15)
|
Dist=UTILS.NMToMeters(stack*angels0+15)
|
||||||
|
|
||||||
-- Get correct radial depending on recovery case including offset.
|
-- Get correct radial depending on recovery case including offset.
|
||||||
local radial
|
local radial
|
||||||
@ -2524,6 +2524,7 @@ function AIRBOSS:OnEventLand(EventData)
|
|||||||
-- Landing distance to carrier position.
|
-- Landing distance to carrier position.
|
||||||
local dist=coord:Get2DDistance(self:GetCoordinate())
|
local dist=coord:Get2DDistance(self:GetCoordinate())
|
||||||
|
|
||||||
|
-- Correct sign if necessary.
|
||||||
if X<0 then
|
if X<0 then
|
||||||
dist=-dist
|
dist=-dist
|
||||||
end
|
end
|
||||||
@ -2538,7 +2539,7 @@ function AIRBOSS:OnEventLand(EventData)
|
|||||||
local w4=self:GetCoordinate():Translate(self.carrierparam.wire4, hdg):MarkToAll("Wire 4")
|
local w4=self:GetCoordinate():Translate(self.carrierparam.wire4, hdg):MarkToAll("Wire 4")
|
||||||
|
|
||||||
-- Get wire
|
-- Get wire
|
||||||
local wire=self:_GetWire(dist)
|
local wire=self:_GetWire(dist, 30)
|
||||||
|
|
||||||
-- Aircraft type.
|
-- Aircraft type.
|
||||||
local _type=EventData.IniUnit:GetTypeName()
|
local _type=EventData.IniUnit:GetTypeName()
|
||||||
@ -2568,7 +2569,7 @@ function AIRBOSS:OnEventLand(EventData)
|
|||||||
local dist=coord:Get2DDistance(self:GetCoordinate())
|
local dist=coord:Get2DDistance(self:GetCoordinate())
|
||||||
|
|
||||||
-- Get wire
|
-- Get wire
|
||||||
local wire=self:_GetWire(dist)
|
local wire=self:_GetWire(dist, 0)
|
||||||
|
|
||||||
-- Aircraft type.
|
-- Aircraft type.
|
||||||
local _type=EventData.IniUnit:GetTypeName()
|
local _type=EventData.IniUnit:GetTypeName()
|
||||||
@ -2969,11 +2970,12 @@ function AIRBOSS:_GetZoneCorridor(case)
|
|||||||
c[8]=c[7]:Translate( UTILS.NMToMeters( y), radial-90) -- back along X
|
c[8]=c[7]:Translate( UTILS.NMToMeters( y), radial-90) -- back along X
|
||||||
c[9]=c[1]:Translate( UTILS.NMToMeters( 1), radial+90) -- 1 left of carrier
|
c[9]=c[1]:Translate( UTILS.NMToMeters( 1), radial+90) -- 1 left of carrier
|
||||||
|
|
||||||
|
|
||||||
-- Create an array of a square!
|
-- Create an array of a square!
|
||||||
local p={}
|
local p={}
|
||||||
for _i,_c in ipairs(c) do
|
for _i,_c in ipairs(c) do
|
||||||
_c:SmokeBlue()
|
if self.Debug then
|
||||||
|
_c:SmokeBlue()
|
||||||
|
end
|
||||||
p[_i]=_c:GetVec2()
|
p[_i]=_c:GetVec2()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3033,10 +3035,13 @@ function AIRBOSS:_GetHoldingZone(playerData)
|
|||||||
|
|
||||||
-- Create an array of a square!
|
-- Create an array of a square!
|
||||||
local p={}
|
local p={}
|
||||||
p[1]=c1:Translate(UTILS.NMToMeters(1), hdg+90):GetVec2() --c1 is at (angels+15) NM directly behind the carrier. We translate it 1 NM starboard.
|
p[1]=c1:Translate(UTILS.NMToMeters(1), hdg-90):GetVec2() --c1 is at (angels+15) NM directly behind the carrier. We translate it 1 NM starboard.
|
||||||
p[2]=c2:Translate(UTILS.NMToMeters(1), hdg+90):GetVec2() --c2 is 10 NM further behind. Also translated 1 NM starboard.
|
p[2]=c2:Translate(UTILS.NMToMeters(1), hdg-90):GetVec2() --c2 is 10 NM further behind. Also translated 1 NM starboard.
|
||||||
p[3]=c2:Translate(UTILS.NMToMeters(7), hdg-90):GetVec2() --p3 6 NM port of carrier.
|
p[3]=c2:Translate(UTILS.NMToMeters(7), hdg+90):GetVec2() --p3 6 NM port of carrier.
|
||||||
p[4]=c1:Translate(UTILS.NMToMeters(7), hdg-90):GetVec2() --p4 6 NM port of carrier.
|
p[4]=c1:Translate(UTILS.NMToMeters(7), hdg+90):GetVec2() --p4 6 NM port of carrier.
|
||||||
|
|
||||||
|
--c1:SmokeBlue()
|
||||||
|
--c2:SmokeOrange()
|
||||||
|
|
||||||
-- Square zone length=10NM width=6 NM behind the carrier starting at angels+15 NM behind the carrier.
|
-- Square zone length=10NM width=6 NM behind the carrier starting at angels+15 NM behind the carrier.
|
||||||
-- So stay 0-5 NM (+1 NM error margin) port of carrier.
|
-- So stay 0-5 NM (+1 NM error margin) port of carrier.
|
||||||
@ -3887,24 +3892,28 @@ end
|
|||||||
--- Get wire from landing position.
|
--- Get wire from landing position.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #number d Distance in meters wrt carrier position where player landed.
|
-- @param #number d Distance in meters wrt carrier position where player landed.
|
||||||
function AIRBOSS:_GetWire(d)
|
-- @param #number dx Correction.
|
||||||
|
function AIRBOSS:_GetWire(d, dx)
|
||||||
|
|
||||||
-- Little offset for the exact wire positions.
|
-- Little offset for the exact wire positions.
|
||||||
local wdx=0
|
dx=dx or 30
|
||||||
|
|
||||||
-- Which wire was caught? X>0 since calculated as distance!
|
-- Which wire was caught? X>0 since calculated as distance!
|
||||||
local wire
|
local wire
|
||||||
if d<self.carrierparam.wire1+wdx then
|
if d-dx<self.carrierparam.wire1 then -- < -104
|
||||||
wire=1
|
wire=1
|
||||||
elseif d<self.carrierparam.wire2+wdx then
|
elseif d-dx<self.carrierparam.wire2 then -- < -92
|
||||||
wire=2
|
wire=2
|
||||||
elseif d<self.carrierparam.wire3+wdx then
|
elseif d-dx<self.carrierparam.wire3 then -- < -80
|
||||||
wire=3
|
wire=3
|
||||||
elseif d<self.carrierparam.wire4+wdx then
|
elseif d-dx<self.carrierparam.wire4 then -- < -68
|
||||||
wire=4
|
wire=4
|
||||||
else
|
else
|
||||||
wire=99
|
wire=99
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Debug output.
|
||||||
|
self:I(string.format("GetWire: d=%.1f m, dx=%.1f m, d-dx=%.1f m ==> wire=%d.", d, dx, d-dx, wire))
|
||||||
|
|
||||||
return wire
|
return wire
|
||||||
end
|
end
|
||||||
@ -5172,18 +5181,18 @@ end
|
|||||||
--- Radio queue item.
|
--- Radio queue item.
|
||||||
-- @type AIRBOSS.Radioitem
|
-- @type AIRBOSS.Radioitem
|
||||||
-- @field #number Tplay Abs time when transmission should be played.
|
-- @field #number Tplay Abs time when transmission should be played.
|
||||||
-- @field #number duration Duration of the transmission in seconds.
|
|
||||||
-- @field #number Tstarted Abs time when transmission began to play.
|
-- @field #number Tstarted Abs time when transmission began to play.
|
||||||
-- @field #number prio Priority 0-100.
|
-- @field #number prio Priority 0-100.
|
||||||
-- @field #boolean isplaying Currently playing.
|
-- @field #boolean isplaying Currently playing.
|
||||||
-- @field Core.Beacon#RADIO radio Radio object.
|
-- @field Core.Beacon#RADIO radio Radio object.
|
||||||
-- @field #AIRBOSS.SoundFile call
|
-- @field #AIRBOSS.RadioSound call Radio sound.
|
||||||
-- @field #boolean loud Play loud version
|
|
||||||
|
|
||||||
--- Check radio queue for transmissions to be broadcasted.
|
--- Check radio queue for transmissions to be broadcasted.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #table radioqueue The radio queue.
|
-- @param #table radioqueue The radio queue.
|
||||||
function AIRBOSS:_CheckRadioQueue(radioqueue)
|
-- @param #string name Name of the queue.
|
||||||
|
function AIRBOSS:_CheckRadioQueue(radioqueue, name)
|
||||||
|
--env.info(string.format("FF: check radio queue %s: n=%d", name, #radioqueue))
|
||||||
|
|
||||||
-- Check if queue is empty.
|
-- Check if queue is empty.
|
||||||
if #radioqueue==0 then
|
if #radioqueue==0 then
|
||||||
@ -5197,7 +5206,7 @@ function AIRBOSS:_CheckRadioQueue(radioqueue)
|
|||||||
local function _sort(a, b)
|
local function _sort(a, b)
|
||||||
return (a.Tplay < b.Tplay) or (a.Tplay==b.Tplay and a.prio < b.prio)
|
return (a.Tplay < b.Tplay) or (a.Tplay==b.Tplay and a.prio < b.prio)
|
||||||
end
|
end
|
||||||
table.sort(radioqueue, _sort)
|
table.sort(radioqueue, _sort)
|
||||||
|
|
||||||
local playing=false
|
local playing=false
|
||||||
local next=nil --#AIRBOSS.Radioitem
|
local next=nil --#AIRBOSS.Radioitem
|
||||||
@ -5212,7 +5221,7 @@ function AIRBOSS:_CheckRadioQueue(radioqueue)
|
|||||||
if transmission.isplaying then
|
if transmission.isplaying then
|
||||||
|
|
||||||
-- Check if transmission is finished.
|
-- Check if transmission is finished.
|
||||||
if time>transmission.Tstarted+transmission.duration then
|
if time>=transmission.Tstarted+transmission.call.duration then
|
||||||
|
|
||||||
-- Transmission over.
|
-- Transmission over.
|
||||||
transmission.isplaying=false
|
transmission.isplaying=false
|
||||||
@ -5272,8 +5281,7 @@ function AIRBOSS:RadioTransmission(radio, call, loud, delay)
|
|||||||
|
|
||||||
transmission.radio=radio
|
transmission.radio=radio
|
||||||
transmission.call=call
|
transmission.call=call
|
||||||
transmission.loud=loud
|
transmission.Tplay=timer.getAbsTime()+(delay or 0)
|
||||||
transmission.Tplay=timer.getAbsTime()+delay
|
|
||||||
transmission.prio=50
|
transmission.prio=50
|
||||||
transmission.isplaying=false
|
transmission.isplaying=false
|
||||||
transmission.Tstarted=nil
|
transmission.Tstarted=nil
|
||||||
|
|||||||
@ -701,7 +701,7 @@ function RESCUEHELO:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
-- Report current fuel.
|
-- Report current fuel.
|
||||||
local text=string.format("Rescue Helo %s: state=%s fuel=%.1f", self.helo:GetName(), self:GetState(), fuel)
|
local text=string.format("Rescue Helo %s: state=%s fuel=%.1f", self.helo:GetName(), self:GetState(), fuel)
|
||||||
self:I(text)
|
self:T(text)
|
||||||
|
|
||||||
-- If fuel < threshold ==> send helo to home base!
|
-- If fuel < threshold ==> send helo to home base!
|
||||||
if fuel<self.lowfuel and self:IsRunning() then
|
if fuel<self.lowfuel and self:IsRunning() then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user