mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aaf77815ca | ||
|
|
3f488cc091 | ||
|
|
bdbbdfe60e | ||
|
|
d15c2be2d0 | ||
|
|
73994914eb | ||
|
|
63b0dae794 | ||
|
|
003e865ff7 | ||
|
|
e3c03287b7 | ||
|
|
73493c3a23 | ||
|
|
562a3f6208 | ||
|
|
3c5f3d6c37 |
@@ -1127,8 +1127,10 @@ do -- SET_GROUP
|
||||
|
||||
local NearestGroup = nil -- Wrapper.Group#GROUP
|
||||
local ClosestDistance = nil
|
||||
|
||||
for ObjectID, ObjectData in pairs( self.Set ) do
|
||||
|
||||
local Set = self:GetAliveSet()
|
||||
|
||||
for ObjectID, ObjectData in pairs( Set ) do
|
||||
if NearestGroup == nil then
|
||||
NearestGroup = ObjectData
|
||||
ClosestDistance = PointVec2:DistanceFromPointVec2( ObjectData:GetCoordinate() )
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2381,7 +2381,7 @@ function RANGE:_DisplayMyStrafePitResults( _unitName )
|
||||
|
||||
-- Sort results table wrt number of hits.
|
||||
local _sort = function( a, b )
|
||||
return a.hits > b.hits
|
||||
return a.roundsHit > b.roundsHit
|
||||
end
|
||||
table.sort( _results, _sort )
|
||||
|
||||
@@ -2398,7 +2398,7 @@ function RANGE:_DisplayMyStrafePitResults( _unitName )
|
||||
|
||||
-- Best result.
|
||||
if _bestMsg == "" then
|
||||
_bestMsg = string.format( "Hits %d - %s - %s", _result.hits, _result.zone.name, _result.text )
|
||||
_bestMsg = string.format( "Hits %d - %s - %s", result.roundsHit, result.name, result.roundsQuality)
|
||||
end
|
||||
|
||||
-- 10 runs
|
||||
@@ -2443,15 +2443,15 @@ function RANGE:_DisplayStrafePitResults( _unitName )
|
||||
-- Get the best result of the player.
|
||||
local _best = nil
|
||||
for _, _result in pairs( _results ) do
|
||||
if _best == nil or _result.hits > _best.hits then
|
||||
if _best == nil or _result.roundsHit > _best.roundsHit then
|
||||
_best = _result
|
||||
end
|
||||
end
|
||||
|
||||
-- Add best result to table.
|
||||
if _best ~= nil then
|
||||
local text = string.format( "%s: Hits %i - %s - %s", _playerName, _best.hits, _best.zone.name, _best.text )
|
||||
table.insert( _playerResults, { msg = text, hits = _best.hits } )
|
||||
local text = string.format( "%s: Hits %i - %s - %s", _playerName, _best.roundsHit, _best.name, _best.roundsQuality )
|
||||
table.insert( _playerResults, { msg = text, hits = _best.roundsHit } )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2667,6 +2667,26 @@ function RANGE:_DisplayRangeInfo( _unitname )
|
||||
text = text .. string.format( "Max strafing alt AGL: %s\n", tstrafemaxalt )
|
||||
text = text .. string.format( "# of strafe targets: %d\n", self.nstrafetargets )
|
||||
text = text .. string.format( "# of bomb targets: %d\n", self.nbombtargets )
|
||||
if self.instructor then
|
||||
local alive = "N/A"
|
||||
if self.instructorrelayname then
|
||||
local relay = UNIT:FindByName( self.instructorrelayname )
|
||||
if relay then
|
||||
alive = tostring( relay:IsAlive() )
|
||||
end
|
||||
end
|
||||
text = text .. string.format( "Instructor %.3f MHz (Relay=%s)\n", self.instructorfreq, alive )
|
||||
end
|
||||
if self.rangecontrol then
|
||||
local alive = "N/A"
|
||||
if self.rangecontrolrelayname then
|
||||
local relay = UNIT:FindByName( self.rangecontrolrelayname )
|
||||
if relay then
|
||||
alive = tostring( relay:IsAlive() )
|
||||
end
|
||||
end
|
||||
text = text .. string.format( "Control %.3f MHz (Relay=%s)\n", self.rangecontrolfreq, alive )
|
||||
end
|
||||
text = text .. texthit
|
||||
text = text .. textbomb
|
||||
text = text .. textdelay
|
||||
@@ -3487,7 +3507,7 @@ function RANGE:_SmokeBombImpactOnOff( unitname )
|
||||
self.PlayerSettings[playername].smokebombimpact = false
|
||||
text = string.format( "%s, %s, smoking impact points of bombs is now OFF.", self.rangename, playername )
|
||||
else
|
||||
self.PlayerSettigs[playername].smokebombimpact = true
|
||||
self.PlayerSettings[playername].smokebombimpact = true
|
||||
text = string.format( "%s, %s, smoking impact points of bombs is now ON.", self.rangename, playername )
|
||||
end
|
||||
self:_DisplayMessageToGroup( unit, text, 5, false, true )
|
||||
@@ -3508,7 +3528,7 @@ function RANGE:_SmokeBombDelayOnOff( unitname )
|
||||
self.PlayerSettings[playername].delaysmoke = false
|
||||
text = string.format( "%s, %s, delayed smoke of bombs is now OFF.", self.rangename, playername )
|
||||
else
|
||||
self.PlayerSettigs[playername].delaysmoke = true
|
||||
self.PlayerSettings[playername].delaysmoke = true
|
||||
text = string.format( "%s, %s, delayed smoke of bombs is now ON.", self.rangename, playername )
|
||||
end
|
||||
self:_DisplayMessageToGroup( unit, text, 5, false, true )
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
-- * [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**]
|
||||
-- * [Juan Carlos I](https://en.wikipedia.org/wiki/Spanish_amphibious_assault_ship_Juan_Carlos_I) (L61) [**WIP**]
|
||||
@@ -53,7 +54,7 @@
|
||||
--
|
||||
-- At the moment, optimized parameters are available for the F/A-18C Hornet (Lot 20) and A-4E community mod as aircraft and the USS John C. Stennis as carrier.
|
||||
--
|
||||
-- The AV-8B Harrier, HMS Hermes, the USS Tarawa, USS America, HMAS Canberra, and Juan Carlos I are WIP. The AV-8B harrier and the LHA's and LHD can only be used together, i.e. these ships are the only carriers the harrier is supposed to land on and
|
||||
-- The AV-8B Harrier, HMS Hermes, HMS Invincible, the USS Tarawa, USS America, HMAS Canberra, and Juan Carlos I are WIP. The AV-8B harrier and the LHA's and LHD can only be used together, i.e. these ships are the only carriers the harrier is supposed to land on and
|
||||
-- no other fixed wing aircraft (human or AI controlled) are supposed to land on these ships. Currently only Case I is supported. Case II/III take slightly different steps from the CVN carrier.
|
||||
-- However, if no offset is used for the holding radial this provides a very close representation of the V/STOL Case III, allowing for an approach to over the deck and a vertical landing.
|
||||
--
|
||||
@@ -1263,7 +1264,7 @@ AIRBOSS = {
|
||||
|
||||
--- Aircraft types capable of landing on carrier (human+AI).
|
||||
-- @type AIRBOSS.AircraftCarrier
|
||||
-- @field #string AV8B AV-8B Night Harrier. Works only with the HMS Hermes, USS Tarawa, USS America, and Juan Carlos I.
|
||||
-- @field #string AV8B AV-8B Night Harrier. Works only with the HMS Hermes, HMS Invincible, USS Tarawa, USS America, and Juan Carlos I.
|
||||
-- @field #string A4EC A-4E Community mod.
|
||||
-- @field #string HORNET F/A-18C Lot 20 Hornet by Eagle Dynamics.
|
||||
-- @field #string F14A F-14A by Heatblur.
|
||||
@@ -1300,6 +1301,7 @@ AIRBOSS.AircraftCarrier={
|
||||
-- @field #string FORRESTAL USS Forrestal (CV-59) [Heatblur Carrier Module]
|
||||
-- @field #string VINSON USS Carl Vinson (CVN-70) [Obsolete]
|
||||
-- @field #string HERMES HMS Hermes (R12) [V/STOL Carrier]
|
||||
-- @field #string INVINCIBLE HMS Invincible (R05) [V/STOL Carrier]
|
||||
-- @field #string TARAWA USS Tarawa (LHA-1) [V/STOL Carrier]
|
||||
-- @field #string AMERICA USS America (LHA-6) [V/STOL Carrier]
|
||||
-- @field #string JCARLOS Juan Carlos I (L61) [V/STOL Carrier]
|
||||
@@ -1314,6 +1316,7 @@ AIRBOSS.CarrierType = {
|
||||
FORRESTAL = "Forrestal",
|
||||
VINSON = "VINSON",
|
||||
HERMES = "HERMES81",
|
||||
INVINCIBLE = "hms_invincible",
|
||||
TARAWA = "LHA_Tarawa",
|
||||
AMERICA = "USS America LHA-6",
|
||||
JCARLOS = "L61",
|
||||
@@ -1988,6 +1991,9 @@ function AIRBOSS:New( carriername, alias )
|
||||
elseif self.carriertype == AIRBOSS.CarrierType.HERMES then
|
||||
-- Hermes parameters.
|
||||
self:_InitHermes()
|
||||
elseif self.carriertype == AIRBOSS.CarrierType.INVINCIBLE then
|
||||
-- Invincible parameters.
|
||||
self:_InitInvincible()
|
||||
elseif self.carriertype == AIRBOSS.CarrierType.TARAWA then
|
||||
-- Tarawa parameters.
|
||||
self:_InitTarawa()
|
||||
@@ -2090,7 +2096,7 @@ function AIRBOSS:New( carriername, alias )
|
||||
-- cL:FlareYellow()
|
||||
|
||||
-- Carrier specific.
|
||||
if self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.HERMES or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.TARAWA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.AMERICA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.JCARLOS or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.CANBERRA then
|
||||
if self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.INVINCIBLE or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.HERMES or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.TARAWA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.AMERICA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.JCARLOS or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.CANBERRA then
|
||||
|
||||
-- Flare wires.
|
||||
local w1 = stern:Translate( self.carrierparam.wire1, FB, true )
|
||||
@@ -2823,7 +2829,7 @@ end
|
||||
function AIRBOSS:SetGlideslopeErrorThresholds(_max,_min, High, HIGH, Low, LOW)
|
||||
|
||||
--Check if V/STOL Carrier
|
||||
if 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 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
|
||||
|
||||
-- allow a larger GSE for V/STOL operations --Pene Testing
|
||||
self.gle._max=_max or 0.7
|
||||
@@ -2860,7 +2866,7 @@ end
|
||||
function AIRBOSS:SetLineupErrorThresholds(_max,_min, Left, LeftMed, LEFT, Right, RightMed, RIGHT)
|
||||
|
||||
--Check if V/STOL Carrier -- Pene testing
|
||||
if 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 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
|
||||
|
||||
-- V/STOL Values -- allow a larger LUE for V/STOL operations
|
||||
self.lue._max=_max or 1.8
|
||||
@@ -4457,8 +4463,48 @@ function AIRBOSS:_InitHermes()
|
||||
self.BreakLate.name = "Late Break"
|
||||
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
|
||||
self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks?
|
||||
self.BreakLate.Zmin = -UTILS.NMToMeters( 0.25 ) -- Not more than 0.25 NM port.
|
||||
self.BreakLate.Zmax = UTILS.NMToMeters( 0.5 ) -- Not more than 0.5 NM starboard.
|
||||
self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port.
|
||||
self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard.
|
||||
self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat.
|
||||
self.BreakLate.LimitXmax = nil
|
||||
self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2
|
||||
self.BreakLate.LimitZmax = nil
|
||||
|
||||
end
|
||||
|
||||
--- Init parameters for R05 HMS Invincible carrier.
|
||||
-- @param #AIRBOSS self
|
||||
function AIRBOSS:_InitInvincible()
|
||||
|
||||
-- Init Stennis as default.
|
||||
self:_InitStennis()
|
||||
|
||||
-- Carrier Parameters.
|
||||
self.carrierparam.sterndist = -105
|
||||
self.carrierparam.deckheight = 12 -- From model viewer WL0.
|
||||
|
||||
-- Total size of the carrier (approx as rectangle).
|
||||
self.carrierparam.totlength = 228.19
|
||||
self.carrierparam.totwidthport = 20.5
|
||||
self.carrierparam.totwidthstarboard = 24.5
|
||||
|
||||
-- Landing runway.
|
||||
self.carrierparam.rwyangle = 0
|
||||
self.carrierparam.rwylength = 215
|
||||
self.carrierparam.rwywidth = 13
|
||||
|
||||
-- Wires.
|
||||
self.carrierparam.wire1 = nil
|
||||
self.carrierparam.wire2 = nil
|
||||
self.carrierparam.wire3 = nil
|
||||
self.carrierparam.wire4 = nil
|
||||
|
||||
-- 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.
|
||||
self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks?
|
||||
self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port.
|
||||
self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard.
|
||||
self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat.
|
||||
self.BreakLate.LimitXmax = nil
|
||||
self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2
|
||||
@@ -6293,7 +6339,7 @@ function AIRBOSS:_GetMarshalAltitude( stack, case )
|
||||
p2 = Carrier:Translate( UTILS.NMToMeters( 1.5 ), hdg )
|
||||
|
||||
-- Tarawa,LHA,LHD Delta patterns.
|
||||
if 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 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
|
||||
|
||||
-- Pattern is directly overhead the carrier.
|
||||
p1 = Carrier:Translate( UTILS.NMToMeters( 1.0 ), hdg + 90 )
|
||||
@@ -8132,7 +8178,7 @@ function AIRBOSS:OnEventLand( EventData )
|
||||
self:T( self.lid .. text )
|
||||
|
||||
-- Check carrier type.
|
||||
if 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 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
|
||||
|
||||
-- Power "Idle".
|
||||
self:RadioTransmission( self.LSORadio, self.LSOCall.IDLE, false, 1, nil, true )
|
||||
@@ -8167,7 +8213,7 @@ function AIRBOSS:OnEventLand( EventData )
|
||||
-- AI unit landed --
|
||||
--------------------
|
||||
|
||||
if 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 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
|
||||
|
||||
-- Coordinate at landing event
|
||||
local coord = EventData.IniUnit:GetCoordinate()
|
||||
@@ -9205,7 +9251,7 @@ function AIRBOSS:_CheckForLongDownwind( playerData )
|
||||
local limit = UTILS.NMToMeters( -1.6 )
|
||||
|
||||
-- For the tarawa, other LHA and LHD we give a bit more space.
|
||||
if 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 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
|
||||
limit = UTILS.NMToMeters( -2.0 )
|
||||
end
|
||||
|
||||
@@ -9292,7 +9338,7 @@ function AIRBOSS:_Ninety( playerData )
|
||||
self:_PlayerHint( playerData )
|
||||
|
||||
-- Next step: wake.
|
||||
if 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 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
|
||||
-- Harrier has no wake stop. It stays port of the boat.
|
||||
self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.FINAL )
|
||||
else
|
||||
@@ -9987,7 +10033,7 @@ function AIRBOSS:_GetSternCoord()
|
||||
-- local stern=self:GetCoordinate()
|
||||
|
||||
-- Stern coordinate (sterndist<0). --Pene testing Case III
|
||||
if 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 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
|
||||
-- CASE III V/STOL translation Due over deck approach if needed.
|
||||
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true)
|
||||
@@ -10628,7 +10674,7 @@ function AIRBOSS:_GetZoneRunwayBox()
|
||||
return self.zoneRunwaybox
|
||||
end
|
||||
|
||||
--- Get zone of primary abeam landing position of HMS Hermes, USS Tarawa, USS America and Juan Carlos. Box length 50 meters and width 30 meters.
|
||||
--- Get zone of primary abeam landing position of HMS Hermes, HMS Invincible, USS Tarawa, USS America and Juan Carlos. Box length 50 meters and width 30 meters.
|
||||
|
||||
--- Allow for Clear to land call from LSO approaching abeam the landing spot if stable as per NATOPS 00-80T
|
||||
-- @param #AIRBOSS self
|
||||
@@ -10733,7 +10779,7 @@ function AIRBOSS:_GetZoneHolding( case, stack )
|
||||
self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", Post:GetVec2(), self.marshalradius )
|
||||
|
||||
-- Delta pattern.
|
||||
if 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 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
|
||||
self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", self.carrier:GetVec2(), UTILS.NMToMeters( 5 ) )
|
||||
end
|
||||
|
||||
@@ -10785,7 +10831,7 @@ function AIRBOSS:_GetZoneCommence( case, stack )
|
||||
-- Three position
|
||||
local Three = self:GetCoordinate():Translate( D, hdg + 275 )
|
||||
|
||||
if 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 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 )
|
||||
|
||||
@@ -11076,7 +11122,7 @@ function AIRBOSS:_GetAltCarrier( unit )
|
||||
return h
|
||||
end
|
||||
|
||||
--- Get optimal landing position of the aircraft. Usually between second and third wire. In case of Tarawa, Canberrra, Juan Carlos and America we take the abeam landing spot 120 ft above and 21 ft abeam the 7.5 position, for the Juan Carlos I and HMS Hermes it is 120 ft above and 21 ft abeam the 5 position. For CASE III it is 120ft directly above the landing spot.
|
||||
--- Get optimal landing position of the aircraft. Usually between second and third wire. In case of Tarawa, Canberrra, Juan Carlos and America we take the abeam landing spot 120 ft above and 21 ft abeam the 7.5 position, for the Juan Carlos I, HMS Invincible, and HMS Hermes and Invincible it is 120 ft above and 21 ft abeam the 5 position. For CASE III it is 120ft directly above the landing spot.
|
||||
-- @param #AIRBOSS self
|
||||
-- @return Core.Point#COORDINATE Optimal landing coordinate.
|
||||
function AIRBOSS:_GetOptLandingCoordinate()
|
||||
@@ -11091,7 +11137,7 @@ function AIRBOSS:_GetOptLandingCoordinate()
|
||||
local FB=self:GetFinalBearing(false)
|
||||
local case=self.case
|
||||
-- set Case III V/STOL abeam landing spot over deck -- Pene Testing
|
||||
if 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 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())
|
||||
@@ -11104,7 +11150,7 @@ function AIRBOSS:_GetOptLandingCoordinate()
|
||||
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35, FB-90, true, true)
|
||||
--stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
||||
|
||||
-- Alitude 120 ft.
|
||||
-- Atlitude 120 ft.
|
||||
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
|
||||
end
|
||||
|
||||
@@ -11142,6 +11188,13 @@ function AIRBOSS:_GetLandingSpotCoordinate()
|
||||
|
||||
-- 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.
|
||||
@@ -12083,7 +12136,7 @@ function AIRBOSS:_GS( step, n )
|
||||
if n == -1 then
|
||||
gp = AIRBOSS.GroovePos.IC
|
||||
elseif n == 1 then
|
||||
if 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 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
|
||||
gp = AIRBOSS.GroovePos.AL
|
||||
else
|
||||
gp = AIRBOSS.GroovePos.IW
|
||||
@@ -13962,7 +14015,7 @@ function AIRBOSS:_IsCarrierAircraft( unit )
|
||||
|
||||
-- Special case for Harrier which can only land on Tarawa, LHA and LHD.
|
||||
if aircrafttype == AIRBOSS.AircraftCarrier.AV8B then
|
||||
if 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 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
|
||||
return true
|
||||
else
|
||||
return false
|
||||
@@ -13970,7 +14023,7 @@ function AIRBOSS:_IsCarrierAircraft( unit )
|
||||
end
|
||||
|
||||
-- Also only Harriers can land on the Tarawa, LHA and LHD.
|
||||
if 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 self.carriertype == AIRBOSS.CarrierType.INVINCIBLE 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 aircrafttype ~= AIRBOSS.AircraftCarrier.AV8B then
|
||||
return false
|
||||
end
|
||||
@@ -17327,7 +17380,7 @@ function AIRBOSS:_MarkCaseZones( _unitName, flare )
|
||||
end
|
||||
|
||||
-- Tarawa, LHA and LHD landing spots.
|
||||
if 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 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
|
||||
text = text .. "\n* abeam landing stop with RED flares"
|
||||
-- Abeam landing spot zone.
|
||||
local ALSPT = self:_GetZoneAbeamLandingSpot()
|
||||
|
||||
@@ -52,8 +52,6 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
--
|
||||
-- # The MSRS Concept
|
||||
--
|
||||
-- This class allows to broadcast sound files or text via Simple Radio Standalone (SRS).
|
||||
@@ -143,7 +141,7 @@ MSRS = {
|
||||
|
||||
--- MSRS class version.
|
||||
-- @field #string version
|
||||
MSRS.version="0.0.6"
|
||||
MSRS.version="0.1.0"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -181,7 +179,7 @@ function MSRS:New(PathToSRS, Frequency, Modulation, Volume)
|
||||
self:SetCoalition()
|
||||
self:SetLabel()
|
||||
self:SetVolume()
|
||||
self.lid = string.format("%s-%s | ",self.name,self.version)
|
||||
self.lid = string.format("%s-%s | ", self.name, self.version)
|
||||
|
||||
if not io or not os then
|
||||
self:E(self.lid.."***** ERROR - io or os NOT desanitized! MSRS will not work!")
|
||||
@@ -455,19 +453,8 @@ function MSRS:PlaySoundFile(Soundfile, Delay)
|
||||
-- Append file.
|
||||
command=command..' --file="'..tostring(soundfile)..'"'
|
||||
|
||||
-- Execute command.
|
||||
self:_ExecCommand(command)
|
||||
|
||||
--[[
|
||||
|
||||
command=command.." > bla.txt"
|
||||
|
||||
-- Debug output.
|
||||
self:I(string.format("MSRS PlaySoundfile command=%s", command))
|
||||
|
||||
-- Execute SRS command.
|
||||
local x=os.execute(command)
|
||||
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
@@ -493,16 +480,6 @@ function MSRS:PlaySoundText(SoundText, Delay)
|
||||
|
||||
-- Execute command.
|
||||
self:_ExecCommand(command)
|
||||
|
||||
--[[
|
||||
command=command.." > bla.txt"
|
||||
|
||||
-- Debug putput.
|
||||
self:I(string.format("MSRS PlaySoundfile command=%s", command))
|
||||
|
||||
-- Execute SRS command.
|
||||
local x=os.execute(command)
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
@@ -529,37 +506,48 @@ function MSRS:PlayText(Text, Delay)
|
||||
-- Execute command.
|
||||
self:_ExecCommand(command)
|
||||
|
||||
--[[
|
||||
|
||||
-- Check that length of command is max 255 chars or os.execute() will not work!
|
||||
if string.len(command)>255 then
|
||||
|
||||
-- Create a tmp file.
|
||||
local filename = os.getenv('TMP') .. "\\MSRS-"..STTS.uuid()..".bat"
|
||||
|
||||
local script = io.open(filename, "w+")
|
||||
script:write(command.." && exit")
|
||||
script:close()
|
||||
|
||||
-- Play command.
|
||||
command=string.format("\"%s\"", filename)
|
||||
|
||||
-- Play file in 0.05 seconds
|
||||
timer.scheduleFunction(os.execute, command, timer.getTime()+0.05)
|
||||
|
||||
-- Remove file in 1 second.
|
||||
timer.scheduleFunction(os.remove, filename, timer.getTime()+1)
|
||||
else
|
||||
|
||||
-- Debug output.
|
||||
self:I(string.format("MSRS Text command=%s", command))
|
||||
end
|
||||
|
||||
-- Execute SRS command.
|
||||
local x=os.execute(command)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Play text message via STTS with explicitly specified options.
|
||||
-- @param #MSRS self
|
||||
-- @param #string Text Text message.
|
||||
-- @param #number Delay Delay in seconds, before the message is played.
|
||||
-- @param #table Frequencies Radio frequencies.
|
||||
-- @param #table Modulations Radio modulations.
|
||||
-- @param #string Gender Gender.
|
||||
-- @param #string Culture Culture.
|
||||
-- @param #string Voice Voice.
|
||||
-- @param #number Volume Volume.
|
||||
-- @param #string Label Label.
|
||||
-- @return #MSRS self
|
||||
function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label)
|
||||
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, MSRS.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label)
|
||||
else
|
||||
|
||||
-- Ensure table.
|
||||
if Frequencies and type(Frequencies)~="table" then
|
||||
Frequencies={Frequencies}
|
||||
end
|
||||
|
||||
-- Ensure table.
|
||||
if Modulations and type(Modulations)~="table" then
|
||||
Modulations={Modulations}
|
||||
end
|
||||
|
||||
-- Get command line.
|
||||
local command=self:_GetCommand(Frequencies, Modulations, nil, Gender, Voice, Culture, Volume, nil, nil, Label)
|
||||
|
||||
-- Append text.
|
||||
command=command..string.format(" --text=\"%s\"", tostring(Text))
|
||||
|
||||
end
|
||||
-- Execute command.
|
||||
self:_ExecCommand(command)
|
||||
|
||||
]]
|
||||
end
|
||||
|
||||
return self
|
||||
@@ -760,6 +748,353 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp
|
||||
return command
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Manages radio transmissions.
|
||||
--
|
||||
-- The purpose of the MSRSQUEUE class is to manage SRS text-to-speech (TTS) messages using the MSRS class.
|
||||
-- This can be used to submit multiple TTS messages and the class takes care that they are transmitted one after the other (and not overlapping).
|
||||
--
|
||||
-- @type MSRSQUEUE
|
||||
-- @field #string ClassName Name of the class "MSRSQUEUE".
|
||||
-- @field #string lid ID for dcs.log.
|
||||
-- @field #table queue The queue of transmissions.
|
||||
-- @field #string alias Name of the radio queue.
|
||||
-- @field #number dt Time interval in seconds for checking the radio queue.
|
||||
-- @field #number Tlast Time (abs) when the last transmission finished.
|
||||
-- @field #boolean checking If `true`, the queue update function is scheduled to be called again.
|
||||
-- @extends Core.Base#BASE
|
||||
MSRSQUEUE = {
|
||||
ClassName = "MSRSQUEUE",
|
||||
Debugmode = nil,
|
||||
lid = nil,
|
||||
queue = {},
|
||||
alias = nil,
|
||||
dt = nil,
|
||||
Tlast = nil,
|
||||
checking = nil,
|
||||
}
|
||||
|
||||
--- Radio queue transmission data.
|
||||
-- @type MSRSQUEUE.Transmission
|
||||
-- @field #string text Text to be transmitted.
|
||||
-- @field Sound.SRS#MSRS msrs MOOSE SRS object.
|
||||
-- @field #number duration Duration in seconds.
|
||||
-- @field #table subgroups Groups to send subtitle to.
|
||||
-- @field #string subtitle Subtitle of the transmission.
|
||||
-- @field #number subduration Duration of the subtitle being displayed.
|
||||
-- @field #number frequency Frequency.
|
||||
-- @field #number modulation Modulation.
|
||||
-- @field #number Tstarted Mission time (abs) in seconds when the transmission started.
|
||||
-- @field #boolean isplaying If true, transmission is currently playing.
|
||||
-- @field #number Tplay Mission time (abs) in seconds when the transmission should be played.
|
||||
-- @field #number interval Interval in seconds before next transmission.
|
||||
|
||||
--- Create a new MSRSQUEUE object for a given radio frequency/modulation.
|
||||
-- @param #MSRSQUEUE self
|
||||
-- @param #string alias (Optional) Name of the radio queue.
|
||||
-- @return #MSRSQUEUE self The MSRSQUEUE object.
|
||||
function MSRSQUEUE:New(alias)
|
||||
|
||||
-- Inherit base
|
||||
local self=BASE:Inherit(self, BASE:New()) --#MSRSQUEUE
|
||||
|
||||
self.alias=alias or "My Radio"
|
||||
|
||||
self.dt=1.0
|
||||
|
||||
self.lid=string.format("MSRSQUEUE %s | ", self.alias)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Clear the radio queue.
|
||||
-- @param #MSRSQUEUE self
|
||||
-- @return #MSRSQUEUE self The MSRSQUEUE object.
|
||||
function MSRSQUEUE:Clear()
|
||||
self:I(self.lid.."Clearning MSRSQUEUE")
|
||||
self.queue={}
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Add a transmission to the radio queue.
|
||||
-- @param #MSRSQUEUE self
|
||||
-- @param #MSRSQUEUE.Transmission transmission The transmission data table.
|
||||
-- @return #MSRSQUEUE self
|
||||
function MSRSQUEUE:AddTransmission(transmission)
|
||||
|
||||
-- Init.
|
||||
transmission.isplaying=false
|
||||
transmission.Tstarted=nil
|
||||
|
||||
-- Add to queue.
|
||||
table.insert(self.queue, transmission)
|
||||
|
||||
-- Start checking.
|
||||
if not self.checking then
|
||||
self:_CheckRadioQueue()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Create a new transmission and add it to the radio queue.
|
||||
-- @param #MSRSQUEUE self
|
||||
-- @param #string text Text to play.
|
||||
-- @param #number duration Duration in seconds the file lasts. Default is determined by number of characters of the text message.
|
||||
-- @param Sound.SRS#MSRS msrs MOOSE SRS object.
|
||||
-- @param #number tstart Start time (abs) seconds. Default now.
|
||||
-- @param #number interval Interval in seconds after the last transmission finished.
|
||||
-- @param #table subgroups Groups that should receive the subtiltle.
|
||||
-- @param #string subtitle Subtitle displayed when the message is played.
|
||||
-- @param #number subduration Duration [sec] of the subtitle being displayed. Default 5 sec.
|
||||
-- @param #number frequency Radio frequency if other than MSRS default.
|
||||
-- @param #number modulation Radio modulation if other then MSRS default.
|
||||
-- @return #MSRSQUEUE.Transmission Radio transmission table.
|
||||
function MSRSQUEUE:NewTransmission(text, duration, msrs, tstart, interval, subgroups, subtitle, subduration, frequency, modulation)
|
||||
|
||||
-- Sanity checks.
|
||||
if not text then
|
||||
self:E(self.lid.."ERROR: No text specified.")
|
||||
return nil
|
||||
end
|
||||
if type(text)~="string" then
|
||||
self:E(self.lid.."ERROR: Text specified is NOT a string.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
-- Create a new transmission object.
|
||||
local transmission={} --#MSRSQUEUE.Transmission
|
||||
transmission.text=text
|
||||
transmission.duration=duration or STTS.getSpeechTime(text)
|
||||
transmission.msrs=msrs
|
||||
transmission.Tplay=tstart or timer.getAbsTime()
|
||||
transmission.subtitle=subtitle
|
||||
transmission.interval=interval or 0
|
||||
transmission.frequency=frequency
|
||||
transmission.modulation=modulation
|
||||
transmission.subgroups=subgroups
|
||||
if transmission.subtitle then
|
||||
transmission.subduration=subduration or transmission.duration
|
||||
else
|
||||
transmission.subduration=0 --nil
|
||||
end
|
||||
|
||||
-- Add transmission to queue.
|
||||
self:AddTransmission(transmission)
|
||||
|
||||
return transmission
|
||||
end
|
||||
|
||||
--- Broadcast radio message.
|
||||
-- @param #MSRSQUEUE self
|
||||
-- @param #MSRSQUEUE.Transmission transmission The transmission.
|
||||
function MSRSQUEUE:Broadcast(transmission)
|
||||
|
||||
if transmission.frequency then
|
||||
transmission.msrs:PlayTextExt(transmission.text, nil, transmission.frequency, transmission.modulation, Gender, Culture, Voice, Volume, Label)
|
||||
else
|
||||
transmission.msrs:PlayText(transmission.text)
|
||||
end
|
||||
|
||||
local function texttogroup(gid)
|
||||
-- Text to group.
|
||||
trigger.action.outTextForGroup(gid, transmission.subtitle, transmission.subduration, true)
|
||||
end
|
||||
|
||||
if transmission.subgroups and #transmission.subgroups>0 then
|
||||
|
||||
for _,_group in pairs(transmission.subgroups) do
|
||||
local group=_group --Wrapper.Group#GROUP
|
||||
|
||||
if group and group:IsAlive() then
|
||||
local gid=group:GetID()
|
||||
|
||||
self:ScheduleOnce(4, texttogroup, gid)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Calculate total transmission duration of all transmission in the queue.
|
||||
-- @param #MSRSQUEUE self
|
||||
-- @return #number Total transmission duration.
|
||||
function MSRSQUEUE:CalcTransmisstionDuration()
|
||||
|
||||
local Tnow=timer.getAbsTime()
|
||||
|
||||
local T=0
|
||||
for _,_transmission in pairs(self.queue) do
|
||||
local transmission=_transmission --#MSRSQUEUE.Transmission
|
||||
|
||||
if transmission.isplaying then
|
||||
|
||||
-- Playing for dt seconds.
|
||||
local dt=Tnow-transmission.Tstarted
|
||||
|
||||
T=T+transmission.duration-dt
|
||||
|
||||
else
|
||||
T=T+transmission.duration
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return T
|
||||
end
|
||||
|
||||
--- Check radio queue for transmissions to be broadcasted.
|
||||
-- @param #MSRSQUEUE self
|
||||
-- @param #number delay Delay in seconds before checking.
|
||||
function MSRSQUEUE:_CheckRadioQueue(delay)
|
||||
|
||||
-- Transmissions in queue.
|
||||
local N=#self.queue
|
||||
|
||||
-- Debug info.
|
||||
self:T2(self.lid..string.format("Check radio queue %s: delay=%.3f sec, N=%d, checking=%s", self.alias, delay or 0, N, tostring(self.checking)))
|
||||
|
||||
if delay and delay>0 then
|
||||
|
||||
-- Delayed call.
|
||||
self:ScheduleOnce(delay, MSRSQUEUE._CheckRadioQueue, self)
|
||||
|
||||
-- Checking on.
|
||||
self.checking=true
|
||||
|
||||
else
|
||||
|
||||
-- Check if queue is empty.
|
||||
if N==0 then
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias))
|
||||
|
||||
-- Queue is now empty. Nothing to else to do. We start checking again, if a transmission is added.
|
||||
self.checking=false
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- Get current abs time.
|
||||
local time=timer.getAbsTime()
|
||||
|
||||
-- Checking on.
|
||||
self.checking=true
|
||||
|
||||
-- Set dt.
|
||||
local dt=self.dt
|
||||
|
||||
|
||||
local playing=false
|
||||
local next=nil --#MSRSQUEUE.Transmission
|
||||
local remove=nil
|
||||
for i,_transmission in ipairs(self.queue) do
|
||||
local transmission=_transmission --#MSRSQUEUE.Transmission
|
||||
|
||||
-- Check if transmission time has passed.
|
||||
if time>=transmission.Tplay then
|
||||
|
||||
-- Check if transmission is currently playing.
|
||||
if transmission.isplaying then
|
||||
|
||||
-- Check if transmission is finished.
|
||||
if time>=transmission.Tstarted+transmission.duration then
|
||||
|
||||
-- Transmission over.
|
||||
transmission.isplaying=false
|
||||
|
||||
-- Remove ith element in queue.
|
||||
remove=i
|
||||
|
||||
-- Store time last transmission finished.
|
||||
self.Tlast=time
|
||||
|
||||
else -- still playing
|
||||
|
||||
-- Transmission is still playing.
|
||||
playing=true
|
||||
|
||||
dt=transmission.duration-(time-transmission.Tstarted)
|
||||
|
||||
end
|
||||
|
||||
else -- not playing yet
|
||||
|
||||
local Tlast=self.Tlast
|
||||
|
||||
if transmission.interval==nil then
|
||||
|
||||
-- Not playing ==> this will be next.
|
||||
if next==nil then
|
||||
next=transmission
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if Tlast==nil or time-Tlast>=transmission.interval then
|
||||
next=transmission
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- We got a transmission or one with an interval that is not due yet. No need for anything else.
|
||||
if next or Tlast then
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- Transmission not due yet.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- Found a new transmission.
|
||||
if next~=nil and not playing then
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Broadcasting text=\"%s\" at T=%.3f", next.text, time))
|
||||
|
||||
-- Call SRS.
|
||||
self:Broadcast(next)
|
||||
|
||||
next.isplaying=true
|
||||
next.Tstarted=time
|
||||
dt=next.duration
|
||||
end
|
||||
|
||||
-- Remove completed call from queue.
|
||||
if remove then
|
||||
-- Remove from queue.
|
||||
table.remove(self.queue, remove)
|
||||
N=N-1
|
||||
|
||||
-- Check if queue is empty.
|
||||
if #self.queue==0 then
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias))
|
||||
|
||||
self.checking=false
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Check queue.
|
||||
self:_CheckRadioQueue(dt)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1724,11 +1724,17 @@ end
|
||||
--- Get OS time. Needs os to be desanitized!
|
||||
-- @return #number Os time in seconds.
|
||||
function UTILS.GetOSTime()
|
||||
if os then
|
||||
return os.clock()
|
||||
end
|
||||
|
||||
return nil
|
||||
if os then
|
||||
local ts = 0
|
||||
local t = os.date("*t")
|
||||
local s = t.sec
|
||||
local m = t.min * 60
|
||||
local h = t.hour * 3600
|
||||
ts = s+m+h
|
||||
return ts
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
--- Shuffle a table accoring to Fisher Yeates algorithm
|
||||
|
||||
@@ -498,6 +498,9 @@ AIRBASE.MarianaIslands = {
|
||||
-- * AIRBASE.SouthAtlantic.Punta_Arenas
|
||||
-- * AIRBASE.SouthAtlantic.Pampa_Guanaco
|
||||
-- * AIRBASE.SouthAtlantic.San_Julian
|
||||
-- * AIRBASE.SouthAtlantic.Puerto_Williams
|
||||
-- * AIRBASE.SouthAtlantic.Puerto_Natales
|
||||
-- * AIRBASE.SouthAtlantic.El_Calafate
|
||||
--
|
||||
--@field MarianaIslands
|
||||
AIRBASE.SouthAtlantic={
|
||||
@@ -511,6 +514,9 @@ AIRBASE.SouthAtlantic={
|
||||
["Punta_Arenas"]="Punta Arenas",
|
||||
["Pampa_Guanaco"]="Pampa Guanaco",
|
||||
["San_Julian"]="San Julian",
|
||||
["Puerto_Williams"]="Puerto Williams",
|
||||
["Puerto_Natales"]="Puerto Natales",
|
||||
["El_Calafate"]="El Calafate",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -537,7 +537,7 @@ function POSITIONABLE:GetBoundingRadius( MinDist )
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the altitude of the POSITIONABLE.
|
||||
--- Returns the altitude above sea level of the POSITIONABLE.
|
||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||
-- @return DCS#Distance The altitude of the POSITIONABLE.
|
||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
||||
@@ -779,7 +779,7 @@ function POSITIONABLE:GetRelativeVelocity( Positionable )
|
||||
return UTILS.VecNorm( vtot )
|
||||
end
|
||||
|
||||
--- Returns the POSITIONABLE height in meters.
|
||||
--- Returns the POSITIONABLE height above sea level in meters.
|
||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||
-- @return DCS#Vec3 The height of the POSITIONABLE in meters.
|
||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
||||
|
||||
@@ -178,8 +178,28 @@ function UNIT:GetDCSObject()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the unit altitude above sea level in meters.
|
||||
-- @param Wrapper.Unit#UNIT self
|
||||
-- @param #boolean FromGround Measure from the ground or from sea level (ASL). Provide **true** for measuring from the ground (AGL). **false** or **nil** if you measure from sea level.
|
||||
-- @return #number The height of the group or nil if is not existing or alive.
|
||||
function UNIT:GetAltitude(FromGround)
|
||||
|
||||
local DCSUnit = Unit.getByName( self.UnitName )
|
||||
|
||||
if DCSUnit then
|
||||
local altitude = 0
|
||||
local point = DCSUnit:getPoint() --DCS#Vec3
|
||||
altitude = point.y
|
||||
if FromGround then
|
||||
local land = land.getHeight( { x = point.x, y = point.z } ) or 0
|
||||
altitude = altitude - land
|
||||
end
|
||||
return altitude
|
||||
end
|
||||
|
||||
return nil
|
||||
|
||||
end
|
||||
|
||||
--- Respawn the @{Wrapper.Unit} using a (tweaked) template of the parent Group.
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user