From dd7a883a33c4200579abe6110377b448d7f51ba4 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 1 Jun 2023 10:02:51 +0200 Subject: [PATCH 1/2] Fixes --- Moose Development/Moose/Core/Database.lua | 2 +- Moose Development/Moose/Core/Spawn.lua | 2 +- Moose Development/Moose/Wrapper/Airbase.lua | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index b2c91dba2..4ad7f9e50 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -1124,7 +1124,7 @@ end -- @param #string AirbaseName Name of the airbase. -- @return #number Category. function DATABASE:GetCategoryFromAirbase( AirbaseName ) - return self.AIRBASES[AirbaseName]:GetCategory() + return self.AIRBASES[AirbaseName]:GetAirbaseCategory() end diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index 6e28be1a1..df22111c3 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -318,7 +318,7 @@ function SPAWN:New( SpawnTemplatePrefix ) self.SpawnInitRadio = nil -- No radio comms setting. self.SpawnInitModex = nil self.SpawnInitAirbase = nil - self.TweakedTemplate = true -- Check if the user is using self made template. + self.TweakedTemplate = false -- Check if the user is using self made template. self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned. else diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 07c2acf7e..0930f88ed 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -2295,3 +2295,17 @@ function AIRBASE:CheckOnRunWay(group, radius, despawn) return false end + +--- Get category of airbase. +-- @param #AIRBASE self +-- @return #number Category of airbase from GetDesc().category. +function AIRBASE:GetCategory() + return self.category +end + +--- Get category name of airbase. +-- @param #AIRBASE self +-- @return #string Category of airbase, i.e. Airdrome, Ship, or Helipad +function AIRBASE:GetCategoryName() + return AIRBASE.CategoryName[self.category] +end From 55ed39478246e4bcc83fd96a8ad83c315399d1d3 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 2 Jun 2023 08:44:14 +0200 Subject: [PATCH 2/2] #UNIT #CTLD * Stabilize that sometimes a unit coordinate cannot be found --- Moose Development/Moose/Ops/CTLD.lua | 13 +++++++++++-- Moose Development/Moose/Wrapper/Unit.lua | 9 ++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 04e84ee7d..0edb51e80 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -22,7 +22,7 @@ -- @module Ops.CTLD -- @image OPS_CTLD.jpg --- Last Update Apr 2023 +-- Last Update June 2023 do @@ -1221,7 +1221,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.37" +CTLD.version="1.0.38" --- Instantiate a new CTLD. -- @param #CTLD self @@ -4308,6 +4308,9 @@ end local uspeed = Unit:GetVelocityMPS() local uheight = Unit:GetHeight() local ucoord = Unit:GetCoordinate() + if not ucoord then + return false + end local gheight = ucoord:GetLandHeight() local aheight = uheight - gheight -- height above ground local maxh = self.maximumHoverHeight -- 15 @@ -4334,6 +4337,9 @@ end local uspeed = Unit:GetVelocityMPS() local uheight = Unit:GetHeight() local ucoord = Unit:GetCoordinate() + if not ucoord then + return false + end local gheight = ucoord:GetLandHeight() local aheight = uheight - gheight -- height above ground local minh = self.HercMinAngels-- 1500m @@ -4419,6 +4425,9 @@ end end local uheight = Unit:GetHeight() local ucoord = Unit:GetCoordinate() + if not ucoord then + return false + end local gheight = ucoord:GetLandHeight() local aheight = uheight - gheight -- height above ground if aheight >= minheight then diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 5eee9236a..e716269a2 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -25,6 +25,7 @@ -- @field #string ClassName Name of the class. -- @field #string UnitName Name of the unit. -- @field #string GroupName Name of the group the unit belongs to. +-- @field #table DCSUnit The DCS Unit object from the API. -- @extends Wrapper.Controllable#CONTROLLABLE --- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the global _DATABASE object (an instance of @{Core.Database#DATABASE}). @@ -92,6 +93,7 @@ UNIT = { ClassName="UNIT", UnitName=nil, GroupName=nil, + DCSUnit = nil, } @@ -124,6 +126,7 @@ function UNIT:Register( UnitName ) if group then self.GroupName=group:getName() end + self.DCSUnit = unit end -- Set event prio. @@ -175,7 +178,11 @@ function UNIT:GetDCSObject() if DCSUnit then return DCSUnit end - + + if self.DCSUnit then + return self.DCSUnit + end + return nil end