From 2620370890b155f78b045121aa54709388c55710 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 1 May 2020 23:01:43 +0200 Subject: [PATCH] Fixes UTILS - Corrected Big Smoke and Fire presets. Issue #1313 CONTROLLABLE - Fixed callsign number in :CommandSetCallsign function. #1314 ENUMS - Added formations (old and new) --- Moose Development/Moose/Utilities/Enums.lua | 85 ++++++++++++++++++- Moose Development/Moose/Utilities/Utils.lua | 47 ++++++---- .../Moose/Wrapper/Controllable.lua | 5 +- 3 files changed, 116 insertions(+), 21 deletions(-) diff --git a/Moose Development/Moose/Utilities/Enums.lua b/Moose Development/Moose/Utilities/Enums.lua index f47e66b94..e59b958f5 100644 --- a/Moose Development/Moose/Utilities/Enums.lua +++ b/Moose Development/Moose/Utilities/Enums.lua @@ -160,4 +160,87 @@ ENUMS.MissionTask={ RUNWAYATTACK="Runway Attack", SEAD="SEAD", TRANSPORT="Transport", -} \ No newline at end of file +} + +--- Formations (new). See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki. +-- @type ENUMS.Formation +ENUMS.Formation={} +ENUMS.Formation.FixedWing={} +ENUMS.Formation.FixedWing.LineAbreast={} +ENUMS.Formation.FixedWing.LineAbreast.Close = 65537 +ENUMS.Formation.FixedWing.LineAbreast.Open = 65538 +ENUMS.Formation.FixedWing.LineAbreast.Group = 65539 +ENUMS.Formation.FixedWing.Trail={} +ENUMS.Formation.FixedWing.Trail.Close = 131073 +ENUMS.Formation.FixedWing.Trail.Open = 131074 +ENUMS.Formation.FixedWing.Trail.Group = 131075 +ENUMS.Formation.FixedWing.Wedge={} +ENUMS.Formation.FixedWing.Wedge.Close = 196609 +ENUMS.Formation.FixedWing.Wedge.Open = 196610 +ENUMS.Formation.FixedWing.Wedge.Group = 196611 +ENUMS.Formation.FixedWing.EchelonRight={} +ENUMS.Formation.FixedWing.EchelonRight.Close = 262145 +ENUMS.Formation.FixedWing.EchelonRight.Open = 262146 +ENUMS.Formation.FixedWing.EchelonRight.Group = 262147 +ENUMS.Formation.FixedWing.EchelonLeft={} +ENUMS.Formation.FixedWing.EchelonLeft.Close = 327681 +ENUMS.Formation.FixedWing.EchelonLeft.Open = 327682 +ENUMS.Formation.FixedWing.EchelonLeft.Group = 327683 +ENUMS.Formation.FixedWing.FingerFour={} +ENUMS.Formation.FixedWing.FingerFour.Close = 393217 +ENUMS.Formation.FixedWing.FingerFour.Open = 393218 +ENUMS.Formation.FixedWing.FingerFour.Group = 393219 +ENUMS.Formation.FixedWing.Spread={} +ENUMS.Formation.FixedWing.Spread.Close = 458753 +ENUMS.Formation.FixedWing.Spread.Open = 458754 +ENUMS.Formation.FixedWing.Spread.Group = 458755 +ENUMS.Formation.FixedWing.BomberElement={} +ENUMS.Formation.FixedWing.BomberElement.Close = 786433 +ENUMS.Formation.FixedWing.BomberElement.Open = 786434 +ENUMS.Formation.FixedWing.BomberElement.Group = 786435 +ENUMS.Formation.FixedWing.BomberElementHeight={} +ENUMS.Formation.FixedWing.BomberElementHeight.Close = 851968 +ENUMS.Formation.FixedWing.FighterVic={} +ENUMS.Formation.FixedWing.FighterVic.Close = 917505 +ENUMS.Formation.FixedWing.FighterVic.Open = 917506 +ENUMS.Formation.RotaryWing={} +ENUMS.Formation.RotaryWing.Column={} +ENUMS.Formation.RotaryWing.Column.D70=720896 +ENUMS.Formation.RotaryWing.Wedge={} +ENUMS.Formation.RotaryWing.Wedge.D70=8 +ENUMS.Formation.RotaryWing.FrontRight={} +ENUMS.Formation.RotaryWing.FrontRight.D300=655361 +ENUMS.Formation.RotaryWing.FrontRight.D600=655362 +ENUMS.Formation.RotaryWing.FrontLeft={} +ENUMS.Formation.RotaryWing.FrontLeft.D300=655617 +ENUMS.Formation.RotaryWing.FrontLeft.D600=655618 +ENUMS.Formation.RotaryWing.EchelonRight={} +ENUMS.Formation.RotaryWing.EchelonRight.D70 =589825 +ENUMS.Formation.RotaryWing.EchelonRight.D300=589826 +ENUMS.Formation.RotaryWing.EchelonRight.D600=589827 +ENUMS.Formation.RotaryWing.EchelonLeft={} +ENUMS.Formation.RotaryWing.EchelonLeft.D70 =590081 +ENUMS.Formation.RotaryWing.EchelonLeft.D300=590082 +ENUMS.Formation.RotaryWing.EchelonLeft.D600=590083 + +--- Formations (old). The old format is a simplified version of the new formation enums, which allow more sophisticated settings. +-- See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki. +-- @type ENUMS.FormationOld +ENUMS.FormationOld={} +ENUMS.FormationOld.FixedWing={} +ENUMS.FormationOld.FixedWing.LineAbreast=1 +ENUMS.FormationOld.FixedWing.Trail=2 +ENUMS.FormationOld.FixedWing.Wedge=3 +ENUMS.FormationOld.FixedWing.EchelonRight=4 +ENUMS.FormationOld.FixedWing.EchelonLeft=5 +ENUMS.FormationOld.FixedWing.FingerFour=6 +ENUMS.FormationOld.FixedWing.SpreadFour=7 +ENUMS.FormationOld.FixedWing.BomberElement=12 +ENUMS.FormationOld.FixedWing.BomberElementHeight=13 +ENUMS.FormationOld.FixedWing.FighterVic=14 +ENUMS.FormationOld={} +ENUMS.FormationOld.RotaryWing={} +ENUMS.FormationOld.RotaryWing.Wedge=8 +ENUMS.FormationOld.RotaryWing.Echelon=9 +ENUMS.FormationOld.RotaryWing.Front=10 +ENUMS.FormationOld.RotaryWing.Column=11 \ No newline at end of file diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 2980550b9..5bba94cc1 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -1,5 +1,4 @@ ---- This module contains derived utilities taken from the MIST framework, --- which are excellent tools to be reused in an OO environment!. +--- This module contains derived utilities taken from the MIST framework, which are excellent tools to be reused in an OO environment. -- -- ### Authors: -- @@ -33,14 +32,14 @@ FLARECOLOR = trigger.flareColor -- #FLARECOLOR --- Big smoke preset enum. -- @type BIGSMOKEPRESET BIGSMOKEPRESET = { - SmallSmokeAndFire=0, - MediumSmokeAndFire=1, - LargeSmokeAndFire=2, - HugeSmokeAndFire=3, - SmallSmoke=4, - MediumSmoke=5, - LargeSmoke=6, - HugeSmoke=7, + SmallSmokeAndFire=1, + MediumSmokeAndFire=2, + LargeSmokeAndFire=3, + HugeSmokeAndFire=4, + SmallSmoke=5, + MediumSmoke=6, + LargeSmoke=7, + HugeSmoke=8, } --- DCS map as returned by env.mission.theatre. @@ -116,6 +115,7 @@ CALLSIGN={ --- Utilities static class. -- @type UTILS +-- @field #number _MarkID Marker index counter. Running number when marker is added. UTILS = { _MarkID = 1 } @@ -183,7 +183,9 @@ UTILS.IsInstanceOf = function( object, className ) end ---from http://lua-users.org/wiki/CopyTable +--- Deep copy a table. See http://lua-users.org/wiki/CopyTable +-- @param #table object The input table. +-- @return #table Copy of the input table. UTILS.DeepCopy = function(object) local lookup_table = {} local function _copy(object) @@ -204,7 +206,8 @@ UTILS.DeepCopy = function(object) end --- porting in Slmod's serialize_slmod2 +--- Porting in Slmod's serialize_slmod2. +-- @param #table tbl Input table. UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function lookup_table = {} @@ -340,18 +343,30 @@ UTILS.MiphToMps = function( miph ) return miph * 0.44704 end +--- Convert meters per second to miles per hour. +-- @param #number mps Speed in m/s. +-- @return #number Speed in miles per hour. UTILS.MpsToMiph = function( mps ) return mps / 0.44704 end +--- Convert meters per second to knots. +-- @param #number knots Speed in m/s. +-- @return #number Speed in knots. UTILS.MpsToKnots = function( mps ) return mps * 1.94384 --3600 / 1852 end +--- Convert knots to meters per second. +-- @param #number knots Speed in knots. +-- @return #number Speed in m/s. UTILS.KnotsToMps = function( knots ) return knots / 1.94384 --* 1852 / 3600 end +--- Convert temperature from Celsius to Farenheit. +-- @param #number Celcius Temperature in degrees Celsius. +-- @return #number Temperature in degrees Farenheit. UTILS.CelciusToFarenheit = function( Celcius ) return Celcius * 9/5 + 32 end @@ -982,7 +997,7 @@ end --- Returns the DCS map/theatre as optained by env.mission.theatre --- @return #string DCS map name . +-- @return #string DCS map name. function UTILS.GetDCSMap() return env.mission.theatre end @@ -1100,7 +1115,7 @@ end --- Get the callsign name from its enumerator value -- @param #number Callsign The enumerator callsign. --- @return #string The callsign name. +-- @return #string The callsign name or "Ghostrider". function UTILS.GetCallsignName(Callsign) for name, value in pairs(CALLSIGN.Aircraft) do @@ -1127,7 +1142,5 @@ function UTILS.GetCallsignName(Callsign) end end - return "Unknown Calsing" + return "Ghostrider" end - --- Just a test to see commits in new environment for Wingthor \ No newline at end of file diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 828188dc9..e1be30eb4 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -751,7 +751,7 @@ end function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay) -- Command to set the callsign. - local CommandSetCallsign={id='SetCallsign', params={callname=CallName, callnumber=CallNumber or 1}} + local CommandSetCallsign={id='SetCallsign', params={callname=CallName, number=CallNumber or 1}} if Delay and Delay>0 then SCHEDULER:New(nil, self.CommandSetCallsign, {self, CallName, CallNumber}, Delay) @@ -1011,7 +1011,6 @@ function CONTROLLABLE:TaskCarpetBombing(Vec2, GroupAttack, WeaponExpend, AttackQ id = 'CarpetBombing', params = { attackType = "Carpet", - point = Vec2, x = Vec2.x, y = Vec2.y, groupAttack = GroupAttack and GroupAttack or false, @@ -1019,7 +1018,7 @@ function CONTROLLABLE:TaskCarpetBombing(Vec2, GroupAttack, WeaponExpend, AttackQ weaponType = WeaponType or ENUMS.WeaponFlag.AnyBomb, expend = WeaponExpend or "All", attackQtyLimit = AttackQty and true or false, - attackQty = AttackQty, + attackQty = AttackQty or 1, directionEnabled = Direction and true or false, direction = Direction and math.rad(Direction) or 0, altitudeEnabled = Altitude and true or false,