#UNIT #CTLD

* Stabilize that sometimes a unit coordinate cannot be found
This commit is contained in:
Applevangelist 2023-06-02 08:45:35 +02:00
commit f7e64bc9b5
2 changed files with 19 additions and 3 deletions

View File

@ -22,7 +22,7 @@
-- @module Ops.CTLD -- @module Ops.CTLD
-- @image OPS_CTLD.jpg -- @image OPS_CTLD.jpg
-- Last Update Apr 2023 -- Last Update June 2023
do do
@ -1221,7 +1221,7 @@ CTLD.UnitTypes = {
--- CTLD class version. --- CTLD class version.
-- @field #string version -- @field #string version
CTLD.version="1.0.37" CTLD.version="1.0.38"
--- Instantiate a new CTLD. --- Instantiate a new CTLD.
-- @param #CTLD self -- @param #CTLD self
@ -4308,6 +4308,9 @@ end
local uspeed = Unit:GetVelocityMPS() local uspeed = Unit:GetVelocityMPS()
local uheight = Unit:GetHeight() local uheight = Unit:GetHeight()
local ucoord = Unit:GetCoordinate() local ucoord = Unit:GetCoordinate()
if not ucoord then
return false
end
local gheight = ucoord:GetLandHeight() local gheight = ucoord:GetLandHeight()
local aheight = uheight - gheight -- height above ground local aheight = uheight - gheight -- height above ground
local maxh = self.maximumHoverHeight -- 15 local maxh = self.maximumHoverHeight -- 15
@ -4334,6 +4337,9 @@ end
local uspeed = Unit:GetVelocityMPS() local uspeed = Unit:GetVelocityMPS()
local uheight = Unit:GetHeight() local uheight = Unit:GetHeight()
local ucoord = Unit:GetCoordinate() local ucoord = Unit:GetCoordinate()
if not ucoord then
return false
end
local gheight = ucoord:GetLandHeight() local gheight = ucoord:GetLandHeight()
local aheight = uheight - gheight -- height above ground local aheight = uheight - gheight -- height above ground
local minh = self.HercMinAngels-- 1500m local minh = self.HercMinAngels-- 1500m
@ -4419,6 +4425,9 @@ end
end end
local uheight = Unit:GetHeight() local uheight = Unit:GetHeight()
local ucoord = Unit:GetCoordinate() local ucoord = Unit:GetCoordinate()
if not ucoord then
return false
end
local gheight = ucoord:GetLandHeight() local gheight = ucoord:GetLandHeight()
local aheight = uheight - gheight -- height above ground local aheight = uheight - gheight -- height above ground
if aheight >= minheight then if aheight >= minheight then

View File

@ -25,6 +25,7 @@
-- @field #string ClassName Name of the class. -- @field #string ClassName Name of the class.
-- @field #string UnitName Name of the unit. -- @field #string UnitName Name of the unit.
-- @field #string GroupName Name of the group the unit belongs to. -- @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 -- @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}). --- 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", ClassName="UNIT",
UnitName=nil, UnitName=nil,
GroupName=nil, GroupName=nil,
DCSUnit = nil,
} }
@ -124,6 +126,7 @@ function UNIT:Register( UnitName )
if group then if group then
self.GroupName=group:getName() self.GroupName=group:getName()
end end
self.DCSUnit = unit
end end
-- Set event prio. -- Set event prio.
@ -175,7 +178,11 @@ function UNIT:GetDCSObject()
if DCSUnit then if DCSUnit then
return DCSUnit return DCSUnit
end end
if self.DCSUnit then
return self.DCSUnit
end
return nil return nil
end end