Fix of bug #97

-- Fixed GROUP:IsAlive()
--- Returns if the Group is alive.
-- The Group must:
--
--   * Exist at run-time.
--   * Has at least one unit.
--
-- When the first @{Unit} of the Group is active, it will return true.
-- If the first @{Unit} of the Group is inactive, it will return false.
--
-- @param #GROUP self
-- @return #boolean true if the Group is alive and active.
-- @return #boolean false if the Group is alive but inactive.
-- @return #nil if the group does not exist anymore.

-- Fixed Identifiable:IsAlive()
--- Returns if the Identifiable is alive.
-- If the Identifiable is not alive, nil is returned.
-- If the Identifiable is alive, true is returned.
-- @param #IDENTIFIABLE self
-- @return #boolean true if Identifiable is alive.
-- @return #nil if the Identifiable is not existing or is not alive.

-- Fixed UNIT:IsAlive()
--- Returns if the Unit is alive.
-- If the Unit is not alive, nil is returned.
-- If the Unit is alive and active, true is returned.
-- If the Unit is alive but not active, false is returned.
-- @param #UNIT self
-- @return #boolean true if Unit is alive and active.
-- @return #boolean false if Unit is alive but not active.
-- @return #nil if the Unit is not existing or is not alive.

-- Updated all test missions, as this is a core change.
This commit is contained in:
FlightControl 2017-03-27 10:34:51 +02:00
parent 3a453ca7d9
commit 0ebcbb4879
150 changed files with 391 additions and 271 deletions

View File

@ -1,4 +1,6 @@
--- This module contains the GROUP class. --- **Wrapper** -- GROUP is a wrapper class for the DCS Class Group.
--
-- ===
-- --
-- The @{#GROUP} class is a wrapper class to handle the DCS Group objects: -- The @{#GROUP} class is a wrapper class to handle the DCS Group objects:
-- --
@ -55,8 +57,6 @@
--- ---
-- # GROUP class, extends @{Controllable#CONTROLLABLE} -- # GROUP class, extends @{Controllable#CONTROLLABLE}
-- --
-- ## GROUP reference methods
--
-- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object. -- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object.
-- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class). -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class).
-- --
@ -183,20 +183,34 @@ function GROUP:GetPositionVec3() -- Overridden from POSITIONABLE:GetPositionVec3
return nil return nil
end end
--- Returns if the DCS Group is alive. --- Returns if the Group is alive.
-- When the group exists at run-time, this method will return true, otherwise false. -- The Group must:
--
-- * Exist at run-time.
-- * Has at least one unit.
--
-- When the first @{Unit} of the Group is active, it will return true.
-- If the first @{Unit} of the Group is inactive, it will return false.
--
-- @param #GROUP self -- @param #GROUP self
-- @return #boolean true if the DCS Group is alive. -- @return #boolean true if the Group is alive and active.
-- @return #boolean false if the Group is alive but inactive.
-- @return #nil if the group does not exist anymore.
function GROUP:IsAlive() function GROUP:IsAlive()
self:F2( self.GroupName ) self:F2( self.GroupName )
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject() -- Dcs.DCSGroup#Group
if DCSGroup then if DCSGroup then
local GroupIsAlive = DCSGroup:isExist() and DCSGroup:getUnit(1) ~= nil if DCSGroup:isExist() then
local DCSUnit = DCSGroup:getUnit(1) -- Dcs.DCSUnit#Unit
if DCSUnit then
local GroupIsAlive = DCSUnit:isActive()
self:T3( GroupIsAlive ) self:T3( GroupIsAlive )
return GroupIsAlive return GroupIsAlive
end end
end
end
return nil return nil
end end

View File

@ -59,13 +59,15 @@ function IDENTIFIABLE:New( IdentifiableName )
end end
--- Returns if the Identifiable is alive. --- Returns if the Identifiable is alive.
-- If the Identifiable is not alive, nil is returned.
-- If the Identifiable is alive, true is returned.
-- @param #IDENTIFIABLE self -- @param #IDENTIFIABLE self
-- @return #boolean true if Identifiable is alive. -- @return #boolean true if Identifiable is alive.
-- @return #nil The DCS Identifiable is not existing or alive. -- @return #nil if the Identifiable is not existing or is not alive.
function IDENTIFIABLE:IsAlive() function IDENTIFIABLE:IsAlive()
self:F3( self.IdentifiableName ) self:F3( self.IdentifiableName )
local DCSIdentifiable = self:GetDCSObject() local DCSIdentifiable = self:GetDCSObject() -- Dcs.DCSObject#Object
if DCSIdentifiable then if DCSIdentifiable then
local IdentifiableIsAlive = DCSIdentifiable:isExist() local IdentifiableIsAlive = DCSIdentifiable:isExist()

View File

@ -1,7 +1,7 @@
--- This module contains the UNIT class. --- **Wrapper** - UNIT is a wrapper class for the DCS Class Unit.
--
-- ===
-- --
-- 1) @{#UNIT} class, extends @{Controllable#CONTROLLABLE}
-- ===========================================================
-- The @{#UNIT} class is a wrapper class to handle the DCS Unit objects: -- The @{#UNIT} class is a wrapper class to handle the DCS Unit objects:
-- --
-- * Support all DCS Unit APIs. -- * Support all DCS Unit APIs.
@ -9,9 +9,14 @@
-- * Handle local Unit Controller. -- * Handle local Unit Controller.
-- * Manage the "state" of the DCS Unit. -- * Manage the "state" of the DCS Unit.
-- --
-- @module Unit
--- @type UNIT
-- @extends Wrapper.Controllable#CONTROLLABLE
---
-- # UNIT class, extends @{Controllable#CONTROLLABLE}
-- --
-- 1.1) UNIT reference methods
-- ----------------------
-- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object. -- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object.
-- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the @{SPAWN} class). -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the @{SPAWN} class).
-- --
@ -29,15 +34,15 @@
-- --
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil). -- IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil).
-- --
-- 1.2) DCS UNIT APIs -- ## DCS UNIT APIs
-- ------------------ --
-- The DCS Unit APIs are used extensively within MOOSE. The UNIT class has for each DCS Unit API a corresponding method. -- The DCS Unit APIs are used extensively within MOOSE. The UNIT class has for each DCS Unit API a corresponding method.
-- To be able to distinguish easily in your code the difference between a UNIT API call and a DCS Unit API call, -- To be able to distinguish easily in your code the difference between a UNIT API call and a DCS Unit API call,
-- the first letter of the method is also capitalized. So, by example, the DCS Unit method @{DCSWrapper.Unit#Unit.getName}() -- the first letter of the method is also capitalized. So, by example, the DCS Unit method @{DCSWrapper.Unit#Unit.getName}()
-- is implemented in the UNIT class as @{#UNIT.GetName}(). -- is implemented in the UNIT class as @{#UNIT.GetName}().
-- --
-- 1.3) Smoke, Flare Units -- ## Smoke, Flare Units
-- ----------------------- --
-- The UNIT class provides methods to smoke or flare units easily. -- The UNIT class provides methods to smoke or flare units easily.
-- The @{#UNIT.SmokeBlue}(), @{#UNIT.SmokeGreen}(),@{#UNIT.SmokeOrange}(), @{#UNIT.SmokeRed}(), @{#UNIT.SmokeRed}() methods -- The @{#UNIT.SmokeBlue}(), @{#UNIT.SmokeGreen}(),@{#UNIT.SmokeOrange}(), @{#UNIT.SmokeRed}(), @{#UNIT.SmokeRed}() methods
-- will smoke the unit in the corresponding color. Note that smoking a unit is done at the current position of the DCS Unit. -- will smoke the unit in the corresponding color. Note that smoking a unit is done at the current position of the DCS Unit.
@ -45,36 +50,29 @@
-- The @{#UNIT.FlareGreen}(), @{#UNIT.FlareRed}(), @{#UNIT.FlareWhite}(), @{#UNIT.FlareYellow}() -- The @{#UNIT.FlareGreen}(), @{#UNIT.FlareRed}(), @{#UNIT.FlareWhite}(), @{#UNIT.FlareYellow}()
-- methods will fire off a flare in the air with the corresponding color. Note that a flare is a one-off shot and its effect is of very short duration. -- methods will fire off a flare in the air with the corresponding color. Note that a flare is a one-off shot and its effect is of very short duration.
-- --
-- 1.4) Location Position, Point -- ## Location Position, Point
-- ----------------------------- --
-- The UNIT class provides methods to obtain the current point or position of the DCS Unit. -- The UNIT class provides methods to obtain the current point or position of the DCS Unit.
-- The @{#UNIT.GetPointVec2}(), @{#UNIT.GetVec3}() will obtain the current **location** of the DCS Unit in a Vec2 (2D) or a **point** in a Vec3 (3D) vector respectively. -- The @{#UNIT.GetPointVec2}(), @{#UNIT.GetVec3}() will obtain the current **location** of the DCS Unit in a Vec2 (2D) or a **point** in a Vec3 (3D) vector respectively.
-- If you want to obtain the complete **3D position** including ori<72>ntation and direction vectors, consult the @{#UNIT.GetPositionVec3}() method respectively. -- If you want to obtain the complete **3D position** including ori<72>ntation and direction vectors, consult the @{#UNIT.GetPositionVec3}() method respectively.
-- --
-- 1.5) Test if alive -- ## Test if alive
-- ------------------ --
-- The @{#UNIT.IsAlive}(), @{#UNIT.IsActive}() methods determines if the DCS Unit is alive, meaning, it is existing and active. -- The @{#UNIT.IsAlive}(), @{#UNIT.IsActive}() methods determines if the DCS Unit is alive, meaning, it is existing and active.
-- --
-- 1.6) Test for proximity -- ## Test for proximity
-- ----------------------- --
-- The UNIT class contains methods to test the location or proximity against zones or other objects. -- The UNIT class contains methods to test the location or proximity against zones or other objects.
-- --
-- ### 1.6.1) Zones -- ### Zones
--
-- To test whether the Unit is within a **zone**, use the @{#UNIT.IsInZone}() or the @{#UNIT.IsNotInZone}() methods. Any zone can be tested on, but the zone must be derived from @{Zone#ZONE_BASE}. -- To test whether the Unit is within a **zone**, use the @{#UNIT.IsInZone}() or the @{#UNIT.IsNotInZone}() methods. Any zone can be tested on, but the zone must be derived from @{Zone#ZONE_BASE}.
-- --
-- ### 1.6.2) Units -- ### Units
--
-- Test if another DCS Unit is within a given radius of the current DCS Unit, use the @{#UNIT.OtherUnitInRadius}() method. -- Test if another DCS Unit is within a given radius of the current DCS Unit, use the @{#UNIT.OtherUnitInRadius}() method.
-- --
-- @module Unit -- @field #UNIT UNIT
-- @author FlightControl
--- The UNIT class
-- @type UNIT
-- @extends Wrapper.Controllable#CONTROLLABLE
UNIT = { UNIT = {
ClassName="UNIT", ClassName="UNIT",
} }
@ -216,7 +214,7 @@ function UNIT:ReSpawn( SpawnVec3, Heading )
end end
-- Remove obscolete units from the group structure -- Remove obscolete units from the group structure
i = 1 local i = 1
while i <= #SpawnGroupTemplate.units do while i <= #SpawnGroupTemplate.units do
local UnitTemplateData = SpawnGroupTemplate.units[i] local UnitTemplateData = SpawnGroupTemplate.units[i]
@ -252,6 +250,27 @@ function UNIT:IsActive()
return nil return nil
end end
--- Returns if the Unit is alive.
-- If the Unit is not alive, nil is returned.
-- If the Unit is alive and active, true is returned.
-- If the Unit is alive but not active, false is returned.
-- @param #UNIT self
-- @return #boolean true if Unit is alive and active.
-- @return #boolean false if Unit is alive but not active.
-- @return #nil if the Unit is not existing or is not alive.
function UNIT:IsAlive()
self:F3( self.UnitName )
local DCSUnit = self:GetDCSObject() -- Dcs.DCSUnit#Unit
if DCSUnit then
local UnitIsAlive = DCSUnit:isExist() and DCSUnit:isActive()
return UnitIsAlive
end
return nil
end
--- Returns the Unit's callsign - the localized string. --- Returns the Unit's callsign - the localized string.

View File

@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' ) env.info( '*** MOOSE STATIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20170326_0853' ) env.info( 'Moose Generation Timestamp: 20170327_1033' )
local base = _G local base = _G
Include = {} Include = {}
@ -13242,13 +13242,15 @@ function IDENTIFIABLE:New( IdentifiableName )
end end
--- Returns if the Identifiable is alive. --- Returns if the Identifiable is alive.
-- If the Identifiable is not alive, nil is returned.
-- If the Identifiable is alive, true is returned.
-- @param #IDENTIFIABLE self -- @param #IDENTIFIABLE self
-- @return #boolean true if Identifiable is alive. -- @return #boolean true if Identifiable is alive.
-- @return #nil The DCS Identifiable is not existing or alive. -- @return #nil if the Identifiable is not existing or is not alive.
function IDENTIFIABLE:IsAlive() function IDENTIFIABLE:IsAlive()
self:F3( self.IdentifiableName ) self:F3( self.IdentifiableName )
local DCSIdentifiable = self:GetDCSObject() local DCSIdentifiable = self:GetDCSObject() -- Dcs.DCSObject#Object
if DCSIdentifiable then if DCSIdentifiable then
local IdentifiableIsAlive = DCSIdentifiable:isExist() local IdentifiableIsAlive = DCSIdentifiable:isExist()
@ -16070,7 +16072,9 @@ function CONTROLLABLE:WayPointExecute( WayPoint, WaitTime )
return self return self
end end
-- Message APIs--- This module contains the GROUP class. -- Message APIs--- **Wrapper** -- GROUP is a wrapper class for the DCS Class Group.
--
-- ===
-- --
-- The @{#GROUP} class is a wrapper class to handle the DCS Group objects: -- The @{#GROUP} class is a wrapper class to handle the DCS Group objects:
-- --
@ -16127,8 +16131,6 @@ end
--- ---
-- # GROUP class, extends @{Controllable#CONTROLLABLE} -- # GROUP class, extends @{Controllable#CONTROLLABLE}
-- --
-- ## GROUP reference methods
--
-- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object. -- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object.
-- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class). -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class).
-- --
@ -16255,20 +16257,34 @@ function GROUP:GetPositionVec3() -- Overridden from POSITIONABLE:GetPositionVec3
return nil return nil
end end
--- Returns if the DCS Group is alive. --- Returns if the Group is alive.
-- When the group exists at run-time, this method will return true, otherwise false. -- The Group must:
--
-- * Exist at run-time.
-- * Has at least one unit.
--
-- When the first @{Unit} of the Group is active, it will return true.
-- If the first @{Unit} of the Group is inactive, it will return false.
--
-- @param #GROUP self -- @param #GROUP self
-- @return #boolean true if the DCS Group is alive. -- @return #boolean true if the Group is alive and active.
-- @return #boolean false if the Group is alive but inactive.
-- @return #nil if the group does not exist anymore.
function GROUP:IsAlive() function GROUP:IsAlive()
self:F2( self.GroupName ) self:F2( self.GroupName )
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject() -- Dcs.DCSGroup#Group
if DCSGroup then if DCSGroup then
local GroupIsAlive = DCSGroup:isExist() and DCSGroup:getUnit(1) ~= nil if DCSGroup:isExist() then
local DCSUnit = DCSGroup:getUnit(1) -- Dcs.DCSUnit#Unit
if DCSUnit then
local GroupIsAlive = DCSUnit:isActive()
self:T3( GroupIsAlive ) self:T3( GroupIsAlive )
return GroupIsAlive return GroupIsAlive
end end
end
end
return nil return nil
end end
@ -17099,10 +17115,10 @@ do -- Players
return PlayerNames return PlayerNames
end end
end--- This module contains the UNIT class. end--- **Wrapper** - UNIT is a wrapper class for the DCS Class Unit.
--
-- ===
-- --
-- 1) @{#UNIT} class, extends @{Controllable#CONTROLLABLE}
-- ===========================================================
-- The @{#UNIT} class is a wrapper class to handle the DCS Unit objects: -- The @{#UNIT} class is a wrapper class to handle the DCS Unit objects:
-- --
-- * Support all DCS Unit APIs. -- * Support all DCS Unit APIs.
@ -17110,9 +17126,14 @@ end--- This module contains the UNIT class.
-- * Handle local Unit Controller. -- * Handle local Unit Controller.
-- * Manage the "state" of the DCS Unit. -- * Manage the "state" of the DCS Unit.
-- --
-- @module Unit
--- @type UNIT
-- @extends Wrapper.Controllable#CONTROLLABLE
---
-- # UNIT class, extends @{Controllable#CONTROLLABLE}
-- --
-- 1.1) UNIT reference methods
-- ----------------------
-- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object. -- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object.
-- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the @{SPAWN} class). -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the @{SPAWN} class).
-- --
@ -17130,15 +17151,15 @@ end--- This module contains the UNIT class.
-- --
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil). -- IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil).
-- --
-- 1.2) DCS UNIT APIs -- ## DCS UNIT APIs
-- ------------------ --
-- The DCS Unit APIs are used extensively within MOOSE. The UNIT class has for each DCS Unit API a corresponding method. -- The DCS Unit APIs are used extensively within MOOSE. The UNIT class has for each DCS Unit API a corresponding method.
-- To be able to distinguish easily in your code the difference between a UNIT API call and a DCS Unit API call, -- To be able to distinguish easily in your code the difference between a UNIT API call and a DCS Unit API call,
-- the first letter of the method is also capitalized. So, by example, the DCS Unit method @{DCSWrapper.Unit#Unit.getName}() -- the first letter of the method is also capitalized. So, by example, the DCS Unit method @{DCSWrapper.Unit#Unit.getName}()
-- is implemented in the UNIT class as @{#UNIT.GetName}(). -- is implemented in the UNIT class as @{#UNIT.GetName}().
-- --
-- 1.3) Smoke, Flare Units -- ## Smoke, Flare Units
-- ----------------------- --
-- The UNIT class provides methods to smoke or flare units easily. -- The UNIT class provides methods to smoke or flare units easily.
-- The @{#UNIT.SmokeBlue}(), @{#UNIT.SmokeGreen}(),@{#UNIT.SmokeOrange}(), @{#UNIT.SmokeRed}(), @{#UNIT.SmokeRed}() methods -- The @{#UNIT.SmokeBlue}(), @{#UNIT.SmokeGreen}(),@{#UNIT.SmokeOrange}(), @{#UNIT.SmokeRed}(), @{#UNIT.SmokeRed}() methods
-- will smoke the unit in the corresponding color. Note that smoking a unit is done at the current position of the DCS Unit. -- will smoke the unit in the corresponding color. Note that smoking a unit is done at the current position of the DCS Unit.
@ -17146,36 +17167,29 @@ end--- This module contains the UNIT class.
-- The @{#UNIT.FlareGreen}(), @{#UNIT.FlareRed}(), @{#UNIT.FlareWhite}(), @{#UNIT.FlareYellow}() -- The @{#UNIT.FlareGreen}(), @{#UNIT.FlareRed}(), @{#UNIT.FlareWhite}(), @{#UNIT.FlareYellow}()
-- methods will fire off a flare in the air with the corresponding color. Note that a flare is a one-off shot and its effect is of very short duration. -- methods will fire off a flare in the air with the corresponding color. Note that a flare is a one-off shot and its effect is of very short duration.
-- --
-- 1.4) Location Position, Point -- ## Location Position, Point
-- ----------------------------- --
-- The UNIT class provides methods to obtain the current point or position of the DCS Unit. -- The UNIT class provides methods to obtain the current point or position of the DCS Unit.
-- The @{#UNIT.GetPointVec2}(), @{#UNIT.GetVec3}() will obtain the current **location** of the DCS Unit in a Vec2 (2D) or a **point** in a Vec3 (3D) vector respectively. -- The @{#UNIT.GetPointVec2}(), @{#UNIT.GetVec3}() will obtain the current **location** of the DCS Unit in a Vec2 (2D) or a **point** in a Vec3 (3D) vector respectively.
-- If you want to obtain the complete **3D position** including ori<72>ntation and direction vectors, consult the @{#UNIT.GetPositionVec3}() method respectively. -- If you want to obtain the complete **3D position** including ori<72>ntation and direction vectors, consult the @{#UNIT.GetPositionVec3}() method respectively.
-- --
-- 1.5) Test if alive -- ## Test if alive
-- ------------------ --
-- The @{#UNIT.IsAlive}(), @{#UNIT.IsActive}() methods determines if the DCS Unit is alive, meaning, it is existing and active. -- The @{#UNIT.IsAlive}(), @{#UNIT.IsActive}() methods determines if the DCS Unit is alive, meaning, it is existing and active.
-- --
-- 1.6) Test for proximity -- ## Test for proximity
-- ----------------------- --
-- The UNIT class contains methods to test the location or proximity against zones or other objects. -- The UNIT class contains methods to test the location or proximity against zones or other objects.
-- --
-- ### 1.6.1) Zones -- ### Zones
--
-- To test whether the Unit is within a **zone**, use the @{#UNIT.IsInZone}() or the @{#UNIT.IsNotInZone}() methods. Any zone can be tested on, but the zone must be derived from @{Zone#ZONE_BASE}. -- To test whether the Unit is within a **zone**, use the @{#UNIT.IsInZone}() or the @{#UNIT.IsNotInZone}() methods. Any zone can be tested on, but the zone must be derived from @{Zone#ZONE_BASE}.
-- --
-- ### 1.6.2) Units -- ### Units
--
-- Test if another DCS Unit is within a given radius of the current DCS Unit, use the @{#UNIT.OtherUnitInRadius}() method. -- Test if another DCS Unit is within a given radius of the current DCS Unit, use the @{#UNIT.OtherUnitInRadius}() method.
-- --
-- @module Unit -- @field #UNIT UNIT
-- @author FlightControl
--- The UNIT class
-- @type UNIT
-- @extends Wrapper.Controllable#CONTROLLABLE
UNIT = { UNIT = {
ClassName="UNIT", ClassName="UNIT",
} }
@ -17317,7 +17331,7 @@ function UNIT:ReSpawn( SpawnVec3, Heading )
end end
-- Remove obscolete units from the group structure -- Remove obscolete units from the group structure
i = 1 local i = 1
while i <= #SpawnGroupTemplate.units do while i <= #SpawnGroupTemplate.units do
local UnitTemplateData = SpawnGroupTemplate.units[i] local UnitTemplateData = SpawnGroupTemplate.units[i]
@ -17353,6 +17367,27 @@ function UNIT:IsActive()
return nil return nil
end end
--- Returns if the Unit is alive.
-- If the Unit is not alive, nil is returned.
-- If the Unit is alive and active, true is returned.
-- If the Unit is alive but not active, false is returned.
-- @param #UNIT self
-- @return #boolean true if Unit is alive and active.
-- @return #boolean false if Unit is alive but not active.
-- @return #nil if the Unit is not existing or is not alive.
function UNIT:IsAlive()
self:F3( self.UnitName )
local DCSUnit = self:GetDCSObject() -- Dcs.DCSUnit#Unit
if DCSUnit then
local UnitIsAlive = DCSUnit:isExist() and DCSUnit:isActive()
return UnitIsAlive
end
return nil
end
--- Returns the Unit's callsign - the localized string. --- Returns the Unit's callsign - the localized string.

View File

@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' ) env.info( '*** MOOSE STATIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20170326_0853' ) env.info( 'Moose Generation Timestamp: 20170327_1033' )
local base = _G local base = _G
Include = {} Include = {}
@ -13242,13 +13242,15 @@ function IDENTIFIABLE:New( IdentifiableName )
end end
--- Returns if the Identifiable is alive. --- Returns if the Identifiable is alive.
-- If the Identifiable is not alive, nil is returned.
-- If the Identifiable is alive, true is returned.
-- @param #IDENTIFIABLE self -- @param #IDENTIFIABLE self
-- @return #boolean true if Identifiable is alive. -- @return #boolean true if Identifiable is alive.
-- @return #nil The DCS Identifiable is not existing or alive. -- @return #nil if the Identifiable is not existing or is not alive.
function IDENTIFIABLE:IsAlive() function IDENTIFIABLE:IsAlive()
self:F3( self.IdentifiableName ) self:F3( self.IdentifiableName )
local DCSIdentifiable = self:GetDCSObject() local DCSIdentifiable = self:GetDCSObject() -- Dcs.DCSObject#Object
if DCSIdentifiable then if DCSIdentifiable then
local IdentifiableIsAlive = DCSIdentifiable:isExist() local IdentifiableIsAlive = DCSIdentifiable:isExist()
@ -16070,7 +16072,9 @@ function CONTROLLABLE:WayPointExecute( WayPoint, WaitTime )
return self return self
end end
-- Message APIs--- This module contains the GROUP class. -- Message APIs--- **Wrapper** -- GROUP is a wrapper class for the DCS Class Group.
--
-- ===
-- --
-- The @{#GROUP} class is a wrapper class to handle the DCS Group objects: -- The @{#GROUP} class is a wrapper class to handle the DCS Group objects:
-- --
@ -16127,8 +16131,6 @@ end
--- ---
-- # GROUP class, extends @{Controllable#CONTROLLABLE} -- # GROUP class, extends @{Controllable#CONTROLLABLE}
-- --
-- ## GROUP reference methods
--
-- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object. -- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object.
-- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class). -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class).
-- --
@ -16255,20 +16257,34 @@ function GROUP:GetPositionVec3() -- Overridden from POSITIONABLE:GetPositionVec3
return nil return nil
end end
--- Returns if the DCS Group is alive. --- Returns if the Group is alive.
-- When the group exists at run-time, this method will return true, otherwise false. -- The Group must:
--
-- * Exist at run-time.
-- * Has at least one unit.
--
-- When the first @{Unit} of the Group is active, it will return true.
-- If the first @{Unit} of the Group is inactive, it will return false.
--
-- @param #GROUP self -- @param #GROUP self
-- @return #boolean true if the DCS Group is alive. -- @return #boolean true if the Group is alive and active.
-- @return #boolean false if the Group is alive but inactive.
-- @return #nil if the group does not exist anymore.
function GROUP:IsAlive() function GROUP:IsAlive()
self:F2( self.GroupName ) self:F2( self.GroupName )
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject() -- Dcs.DCSGroup#Group
if DCSGroup then if DCSGroup then
local GroupIsAlive = DCSGroup:isExist() and DCSGroup:getUnit(1) ~= nil if DCSGroup:isExist() then
local DCSUnit = DCSGroup:getUnit(1) -- Dcs.DCSUnit#Unit
if DCSUnit then
local GroupIsAlive = DCSUnit:isActive()
self:T3( GroupIsAlive ) self:T3( GroupIsAlive )
return GroupIsAlive return GroupIsAlive
end end
end
end
return nil return nil
end end
@ -17099,10 +17115,10 @@ do -- Players
return PlayerNames return PlayerNames
end end
end--- This module contains the UNIT class. end--- **Wrapper** - UNIT is a wrapper class for the DCS Class Unit.
--
-- ===
-- --
-- 1) @{#UNIT} class, extends @{Controllable#CONTROLLABLE}
-- ===========================================================
-- The @{#UNIT} class is a wrapper class to handle the DCS Unit objects: -- The @{#UNIT} class is a wrapper class to handle the DCS Unit objects:
-- --
-- * Support all DCS Unit APIs. -- * Support all DCS Unit APIs.
@ -17110,9 +17126,14 @@ end--- This module contains the UNIT class.
-- * Handle local Unit Controller. -- * Handle local Unit Controller.
-- * Manage the "state" of the DCS Unit. -- * Manage the "state" of the DCS Unit.
-- --
-- @module Unit
--- @type UNIT
-- @extends Wrapper.Controllable#CONTROLLABLE
---
-- # UNIT class, extends @{Controllable#CONTROLLABLE}
-- --
-- 1.1) UNIT reference methods
-- ----------------------
-- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object. -- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object.
-- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the @{SPAWN} class). -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the @{SPAWN} class).
-- --
@ -17130,15 +17151,15 @@ end--- This module contains the UNIT class.
-- --
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil). -- IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil).
-- --
-- 1.2) DCS UNIT APIs -- ## DCS UNIT APIs
-- ------------------ --
-- The DCS Unit APIs are used extensively within MOOSE. The UNIT class has for each DCS Unit API a corresponding method. -- The DCS Unit APIs are used extensively within MOOSE. The UNIT class has for each DCS Unit API a corresponding method.
-- To be able to distinguish easily in your code the difference between a UNIT API call and a DCS Unit API call, -- To be able to distinguish easily in your code the difference between a UNIT API call and a DCS Unit API call,
-- the first letter of the method is also capitalized. So, by example, the DCS Unit method @{DCSWrapper.Unit#Unit.getName}() -- the first letter of the method is also capitalized. So, by example, the DCS Unit method @{DCSWrapper.Unit#Unit.getName}()
-- is implemented in the UNIT class as @{#UNIT.GetName}(). -- is implemented in the UNIT class as @{#UNIT.GetName}().
-- --
-- 1.3) Smoke, Flare Units -- ## Smoke, Flare Units
-- ----------------------- --
-- The UNIT class provides methods to smoke or flare units easily. -- The UNIT class provides methods to smoke or flare units easily.
-- The @{#UNIT.SmokeBlue}(), @{#UNIT.SmokeGreen}(),@{#UNIT.SmokeOrange}(), @{#UNIT.SmokeRed}(), @{#UNIT.SmokeRed}() methods -- The @{#UNIT.SmokeBlue}(), @{#UNIT.SmokeGreen}(),@{#UNIT.SmokeOrange}(), @{#UNIT.SmokeRed}(), @{#UNIT.SmokeRed}() methods
-- will smoke the unit in the corresponding color. Note that smoking a unit is done at the current position of the DCS Unit. -- will smoke the unit in the corresponding color. Note that smoking a unit is done at the current position of the DCS Unit.
@ -17146,36 +17167,29 @@ end--- This module contains the UNIT class.
-- The @{#UNIT.FlareGreen}(), @{#UNIT.FlareRed}(), @{#UNIT.FlareWhite}(), @{#UNIT.FlareYellow}() -- The @{#UNIT.FlareGreen}(), @{#UNIT.FlareRed}(), @{#UNIT.FlareWhite}(), @{#UNIT.FlareYellow}()
-- methods will fire off a flare in the air with the corresponding color. Note that a flare is a one-off shot and its effect is of very short duration. -- methods will fire off a flare in the air with the corresponding color. Note that a flare is a one-off shot and its effect is of very short duration.
-- --
-- 1.4) Location Position, Point -- ## Location Position, Point
-- ----------------------------- --
-- The UNIT class provides methods to obtain the current point or position of the DCS Unit. -- The UNIT class provides methods to obtain the current point or position of the DCS Unit.
-- The @{#UNIT.GetPointVec2}(), @{#UNIT.GetVec3}() will obtain the current **location** of the DCS Unit in a Vec2 (2D) or a **point** in a Vec3 (3D) vector respectively. -- The @{#UNIT.GetPointVec2}(), @{#UNIT.GetVec3}() will obtain the current **location** of the DCS Unit in a Vec2 (2D) or a **point** in a Vec3 (3D) vector respectively.
-- If you want to obtain the complete **3D position** including ori<72>ntation and direction vectors, consult the @{#UNIT.GetPositionVec3}() method respectively. -- If you want to obtain the complete **3D position** including ori<72>ntation and direction vectors, consult the @{#UNIT.GetPositionVec3}() method respectively.
-- --
-- 1.5) Test if alive -- ## Test if alive
-- ------------------ --
-- The @{#UNIT.IsAlive}(), @{#UNIT.IsActive}() methods determines if the DCS Unit is alive, meaning, it is existing and active. -- The @{#UNIT.IsAlive}(), @{#UNIT.IsActive}() methods determines if the DCS Unit is alive, meaning, it is existing and active.
-- --
-- 1.6) Test for proximity -- ## Test for proximity
-- ----------------------- --
-- The UNIT class contains methods to test the location or proximity against zones or other objects. -- The UNIT class contains methods to test the location or proximity against zones or other objects.
-- --
-- ### 1.6.1) Zones -- ### Zones
--
-- To test whether the Unit is within a **zone**, use the @{#UNIT.IsInZone}() or the @{#UNIT.IsNotInZone}() methods. Any zone can be tested on, but the zone must be derived from @{Zone#ZONE_BASE}. -- To test whether the Unit is within a **zone**, use the @{#UNIT.IsInZone}() or the @{#UNIT.IsNotInZone}() methods. Any zone can be tested on, but the zone must be derived from @{Zone#ZONE_BASE}.
-- --
-- ### 1.6.2) Units -- ### Units
--
-- Test if another DCS Unit is within a given radius of the current DCS Unit, use the @{#UNIT.OtherUnitInRadius}() method. -- Test if another DCS Unit is within a given radius of the current DCS Unit, use the @{#UNIT.OtherUnitInRadius}() method.
-- --
-- @module Unit -- @field #UNIT UNIT
-- @author FlightControl
--- The UNIT class
-- @type UNIT
-- @extends Wrapper.Controllable#CONTROLLABLE
UNIT = { UNIT = {
ClassName="UNIT", ClassName="UNIT",
} }
@ -17317,7 +17331,7 @@ function UNIT:ReSpawn( SpawnVec3, Heading )
end end
-- Remove obscolete units from the group structure -- Remove obscolete units from the group structure
i = 1 local i = 1
while i <= #SpawnGroupTemplate.units do while i <= #SpawnGroupTemplate.units do
local UnitTemplateData = SpawnGroupTemplate.units[i] local UnitTemplateData = SpawnGroupTemplate.units[i]
@ -17353,6 +17367,27 @@ function UNIT:IsActive()
return nil return nil
end end
--- Returns if the Unit is alive.
-- If the Unit is not alive, nil is returned.
-- If the Unit is alive and active, true is returned.
-- If the Unit is alive but not active, false is returned.
-- @param #UNIT self
-- @return #boolean true if Unit is alive and active.
-- @return #boolean false if Unit is alive but not active.
-- @return #nil if the Unit is not existing or is not alive.
function UNIT:IsAlive()
self:F3( self.UnitName )
local DCSUnit = self:GetDCSObject() -- Dcs.DCSUnit#Unit
if DCSUnit then
local UnitIsAlive = DCSUnit:isExist() and DCSUnit:isActive()
return UnitIsAlive
end
return nil
end
--- Returns the Unit's callsign - the localized string. --- Returns the Unit's callsign - the localized string.

Some files were not shown because too many files have changed in this diff Show More