mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'develop' into FF/Ops
This commit is contained in:
commit
7538f63c00
@ -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,14 @@ 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
|
||||
|
||||
--- 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,10 +3284,58 @@ 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
|
||||
-- Ruskis
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
SpawnTemplate.units[UnitID].callsign = math.random(1,999)
|
||||
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
|
||||
-- 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
|
||||
@ -3289,6 +3346,61 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
||||
SpawnTemplate.units[UnitID].callsign = Callsign + SpawnIndex
|
||||
end
|
||||
end
|
||||
-- Link16
|
||||
local AddProps = SpawnTemplate.units[UnitID].AddPropAircraft
|
||||
if AddProps then
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 then
|
||||
-- 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].callsign[2] .. SpawnTemplate.units[UnitID].callsign[3]
|
||||
end
|
||||
-- VoiceCallsignLabel
|
||||
if SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignLabel 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
|
||||
-- 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
|
||||
|
||||
self:T3( { "Template:", SpawnTemplate } )
|
||||
|
||||
@ -1217,6 +1217,10 @@ end
|
||||
-- atis:Start()
|
||||
function MSRS:LoadConfigFile(Path,Filename)
|
||||
|
||||
if lfs == nil then
|
||||
env.info("*****Note - lfs and os need to be desanitized for MSRS to work!")
|
||||
return false
|
||||
end
|
||||
local path = Path or lfs.writedir()..MSRS.ConfigFilePath
|
||||
local file = Filename or MSRS.ConfigFileName or "Moose_MSRS.lua"
|
||||
local pathandfile = path..file
|
||||
|
||||
@ -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,19 +441,22 @@ 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 idents
|
||||
function UTILS.PrintTableToLog(table, indent)
|
||||
if not table then
|
||||
BASE:E("No table passed!")
|
||||
env.warning("No table passed!")
|
||||
return
|
||||
end
|
||||
if not indent then indent = 0 end
|
||||
for k, v in pairs(table) do
|
||||
if type(v) == "table" then
|
||||
BASE:I(string.rep(" ", indent) .. tostring(k) .. " = {")
|
||||
env.info(string.rep(" ", indent) .. tostring(k) .. " = {")
|
||||
UTILS.PrintTableToLog(v, indent + 1)
|
||||
BASE:I(string.rep(" ", indent) .. "}")
|
||||
env.info(string.rep(" ", indent) .. "}")
|
||||
else
|
||||
BASE:I(string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(v))
|
||||
env.info(string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -3325,7 +3328,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 +3602,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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user