+
ESCORT.ReportTargetsScheduler
diff --git a/Documentation/MissileTrainer.html b/Documentation/MissileTrainer.html
index 2eebd576b..e97906500 100644
--- a/Documentation/MissileTrainer.html
+++ b/Documentation/MissileTrainer.html
@@ -90,9 +90,9 @@ It suports the following functionality:
Alerts: Menu to configure alert messages.
- To All: Shows alert messages to all players.
- - To Target: Shows alter messages only to the player where the missile is (was) targetted at.
+ - To Target: Shows alert messages only to the player where the missile is (was) targetted at.
- Hits On: Show missile hit alert messages.
- - Hits Off: Disable missile hit altert messages.
+ - Hits Off: Disable missile hit alert messages.
- Launches On: Show missile launch messages.
- Launches Off: Disable missile launch messages.
diff --git a/Documentation/Unit.html b/Documentation/Unit.html
index ec8a45111..f08c9006c 100644
--- a/Documentation/Unit.html
+++ b/Documentation/Unit.html
@@ -112,42 +112,96 @@
UNIT:FlareYellow() |
Signal a yellow flare at the position of the UNIT.
+ |
+
+
+ | UNIT:GetAmmo() |
+
+ Returns the Unit's ammunition.
|
| UNIT:GetCallSign() |
-
+ Returns the unit's callsign - the localized string.
|
| UNIT:GetCategoryName() |
-
+ Returns the Unit's Category Name as defined within the Unit's Descriptor.
+ |
+
+
+ | UNIT:GetCoalition() |
+
+ Returns coalition of the Unit.
+ |
+
+
+ | UNIT:GetCountry() |
+
+ Returns country of the Unit.
|
| UNIT:GetDCSUnit() |
+ |
+
+
+ | UNIT:GetDesc() |
+
+ Returns unit descriptor.
+ |
+
+
+ | UNIT:GetFuel() |
+
+ Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks.
+ |
+
+
+ | UNIT:GetGroup() |
+
+ Returns the unit's group if it exist and nil otherwise.
|
| UNIT:GetID() |
-
+ Returns the unit's unique identifier.
+ |
+
+
+ | UNIT:GetLife() |
+
+ Returns the unit's health.
+ |
+
+
+ | UNIT:GetLife0() |
+
+ Returns the Unit's initial health.
|
| UNIT:GetName() |
-
+ Returns unit object by the name assigned to the unit in Mission Editor.
+ |
+
+
+ | UNIT:GetNumber() |
+
+ Returns the unit's number in the group.
|
| UNIT:GetPlayerName() |
-
+ Returns name of the player that control the unit or nil if the unit is controlled by A.I.
|
@@ -166,12 +220,46 @@
| UNIT:GetPrefix() |
+ |
+
+
+ | UNIT:GetRadar() |
+
+ Returns two values:
+
+
+ - First value indicates if at least one of the unit's radar(s) is on.
+
+ |
+
+
+ | UNIT:GetSensors() |
+
+ Returns the unit sensors.
|
| UNIT:GetTypeName() |
+ |
+
+
+ | UNIT:GetVelocity() |
+
+ Returns the unit's velocity vector.
+ |
+
+
+ | UNIT:InAir() |
+
+ Returns true if the Unit is in air.
+ |
+
+
+ | UNIT:IsActive() |
+
+ Returns if the unit is activated.
|
@@ -183,13 +271,19 @@
| UNIT:IsAlive() |
-
+ Returns if the unit is alive.
|
| UNIT:New(DCSUnit) |
Create a new UNIT from DCSUnit.
+ |
+
+
+ | UNIT:NewFromName(Unit, UnitName) |
+
+ Create a new UNIT from a Unit Name.
|
@@ -439,6 +533,24 @@
Signal a yellow flare at the position of the UNIT.
+
+
+
+-
+
+
+UNIT:GetAmmo()
+
+
+-
+
+
Returns the Unit's ammunition.
+
+ Return value
+
+DCSUnit#Unit.Ammo:
+
+
@@ -450,7 +562,12 @@
-
+
Returns the unit's callsign - the localized string.
+ Return value
+
+#string:
+The Callsign of the Unit.
@@ -463,7 +580,48 @@
+Returns the Unit's Category Name as defined within the Unit's Descriptor.
+ Return value
+
+#string:
+Unit's Category Name
+
+
+
+
+-
+
+
+UNIT:GetCoalition()
+
+
+-
+
+
Returns coalition of the Unit.
+
+ Return value
+
+DCSCoalitionObject#coalition.side:
+
+
+
+
+
+-
+
+
+UNIT:GetCountry()
+
+
+-
+
+
Returns country of the Unit.
+
+ Return value
+
+DCScountry#country.id:
+The country identifyer.
@@ -478,6 +636,66 @@
+
+
+
+-
+
+
+UNIT:GetDesc()
+
+
+-
+
+
Returns unit descriptor.
+
+
+Descriptor type depends on unit category.
+
+ Return value
+
+DCSUnit#Unit.Desc:
+The Unit descriptor.
+
+
+
+
+-
+
+
+UNIT:GetFuel()
+
+
+-
+
+
Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks.
+
+
+If there are additional fuel tanks the value may be greater than 1.0.
+
+ Return value
+
+#number:
+The relative amount of fuel (from 0.0 to 1.0).
+
+
+
+
+-
+
+
+UNIT:GetGroup()
+
+
+-
+
+
Returns the unit's group if it exist and nil otherwise.
+
+ Return value
+
+Group#GROUP:
+The Group of the Unit.
+
@@ -489,7 +707,51 @@
-
+
Returns the unit's unique identifier.
+ Return value
+
+DCSUnit#Unit.ID:
+Unit ID
+
+
+
+
+-
+
+
+UNIT:GetLife()
+
+
+-
+
+
Returns the unit's health.
+
+
+Dead units has health <= 1.0.
+
+ Return value
+
+#number:
+The Unit's health value.
+
+
+
+
+-
+
+
+UNIT:GetLife0()
+
+
+-
+
+
Returns the Unit's initial health.
+
+ Return value
+
+#number:
+The Unit's initial health value.
@@ -502,7 +764,35 @@
+Returns unit object by the name assigned to the unit in Mission Editor.
+
+If there is unit with such name or the unit is destroyed the function will return nil.
+The function provides access to non-activated units too.
+
+
+
+
+
+-
+
+
+UNIT:GetNumber()
+
+
+-
+
+
Returns the unit's number in the group.
+
+
+The number is the same number the unit has in ME.
+It may not be changed during the mission.
+If any unit in the group is destroyed, the numbers of another units will not be changed.
+
+ Return value
+
+#number:
+The Unit number.
@@ -515,7 +805,12 @@
+Returns name of the player that control the unit or nil if the unit is controlled by A.I.
+ Return value
+
+#string:
+Player Name
@@ -556,6 +851,61 @@
+
+
+
+-
+
+
+UNIT:GetRadar()
+
+
+-
+
+
Returns two values:
+
+
+ - First value indicates if at least one of the unit's radar(s) is on.
+
+
+
+
+ - Second value is the object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.
+
+
+ Return values
+
+ -
+
+
#boolean:
+ Indicates if at least one of the unit's radar(s) is on.
+
+
+ -
+
+
DCSObject#Object:
+The object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.
+
+
+
+
+
+
+-
+
+
+UNIT:GetSensors()
+
+
+-
+
+
Returns the unit sensors.
+
+ Return value
+
+DCSUnit#Unit.Sensors:
+
+
@@ -569,6 +919,60 @@
+
+
+
+-
+
+
+UNIT:GetVelocity()
+
+
+-
+
+
Returns the unit's velocity vector.
+
+ Return value
+
+DCSTypes#Vec3:
+Velocity Vector
+
+
+
+
+-
+
+
+UNIT:InAir()
+
+
+-
+
+
Returns true if the Unit is in air.
+
+ Return value
+
+#boolean:
+true if in the air.
+
+
+
+
+-
+
+
+UNIT:IsActive()
+
+
+-
+
+
Returns if the unit is activated.
+
+ Return value
+
+#boolean:
+true if Unit is activated.
+
@@ -601,7 +1005,12 @@ Air category evaluation result.
-
+
Returns if the unit is alive.
+ Return value
+
+#boolean:
+true if Unit is alive.
@@ -629,6 +1038,38 @@ Air category evaluation result.
Unit#UNIT:
+
+
+
+-
+
+
+UNIT:NewFromName(Unit, UnitName)
+
+
+-
+
+
Create a new UNIT from a Unit Name.
+
+ Parameters
+
+ -
+
+
#string Unit :
+Name
+
+
+ -
+
+
UnitName :
+
+
+
+ Return value
+
+Unit#UNIT:
+
+
diff --git a/Moose/Database.lua b/Moose/Database.lua
index de88095e0..3347e34d7 100644
--- a/Moose/Database.lua
+++ b/Moose/Database.lua
@@ -161,6 +161,28 @@ function DATABASE:New()
return self
end
+--- Finds a Unit based on the Unit Name.
+-- @param #DATABASE self
+-- @param #string UnitName
+-- @return Unit#UNIT The found Unit.
+function DATABASE:FindUnit( UnitName )
+
+ local UnitFound = self.Units[UnitName]
+ return UnitFound
+end
+
+--- Finds a Unit based on the Unit Name.
+-- @param #DATABASE self
+-- @param Unit#UNIT UnitToAdd
+-- @return Unit#UNIT The added Unit.
+function DATABASE:AddUnit( UnitToAdd )
+
+ self.Units[UnitToAdd.UnitName] = UnitToAdd
+ return self.Units[UnitToAdd.UnitName]
+end
+
+
+
--- Builds a set of units of coalitons.
-- Possible current coalitions are red, blue and neutral.
-- @param #DATABASE self
@@ -472,7 +494,8 @@ function DATABASE:_RegisterDatabase()
self:E( { "Register Unit:", DCSUnit, DCSUnitName } )
self.DCSUnits[DCSUnitName] = DCSUnit
- self.Units[DCSUnitName] = UNIT:New( DCSUnit )
+ self:AddUnit( UNIT:Register( DCSUnit ) )
+ --self.Units[DCSUnitName] = UNIT:Register( DCSUnit )
if self:_IsAliveDCSUnit(DCSUnit) then
self:E( { "Register Alive Unit:", DCSUnit, DCSUnitName } )
@@ -506,7 +529,8 @@ function DATABASE:_EventOnBirth( Event )
if self:_IsIncludeDCSUnit( Event.IniDCSUnit ) then
self.DCSUnits[Event.IniDCSUnitName] = Event.IniDCSUnit
self.DCSUnitsAlive[Event.IniDCSUnitName] = Event.IniDCSUnit
- self.Units[Event.IniDCSUnitName] = UNIT:New( Event.IniDCSUnit )
+ self:AddUnit( UNIT:Register( Event.IniDCSUnit ) )
+ --self.Units[Event.IniDCSUnitName] = UNIT:Register( Event.IniDCSUnit )
--if not self.DCSGroups[Event.IniDCSGroupName] then
-- self.DCSGroups[Event.IniDCSGroupName] = Event.IniDCSGroupName
diff --git a/Moose/MissileTrainer.lua b/Moose/MissileTrainer.lua
index 71abfabd5..051ad1b10 100644
--- a/Moose/MissileTrainer.lua
+++ b/Moose/MissileTrainer.lua
@@ -452,8 +452,8 @@ function MISSILETRAINER:_EventShot( Event )
local Client = self.DBClients[TrainerTargetDCSUnitName]
if Client then
- local TrainerSourceUnit = UNIT:New(TrainerSourceDCSUnit)
- local TrainerTargetUnit = UNIT:New(TrainerTargetDCSUnit)
+ local TrainerSourceUnit = UNIT:New( TrainerSourceDCSUnit )
+ local TrainerTargetUnit = UNIT:New( TrainerTargetDCSUnit )
if self.MessagesOnOff == true and self.AlertsLaunchesOnOff == true then
diff --git a/Moose/Unit.lua b/Moose/Unit.lua
index f41c85122..ee7c24357 100644
--- a/Moose/Unit.lua
+++ b/Moose/Unit.lua
@@ -50,23 +50,44 @@ UNIT = {
-- @field Blue
---- Create a new UNIT from DCSUnit.
+--- Finds the Unit from the _DATABASE.
-- @param #UNIT self
-- @param DCSUnit#Unit DCSUnit
-- @return Unit#UNIT
function UNIT:New( DCSUnit )
- local self = BASE:Inherit( self, BASE:New() )
- self:F( DCSUnit )
- if DCSUnit then
- self.UnitName = DCSUnit:getName()
- return self
+ if DCSUnit then
+ local UnitName = DCSUnit:getName()
+ if _DATABASE then
+ local UnitFound = _DATABASE:FindUnit( UnitName )
+ if UnitFound then
+ return UnitFound
+ end
+ end
end
self.UnitName = nil
return nil
end
+--- Create a new UNIT from DCSUnit.
+-- @param #UNIT self
+-- @param DCSUnit#Unit DCSUnit
+-- @param Database#DATABASE Database
+-- @return Unit#UNIT
+function UNIT:Register( DCSUnit )
+
+ if DCSUnit then
+ local self = BASE:Inherit( self, BASE:New() )
+ self:F( DCSUnit )
+ self.UnitName = DCSUnit:getName()
+ return self
+ end
+
+ self.UnitName = nil
+ return nil
+end
+
--- Create a new UNIT from a Unit Name.
-- @param #UNIT self
-- @param #string Unit Name
@@ -95,9 +116,9 @@ function UNIT:GetDCSUnit()
return nil
end
---- Returns coalition of the object.
+--- Returns coalition of the Unit.
-- @param Unit#UNIT self
--- @return #DCSCoalitionObject#coalition.side
+-- @return DCSCoalitionObject#coalition.side
function UNIT:GetCoalition()
self:F( self.UnitName )
@@ -110,9 +131,26 @@ function UNIT:GetCoalition()
end
return nil
-
end
+--- Returns country of the Unit.
+-- @param Unit#UNIT self
+-- @return DCScountry#country.id The country identifyer.
+function UNIT:GetCountry()
+ self:F( self.UnitName )
+
+ local DCSUnit = self:GetDCSUnit()
+
+ if DCSUnit then
+ local UnitCountry = DCSUnit:getCountry()
+ self:T( UnitCountry )
+ return UnitCountry
+ end
+
+ return nil
+end
+
+
--- Returns unit object by the name assigned to the unit in Mission Editor.
-- If there is unit with such name or the unit is destroyed the function will return nil.
-- The function provides access to non-activated units too.
@@ -420,6 +458,8 @@ end
function UNIT:GetPositionVec3()
+ self:F( self.UnitName )
+
local DCSUnit = self:GetDCSUnit()
if DCSUnit then
@@ -431,6 +471,55 @@ function UNIT:GetPositionVec3()
return nil
end
+--- Returns the unit's velocity vector.
+-- @param Unit#UNIT self
+-- @return DCSTypes#Vec3 Velocity Vector
+function UNIT:GetVelocity()
+ self:F( self.UnitName )
+
+ local DCSUnit = self:GetDCSUnit()
+
+ if DCSUnit then
+ local UnitVelocityVec3 = DCSUnit:getVelocity()
+ self:T( UnitVelocityVec3 )
+ return UnitVelocityVec3
+ end
+
+ return nil
+end
+
+--- Returns true if the Unit is in air.
+-- @param Unit#UNIT self
+-- @return #boolean true if in the air.
+function UNIT:InAir()
+ self:F( self.UnitName )
+
+ local DCSUnit = self:GetDCSUnit()
+
+ if DCSUnit then
+ local UnitInAir = DCSUnit:inAir()
+ self:T( UnitInAir )
+ return UnitInAir
+ end
+
+ return nil
+end
+
+function UNIT:GetPositionVec3()
+ self:F( self.UnitName )
+
+ local DCSUnit = self:GetDCSUnit()
+
+ if DCSUnit then
+ local UnitPos = DCSUnit:getPosition().p
+ self:T( UnitPos )
+ return UnitPos
+ end
+
+ return nil
+end
+
+
function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
self:F( { self.UnitName, AwaitUnit.UnitName, Radius } )
diff --git a/Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz b/Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz
index 009a8dcde..2c83c8948 100644
Binary files a/Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz and b/Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz differ