From e8c75b87958da7358e7e74a2f480cd4b9d89f425 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 22 Feb 2024 11:52:43 +0100 Subject: [PATCH] SPAWN:InitSpeedMPS() etc --- Moose Development/Moose/Core/Base.lua | 1 + Moose Development/Moose/Core/Spawn.lua | 55 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index dede44ad3..6ab927288 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -1153,6 +1153,7 @@ function BASE:_Serialize(Arguments) text = string.gsub(text,"\n","") text = string.gsub(text,"%(%(","%(") text = string.gsub(text,"%)%)","%)") + text = string.gsub(text,"(%s+)","") return text end diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index 705da5929..65f7dba21 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -204,6 +204,17 @@ -- -- *{#SPAWN.InitSTN}(): Set the STN of the first unit in the group. All other units will have consecutive STNs, provided they have not been used yet. -- *{#SPAWN.InitSADL}(): Set the SADL of the first unit in the group. All other units will have consecutive SADLs, provided they have not been used yet. +-- +-- ### Callsigns +-- +-- *{#SPAWN.InitRandomizeCallsign}(): Set a random callsign name per spawn. +-- *{#SPAWN.SpawnInitCallSign}(): Set a specific callsign for a spawned group. +-- +-- ### Speed +-- +-- *{#SPAWN.InitSpeedMps}(): Set the initial speed on spawning in meters per second. +-- *{#SPAWN.InitSpeedKph}(): Set the initial speed on spawning in kilometers per hour. +-- *{#SPAWN.InitSpeedKnots}(): Set the initial speed on spawning in knots. -- -- ## SPAWN **Spawn** methods -- @@ -821,6 +832,46 @@ function SPAWN:InitSADL(Octal) return self end +--- [Airplane] Set the initial speed on spawning in meters per second. Useful when spawning in-air only. +-- @param #SPAWN self +-- @param #number MPS The speed in MPS to use. +-- @return #SPAWN self +function SPAWN:InitSpeedMps(MPS) +self:F( { MPS = MPS } ) + if MPS == nil or tonumber(MPS)<0 then + MPS=125 + end + self.InitSpeed = MPS + return self +end + +--- [Airplane] Set the initial speed on spawning in knots. Useful when spawning in-air only. +-- @param #SPAWN self +-- @param #number Knots The speed in knots to use. +-- @return #SPAWN self +function SPAWN:InitSpeedKnots(Knots) +self:F( { Knots = Knots } ) + if Knots == nil or tonumber(Knots)<0 then + Knots=300 + end + self.InitSpeed = UTILS.KnotsToMps(Knots) + return self +end + +--- [Airplane] Set the initial speed on spawning in kilometers per hour. Useful when spawning in-air only. +-- @param #SPAWN self +-- @param #number KPH The speed in KPH to use. +-- @return #SPAWN self +function SPAWN:InitSpeedKph(KPH) + self:F( { KPH = KPH } ) + if KPH == nil or tonumber(KPH)<0 then + KPH=UTILS.KnotsToKmph(300) + end + self.InitSpeed = UTILS.KmphToMps(KPH) + return self +end + + --- Sets the radio communication on or off. Same as checking/unchecking the COMM box in the mission editor. -- @param #SPAWN self -- @param #number switch If true (or nil), enables the radio communication. If false, disables the radio for the spawned group. @@ -3437,6 +3488,10 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2 SpawnTemplate.units[UnitID].callsign = Callsign + SpawnIndex end end + -- Speed + if self.InitSpeed then + SpawnTemplate.units[UnitID].speed = self.InitSpeed + end -- Link16 local AddProps = SpawnTemplate.units[UnitID].AddPropAircraft if AddProps then