mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'master' into FF/MasterDevel
This commit is contained in:
@@ -1348,7 +1348,8 @@ function EVENT:onEvent( Event )
|
||||
Event.Weapon = Event.weapon
|
||||
Event.WeaponName = Event.Weapon:getTypeName()
|
||||
Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit!
|
||||
Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName()
|
||||
Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon.getPlayerName and Event.Weapon:getPlayerName()
|
||||
--Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName()
|
||||
Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition()
|
||||
Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category
|
||||
Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName()
|
||||
|
||||
@@ -98,7 +98,7 @@ function MESSAGE:New( MessageText, MessageDuration, MessageCategory, ClearScreen
|
||||
|
||||
self.MessageType = nil
|
||||
|
||||
-- When no MessageCategory is given, we don't show it as a title...
|
||||
-- When no MessageCategory is given, we don't show it as a title...
|
||||
if MessageCategory and MessageCategory ~= "" then
|
||||
if MessageCategory:sub( -1 ) ~= "\n" then
|
||||
self.MessageCategory = MessageCategory .. ": "
|
||||
@@ -368,7 +368,7 @@ function MESSAGE:ToCoalition( CoalitionSide, Settings )
|
||||
if CoalitionSide then
|
||||
if self.MessageDuration ~= 0 then
|
||||
self:T( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ) .. " / " .. self.MessageDuration )
|
||||
trigger.action.outTextForCoalition( CoalitionSide, self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen )
|
||||
trigger.action.outTextForCoalition( CoalitionSide, self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,22 +8,6 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # Demo Missions
|
||||
--
|
||||
-- ### [POINT_VEC Demo Missions source code]()
|
||||
--
|
||||
-- ### [POINT_VEC Demo Missions, only for beta testers]()
|
||||
--
|
||||
-- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # YouTube Channel
|
||||
--
|
||||
-- ### [POINT_VEC YouTube Channel]()
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Authors:
|
||||
--
|
||||
-- * FlightControl (Design & Programming)
|
||||
@@ -40,8 +24,9 @@
|
||||
|
||||
|
||||
do -- COORDINATE
|
||||
|
||||
--- @type COORDINATE
|
||||
|
||||
---
|
||||
-- @type COORDINATE
|
||||
-- @field #string ClassName Name of the class
|
||||
-- @field #number x Component of the 3D vector.
|
||||
-- @field #number y Component of the 3D vector.
|
||||
@@ -920,7 +905,7 @@ do -- COORDINATE
|
||||
end
|
||||
|
||||
|
||||
--- Return an angle in radians from the COORDINATE using a direction vector in Vec3 format.
|
||||
--- Return an angle in radians from the COORDINATE using a **direction vector in Vec3 format**.
|
||||
-- @param #COORDINATE self
|
||||
-- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
||||
-- @return #number DirectionRadians The angle in radians.
|
||||
@@ -933,10 +918,12 @@ do -- COORDINATE
|
||||
return DirectionRadians
|
||||
end
|
||||
|
||||
--- Return an angle in degrees from the COORDINATE using a direction vector in Vec3 format.
|
||||
--- Return an angle in degrees from the COORDINATE using a **direction vector in Vec3 format**.
|
||||
-- @param #COORDINATE self
|
||||
-- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
||||
-- @return #number DirectionRadians The angle in degrees.
|
||||
-- @usage
|
||||
-- local directionAngle = currentCoordinate:GetAngleDegrees(currentCoordinate:GetDirectionVec3(sourceCoordinate:GetVec3()))
|
||||
function COORDINATE:GetAngleDegrees( DirectionVec3 )
|
||||
local AngleRadians = self:GetAngleRadians( DirectionVec3 )
|
||||
local Angle = UTILS.ToDegree( AngleRadians )
|
||||
@@ -2565,7 +2552,7 @@ do -- COORDINATE
|
||||
|
||||
Offset=Offset or 2
|
||||
|
||||
-- Measurement of visibility should not be from the ground, so Adding a hypotethical 2 meters to each Coordinate.
|
||||
-- Measurement of visibility should not be from the ground, so Adding a hypothetical 2 meters to each Coordinate.
|
||||
local FromVec3 = self:GetVec3()
|
||||
FromVec3.y = FromVec3.y + Offset
|
||||
|
||||
@@ -2966,10 +2953,10 @@ do -- COORDINATE
|
||||
end
|
||||
|
||||
-- corrected Track to be direction of travel of bogey (self in this case)
|
||||
local track = "Maneuver"
|
||||
|
||||
if self.Heading then
|
||||
track = UTILS.BearingToCardinal(self.Heading) or "North"
|
||||
local track = "Maneuver"
|
||||
|
||||
if self.Heading then
|
||||
track = UTILS.BearingToCardinal(self.Heading) or "North"
|
||||
end
|
||||
|
||||
if rangeNM > 3 then
|
||||
@@ -3021,6 +3008,16 @@ do -- COORDINATE
|
||||
return BRAANATO
|
||||
end
|
||||
|
||||
--- Return the BULLSEYE as COORDINATE Object
|
||||
-- @param #number Coalition Coalition of the bulls eye to return, e.g. coalition.side.BLUE
|
||||
-- @return #COORDINATE self
|
||||
-- @usage
|
||||
-- -- note the dot (.) here,not using the colon (:)
|
||||
-- local redbulls = COORDINATE.GetBullseyeCoordinate(coalition.side.RED)
|
||||
function COORDINATE.GetBullseyeCoordinate(Coalition)
|
||||
return COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) )
|
||||
end
|
||||
|
||||
--- Return a BULLS string out of the BULLS of the coalition to the COORDINATE.
|
||||
-- @param #COORDINATE self
|
||||
-- @param DCS#coalition.side Coalition The coalition.
|
||||
@@ -3104,6 +3101,49 @@ do -- COORDINATE
|
||||
local MGRS = coord.LLtoMGRS( lat, lon )
|
||||
return "MGRS " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy )
|
||||
end
|
||||
|
||||
--- Provides a COORDINATE from an MGRS String
|
||||
-- @param #COORDINATE self
|
||||
-- @param #string MGRSString MGRS String, e.g. "MGRS 37T DK 12345 12345"
|
||||
-- @return #COORDINATE self
|
||||
function COORDINATE:NewFromMGRSString( MGRSString )
|
||||
local myparts = UTILS.Split(MGRSString," ")
|
||||
local northing = tostring(myparts[5]) or ""
|
||||
local easting = tostring(myparts[4]) or ""
|
||||
if string.len(easting) < 5 then easting = easting..string.rep("0",5-string.len(easting)) end
|
||||
if string.len(northing) < 5 then northing = northing..string.rep("0",5-string.len(northing)) end
|
||||
local MGRS = {
|
||||
UTMZone = myparts[2],
|
||||
MGRSDigraph = myparts[3],
|
||||
Easting = easting,
|
||||
Northing = northing,
|
||||
}
|
||||
local lat, lon = coord.MGRStoLL(MGRS)
|
||||
local point = coord.LLtoLO(lat, lon, 0)
|
||||
local coord = COORDINATE:NewFromVec2({x=point.x,y=point.z})
|
||||
return coord
|
||||
end
|
||||
|
||||
--- Provides a COORDINATE from an MGRS Coordinate
|
||||
-- @param #COORDINATE self
|
||||
-- @param #string UTMZone UTM Zone, e.g. "37T"
|
||||
-- @param #string MGRSDigraph Digraph, e.g. "DK"
|
||||
-- @param #string Easting Meters easting - string in order to allow for leading zeros, e.g. "01234". Should be 5 digits.
|
||||
-- @param #string Northing Meters northing - string in order to allow for leading zeros, e.g. "12340". Should be 5 digits.
|
||||
-- @return #COORDINATE self
|
||||
function COORDINATE:NewFromMGRS( UTMZone, MGRSDigraph, Easting, Northing )
|
||||
if string.len(Easting) < 5 then Easting = Easting..string.rep("0",5-string.len(Easting) )end
|
||||
if string.len(Northing) < 5 then Northing = Northing..string.rep("0",5-string.len(Northing) )end
|
||||
local MGRS = {
|
||||
UTMZone = UTMZone,
|
||||
MGRSDigraph = MGRSDigraph,
|
||||
Easting = Easting,
|
||||
Northing = Northing,
|
||||
}
|
||||
local lat, lon = coord.MGRStoLL(MGRS)
|
||||
local point = coord.LLtoLO(lat, lon, 0)
|
||||
local coord = COORDINATE:NewFromVec2({x=point.x,y=point.z})
|
||||
end
|
||||
|
||||
--- Provides a coordinate string of the point, based on a coordinate format system:
|
||||
-- * Uses default settings in COORDINATE.
|
||||
@@ -3617,7 +3657,7 @@ end
|
||||
|
||||
do -- POINT_VEC2
|
||||
|
||||
--- @type POINT_VEC2
|
||||
-- @type POINT_VEC2
|
||||
-- @field DCS#Distance x The x coordinate in meters.
|
||||
-- @field DCS#Distance y the y coordinate in meters.
|
||||
-- @extends Core.Point#COORDINATE
|
||||
|
||||
@@ -419,7 +419,11 @@ do -- SET_BASE
|
||||
-- @param #SET_BASE self
|
||||
-- @return Core.Base#BASE
|
||||
function SET_BASE:GetRandom()
|
||||
local tablemax = table.maxn(self.Index)
|
||||
local tablemax = 0
|
||||
for _,_ind in pairs(self.Index) do
|
||||
tablemax = tablemax + 1
|
||||
end
|
||||
--local tablemax = table.maxn(self.Index)
|
||||
local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
|
||||
self:T3( { RandomItem } )
|
||||
return RandomItem
|
||||
@@ -561,10 +565,12 @@ do -- SET_BASE
|
||||
return self
|
||||
end
|
||||
|
||||
--- Iterate the SET_BASE while identifying the nearest object from a @{Core.Point#POINT_VEC2}.
|
||||
--- Iterate the SET_BASE while identifying the nearest object in the set from a @{Core.Point#POINT_VEC2}.
|
||||
-- @param #SET_BASE self
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2 A @{Core.Point#POINT_VEC2} object from where to evaluate the closest object in the set.
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2 A @{Core.Point#COORDINATE} or @{Core.Point#POINT_VEC2} object (but **not** a simple DCS#Vec2!) from where to evaluate the closest object in the set.
|
||||
-- @return Core.Base#BASE The closest object.
|
||||
-- @usage
|
||||
-- myset:FindNearestObjectFromPointVec2( ZONE:New("Test Zone"):GetCoordinate() )
|
||||
function SET_BASE:FindNearestObjectFromPointVec2( PointVec2 )
|
||||
self:F2( PointVec2 )
|
||||
|
||||
@@ -1065,8 +1071,15 @@ do
|
||||
self:FilterActive( false )
|
||||
|
||||
return self
|
||||
|
||||
--- Filter the set once
|
||||
-- @function [parent=#SET_GROUP] FilterOnce
|
||||
-- @param #SET_GROUP self
|
||||
-- @return #SET_GROUP self
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Get a *new* set that only contains alive groups.
|
||||
-- @param #SET_GROUP self
|
||||
-- @return #SET_GROUP Set of alive groups.
|
||||
@@ -1976,6 +1989,7 @@ do
|
||||
--- Get the closest group of the set with respect to a given reference coordinate. Optionally, only groups of given coalitions are considered in the search.
|
||||
-- @param #SET_GROUP self
|
||||
-- @param Core.Point#COORDINATE Coordinate Reference Coordinate from which the closest group is determined.
|
||||
-- @param #table Coalitions (Optional) Table of coalition #number entries to filter for.
|
||||
-- @return Wrapper.Group#GROUP The closest group (if any).
|
||||
-- @return #number Distance in meters to the closest group.
|
||||
function SET_GROUP:GetClosestGroup(Coordinate, Coalitions)
|
||||
@@ -2840,59 +2854,50 @@ do -- SET_UNIT
|
||||
-- @return Core.Point#COORDINATE The center coordinate of all the units in the set, including heading in degrees and speed in mps in case of moving units.
|
||||
function SET_UNIT:GetCoordinate()
|
||||
|
||||
local Coordinate = nil
|
||||
local unit = self:GetRandom()
|
||||
if self:Count() == 1 and unit then
|
||||
return unit:GetCoordinate()
|
||||
end
|
||||
if unit then
|
||||
local Coordinate = unit:GetCoordinate()
|
||||
--self:F({Coordinate:GetVec3()})
|
||||
|
||||
|
||||
local x1 = Coordinate.x
|
||||
local x2 = Coordinate.x
|
||||
local y1 = Coordinate.y
|
||||
local y2 = Coordinate.y
|
||||
local z1 = Coordinate.z
|
||||
local z2 = Coordinate.z
|
||||
local MaxVelocity = 0
|
||||
local AvgHeading = nil
|
||||
local MovingCount = 0
|
||||
|
||||
for UnitName, UnitData in pairs( self:GetAliveSet() ) do
|
||||
|
||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||
local Coordinate = Unit:GetCoordinate()
|
||||
|
||||
x1 = (Coordinate.x < x1) and Coordinate.x or x1
|
||||
x2 = (Coordinate.x > x2) and Coordinate.x or x2
|
||||
y1 = (Coordinate.y < y1) and Coordinate.y or y1
|
||||
y2 = (Coordinate.y > y2) and Coordinate.y or y2
|
||||
z1 = (Coordinate.y < z1) and Coordinate.z or z1
|
||||
z2 = (Coordinate.y > z2) and Coordinate.z or z2
|
||||
|
||||
local Velocity = Coordinate:GetVelocity()
|
||||
if Velocity ~= 0 then
|
||||
MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity
|
||||
local Heading = Coordinate:GetHeading()
|
||||
AvgHeading = AvgHeading and (AvgHeading + Heading) or Heading
|
||||
MovingCount = MovingCount + 1
|
||||
local function GetSetVec3(units)
|
||||
-- Init.
|
||||
local x=0
|
||||
local y=0
|
||||
local z=0
|
||||
local n=0
|
||||
-- Loop over all units.
|
||||
for _,unit in pairs(units) do
|
||||
local vec3=nil --DCS#Vec3
|
||||
if unit and unit:IsAlive() then
|
||||
vec3 = unit:GetVec3()
|
||||
end
|
||||
if vec3 then
|
||||
-- Sum up posits.
|
||||
x=x+vec3.x
|
||||
y=y+vec3.y
|
||||
z=z+vec3.z
|
||||
-- Increase counter.
|
||||
n=n+1
|
||||
end
|
||||
end
|
||||
|
||||
AvgHeading = AvgHeading and (AvgHeading / MovingCount)
|
||||
|
||||
Coordinate.x = (x2 - x1) / 2 + x1
|
||||
Coordinate.y = (y2 - y1) / 2 + y1
|
||||
Coordinate.z = (z2 - z1) / 2 + z1
|
||||
Coordinate:SetHeading( AvgHeading )
|
||||
Coordinate:SetVelocity( MaxVelocity )
|
||||
|
||||
self:F( { Coordinate = Coordinate } )
|
||||
if n>0 then
|
||||
-- Average.
|
||||
local Vec3={x=x/n, y=y/n, z=z/n} --DCS#Vec3
|
||||
return Vec3
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local Coordinate = nil
|
||||
local Vec3 = GetSetVec3(self.Set)
|
||||
if Vec3 then
|
||||
Coordinate = COORDINATE:NewFromVec3(Vec3)
|
||||
end
|
||||
return Coordinate
|
||||
|
||||
if Coordinate then
|
||||
local heading = self:GetHeading() or 0
|
||||
local velocity = self:GetVelocity() or 0
|
||||
Coordinate:SetHeading( heading )
|
||||
Coordinate:SetVelocity( velocity )
|
||||
self:I(UTILS.PrintTableToLog(Coordinate))
|
||||
end
|
||||
|
||||
return Coordinate
|
||||
end
|
||||
|
||||
--- Get the maximum velocity of the SET_UNIT.
|
||||
|
||||
@@ -320,7 +320,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
||||
self.AIOnOff = true -- The AI is on by default when spawning a group.
|
||||
self.SpawnUnControlled = false
|
||||
self.SpawnInitKeepUnitNames = false -- Overwrite unit names by default with group name.
|
||||
self.DelayOnOff = false -- No intial delay when spawning the first group.
|
||||
self.DelayOnOff = false -- No initial delay when spawning the first group.
|
||||
self.SpawnGrouping = nil -- No grouping.
|
||||
self.SpawnInitLivery = nil -- No special livery.
|
||||
self.SpawnInitSkill = nil -- No special skill.
|
||||
@@ -332,6 +332,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
||||
self.SpawnInitModexPostfix = nil
|
||||
self.SpawnInitAirbase = nil
|
||||
self.TweakedTemplate = false -- Check if the user is using self made template.
|
||||
self.SpawnRandomCallsign = false
|
||||
|
||||
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
||||
else
|
||||
@@ -1099,6 +1100,30 @@ function SPAWN:InitRandomizeZones( SpawnZoneTable )
|
||||
return self
|
||||
end
|
||||
|
||||
--- [AIR/Fighter only!] This method randomizes the callsign for a new group.
|
||||
-- @param #SPAWN self
|
||||
-- @return #SPAWN self
|
||||
function SPAWN:InitRandomizeCallsign()
|
||||
self.SpawnRandomCallsign = true
|
||||
return self
|
||||
end
|
||||
|
||||
--- [BLUE AIR only!] This method sets a specific callsign for a spawned group. Use for a group with one unit only!
|
||||
-- @param #SPAWN self
|
||||
-- @param #number ID ID of the callsign enumerator, e.g. CALLSIGN.Tanker.Texaco - - resulting in e.g. Texaco-2-1
|
||||
-- @param #string Name Name of this callsign as it cannot be determined from the ID because of the dependency on the task type of the plane, and the plane type. E.g. "Texaco"
|
||||
-- @param #number Minor Minor number, i.e. the unit number within the group, e.g 2 - resulting in e.g. Texaco-2-1
|
||||
-- @param #number Major Major number, i.e. the group number of this name, e.g. 1 - resulting in e.g. Texaco-2-1
|
||||
-- @return #SPAWN self
|
||||
function SPAWN:InitCallSign(ID,Name,Minor,Major)
|
||||
self.SpawnInitCallSign = true
|
||||
self.SpawnInitCallSignID = ID or 1
|
||||
self.SpawnInitCallSignMinor = Minor or 1
|
||||
self.SpawnInitCallSignMajor = Major or 1
|
||||
self.SpawnInitCallSignName = string.lower(Name) or "enfield"
|
||||
return self
|
||||
end
|
||||
|
||||
--- This method sets a spawn position for the group that is different from the location of the template.
|
||||
-- @param #SPAWN self
|
||||
-- @param Core.Point#COORDINATE Coordinate The position to spawn from
|
||||
@@ -3275,17 +3300,78 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
||||
end
|
||||
|
||||
-- Callsign
|
||||
|
||||
if self.SpawnRandomCallsign and SpawnTemplate.units[1].callsign then
|
||||
if type( SpawnTemplate.units[1].callsign ) ~= "number" then
|
||||
-- change callsign
|
||||
local min = 1
|
||||
local max = 8
|
||||
local ctable = CALLSIGN.Aircraft
|
||||
if string.find(SpawnTemplate.units[1].type, "A-10",1,true) then
|
||||
max = 12
|
||||
end
|
||||
if string.find(SpawnTemplate.units[1].type, "18",1,true) then
|
||||
min = 9
|
||||
max = 20
|
||||
ctable = CALLSIGN.F18
|
||||
end
|
||||
if string.find(SpawnTemplate.units[1].type, "16",1,true) then
|
||||
min = 9
|
||||
max = 20
|
||||
ctable = CALLSIGN.F16
|
||||
end
|
||||
if SpawnTemplate.units[1].type == "F-15E" then
|
||||
min = 9
|
||||
max = 18
|
||||
ctable = CALLSIGN.F15E
|
||||
end
|
||||
local callsignnr = math.random(min,max)
|
||||
local callsignname = "Enfield"
|
||||
for name, value in pairs(ctable) do
|
||||
if value==callsignnr then
|
||||
callsignname = name
|
||||
end
|
||||
end
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
SpawnTemplate.units[UnitID].callsign[1] = callsignnr
|
||||
SpawnTemplate.units[UnitID].callsign[2] = UnitID
|
||||
SpawnTemplate.units[UnitID].callsign[3] = "1"
|
||||
SpawnTemplate.units[UnitID].callsign["name"] = tostring(callsignname)..tostring(UnitID).."1"
|
||||
-- UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].callsign,1)
|
||||
end
|
||||
else
|
||||
-- Russkis
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
SpawnTemplate.units[UnitID].callsign = math.random(1,999)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.SpawnInitCallSign then
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
local Callsign = SpawnTemplate.units[UnitID].callsign
|
||||
if Callsign and type( Callsign ) ~= "number" then
|
||||
SpawnTemplate.units[UnitID].callsign[1] = self.SpawnInitCallSignID
|
||||
SpawnTemplate.units[UnitID].callsign[2] = self.SpawnInitCallSignMinor
|
||||
SpawnTemplate.units[UnitID].callsign[3] = self.SpawnInitCallSignMajor
|
||||
SpawnTemplate.units[UnitID].callsign["name"] = string.format("%s%d%d",self.SpawnInitCallSignName,self.SpawnInitCallSignMinor,self.SpawnInitCallSignMajor)
|
||||
--UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].callsign,1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
local Callsign = SpawnTemplate.units[UnitID].callsign
|
||||
if Callsign then
|
||||
if type( Callsign ) ~= "number" then -- blue callsign
|
||||
if type( Callsign ) ~= "number" and not self.SpawnInitCallSign then -- blue callsign
|
||||
-- UTILS.PrintTableToLog(Callsign,1)
|
||||
Callsign[2] = ((SpawnIndex - 1) % 10) + 1
|
||||
local CallsignName = SpawnTemplate.units[UnitID].callsign["name"] -- #string
|
||||
CallsignName = string.match(CallsignName,"^(%a+)") -- 2.8 - only the part w/o numbers
|
||||
local CallsignLen = CallsignName:len()
|
||||
SpawnTemplate.units[UnitID].callsign[2] = UnitID
|
||||
SpawnTemplate.units[UnitID].callsign["name"] = CallsignName:sub( 1, CallsignLen ) .. SpawnTemplate.units[UnitID].callsign[2] .. SpawnTemplate.units[UnitID].callsign[3]
|
||||
else
|
||||
elseif type( Callsign ) == "number" then
|
||||
SpawnTemplate.units[UnitID].callsign = Callsign + SpawnIndex
|
||||
end
|
||||
end
|
||||
@@ -3293,25 +3379,77 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
||||
local AddProps = SpawnTemplate.units[UnitID].AddPropAircraft
|
||||
if AddProps then
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 then
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 = SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16+UnitID-1
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 < 10000 then
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 = string.format("0%d",SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16)
|
||||
-- 4 digit octal with leading 0
|
||||
if tonumber(SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16) ~= nil then
|
||||
local octal = SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16
|
||||
local decimal = UTILS.OctalToDecimal(octal)+UnitID-1
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 = string.format("%05d",UTILS.DecimalToOctal(decimal))
|
||||
else -- ED bug - chars in here
|
||||
local STN = math.floor(UTILS.RandomGaussian(4088/2,nil,1000,4088))
|
||||
STN = STN+UnitID-1
|
||||
local OSTN = UTILS.DecimalToOctal(STN)
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 = string.format("%05d",OSTN)
|
||||
end
|
||||
end
|
||||
-- A10CII
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN then
|
||||
-- 3 digit octal with leading 0
|
||||
if tonumber(SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN) ~= nil then
|
||||
local octal = SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN
|
||||
local decimal = UTILS.OctalToDecimal(octal)+UnitID-1
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN = string.format("%04d",UTILS.DecimalToOctal(decimal))
|
||||
else -- ED bug - chars in here
|
||||
local STN = math.floor(UTILS.RandomGaussian(504/2,nil,100,504))
|
||||
STN = STN+UnitID-1
|
||||
local OSTN = UTILS.DecimalToOctal(STN)
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN = string.format("%04d",OSTN)
|
||||
end
|
||||
end
|
||||
-- VoiceCallsignNumber
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignNumber then
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignNumber = SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignNumber+UnitID-1
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignNumber and type( Callsign ) ~= "number" then
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignNumber = SpawnTemplate.units[UnitID].callsign[2] .. SpawnTemplate.units[UnitID].callsign[3]
|
||||
end
|
||||
--UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].AddPropAircraft,1)
|
||||
-- VoiceCallsignLabel
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignLabel and type( Callsign ) ~= "number" then
|
||||
local CallsignName = SpawnTemplate.units[UnitID].callsign["name"] -- #string
|
||||
CallsignName = string.match(CallsignName,"^(%a+)") -- 2.8 - only the part w/o numbers
|
||||
local label = "NY" -- Navy One exception
|
||||
if not string.find(CallsignName," ") then
|
||||
label = string.upper(string.match(CallsignName,"^%a")..string.match(CallsignName,"%a$"))
|
||||
end
|
||||
SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignLabel = label
|
||||
end
|
||||
-- UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].AddPropAircraft,1)
|
||||
-- FlightLead
|
||||
if SpawnTemplate.units[UnitID].datalinks and SpawnTemplate.units[UnitID].datalinks.Link16 and SpawnTemplate.units[UnitID].datalinks.Link16.settings then
|
||||
SpawnTemplate.units[UnitID].datalinks.Link16.settings.flightLead = UnitID == 1 and true or false
|
||||
end
|
||||
--UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].datalinks,1)
|
||||
-- A10CII
|
||||
if SpawnTemplate.units[UnitID].datalinks and SpawnTemplate.units[UnitID].datalinks.SADL and SpawnTemplate.units[UnitID].datalinks.SADL.settings then
|
||||
SpawnTemplate.units[UnitID].datalinks.SADL.settings.flightLead = UnitID == 1 and true or false
|
||||
end
|
||||
-- UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].datalinks,1)
|
||||
end
|
||||
end
|
||||
-- Link16 team members
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
if SpawnTemplate.units[UnitID].datalinks and SpawnTemplate.units[UnitID].datalinks.Link16 and SpawnTemplate.units[UnitID].datalinks.Link16.network then
|
||||
local team = {}
|
||||
local isF16 = string.find(SpawnTemplate.units[UnitID].type,"F-16",1,true) and true or false
|
||||
for ID = 1, #SpawnTemplate.units do
|
||||
local member = {}
|
||||
member.missionUnitId = ID
|
||||
if isF16 then
|
||||
member.TDOA = true
|
||||
end
|
||||
table.insert(team,member)
|
||||
end
|
||||
SpawnTemplate.units[UnitID].datalinks.Link16.network.teamMembers = team
|
||||
end
|
||||
end
|
||||
|
||||
self:T3( { "Template:", SpawnTemplate } )
|
||||
--UTILS.PrintTableToLog(SpawnTemplate,1)
|
||||
return SpawnTemplate
|
||||
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,8 +38,9 @@
|
||||
-- @image Detection.JPG
|
||||
|
||||
do -- DETECTION_BASE
|
||||
|
||||
--- @type DETECTION_BASE
|
||||
|
||||
---
|
||||
-- @type DETECTION_BASE
|
||||
-- @field Core.Set#SET_GROUP DetectionSetGroup The @{Core.Set} of GROUPs in the Forward Air Controller role.
|
||||
-- @field DCS#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||
-- @field #DETECTION_BASE.DetectedObjects DetectedObjects The list of detected objects.
|
||||
@@ -91,6 +92,11 @@ do -- DETECTION_BASE
|
||||
--
|
||||
-- DetectionObject:FilterCategories( { Unit.Category.AIRPLANE, Unit.Category.HELICOPTER } )
|
||||
--
|
||||
--
|
||||
-- ## Radar Blur - use to make the radar less exact, e.g. for WWII scenarios
|
||||
--
|
||||
-- * @{DETECTION_BASE.SetRadarBlur}(): Set the radar blur to be used.
|
||||
--
|
||||
-- ## **DETECTION_ derived classes** group the detected units into a **DetectedItems[]** list
|
||||
--
|
||||
-- DETECTION_BASE derived classes build a list called DetectedItems[], which is essentially a first later
|
||||
@@ -268,11 +274,13 @@ do -- DETECTION_BASE
|
||||
DetectedItems = {},
|
||||
DetectedItemsByIndex = {},
|
||||
}
|
||||
|
||||
--- @type DETECTION_BASE.DetectedObjects
|
||||
|
||||
---
|
||||
-- @type DETECTION_BASE.DetectedObjects
|
||||
-- @list <#DETECTION_BASE.DetectedObject>
|
||||
|
||||
--- @type DETECTION_BASE.DetectedObject
|
||||
---
|
||||
-- @type DETECTION_BASE.DetectedObject
|
||||
-- @field #string Name
|
||||
-- @field #boolean IsVisible
|
||||
-- @field #boolean KnowType
|
||||
@@ -283,8 +291,9 @@ do -- DETECTION_BASE
|
||||
-- @field #number LastTime
|
||||
-- @field #boolean LastPos
|
||||
-- @field #number LastVelocity
|
||||
|
||||
--- @type DETECTION_BASE.DetectedItems
|
||||
|
||||
---
|
||||
-- @type DETECTION_BASE.DetectedItems
|
||||
-- @list <#DETECTION_BASE.DetectedItem>
|
||||
|
||||
--- Detected item data structure.
|
||||
@@ -522,7 +531,7 @@ do -- DETECTION_BASE
|
||||
|
||||
do -- State Transition Handling
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
@@ -530,7 +539,7 @@ do -- DETECTION_BASE
|
||||
self:__Detect( 1 )
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
@@ -570,7 +579,7 @@ do -- DETECTION_BASE
|
||||
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number The amount of alive recce.
|
||||
function DETECTION_BASE:CountAliveRecce()
|
||||
|
||||
@@ -578,7 +587,7 @@ do -- DETECTION_BASE
|
||||
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
function DETECTION_BASE:ForEachAliveRecce( IteratorFunction, ... )
|
||||
self:F2( arg )
|
||||
|
||||
@@ -587,7 +596,7 @@ do -- DETECTION_BASE
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
@@ -712,6 +721,31 @@ do -- DETECTION_BASE
|
||||
end
|
||||
end
|
||||
|
||||
-- Calculate radar blur probability
|
||||
|
||||
if self.RadarBlur then
|
||||
MESSAGE:New("Radar Blur",10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||
local minheight = self.RadarBlurMinHeight or 250 -- meters
|
||||
local thresheight = self.RadarBlurThresHeight or 90 -- 10% chance to find a low flying group
|
||||
local thresblur = self.RadarBlurThresBlur or 85 -- 25% chance to escape the radar overall
|
||||
local dist = math.floor(Distance)
|
||||
if dist <= self.RadarBlurClosing then
|
||||
thresheight = (((dist*dist)/self.RadarBlurClosingSquare)*thresheight)
|
||||
thresblur = (((dist*dist)/self.RadarBlurClosingSquare)*thresblur)
|
||||
end
|
||||
local fheight = math.floor(math.random(1,10000)/100)
|
||||
local fblur = math.floor(math.random(1,10000)/100)
|
||||
local unit = UNIT:FindByName(DetectedObjectName)
|
||||
if unit and unit:IsAlive() then
|
||||
local AGL = unit:GetAltitude(true)
|
||||
MESSAGE:New("Unit "..DetectedObjectName.." is at "..math.floor(AGL).."m. Distance "..math.floor(Distance).."km.",10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||
MESSAGE:New(string.format("fheight = %d/%d | fblur = %d/%d",fheight,thresheight,fblur,thresblur),10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||
if fblur > thresblur then DetectionAccepted = false end
|
||||
if AGL <= minheight and fheight < thresheight then DetectionAccepted = false end
|
||||
MESSAGE:New("Detection Accepted = "..tostring(DetectionAccepted),10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||
end
|
||||
end
|
||||
|
||||
-- Calculate additional probabilities
|
||||
|
||||
if not self.DetectedObjects[DetectedObjectName] and TargetIsVisible and self.DistanceProbability then
|
||||
@@ -1011,7 +1045,24 @@ do -- DETECTION_BASE
|
||||
return self
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Method to make the radar detection less accurate, e.g. for WWII scenarios.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number minheight Minimum flight height to be detected, in meters AGL (above ground)
|
||||
-- @param #number thresheight Threshold to escape the radar if flying below minheight, defaults to 90 (90% escape chance)
|
||||
-- @param #number thresblur Threshold to be detected by the radar overall, defaults to 85 (85% chance to be found)
|
||||
-- @param #number closing Closing-in in km - the limit of km from which on it becomes increasingly difficult to escape radar detection if flying towards the radar position. Should be about 1/3 of the radar detection radius in kilometers, defaults to 20.
|
||||
-- @return #DETECTION_BASE self
|
||||
function DETECTION_BASE:SetRadarBlur(minheight,thresheight,thresblur,closing)
|
||||
self.RadarBlur = true
|
||||
self.RadarBlurMinHeight = minheight or 250 -- meters
|
||||
self.RadarBlurThresHeight = thresheight or 90 -- 10% chance to find a low flying group
|
||||
self.RadarBlurThresBlur = thresblur or 85 -- 25% chance to escape the radar overall
|
||||
self.RadarBlurClosing = closing or 20 -- 20km
|
||||
self.RadarBlurClosingSquare = self.RadarBlurClosing * self.RadarBlurClosing
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do
|
||||
@@ -1354,7 +1405,7 @@ do -- DETECTION_BASE
|
||||
}
|
||||
}
|
||||
|
||||
--- @param DCS#Unit FoundDCSUnit
|
||||
-- @param DCS#Unit FoundDCSUnit
|
||||
-- @param Wrapper.Group#GROUP ReportGroup
|
||||
-- @param Core.Set#SET_GROUP ReportSetGroup
|
||||
local FindNearByFriendlies = function( FoundDCSUnit, ReportGroupData )
|
||||
@@ -1419,7 +1470,7 @@ do -- DETECTION_BASE
|
||||
DetectedItem.PlayersNearBy = nil
|
||||
|
||||
_DATABASE:ForEachPlayer(
|
||||
--- @param Wrapper.Unit#UNIT PlayerUnit
|
||||
-- @param Wrapper.Unit#UNIT PlayerUnit
|
||||
function( PlayerUnitName )
|
||||
local PlayerUnit = UNIT:FindByName( PlayerUnitName )
|
||||
|
||||
@@ -1975,8 +2026,9 @@ do -- DETECTION_BASE
|
||||
end
|
||||
|
||||
do -- DETECTION_UNITS
|
||||
|
||||
--- @type DETECTION_UNITS
|
||||
|
||||
---
|
||||
-- @type DETECTION_UNITS
|
||||
-- @field DCS#Distance DetectionRange The range till which targets are detected.
|
||||
-- @extends Functional.Detection#DETECTION_BASE
|
||||
|
||||
@@ -2231,8 +2283,9 @@ do -- DETECTION_UNITS
|
||||
end
|
||||
|
||||
do -- DETECTION_TYPES
|
||||
|
||||
--- @type DETECTION_TYPES
|
||||
|
||||
---
|
||||
-- @type DETECTION_TYPES
|
||||
-- @extends Functional.Detection#DETECTION_BASE
|
||||
|
||||
--- Will detect units within the battle zone.
|
||||
@@ -2434,8 +2487,9 @@ do -- DETECTION_TYPES
|
||||
end
|
||||
|
||||
do -- DETECTION_AREAS
|
||||
|
||||
--- @type DETECTION_AREAS
|
||||
|
||||
---
|
||||
-- @type DETECTION_AREAS
|
||||
-- @field DCS#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||
-- @field #DETECTION_BASE.DetectedItems DetectedItems A list of areas containing the set of @{Wrapper.Unit}s, @{Core.Zone}s, the center @{Wrapper.Unit} within the zone, and ID of each area that was detected within a DetectionZoneRange.
|
||||
-- @extends Functional.Detection#DETECTION_BASE
|
||||
@@ -2961,7 +3015,7 @@ do -- DETECTION_AREAS
|
||||
|
||||
-- DetectedSet:Flush( self )
|
||||
|
||||
DetectedSet:ForEachUnit( --- @param Wrapper.Unit#UNIT DetectedUnit
|
||||
DetectedSet:ForEachUnit( -- @param Wrapper.Unit#UNIT DetectedUnit
|
||||
function( DetectedUnit )
|
||||
if DetectedUnit:IsAlive() then
|
||||
-- self:T( "Detected Set #" .. DetectedItem.ID .. ":" .. DetectedUnit:GetName() )
|
||||
|
||||
@@ -1207,18 +1207,18 @@ end
|
||||
-- @return #RANGE self
|
||||
function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume, PathToGoogleKey)
|
||||
|
||||
if PathToSRS then
|
||||
if PathToSRS or MSRS.path then
|
||||
|
||||
self.useSRS=true
|
||||
|
||||
self.controlmsrs=MSRS:New(PathToSRS, Frequency or 256, Modulation or radio.modulation.AM, Volume or 1.0)
|
||||
self.controlmsrs:SetPort(Port)
|
||||
self.controlmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 256, Modulation or radio.modulation.AM, Volume or 1.0)
|
||||
self.controlmsrs:SetPort(Port or MSRS.port)
|
||||
self.controlmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
||||
self.controlmsrs:SetLabel("RANGEC")
|
||||
self.controlsrsQ = MSRSQUEUE:New("CONTROL")
|
||||
|
||||
self.instructmsrs=MSRS:New(PathToSRS, Frequency or 305, Modulation or radio.modulation.AM, Volume or 1.0)
|
||||
self.instructmsrs:SetPort(Port)
|
||||
self.instructmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 305, Modulation or radio.modulation.AM, Volume or 1.0)
|
||||
self.instructmsrs:SetPort(Port or MSRS.port)
|
||||
self.instructmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
||||
self.instructmsrs:SetLabel("RANGEI")
|
||||
self.instructsrsQ = MSRSQUEUE:New("INSTRUCT")
|
||||
@@ -1234,7 +1234,7 @@ function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume,
|
||||
return self
|
||||
end
|
||||
|
||||
--- (SRS) Set range control frequency and voice.
|
||||
--- (SRS) Set range control frequency and voice. Use `RANGE:SetSRS()` once first before using this function.
|
||||
-- @param #RANGE self
|
||||
-- @param #number frequency Frequency in MHz. Default 256 MHz.
|
||||
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
||||
@@ -1244,6 +1244,10 @@ end
|
||||
-- @param #string relayunitname Name of the unit used for transmission location.
|
||||
-- @return #RANGE self
|
||||
function RANGE:SetSRSRangeControl( frequency, modulation, voice, culture, gender, relayunitname )
|
||||
if not self.instructmsrs then
|
||||
self:E(self.lid.."Use myrange:SetSRS() once first before using myrange:SetSRSRangeControl!")
|
||||
return self
|
||||
end
|
||||
self.rangecontrolfreq = frequency or 256
|
||||
self.controlmsrs:SetFrequencies(self.rangecontrolfreq)
|
||||
self.controlmsrs:SetModulations(modulation or radio.modulation.AM)
|
||||
@@ -1259,7 +1263,7 @@ function RANGE:SetSRSRangeControl( frequency, modulation, voice, culture, gender
|
||||
return self
|
||||
end
|
||||
|
||||
--- (SRS) Set range instructor frequency and voice.
|
||||
--- (SRS) Set range instructor frequency and voice. Use `RANGE:SetSRS()` once first before using this function.
|
||||
-- @param #RANGE self
|
||||
-- @param #number frequency Frequency in MHz. Default 305 MHz.
|
||||
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
||||
@@ -1269,6 +1273,10 @@ end
|
||||
-- @param #string relayunitname Name of the unit used for transmission location.
|
||||
-- @return #RANGE self
|
||||
function RANGE:SetSRSRangeInstructor( frequency, modulation, voice, culture, gender, relayunitname )
|
||||
if not self.instructmsrs then
|
||||
self:E(self.lid.."Use myrange:SetSRS() once first before using myrange:SetSRSRangeInstructor!")
|
||||
return self
|
||||
end
|
||||
self.instructorfreq = frequency or 305
|
||||
self.instructmsrs:SetFrequencies(self.instructorfreq)
|
||||
self.instructmsrs:SetModulations(modulation or radio.modulation.AM)
|
||||
@@ -2179,7 +2187,7 @@ function RANGE:onafterExitRange( From, Event, To, player )
|
||||
|
||||
local text = "You left the bombing range zone. "
|
||||
|
||||
local r=math.random(2)
|
||||
local r=math.random(5)
|
||||
|
||||
if r==1 then
|
||||
text=text.."Have a nice day!"
|
||||
|
||||
@@ -7404,6 +7404,8 @@ function WAREHOUSE:_CheckRequestNow(request)
|
||||
|
||||
-- Check if at least one (cargo) asset is available.
|
||||
if _nassets>0 then
|
||||
|
||||
local asset=_assets[1] --#WAREHOUSE.Assetitem
|
||||
|
||||
-- Get the attibute of the requested asset.
|
||||
_assetattribute=_assets[1].attribute
|
||||
@@ -7414,11 +7416,24 @@ function WAREHOUSE:_CheckRequestNow(request)
|
||||
if _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER then
|
||||
|
||||
if self.airbase and self.airbase:GetCoalition()==self:GetCoalition() then
|
||||
|
||||
-- Check if DCS warehouse of airbase has enough assets
|
||||
if self.airbase.storage then
|
||||
local nS=self.airbase.storage:GetAmount(asset.unittype)
|
||||
local nA=asset.nunits*request.nasset -- Number of units requested
|
||||
if nS<nA then
|
||||
local text=string.format("Warehouse %s: Request denied! DCS Warehouse has only %d assets of type %s ==> NOT enough to spawn the requested %d asset units (%d groups)",
|
||||
self.alias, nS, asset.unittype, nA, request.nasset)
|
||||
self:_InfoMessage(text, 5)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self:IsRunwayOperational() or _assetairstart then
|
||||
|
||||
if _assetairstart then
|
||||
-- Airstart no need to check parking
|
||||
-- Airstart no need to check parking
|
||||
else
|
||||
|
||||
-- Check parking.
|
||||
@@ -7530,6 +7545,9 @@ function WAREHOUSE:_CheckRequestNow(request)
|
||||
self:_InfoMessage(text, 5)
|
||||
return false
|
||||
end
|
||||
|
||||
elseif _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER then
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -312,10 +312,16 @@
|
||||
--
|
||||
-- atis=ATIS:New("Batumi", 305, radio.modulation.AM)
|
||||
-- atis:SetSRS("D:\\DCS\\_SRS\\", "male", "en-US")
|
||||
-- atis:Start()
|
||||
-- atis:Start()
|
||||
--
|
||||
-- This uses a male voice with US accent. It requires SRS to be installed in the `D:\DCS\_SRS\` directory. Note that backslashes need to be escaped or simply use slashes (as in linux).
|
||||
--
|
||||
-- ### SRS can use multiple frequencies:
|
||||
--
|
||||
-- atis=ATIS:New("Batumi", {305,103.85}, {radio.modulation.AM,radio.modulation.FM})
|
||||
-- atis:SetSRS("D:\\DCS\\_SRS\\", "male", "en-US")
|
||||
-- atis:Start()
|
||||
--
|
||||
-- ### SRS Localization
|
||||
--
|
||||
-- You can localize the SRS output, all you need is to provide a table of translations and set the `locale` of your instance. You need to provide the translations in your script **before you instantiate your ATIS**.
|
||||
@@ -884,13 +890,14 @@ _ATIS = {}
|
||||
|
||||
--- ATIS class version.
|
||||
-- @field #string version
|
||||
ATIS.version = "0.10.3"
|
||||
ATIS.version = "0.10.4"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: Correct fog for elevation.
|
||||
-- DONE: Option to add multiple frequencies for SRS
|
||||
-- DONE: Zulu time --> Zulu in output.
|
||||
-- DONE: Fix for AB not having a runway - Helopost like Naqoura
|
||||
-- DONE: Add new Normandy airfields.
|
||||
@@ -899,7 +906,7 @@ ATIS.version = "0.10.3"
|
||||
-- DONE: Visibility reported twice over SRS
|
||||
-- DONE: Add text report for output.
|
||||
-- DONE: Add stop FMS functions.
|
||||
-- NOGO: Use local time. Not realisitc!
|
||||
-- NOGO: Use local time. Not realistic!
|
||||
-- DONE: Dew point. Approx. done.
|
||||
-- DONE: Metric units.
|
||||
-- DONE: Set UTC correction.
|
||||
@@ -915,8 +922,8 @@ ATIS.version = "0.10.3"
|
||||
--- Create a new ATIS class object for a specific airbase.
|
||||
-- @param #ATIS self
|
||||
-- @param #string AirbaseName Name of the airbase.
|
||||
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz.
|
||||
-- @param #number Modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators.
|
||||
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz. When using **SRS** this can be passed as a table of multiple frequencies.
|
||||
-- @param #number Modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators. When using **SRS** this can be passed as a table of multiple modulations.
|
||||
-- @return #ATIS self
|
||||
function ATIS:New(AirbaseName, Frequency, Modulation)
|
||||
|
||||
@@ -1594,8 +1601,16 @@ function ATIS:onafterStart( From, Event, To )
|
||||
end
|
||||
|
||||
-- Info.
|
||||
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation ) )
|
||||
|
||||
if type(self.frequency) == "table" then
|
||||
local frequency = table.concat(self.frequency,"/")
|
||||
local modulation = self.modulation
|
||||
if type(self.modulation) == "table" then
|
||||
modulation = table.concat(self.modulation,"/")
|
||||
end
|
||||
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %s MHz Modulation=%s", ATIS.version, self.airbasename, frequency, modulation ) )
|
||||
else
|
||||
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation ) )
|
||||
end
|
||||
-- Start radio queue.
|
||||
if not self.useSRS then
|
||||
self.radioqueue = RADIOQUEUE:New( self.frequency, self.modulation, string.format( "ATIS %s", self.airbasename ) )
|
||||
@@ -1653,7 +1668,17 @@ function ATIS:onafterStatus( From, Event, To )
|
||||
end
|
||||
|
||||
-- Info text.
|
||||
local text = string.format( "State %s: Freq=%.3f MHz %s", fsmstate, self.frequency, UTILS.GetModulationName( self.modulation ) )
|
||||
local text = ""
|
||||
if type(self.frequency) == "table" then
|
||||
local frequency = table.concat(self.frequency,"/")
|
||||
local modulation = self.modulation
|
||||
if type(self.modulation) == "table" then
|
||||
modulation = table.concat(self.modulation,"/")
|
||||
end
|
||||
text = string.format( "State %s: Freq=%s MHz %s", fsmstate, frequency, modulation )
|
||||
else
|
||||
text = string.format( "State %s: Freq=%.3f MHz %s", fsmstate, self.frequency, UTILS.GetModulationName( self.modulation ) )
|
||||
end
|
||||
if self.useSRS then
|
||||
text = text .. string.format( ", SRS path=%s (%s), gender=%s, culture=%s, voice=%s", tostring( self.msrs.path ), tostring( self.msrs.port ), tostring( self.msrs.gender ), tostring( self.msrs.culture ), tostring( self.msrs.voice ) )
|
||||
else
|
||||
@@ -2919,8 +2944,17 @@ function ATIS:UpdateMarker( information, runact, wind, altimeter, temperature )
|
||||
if self.markerid then
|
||||
self.airbase:GetCoordinate():RemoveMark( self.markerid )
|
||||
end
|
||||
|
||||
local text = string.format( "ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName( self.modulation ), tostring( information ) )
|
||||
local text = ""
|
||||
if type(self.frequency) == "table" then
|
||||
local frequency = table.concat(self.frequency,"/")
|
||||
local modulation = self.modulation
|
||||
if type(modulation) == "table" then
|
||||
modulation = table.concat(self.modulation,"/")
|
||||
end
|
||||
text = string.format( "ATIS on %s %s, %s:\n", tostring(frequency), tostring(modulation), tostring( information ) )
|
||||
else
|
||||
text = string.format( "ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName( self.modulation ), tostring( information ) )
|
||||
end
|
||||
text = text .. string.format( "%s\n", tostring( runact ) )
|
||||
text = text .. string.format( "%s\n", tostring( wind ) )
|
||||
text = text .. string.format( "%s\n", tostring( altimeter ) )
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
-- @module Ops.CTLD
|
||||
-- @image OPS_CTLD.jpg
|
||||
|
||||
-- Last Update November 2023
|
||||
-- Last Update December 2023
|
||||
|
||||
do
|
||||
|
||||
@@ -1228,7 +1228,7 @@ CTLD.UnitTypeCapabilities = {
|
||||
|
||||
--- CTLD class version.
|
||||
-- @field #string version
|
||||
CTLD.version="1.0.43"
|
||||
CTLD.version="1.0.44"
|
||||
|
||||
--- Instantiate a new CTLD.
|
||||
-- @param #CTLD self
|
||||
@@ -2561,6 +2561,40 @@ function CTLD:_ListCratesNearby( _group, _unit)
|
||||
return self
|
||||
end
|
||||
|
||||
-- (Internal) Function to find and Remove nearby crates.
|
||||
-- @param #CTLD self
|
||||
-- @param Wrapper.Group#GROUP Group
|
||||
-- @param Wrapper.Unit#UNIT Unit
|
||||
-- @return #CTLD self
|
||||
function CTLD:_RemoveCratesNearby( _group, _unit)
|
||||
self:T(self.lid .. " _RemoveCratesNearby")
|
||||
local finddist = self.CrateDistance or 35
|
||||
local crates,number = self:_FindCratesNearby(_group,_unit, finddist,true) -- #table
|
||||
if number > 0 then
|
||||
local text = REPORT:New("Removing Crates Found Nearby:")
|
||||
text:Add("------------------------------------------------------------")
|
||||
for _,_entry in pairs (crates) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
local name = entry:GetName() --#string
|
||||
local dropped = entry:WasDropped()
|
||||
if dropped then
|
||||
text:Add(string.format("Crate for %s, %dkg removed",name, entry.PerCrateMass))
|
||||
else
|
||||
text:Add(string.format("Crate for %s, %dkg removed",name, entry.PerCrateMass))
|
||||
end
|
||||
entry:GetPositionable():Destroy(false)
|
||||
end
|
||||
if text:GetCount() == 1 then
|
||||
text:Add(" N O N E")
|
||||
end
|
||||
text:Add("------------------------------------------------------------")
|
||||
self:_SendMessage(text:Text(), 30, true, _group)
|
||||
else
|
||||
self:_SendMessage(string.format("No (loadable) crates within %d meters!",finddist), 10, false, _group)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Internal) Return distance in meters between two coordinates.
|
||||
-- @param #CTLD self
|
||||
-- @param Core.Point#COORDINATE _point1 Coordinate one
|
||||
@@ -2976,6 +3010,35 @@ function CTLD:IsHercules(Unit)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- (Internal) Function to set troops positions of a template to a nice circle
|
||||
-- @param #CTLD self
|
||||
-- @param Core.Point#COORDINATE Coordinate Start coordinate to use
|
||||
-- @param #number Radius Radius to be used
|
||||
-- @param #number Heading Heading starting with
|
||||
-- @param #string Template The group template name
|
||||
-- @return #table Positions The positions table
|
||||
function CTLD:_GetUnitPositions(Coordinate,Radius,Heading,Template)
|
||||
local Positions = {}
|
||||
local template = _DATABASE:GetGroupTemplate(Template)
|
||||
UTILS.PrintTableToLog(template)
|
||||
local numbertroops = #template.units
|
||||
local newcenter = Coordinate:Translate(Radius,((Heading+270)%360))
|
||||
for i=1,360,math.floor(360/numbertroops) do
|
||||
local phead = ((Heading+270+i)%360)
|
||||
local post = newcenter:Translate(Radius,phead)
|
||||
local pos1 = post:GetVec2()
|
||||
local p1t = {
|
||||
x = pos1.x,
|
||||
y = pos1.y,
|
||||
heading = phead,
|
||||
}
|
||||
table.insert(Positions,p1t)
|
||||
end
|
||||
UTILS.PrintTableToLog(Positions)
|
||||
return Positions
|
||||
end
|
||||
|
||||
--- (Internal) Function to unload troops from heli.
|
||||
-- @param #CTLD self
|
||||
-- @param Wrapper.Group#GROUP Group
|
||||
@@ -3027,14 +3090,29 @@ function CTLD:_UnloadTroops(Group, Unit)
|
||||
zoneradius = Unit:GetVelocityMPS() or 100
|
||||
end
|
||||
local zone = ZONE_GROUP:New(string.format("Unload zone-%s",unitname),Group,zoneradius*factor)
|
||||
local randomcoord = zone:GetRandomCoordinate(10,30*factor):GetVec2()
|
||||
local randomcoord = zone:GetRandomCoordinate(10,30*factor) --:GetVec2()
|
||||
local heading = Group:GetHeading() or 0
|
||||
-- Spawn troops left from us, closer when hovering, further off when landed
|
||||
if hoverunload or grounded then
|
||||
randomcoord = Group:GetCoordinate()
|
||||
-- slightly left from us
|
||||
local Angle = (heading+270)%360
|
||||
local offset = hoverunload and 1.5 or 5
|
||||
randomcoord:Translate(offset,Angle,nil,true)
|
||||
end
|
||||
local tempcount = 0
|
||||
for _,_template in pairs(temptable) do
|
||||
self.TroopCounter = self.TroopCounter + 1
|
||||
tempcount = tempcount+1
|
||||
local alias = string.format("%s-%d", _template, math.random(1,100000))
|
||||
local rad = 2.5+tempcount
|
||||
local Positions = self:_GetUnitPositions(randomcoord,rad,heading,_template)
|
||||
self.DroppedTroops[self.TroopCounter] = SPAWN:NewWithAlias(_template,alias)
|
||||
:InitRandomizeUnits(true,20,2)
|
||||
--:InitRandomizeUnits(true,20,2)
|
||||
--:InitHeading(heading)
|
||||
:InitDelayOff()
|
||||
:SpawnFromVec2(randomcoord)
|
||||
:InitSetUnitAbsolutePositions(Positions)
|
||||
:SpawnFromVec2(randomcoord:GetVec2())
|
||||
self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter],type)
|
||||
end -- template loop
|
||||
cargo:SetWasDropped(true)
|
||||
@@ -3637,6 +3715,7 @@ function CTLD:_RefreshF10Menus()
|
||||
local loadmenu = MENU_GROUP_COMMAND:New(_group,"Load crates",topcrates, self._LoadCratesNearby, self, _group, _unit)
|
||||
local cratesmenu = MENU_GROUP:New(_group,"Get Crates",topcrates)
|
||||
local packmenu = MENU_GROUP_COMMAND:New(_group, "Pack crates", topcrates, self._PackCratesNearby, self, _group, _unit)
|
||||
local removecratesmenu = MENU_GROUP:New(_group, "Remove crates", topcrates)
|
||||
|
||||
if self.usesubcats then
|
||||
local subcatmenus = {}
|
||||
@@ -3672,6 +3751,7 @@ function CTLD:_RefreshF10Menus()
|
||||
end
|
||||
end
|
||||
listmenu = MENU_GROUP_COMMAND:New(_group,"List crates nearby",topcrates, self._ListCratesNearby, self, _group, _unit)
|
||||
removecrates = MENU_GROUP_COMMAND:New(_group,"Remove crates nearby",removecratesmenu, self._RemoveCratesNearby, self, _group, _unit)
|
||||
local unloadmenu = MENU_GROUP_COMMAND:New(_group,"Drop crates",topcrates, self._UnloadCrates, self, _group, _unit)
|
||||
if not self.nobuildmenu then
|
||||
local buildmenu = MENU_GROUP_COMMAND:New(_group,"Build crates",topcrates, self._BuildCrates, self, _group, _unit)
|
||||
|
||||
@@ -137,7 +137,7 @@ do -- UserSound
|
||||
return self
|
||||
end
|
||||
|
||||
--- Play the usersound to the given @{Wrapper.Unit}.
|
||||
--- Play the usersound to the given @{Wrapper.Unit}.
|
||||
-- @param #USERSOUND self
|
||||
-- @param Wrapper.Unit#UNIT Unit The @{Wrapper.Unit} to play the usersound to.
|
||||
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
||||
@@ -159,4 +159,24 @@ do -- UserSound
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Play the usersound to the given @{Wrapper.Client}.
|
||||
-- @param #USERSOUND self
|
||||
-- @param Wrapper.Client#CLIENT The @{Wrapper.Client} to play the usersound to.
|
||||
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
||||
-- @return #USERSOUND The usersound instance.
|
||||
-- @usage
|
||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||
-- local PlayerUnit = CLIENT:FindByPlayerName("Karl Heinz")-- Search for the active client with playername "Karl Heinz", a human player.
|
||||
-- BlueVictory:ToClient( PlayerUnit ) -- Play the victory sound to the player unit.
|
||||
--
|
||||
function USERSOUND:ToClient( Client, Delay )
|
||||
Delay=Delay or 0
|
||||
if Delay>0 then
|
||||
SCHEDULER:New(nil, USERSOUND.ToClient,{self, Client}, Delay)
|
||||
else
|
||||
trigger.action.outSoundForUnit( Client:GetID(), self.UserSoundFileName )
|
||||
end
|
||||
return self
|
||||
end
|
||||
end
|
||||
@@ -29,7 +29,6 @@ ENUMS = {}
|
||||
--- Suppress the error box
|
||||
env.setErrorMessageBoxEnabled( false )
|
||||
|
||||
|
||||
--- Rules of Engagement.
|
||||
-- @type ENUMS.ROE
|
||||
-- @field #number WeaponFree [AIR] AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
|
||||
@@ -567,6 +566,14 @@ ENUMS.ReportingName =
|
||||
}
|
||||
}
|
||||
|
||||
--- Enums for Link16 transmit power
|
||||
-- @type ENUMS.Link16Power
|
||||
ENUMS.Link16Power = {
|
||||
none = 0,
|
||||
low = 1,
|
||||
medium = 2,
|
||||
high = 3,
|
||||
}
|
||||
|
||||
|
||||
--- Enums for the STORAGE class for stores - which need to be in ""
|
||||
|
||||
@@ -441,21 +441,37 @@ UTILS.BasicSerialize = function(s)
|
||||
end
|
||||
end
|
||||
|
||||
--- Print a table to log in a nice format
|
||||
-- @param #table table The table to print
|
||||
-- @param #number indent Number of indents
|
||||
-- @return #string text Text created on the fly of the log output
|
||||
function UTILS.PrintTableToLog(table, indent)
|
||||
local text = "\n"
|
||||
if not table then
|
||||
BASE:E("No table passed!")
|
||||
return
|
||||
env.warning("No table passed!")
|
||||
return nil
|
||||
end
|
||||
if not indent then indent = 0 end
|
||||
for k, v in pairs(table) do
|
||||
if string.find(k," ") then k='"'..k..'"'end
|
||||
if type(v) == "table" then
|
||||
BASE:I(string.rep(" ", indent) .. tostring(k) .. " = {")
|
||||
UTILS.PrintTableToLog(v, indent + 1)
|
||||
BASE:I(string.rep(" ", indent) .. "}")
|
||||
env.info(string.rep(" ", indent) .. tostring(k) .. " = {")
|
||||
text = text ..string.rep(" ", indent) .. tostring(k) .. " = {\n"
|
||||
text = text .. tostring(UTILS.PrintTableToLog(v, indent + 1)).."\n"
|
||||
env.info(string.rep(" ", indent) .. "},")
|
||||
text = text .. string.rep(" ", indent) .. "},\n"
|
||||
else
|
||||
BASE:I(string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(v))
|
||||
local value
|
||||
if tostring(v) == "true" or tostring(v) == "false" or tonumber(v) ~= nil then
|
||||
value=v
|
||||
else
|
||||
value = '"'..tostring(v)..'"'
|
||||
end
|
||||
env.info(string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(value)..",\n")
|
||||
text = text .. string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(value)..",\n"
|
||||
end
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
--- Returns table in a easy readable string representation.
|
||||
@@ -3325,7 +3341,7 @@ function UTILS.GetZoneProperties(zone_name)
|
||||
for _, property in pairs(zone["properties"]) do
|
||||
return_table[property["key"]] = property["value"]
|
||||
end
|
||||
return return_table
|
||||
return return_table
|
||||
else
|
||||
BASE:I(string.format("%s doesn't have any properties", zone_name))
|
||||
return {}
|
||||
@@ -3599,3 +3615,30 @@ function table.find_key_value_pair(tbl, key, value)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Convert a decimal to octal
|
||||
-- @param #number Number the number to convert
|
||||
-- @return #number Octal
|
||||
function UTILS.DecimalToOctal(Number)
|
||||
if Number < 8 then return Number end
|
||||
local number = tonumber(Number)
|
||||
local octal = ""
|
||||
local n=1
|
||||
while number > 7 do
|
||||
local number1 = number%8
|
||||
octal = string.format("%d",number1)..octal
|
||||
local number2 = math.abs(number/8)
|
||||
if number2 < 8 then
|
||||
octal = string.format("%d",number2)..octal
|
||||
end
|
||||
number = number2
|
||||
n=n+1
|
||||
end
|
||||
return tonumber(octal)
|
||||
end
|
||||
|
||||
--- Convert an octal to decimal
|
||||
-- @param #number Number the number to convert
|
||||
-- @return #number Decimal
|
||||
function UTILS.OctalToDecimal(Number)
|
||||
return tonumber(Number,8)
|
||||
end
|
||||
|
||||
@@ -239,6 +239,13 @@ AIRBASE.Nevada = {
|
||||
-- * AIRBASE.Normandy.Broglie
|
||||
-- * AIRBASE.Normandy.Bernay_Saint_Martin
|
||||
-- * AIRBASE.Normandy.Saint_Andre_de_lEure
|
||||
-- * AIRBASE.Normandy.Biggin_Hill
|
||||
-- * AIRBASE.Normandy.Manston
|
||||
-- * AIRBASE.Normandy.Detling
|
||||
-- * AIRBASE.Normandy.Lympne
|
||||
-- * AIRBASE.Normandy.Abbeville_Drucat
|
||||
-- * AIRBASE.Normandy.Merville_Calonne
|
||||
-- * AIRBASE.Normandy.Saint_Omer_Wizernes
|
||||
--
|
||||
-- @field Normandy
|
||||
AIRBASE.Normandy = {
|
||||
@@ -311,7 +318,14 @@ AIRBASE.Normandy = {
|
||||
["Beaumont_le_Roger"] = "Beaumont-le-Roger",
|
||||
["Broglie"] = "Broglie",
|
||||
["Bernay_Saint_Martin"] = "Bernay Saint Martin",
|
||||
["Saint_Andre_de_lEure"] = "Saint-Andre-de-lEure",
|
||||
["Saint_Andre_de_lEure"] = "Saint-Andre-de-lEure",
|
||||
["Biggin_Hill"] = "Biggin Hill",
|
||||
["Manston"] = "Manston",
|
||||
["Detling"] = "Detling",
|
||||
["Lympne"] = "Lympne",
|
||||
["Abbeville_Drucat"] = "Abbeville Drucat",
|
||||
["Merville_Calonne"] = "Merville Calonne",
|
||||
["Saint_Omer_Wizernes"] = "Saint-Omer Wizernes",
|
||||
}
|
||||
|
||||
--- Airbases of the Persion Gulf Map:
|
||||
|
||||
@@ -3974,7 +3974,7 @@ function CONTROLLABLE:OptionAAAttackRange( range )
|
||||
local Controller = self:_GetController()
|
||||
if Controller then
|
||||
if self:IsAir() then
|
||||
self:SetOption( AI.Option.Air.val.MISSILE_ATTACK, range )
|
||||
self:SetOption( AI.Option.Air.id.MISSILE_ATTACK, range )
|
||||
end
|
||||
end
|
||||
return self
|
||||
|
||||
@@ -1157,6 +1157,7 @@ function GROUP:GetAverageCoordinate()
|
||||
local coord = COORDINATE:NewFromVec3(vec3)
|
||||
local Heading = self:GetHeading()
|
||||
coord.Heading = Heading
|
||||
return coord
|
||||
else
|
||||
BASE:E( { "Cannot GetAverageCoordinate", Group = self, Alive = self:IsAlive() } )
|
||||
return nil
|
||||
@@ -2922,7 +2923,7 @@ function GROUP:GetCustomCallSign(ShortCallsign,Keepnumber,CallsignTranslations)
|
||||
return callsign
|
||||
end
|
||||
|
||||
---
|
||||
--- Set a GROUP to act as recovery tanker
|
||||
-- @param #GROUP self
|
||||
-- @param Wrapper.Group#GROUP CarrierGroup.
|
||||
-- @param #number Speed Speed in knots.
|
||||
@@ -2948,3 +2949,37 @@ function GROUP:SetAsRecoveryTanker(CarrierGroup,Speed,ToKIAS,Altitude,Delay,Last
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get a list of Link16 S/TN data from a GROUP. Can (as of Nov 2023) be obtained from F-18, F-16, F-15E (not the user flyable one) and A-10C-II groups.
|
||||
-- @param #GROUP self
|
||||
-- @return #table Table of data entries, indexed by unit name, each entry is a table containing STN, VCL (voice call label), VCN (voice call number), and Lead (#boolean, if true it's the flight lead)
|
||||
-- @return #string Report Formatted report of all data
|
||||
function GROUP:GetGroupSTN()
|
||||
local tSTN = {} -- table
|
||||
local units = self:GetUnits()
|
||||
local gname = self:GetName()
|
||||
gname = string.gsub(gname,"(#%d+)$","")
|
||||
local report = REPORT:New()
|
||||
report:Add("Link16 S/TN Report")
|
||||
report:Add("Group: "..gname)
|
||||
report:Add("==================")
|
||||
for _,_unit in pairs(units) do
|
||||
local unit = _unit -- Wrapper.Unit#UNIT
|
||||
if unit and unit:IsAlive() then
|
||||
local STN, VCL, VCN, Lead = unit:GetSTN()
|
||||
local name = unit:GetName()
|
||||
tSTN[name] = {
|
||||
STN=STN,
|
||||
VCL=VCL,
|
||||
VCN=VCN,
|
||||
Lead=Lead,
|
||||
}
|
||||
local lead = Lead == true and "(*)" or ""
|
||||
report:Add(string.format("| %s%s %s %s",tostring(VCL),tostring(VCN),tostring(STN),lead))
|
||||
end
|
||||
end
|
||||
report:Add("==================")
|
||||
local text = report:Text()
|
||||
return tSTN,text
|
||||
end
|
||||
|
||||
|
||||
@@ -1659,3 +1659,36 @@ function UNIT:GetSkill()
|
||||
local skill = _DATABASE.Templates.Units[name].Template.skill or "Random"
|
||||
return skill
|
||||
end
|
||||
|
||||
--- Get Link16 STN or SADL TN and other datalink info from Unit, if any.
|
||||
-- @param #UNIT self
|
||||
-- @return #string STN STN or TN Octal as string, or nil if not set/capable.
|
||||
-- @return #string VCL Voice Callsign Label or nil if not set/capable.
|
||||
-- @return #string VCN Voice Callsign Number or nil if not set/capable.
|
||||
-- @return #string Lead If true, unit is Flight Lead, else false or nil.
|
||||
function UNIT:GetSTN()
|
||||
self:F2(self.UnitName)
|
||||
local STN = nil -- STN/TN
|
||||
local VCL = nil -- VoiceCallsignLabel
|
||||
local VCN = nil -- VoiceCallsignNumber
|
||||
local FGL = false -- FlightGroupLeader
|
||||
local template = self:GetTemplate()
|
||||
if template.AddPropAircraft then
|
||||
if template.AddPropAircraft.STN_L16 then
|
||||
STN = template.AddPropAircraft.STN_L16
|
||||
elseif template.AddPropAircraft.SADL_TN then
|
||||
STN = template.AddPropAircraft.SADL_TN
|
||||
end
|
||||
VCN = template.AddPropAircraft.VoiceCallsignNumber
|
||||
VCL = template.AddPropAircraft.VoiceCallsignLabel
|
||||
end
|
||||
if template.datalinks and template.datalinks.Link16 and template.datalinks.Link16.settings then
|
||||
FGL = template.datalinks.Link16.settings.flightLead
|
||||
end
|
||||
-- A10CII
|
||||
if template.datalinks and template.datalinks.SADL and template.datalinks.SADL.settings then
|
||||
FGL = template.datalinks.SADL.settings.flightLead
|
||||
end
|
||||
|
||||
return STN, VCL, VCN, FGL
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user