Updates Misc

This commit is contained in:
Frank
2020-04-24 16:03:28 +02:00
parent df512f7a58
commit 7360c51a8f
10 changed files with 1026 additions and 517 deletions

View File

@@ -424,9 +424,9 @@ function UNIT:GetRange()
local Desc = self:GetDesc()
if Desc then
local Range = Desc.range --This is in nautical miles for some reason. But should check again!
local Range = Desc.range --This is in kilometers (not meters) for some reason. But should check again!
if Range then
Range=UTILS.NMToMeters(Range)
Range=Range*1000 -- convert to meters.
else
Range=10000000 --10.000 km if no range
end
@@ -436,6 +436,64 @@ function UNIT:GetRange()
return nil
end
--- Check if the unit is refuelable. Also retrieves the refuelling system (boom or probe) if applicable.
-- @param #UNIT self
-- @return #boolean If true, unit is refuelable (checks for the attribute "Refuelable").
-- @return #number Refueling system (if any): 0=boom, 1=probe.
function UNIT:IsRefuelable()
self:F2( self.UnitName )
local refuelable=self:HasAttribute("Refuelable")
local system=nil
local Desc=self:GetDesc()
if Desc and Desc.tankerType then
system=Desc.tankerType
end
return refuelable, system
end
--- Check if the unit is a tanker. Also retrieves the refuelling system (boom or probe) if applicable.
-- @param #UNIT self
-- @return #boolean If true, unit is refuelable (checks for the attribute "Refuelable").
-- @return #number Refueling system (if any): 0=boom, 1=probe.
function UNIT:IsTanker()
self:F2( self.UnitName )
local tanker=self:HasAttribute("Tankers")
local system=nil
if tanker then
local Desc=self:GetDesc()
if Desc and Desc.tankerType then
system=Desc.tankerType
end
local typename=self:GetTypeName()
-- Some hard coded data as this is not in the descriptors...
if typename=="IL-78M" then
system=1 --probe
elseif typename=="KC130" then
system=1 --probe
elseif typename=="KC135BDA" then
system=1 --probe
elseif typename=="KC135MPRS" then
system=1 --probe
elseif typename=="S-3B Tanker" then
system=1 --probe
end
end
return tanker, system
end
--- Returns the unit's group if it exist and nil otherwise.
-- @param Wrapper.Unit#UNIT self
-- @return Wrapper.Group#GROUP The Group of the Unit.
@@ -756,6 +814,27 @@ function UNIT:GetDamageRelative()
return 1
end
--- Returns the category of the #UNIT from descriptor. Returns one of
--
-- * Unit.Category.AIRPLANE
-- * Unit.Category.HELICOPTER
-- * Unit.Category.GROUND_UNIT
-- * Unit.Category.SHIP
-- * Unit.Category.STRUCTURE
--
-- @param #UNIT self
-- @return #number Unit category from `getDesc().category`.
function UNIT:GetUnitCategory()
self:F3( self.UnitName )
local DCSUnit = self:GetDCSObject()
if DCSUnit then
return DCSUnit:getDesc().category
end
return nil
end
--- Returns the category name of the #UNIT.
-- @param #UNIT self
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship
@@ -833,7 +912,9 @@ end
-- * Threat level 10: Unit is AAA.
--
--
-- @param #UNIT self
-- @param #UNIT self
-- @return #number Number between 0 (low threat level) and 10 (high threat level).
-- @return #string Some text.
function UNIT:GetThreatLevel()