Module Ops.Target
Ops - Target.
Main Features:
- Manages target, number alive, life points, damage etc.
- Events when targets are damaged or destroyed
- Various target objects: UNIT, GROUP, STATIC, SCENERY, AIRBASE, COORDINATE, ZONE, SET_GROUP, SET_UNIT, SET_STATIC, SET_SCENERY, SET_ZONE
Author: funkyfranky
Additions: applevangelist
Global(s)
Global TARGET |
It is far more important to be able to hit the target than it is to haggle over who makes a weapon or who pulls a trigger -- Dwight D Eisenhower The TARGET ConceptDefine a target of your mission and monitor its status. |
It is far more important to be able to hit the target than it is to haggle over who makes a weapon or who pulls a trigger -- Dwight D Eisenhower
The TARGET Concept
Define a target of your mission and monitor its status.
Events are triggered when the target is damaged or destroyed.
A target can consist of one or multiple "objects".
Global _TARGETID |
Global target ID counter. |
Global target ID counter.
Type(s)
Fields and Methods inherited from TARGET | Description |
---|---|
Add start condition. |
|
Add stop condition. |
|
Create target data from a given object. |
|
TARGET:AddResource(MissionType, Nmin, Nmax, Attributes, Properties) |
Add mission type and number of required assets to resource. |
Name of the class. |
|
Count alive objects. |
|
Count alive targets. |
|
Triggers the FSM event "Damaged". |
|
Triggers the FSM event "Dead". |
|
Triggers the FSM event "Destroyed". |
|
Check if all given condition are true. |
|
Check if any of the given conditions is true. |
|
Get average coordinate. |
|
Get category. |
|
Get coordinate. |
|
Get current damage. |
|
Get heading of target. |
|
Get current total life points. |
|
Get target life points. |
|
Get name. |
|
Get the first target object alive. |
|
Get the first target objective alive. |
|
Get a target object by its name. |
|
Get target category. |
|
Get coalition of target object. |
|
Get target coordinate. |
|
Get heading of the target. |
|
Get target life points. |
|
Get target name. |
|
Get target threat level |
|
Get target 2D position vector. |
|
Get target 3D position vector. |
|
Get threat level. |
|
Get 2D vector. |
|
Get 3D vector. |
|
Check if TARGET is alive. |
|
Check if something is a a casualty of this TARGET. |
|
Check if TARGET is dead. |
|
Check if TARGET is destroyed. |
|
Check if something is an element of the TARGET. |
|
Check if target object is alive. |
|
Check if target object is dead. |
|
Number of initial target elements/units. |
|
Number of target elements/units that are dead (destroyed or despawned). |
|
Number of target elements/units that were destroyed. |
|
Create a new TARGET object and start the FSM. |
|
Number of initial target objects. |
|
Triggers the FSM event "ObjectDamaged". |
|
Triggers the FSM event "ObjectDead". |
|
Triggers the FSM event "ObjectDestroyed". |
|
On After "Damaged" event. |
|
On After "Dead" event. |
|
On After "Destroyed" event. |
|
On After "ObjectDamaged" event. |
|
On After "ObjectDead" event. |
|
On After "ObjectDestroyed" event. |
|
Event function handling the loss of a unit. |
|
Set importance of the target. |
|
Set priority of the target. |
|
Triggers the FSM event "Start". |
|
Triggers the FSM event "Status". |
|
Create target data from a given object. |
|
Triggers the FSM event "Start" after a delay. |
|
Triggers the FSM event "Status" after a delay. |
|
Triggers the FSM event "Stop" after a delay. |
|
Table of dead element names. |
|
Target category (Ground, Air, Sea). |
|
Start condition functions. |
|
Contact attached to this target. |
|
Table of target elements/units. |
|
Importance. |
|
If true, target objects were destroyed. |
|
Class id string for output to DCS log file. |
|
Total life points on last status update. |
|
Total life points of completely healthy targets. |
|
Mission attached to this target. |
|
On after "Damaged" event. |
|
On after "Dead" event. |
|
On after "Destroyed" event. |
|
On after "ObjectDamaged" event. |
|
On after "ObjectDead" event. |
|
On after "ObjectDestroyed" event. |
|
On after Start event. |
|
On after "Status" event. |
|
Operation this target is part of. |
|
Priority. |
|
Resource list. |
|
Running number to generate target object IDs. |
|
Table of target objects. |
|
Initial threat level. |
|
Unique ID of the target. |
|
Verbosity level. |
|
TARGET class version. |
Fields and Methods inherited from FSM | Description |
---|---|
Adds an End state. |
|
Set the default #FSM_PROCESS template with key ProcessName providing the ProcessClass and the process object when it is assigned to a Wrapper.Controllable by the task. |
|
Adds a score for the FSM to be achieved. |
|
TARGET:AddScoreProcess(From, Event, State, ScoreText, Score) |
Adds a score for the FSM_PROCESS to be achieved. |
Add a new transition rule to the FSM. |
|
Get current state. |
|
Returns the End states. |
|
Returns a table of the SubFSM rules defined within the FSM. |
|
Returns a table with the scores defined. |
|
Returns the start state of the FSM. |
|
Get current state. |
|
Returns a table with the Subs defined. |
|
Returns a table of the transition rules defined within the FSM. |
|
Check if FSM is in state. |
|
Load call backs. |
|
Creates a new FSM object. |
|
Sets the start state of the FSM. |
|
Add to map. |
|
Call handler. |
|
Create transition. |
|
Delayed transition. |
|
Event map. |
|
Go sub. |
|
Handler. |
|
Is end state. |
|
Sub maps. |
|
Check if can do an event. |
|
Check if cannot do an event. |
|
Check if FSM is in state. |
|
Fields and Methods inherited from TARGET.Category | Description |
---|---|
Fields and Methods inherited from TARGET.Object | Description |
---|---|
of the target object. |
|
Target unique ID. |
|
Life points on last status update. |
|
Life points of completely healthy target. |
|
Number of initial elements. |
|
Target name. |
|
Number of dead elements. |
|
Number of destroyed elements. |
|
The object, which can be many things, e.g. a UNIT, GROUP, STATIC, SCENERY, AIRBASE or COORDINATE object. |
|
Status "Alive" or "Dead". |
|
Target type. |
Fields and Methods inherited from TARGET.ObjectStatus | Description |
---|---|
Object is alive. |
|
Object is damaged. |
|
Object is dead. |
Fields and Methods inherited from TARGET.ObjectType | Description |
---|---|
Target is an AIRBASE. |
|
Target is a COORDINATE. |
|
Target is a GROUP object. |
|
Target is an OPSZONE object. |
|
Target is a SCENERY object. |
|
Target is a STATIC object. |
|
Target is a UNIT object. |
|
Target is a ZONE object. |
Fields and Methods inherited from TARGET.Resource | Description |
---|---|
Generalized attribute, e.g. |
|
Mission type, e.g. |
|
Max number of assets. |
|
Min number of assets. |
|
Properties (DCS attributes), e.g. |
|
Attached mission. |
TARGET class.
Field(s)
Name of the class.
Number of initial target elements/units.
Number of target elements/units that are dead (destroyed or despawned).
Number of target elements/units that were destroyed.
Number of initial target objects.
Table of dead element names.
Target category (Ground, Air, Sea).
Start condition functions.
Table of target elements/units.
Importance.
If true, target objects were destroyed.
Class id string for output to DCS log file.
Total life points on last status update.
Total life points of completely healthy targets.
Priority.
Resource list.
Running number to generate target object IDs.
Table of target objects.
Initial threat level.
Unique ID of the target.
Verbosity level.
TARGET class version.
Function(s)
Add start condition.
Defined in:
TARGET
Parameters:
#function ConditionFunction
Function that needs to be true before the mission can be started. Must return a #boolean.
...
Condition function arguments if any.
Return value:
self
Add stop condition.
Defined in:
TARGET
Parameters:
#function ConditionFunction
Function that needs to be true before the mission can be started. Must return a #boolean.
...
Condition function arguments if any.
Return value:
self
Create target data from a given object.
Valid objects are:
- GROUP
- UNIT
- STATIC
- SCENERY
- AIRBASE
- COORDINATE
- ZONE
- SET_GROUP
- SET_UNIT
- SET_STATIC
- SET_SCENERY
- SET_OPSGROUP
- SET_ZONE
- SET_OPSZONE
Defined in:
TARGET
Parameter:
The target UNIT, GROUP, STATIC, SCENERY, AIRBASE, COORDINATE, ZONE, SET_GROUP, SET_UNIT, SET_STATIC, SET_SCENERY, SET_ZONE
Add mission type and number of required assets to resource.
Defined in:
TARGET
Parameters:
#string MissionType
Mission Type.
#number Nmin
Min number of required assets.
#number Nmax
Max number of requried assets.
#table Attributes
Generalized attribute(s).
#table Properties
DCS attribute(s). Default nil
.
Return value:
The resource table.
Count alive objects.
Defined in:
TARGET
Parameters:
#TARGET.Object Target
Target objective.
#table Coalitions
(Optional) Only count targets of the given coalition(s).
Return value:
#number:
Number of alive target objects.
Count alive targets.
Defined in:
TARGET
Parameter:
#table Coalitions
(Optional) Only count targets of the given coalition(s).
Return value:
#number:
Number of alive target objects.
Check if all given condition are true.
Defined in:
TARGET
Parameter:
#table Conditions
Table of conditions.
Return value:
#boolean:
If true, all conditions were true. Returns false if at least one condition returned false.
Check if any of the given conditions is true.
Defined in:
TARGET
Parameter:
#table Conditions
Table of conditions.
Return value:
#boolean:
If true, at least one condition is true.
Get average coordinate.
Get category.
Defined in:
TARGET
Return value:
#string:
Target category. See TARGET.Category.X
, where X=AIRCRAFT, GROUND
.
Get coordinate.
Get heading of target.
Defined in:
TARGET
Return value:
#number:
Heading of the target in degrees.
Get current total life points.
This is the sum of all target objects.
Defined in:
TARGET
Return value:
#number:
Life points of target.
Get target life points.
Defined in:
TARGET
Return value:
#number:
Number of initial life points when mission was planned.
Get name.
Defined in:
TARGET
Return value:
#string:
Name of the target usually the first object.
Get the first target object alive.
Defined in:
TARGET
Parameters:
Core.Point#COORDINATE RefCoordinate
Reference coordinate to determine the closest target objective.
#table Coalitions
(Optional) Only consider targets of the given coalition(s).
Return value:
The target object or nil.
Get the first target objective alive.
Defined in:
TARGET
Parameters:
Core.Point#COORDINATE RefCoordinate
(Optional) Reference coordinate to determine the closest target objective.
#table Coalitions
(Optional) Only consider targets of the given coalition(s).
Return value:
The target objective.
Get a target object by its name.
Defined in:
TARGET
Parameter:
#string ObjectName
Object name.
Return value:
The target object table or nil.
Get target category.
Get coalition of target object.
If an object has no coalition (e.g. a coordinate) it is returned as neutral.
Defined in:
TARGET
Parameter:
#TARGET.Object Target
Target object.
Return value:
#number:
Coalition number.
Get target coordinate.
Defined in:
TARGET
Parameters:
#TARGET.Object Target
Target object.
#boolean Average
Return value:
Coordinate of the target.
Get heading of the target.
Defined in:
TARGET
Parameter:
#TARGET.Object Target
Target object.
Return value:
#number:
Heading in degrees.
Get target life points.
Defined in:
TARGET
Parameter:
#TARGET.Object Target
Target object.
Return value:
#number:
Life points of target.
Get target name.
Defined in:
TARGET
Parameter:
#TARGET.Object Target
Target object.
Return value:
#string:
Name of the target object.
Get target threat level
Defined in:
TARGET
Parameter:
#TARGET.Object Target
Target object.
Return value:
#number:
Threat level of target.
Get target 2D position vector.
Defined in:
TARGET
Parameter:
#TARGET.Object Target
Target object.
Return value:
Vector with x,y components.
Get target 3D position vector.
Defined in:
TARGET
Parameters:
#TARGET.Object Target
Target object.
#boolean Average
Return value:
Vector with x,y,z components.
Get threat level.
Defined in:
TARGET
Return value:
#number:
Threat level.
Check if TARGET is alive.
Defined in:
TARGET
Return value:
#boolean:
If true, target is alive.
Check if something is a a casualty of this TARGET.
Defined in:
TARGET
Parameter:
#string Name
The name of the potential element.
Return value:
#boolean:
If true
, this name is a casualty of this TARGET.
Check if TARGET is dead.
Defined in:
TARGET
Return value:
#boolean:
If true, target is dead.
Check if TARGET is destroyed.
Defined in:
TARGET
Return value:
#boolean:
If true, target is destroyed.
Check if something is an element of the TARGET.
Defined in:
TARGET
Parameter:
#string Name
The name of the potential element.
Return value:
#boolean:
If true
, this name is part of this TARGET.
Check if target object is alive.
Defined in:
TARGET
Parameter:
#TARGET.Object TargetObject
The target object.
Return value:
#boolean:
If true, target is dead.
Check if target object is dead.
Defined in:
TARGET
Parameter:
#TARGET.Object TargetObject
The target object.
Return value:
#boolean:
If true, target is dead.
Create a new TARGET object and start the FSM.
Defined in:
TARGET
Parameter:
#table TargetObject
Target object. Can be a: UNIT, GROUP, STATIC, SCENERY, AIRBASE, COORDINATE, ZONE, SET_GROUP, SET_UNIT, SET_STATIC, SET_SCENERY, SET_ZONE
Return value:
self
Triggers the FSM event "ObjectDamaged".
Triggers the FSM event "ObjectDead".
Triggers the FSM event "ObjectDestroyed".
On After "Damaged" event.
Any of the target objects has been damaged.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
On After "Dead" event.
All target objects are dead.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
On After "Destroyed" event.
All target objects have been destroyed.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
On After "ObjectDamaged" event.
A (sub-) target object has been damaged, e.g. a UNIT of a GROUP, or an object of a SET
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
#TARGET.Object Target
Target object.
On After "ObjectDead" event.
A (sub-) target object is dead, e.g. a UNIT of a GROUP, or an object of a SET
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
#TARGET.Object Target
Target object.
On After "ObjectDestroyed" event.
A (sub-) target object has been destroyed, e.g. a UNIT of a GROUP, or an object of a SET
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
#TARGET.Object Target
Target object.
Event function handling the loss of a unit.
Set importance of the target.
Defined in:
TARGET
Parameter:
#number Importance
Importance of the target. Default nil
.
Return value:
self
Set priority of the target.
Defined in:
TARGET
Parameter:
#number Priority
Priority of the target. Default 50.
Return value:
self
Triggers the FSM event "Start".
Starts the TARGET. Initializes parameters and starts event handlers.
Defined in:
TARGET
Create target data from a given object.
Defined in:
TARGET
Parameter:
The target UNIT, GROUP, STATIC, SCENERY, AIRBASE, COORDINATE, ZONE, SET_GROUP, SET_UNIT, SET_STATIC, SET_SCENERY, SET_ZONE
Triggers the FSM event "Start" after a delay.
Starts the TARGET. Initializes parameters and starts event handlers.
Defined in:
TARGET
Parameter:
#number delay
Delay in seconds.
Triggers the FSM event "Status" after a delay.
Defined in:
TARGET
Parameter:
#number delay
Delay in seconds.
Triggers the FSM event "Stop" after a delay.
Stops the TARGET and all its event handlers.
Defined in:
TARGET
Parameter:
#number delay
Delay in seconds.
On after "Damaged" event.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
On after "Dead" event.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
On after "Destroyed" event.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
On after "ObjectDamaged" event.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
#TARGET.Object Target
Target object.
On after "ObjectDead" event.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
#TARGET.Object Target
Target object.
On after "ObjectDestroyed" event.
Defined in:
TARGET
Parameters:
#string From
From state.
#string Event
Event.
#string To
To state.
#TARGET.Object Target
Target object.
On after Start event.
Starts the FLIGHTGROUP FSM and event handlers.
Defined in:
TARGET
Parameters:
Wrapper.Group#GROUP Group
Flight group.
#string From
From state.
#string Event
Event.
#string To
To state.
On after "Status" event.
Defined in:
TARGET
Parameters:
Wrapper.Group#GROUP Group
Flight group.
#string From
From state.
#string Event
Event.
#string To
To state.
Field(s)
Name of the class.
Number of initial target elements/units.
Number of target elements/units that are dead (destroyed or despawned).
Number of target elements/units that were destroyed.
Number of initial target objects.
Table of dead element names.
Target category (Ground, Air, Sea).
Start condition functions.
Table of target elements/units.
Importance.
If true, target objects were destroyed.
Class id string for output to DCS log file.
Total life points on last status update.
Total life points of completely healthy targets.
Priority.
Resource list.
Running number to generate target object IDs.
Table of target objects.
Initial threat level.
Unique ID of the target.
Verbosity level.
TARGET class version.
Function(s)
Adds an End state.
Set the default #FSM_PROCESS template with key ProcessName providing the ProcessClass and the process object when it is assigned to a Wrapper.Controllable by the task.
Defined in:
Parameters:
#table From
Can contain a string indicating the From state or a table of strings containing multiple From states.
#string Event
The Event name.
Core.Fsm#FSM_PROCESS Process
An sub-process FSM.
#table ReturnEvents
A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
Return value:
The SubFSM.
Adds a score for the FSM to be achieved.
Defined in:
Parameters:
#string State
is the state of the process when the score needs to be given. (See the relevant state descriptions of the process).
#string ScoreText
is a text describing the score that is given according the status.
#number Score
is a number providing the score of the status.
Return value:
#FSM:
self
Adds a score for the FSM_PROCESS to be achieved.
Defined in:
Parameters:
#string From
is the From State of the main process.
#string Event
is the Event of the main process.
#string State
is the state of the process when the score needs to be given. (See the relevant state descriptions of the process).
#string ScoreText
is a text describing the score that is given according the status.
#number Score
is a number providing the score of the status.
Return value:
#FSM:
self
Add a new transition rule to the FSM.
A transition rule defines when and if the FSM can transition from a state towards another state upon a triggered event.
Defined in:
Parameters:
#table From
Can contain a string indicating the From state or a table of strings containing multiple From states.
#string Event
The Event name.
#string To
The To state.
Get current state.
Returns the End states.
Returns a table of the SubFSM rules defined within the FSM.
Returns a table with the scores defined.
Returns the start state of the FSM.
Get current state.
Returns a table with the Subs defined.
Returns a table of the transition rules defined within the FSM.
Check if FSM is in state.
Defined in:
Parameter:
#string State
State name.
Return value:
#boolean:
If true, FSM is in this state.
Load call backs.
Sets the start state of the FSM.
Add to map.
Call handler.
Defined in:
Parameters:
#string step
Step "onafter", "onbefore", "onenter", "onleave".
#string trigger
Trigger.
#table params
Parameters.
#string EventName
Event name.
Return value:
Value.
Create transition.
Defined in:
Parameter:
#string EventName
Event name.
Return value:
#function:
Function.
Delayed transition.
Defined in:
Parameter:
#string EventName
Event name.
Return value:
#function:
Function.
Event map.
Go sub.
Defined in:
Parameters:
#string ParentFrom
Parent from state.
#string ParentEvent
Parent event name.
Return value:
#table:
Subs.
Handler.
Is end state.
Defined in:
Parameter:
#string Current
Current state name.
Return values:
#table:
FSM parent.
#string:
Event name.
Sub maps.
Check if can do an event.
Defined in:
Parameter:
#string e
Event name.
Return values:
#boolean:
If true, FSM can do the event.
#string:
To state.
Check if cannot do an event.
Defined in:
Parameter:
#string e
Event name.
Return value:
#boolean:
If true, FSM cannot do the event.
Check if FSM is in state.
Defined in:
Parameters:
#string State
State name.
state
Return value:
#boolean:
If true, FSM is in this state.
Category.
Field(s)
Function(s)
Target object.
Field(s)
Target unique ID.
Life points on last status update.
Life points of completely healthy target.
Number of initial elements.
Target name.
Number of dead elements.
Number of destroyed elements.
The object, which can be many things, e.g. a UNIT, GROUP, STATIC, SCENERY, AIRBASE or COORDINATE object.
Status "Alive" or "Dead".
Target type.
Function(s)
Object status.
Field(s)
Object is alive.
Object is damaged.
Object is dead.
Function(s)
Type.
Field(s)
Target is an AIRBASE.
Target is a COORDINATE.
Target is a GROUP object.
Target is an OPSZONE object.
Target is a SCENERY object.
Target is a STATIC object.
Target is a UNIT object.
Target is a ZONE object.
Function(s)
Resource.
Field(s)
Generalized attribute, e.g. {GROUP.Attribute.GROUND_INFANTRY}
.
Mission type, e.g. AUFTRAG.Type.BAI
.
Max number of assets.
Min number of assets.
Properties (DCS attributes), e.g. "Attack helicopters"
or "Mobile AAA"
.