Module Functional.Range
Functional - Range Practice.
The RANGE class enables easy set up of bombing and strafing ranges within DCS World.
Implementation is based on the Simple Range Script by Ciribob, which itself was motivated by a script by SNAFU see here.
476th - Air Weapons Range Objects mod is highly recommended for this class.
Features:
- Impact points of bombs, rockets and missils are recorded and distance to closest range target is measured and reported to the player.
- Number of hits on strafing passes are counted and reported. Also the percentage of hits w.r.t fired shots is evaluated.
- Results of all bombing and strafing runs are stored and top 10 results can be displayed.
- Range targets can be marked by smoke.
- Range can be illuminated by illumination bombs for night practices.
- Bomb, rocket and missile impact points can be marked by smoke.
- Direct hits on targets can trigger flares.
- Smoke and flare colors can be adjusted for each player via radio menu.
- Range information and weather report at the range can be reported via radio menu.
More information and examples can be found below.
MOOSE YouTube Channel
MOOSE - On the Range - Demonstration Video
Author: funkyfranky
Contributions: FlightControl, Ciribob
Global(s)
Global RANGE |
Enables a mission designer to easily set up practice ranges in DCS. |
Enables a mission designer to easily set up practice ranges in DCS.
A new RANGE object can be created with the RANGE.New(rangename) contructor. The parameter "rangename" defindes the name of the range. It has to be unique since this is also the name displayed in the radio menu.
Generally, a range consists of strafe pits and bombing targets. For strafe pits the number of hits for each pass is counted and tabulated. For bombing targets, the distance from the impact point of the bomb, rocket or missile to the closest range target is measured and tabulated. Each player can display his best results via a function in the radio menu or see the best best results from all players.
When all targets have been defined in the script, the range is started by the RANGE.Start() command.
IMPORTANT
Due to a DCS bug, it is not possible to directly monitor when a player enters a plane. So in a mission with client slots, it is vital that a player first enters as spector and after that jumps into the slot of his aircraft! If that is not done, the script is not started correctly. This can be checked by looking at the radio menues. If the mission was entered correctly, there should be an "On the Range" menu items in the "F10. Other..." menu.
Strafe Pits
Each strafe pit can consist of multiple targets. Often one findes two or three strafe targets next to each other.
A strafe pit can be added to the range by the RANGE.AddStrafePit(targetnames, boxlength, boxwidth, heading, inverseheading, goodpass, foulline) function.
- The first parameter targetnames defines the target or targets. This has to be given as a lua table which contains the names of Wrapper.Unit or Static objects defined in the mission editor.
- In order to perform a valid pass on the strafe pit, the pilot has to begin his run from the correct direction. Therefore, an "approach box" is defined in front of the strafe targets. The parameters boxlength and boxwidth define the size of the box while the parameter heading defines its direction. If the parameter heading is passed as nil, the heading is automatically taken from the heading of the first target unit as defined in the ME. The parameter inverseheading turns the heading around by 180 degrees. This is sometimes useful, since the default heading of strafe target units point in the wrong/opposite direction.
- The parameter goodpass defines the number of hits a pilot has to achive during a run to be judged as a "good" pass.
- The last parameter foulline sets the distance from the pit targets to the foul line. Hit from closer than this line are not counted!
Another function to add a strafe pit is RANGE.AddStrafePitGroup(group, boxlength, boxwidth, heading, inverseheading, goodpass, foulline). Here, the first parameter group is a MOOSE Wrapper.Group object and all units in this group define one strafe pit.
Finally, a valid approach has to be performed below a certain maximum altitude. The default is 914 meters (3000 ft) AGL. This is a parameter valid for all strafing pits of the range and can be adjusted by the RANGE.SetMaxStrafeAlt(maxalt) function.
Bombing targets
One ore multiple bombing targets can be added to the range by the RANGE.AddBombingTargets(targetnames, goodhitrange, randommove) function.
- The first parameter targetnames has to be a lua table, which contains the names of Wrapper.Unit and/or Static objects defined in the mission editor. Note that the Range logic automatically determines, if a name belongs to a Wrapper.Unit or Static object now.
- The (optional) parameter goodhitrange specifies the radius around the target. If a bomb or rocket falls at a distance smaller than this number, the hit is considered to be "good".
- If final (optional) parameter "randommove" can be enabled to create moving targets. If this parameter is set to true, the units of this bombing target will randomly move within the range zone. Note that there might be quirks since DCS units can get stuck in buildings etc. So it might be safer to manually define a route for the units in the mission editor if moving targets are desired.
Another possibility to add bombing targets is the RANGE.AddBombingTargetGroup(group, goodhitrange, randommove) function. Here the parameter group is a MOOSE Wrapper.Group object and all units in this group are defined as bombing targets.
Fine Tuning
Many range parameters have good default values. However, the mission designer can change these settings easily with the supplied user functions:
- RANGE.SetMaxStrafeAlt() sets the max altitude for valid strafing runs.
- RANGE.SetMessageTimeDuration() sets the duration how long (most) messages are displayed.
- RANGE.SetDisplayedMaxPlayerResults() sets the number of results displayed.
- RANGE.SetRangeRadius() defines the total range area.
- RANGE.SetBombTargetSmokeColor() sets the color used to smoke bombing targets.
- RANGE.SetStrafeTargetSmokeColor() sets the color used to smoke strafe targets.
- RANGE.SetStrafePitSmokeColor() sets the color used to smoke strafe pit approach boxes.
- RANGE.SetSmokeTimeDelay() sets the time delay between smoking bomb/rocket impact points after impact.
- RANGE.TrackBombsON() or RANGE.TrackBombsOFF() can be used to enable/disable tracking and evaluating of all bomb types a player fires.
- RANGE.TrackRocketsON() or RANGE.TrackRocketsOFF() can be used to enable/disable tracking and evaluating of all rocket types a player fires.
- RANGE.TrackMissilesON() or RANGE.TrackMissilesOFF() can be used to enable/disable tracking and evaluating of all missile types a player fires.
Radio Menu
Each range gets a radio menu with various submenus where each player can adjust his individual settings or request information about the range or his scores.
The main range menu can be found at "F10. Other..." --> "Fxx. On the Range..." --> "F1. Your Range Name...".
The range menu contains the following submenues:
- "F1. Mark Targets": Various ways to mark targets.
- "F2. My Settings": Player specific settings.
- "F3. Stats" Player: statistics and scores.
- "Range Information": Information about the range, such as bearing and range. Also range and player specific settings are displayed.
- "Weather Report": Temperatur, wind and QFE pressure information is provided.
Examples
Goldwater Range
This example shows hot to set up the Barry M. Goldwater range. It consists of two strafe pits each has two targets plus three bombing targets.
-- Strafe pits. Each pit can consist of multiple targets. Here we have two pits and each of the pits has two targets.
-- These are names of the corresponding units defined in the ME.
local strafepit_left={"GWR Strafe Pit Left 1", "GWR Strafe Pit Left 2"}
local strafepit_right={"GWR Strafe Pit Right 1", "GWR Strafe Pit Right 2"}
-- Table of bombing target names. Again these are the names of the corresponding units as defined in the ME.
local bombtargets={"GWR Bomb Target Circle Left", "GWR Bomb Target Circle Right", "GWR Bomb Target Hard"}
-- Create a range object.
GoldwaterRange=RANGE:New("Goldwater Range")
-- Distance between strafe target and foul line. You have to specify the names of the unit or static objects.
-- Note that this could also be done manually by simply measuring the distance between the target and the foul line in the ME.
GoldwaterRange:GetFoullineDistance("GWR Strafe Pit Left 1", "GWR Foul Line Left")
-- Add strafe pits. Each pit (left and right) consists of two targets.
GoldwaterRange:AddStrafePit(strafepit_left, 3000, 300, nil, true, 20, fouldist)
GoldwaterRange:AddStrafePit(strafepit_right, nil, nil, nil, true, nil, fouldist)
-- Add bombing targets. A good hit is if the bomb falls less then 50 m from the target.
GoldwaterRange:AddBombingTargets(bombtargets, 50)
-- Start range.
GoldwaterRange:Start()
The 476th - Air Weapons Range Objects mod is (implicitly) used in this example.
Debugging
In case you have problems, it is always a good idea to have a look at your DCS log file. You find it in your "Saved Games" folder, so for example in
C:\Users\<yourname>\Saved Games\DCS\Logs\dcs.log
All output concerning the RANGE class should have the string "RANGE" in the corresponding line.
The verbosity of the output can be increased by adding the following lines to your script:
BASE:TraceOnOff(true)
BASE:TraceLevel(1)
BASE:TraceClass("RANGE")
To get even more output you can increase the trace level to 2 or even 3, c.f. BASE for more details.
The function RANGE.DebugON() can be used to send messages on screen. It also smokes all defined strafe and bombing targets, the strafe pit approach boxes and the range zone.
Note that it can happen that the RANGE radio menu is not shown. Check that the range object is defined as a global variable rather than a local one. The could avoid the lua garbage collection to accidentally/falsely deallocate the RANGE objects.
Type(s)
| Fields and Methods inherited from RANGE | Description |
|---|---|
RANGE:AddBombingTargetGroup(group, goodhitrange, randommove) |
Add all units of a group as bombing targets. |
|
Add a unit or static object as bombing target. |
|
RANGE:AddBombingTargets(targetnames, goodhitrange, randommove) |
Add bombing target(s) to range. |
RANGE:AddStrafePit(targetnames, boxlength, boxwidth, heading, inverseheading, goodpass, foulline) |
Add new strafe pit. |
RANGE:AddStrafePitGroup(group, boxlength, boxwidth, heading, inverseheading, goodpass, foulline) |
Add all units of a group as one new strafe target pit. |
|
Color id used for smoking bomb targets. |
|
|
Bombs/rockets/missiles are only tracked if player-range distance is smaller than this threashold [m]. Default 25000 m. |
|
|
Name of the Class. |
|
|
If true, debug info is send as messages on the screen. |
|
|
Disable debug modus. |
|
|
Enable debug modus. |
|
|
Default range parameters. |
|
|
Measures the foule line distance between two unit or static objects. |
|
|
Table for monitoring which players already got an F10 menu. |
|
|
Main radio menu. |
|
|
Global list of all defined range names. |
|
|
RANGE contructor. |
|
|
Range event handler for event birth. |
|
|
Range event handler for event hit. |
|
|
Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun). |
|
|
Indiviual player settings. |
|
|
Set smoke color for marking bomb targets. |
|
|
Set bomb track threshold distance. |
|
|
Set time interval for tracking bombs. |
|
|
Set max number of player results that are displayed. |
|
|
Set maximal strafing altitude. |
|
|
Set time how long (most) messages are displayed. |
|
|
Set messages to examiner. |
|
|
Set range location. |
|
|
Set range radius. |
|
|
Set time delay between bomb impact and starting to smoke the impact point. |
|
|
Set smoke color for marking strafe pit approach boxes. |
|
|
Set smoke color for marking strafe targets. |
|
|
Initializes number of targets and location of the range. |
|
|
Color id used to smoke strafe pit approach boxes. |
|
|
Color id used to smoke strafe targets. |
|
|
Time delay in seconds between impact of bomb and starting the smoke. Default 3 seconds. |
|
|
Time [sec] messages to players are displayed. Default 30 sec. |
|
|
Disables tracking of all bomb types. |
|
|
Enables tracking of all bomb types. |
|
|
Disables tracking of all missile types. |
|
|
Enables tracking of all missile types. |
|
|
Disables tracking of all rocket types. |
|
|
Enables tracking of all rocket types. |
|
|
Add menu commands for player. |
|
|
Check if player is inside a strafing zone. |
|
|
Checks if a static object with a certain name exists. |
|
|
Start smoking a coordinate with a delay. |
|
|
Display bombing target locations to player. |
|
|
Display best bombing results of top 10 players. |
|
|
Display message to group. |
|
|
Display top 10 bombing run results of specific player. |
|
|
Display top 10 stafing results of a specific player. |
|
|
Report information like bearing and range from player unit to range. |
|
|
Report weather conditions at range. |
|
|
Display top 10 strafing results of all players. |
|
|
Display pit location and heading to player. |
|
|
Toggle status of flaring direct hits of range targets. |
|
|
Get the number of shells a unit currently has. |
|
|
Returns the unit of a player and the player name. |
|
|
Get max speed of controllable. |
|
|
Illuminate targets. |
|
|
Mark targets on F10 map. |
|
|
Reset player statistics. |
|
|
Toggle status of time delay for smoking bomb impact points |
|
|
Toggle status of smoking bomb impact points. |
|
|
Mark bombing targets with smoke. |
|
|
Mark approach boxes of strafe targets with smoke. |
|
|
Mark strafing targets with smoke. |
|
|
Sets the flare color used to flare players direct target hits. |
|
|
Returns a string which consits of this callsign and the player name. |
|
|
Sets the flare color used when player makes a direct hit on target. |
|
|
Sets the smoke color used to smoke players bomb impact points. |
|
|
Converts a smoke color id to text. |
|
|
Split string. |
|
|
Table containing the bombing results of each player. |
|
|
Table of targets to bomb. |
|
|
Time step [sec] used for tracking released bomb/rocket positions. Default 0.005 seconds. |
|
|
If true, events are handled by MOOSE. If false, events are handled directly by DCS eventhandler. Default true. |
|
|
If true, only the examiner gets messages. If false, clients and examiner get messages. |
|
|
Name of the examiner group which should get all messages. |
|
|
Some ID to identify who we are in output of the DCS.log file. |
|
|
Maximum altitude AGL in meters at which illumination bombs are fired. Default is 1000 m. |
|
|
Minimum altitude AGL in meters at which illumination bombs are fired. Default is 500 m. |
|
|
Coordinate of the range location. |
|
|
Number of bombing targets. |
|
|
Number of (player) results that a displayed. Default is 10. |
|
|
Number of strafing targets. |
|
|
General event handler. |
|
|
Table for administration. |
|
|
Name of the range. |
|
|
Radius of range defining its total size for e.g. smoking bomb impact points and sending radio messages. Default 5 km. |
|
|
MOOSE zone object of the range. For example, no bomb impacts are smoked if bombs fall outside of the range zone. |
|
|
Distance from closest target up to which bomb hits are counted. Default 1000 m. |
|
|
Table containing the strafing results of each player. |
|
|
Table containing the current strafing target a player as assigned to. |
|
|
Table of strafing targets. |
|
|
Maximum altitude above ground for registering for a strafe run. Default is 914 m = 3000 ft. |
|
|
If true (default), all bomb types are tracked and impact point to closest bombing target is evaluated. |
|
|
If true (default), all missile types are tracked and impact point to closest bombing target is evaluated. |
|
|
If true (default), all rocket types are tracked and impact point to closest bombing target is evaluated. |
|
|
Range script version. |
| Fields and Methods inherited from BASE | Description |
|---|---|
|
The ID number of the class. |
|
|
The name of the class. |
|
|
The name of the class concatenated with the ID number of the class. |
|
|
Clear the state of an object. |
|
RANGE:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace) |
Creation of a Birth Event. |
|
Creation of a Crash Event. |
|
|
Creation of a Dead Event. |
|
|
Creation of a Remove Unit Event. |
|
|
Creation of a Takeoff Event. |
|
|
Log an exception which will be traced always. |
|
|
Returns the event dispatcher |
|
|
Remove all subscribed events |
|
|
Trace a function call. |
|
|
Trace a function call level 2. |
|
|
Trace a function call level 3. |
|
|
Get the ClassID of the class instance. |
|
|
Get the ClassName of the class instance. |
|
|
Get the ClassName + ClassID of the class instance. |
|
|
Get the Class Event processing Priority. |
|
|
This is the worker method to retrieve the Parent class. |
|
|
Get a Value given a Key from the Object. |
|
|
Subscribe to a DCS Event. |
|
|
Log an information which will be traced always. |
|
|
This is the worker method to inherit from a parent class. |
|
|
This is the worker method to check if an object is an (sub)instance of a class. |
|
|
Enquires if tracing is on (for the class). |
|
|
BASE constructor. |
|
|
Occurs when an object is completely destroyed. |
|
|
Occurs when a ground unit captures either an airbase or a farp. |
|
|
Occurs when any object is spawned into the mission. |
|
|
Occurs when any aircraft crashes into the ground and is completely destroyed. |
|
|
Occurs when an object is dead. |
|
|
Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected |
|
|
Occurs when any aircraft shuts down its engines. |
|
|
Occurs when any aircraft starts its engines. |
|
|
Occurs whenever an object is hit by a weapon. |
|
|
Occurs when any system fails on a human controlled aircraft. |
|
|
Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed place: Object that the unit landed on. |
|
|
Occurs when a mission ends |
|
|
Occurs when a mission starts |
|
|
Occurs when the pilot of an aircraft is killed. |
|
|
Occurs when any player assumes direct control of a unit. |
|
|
Occurs when any player relieves control of a unit to the AI. |
|
|
Occurs when an aircraft connects with a tanker and begins taking on fuel. |
|
|
Occurs when an aircraft is finished taking fuel. |
|
|
Occurs when any unit stops firing its weapon. |
|
|
Occurs when any unit begins firing a weapon that has a high rate of fire. |
|
|
Occurs whenever any unit in a mission fires a weapon. |
|
|
Occurs when an aircraft takes off from an airbase, farp, or ship. |
|
|
Schedule a new time event. |
|
RANGE:ScheduleRepeat(Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ...) |
Schedule a new time event. |
|
Stops the Schedule. |
|
|
Set the Class Event processing Priority. |
|
|
Set a state or property of the Object given a Key and a Value. |
|
|
Trace a function logic level 1. |
|
|
Trace a function logic level 2. |
|
|
Trace a function logic level 3. |
|
|
Trace all methods in MOOSE |
|
|
Set tracing for a class |
|
|
Set tracing for a specific method of class |
|
|
Set trace level |
|
|
Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default. |
|
|
UnSubscribe to a DCS event. |
|
RANGE:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam) |
Trace a function call. |
RANGE:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam) |
Trace a function logic. |
- RANGE class
Field(s)
Bombs/rockets/missiles are only tracked if player-range distance is smaller than this threashold [m]. Default 25000 m.
Name of the Class.
If true, debug info is send as messages on the screen.
Default range parameters.
Table for monitoring which players already got an F10 menu.
Main radio menu.
Global list of all defined range names.
Indiviual player settings.
Color id used to smoke strafe pit approach boxes.
Time delay in seconds between impact of bomb and starting the smoke. Default 3 seconds.
Time [sec] messages to players are displayed. Default 30 sec.
Table containing the bombing results of each player.
Table of targets to bomb.
Time step [sec] used for tracking released bomb/rocket positions. Default 0.005 seconds.
If true, events are handled by MOOSE. If false, events are handled directly by DCS eventhandler. Default true.
If true, only the examiner gets messages. If false, clients and examiner get messages.
Name of the examiner group which should get all messages.
Some ID to identify who we are in output of the DCS.log file.
Maximum altitude AGL in meters at which illumination bombs are fired. Default is 1000 m.
Minimum altitude AGL in meters at which illumination bombs are fired. Default is 500 m.
Number of bombing targets.
Number of (player) results that a displayed. Default is 10.
Number of strafing targets.
Table for administration.
Name of the range.
Radius of range defining its total size for e.g. smoking bomb impact points and sending radio messages. Default 5 km.
MOOSE zone object of the range. For example, no bomb impacts are smoked if bombs fall outside of the range zone.
Distance from closest target up to which bomb hits are counted. Default 1000 m.
Table containing the strafing results of each player.
Table containing the current strafing target a player as assigned to.
Table of strafing targets.
Maximum altitude above ground for registering for a strafe run. Default is 914 m = 3000 ft.
If true (default), all bomb types are tracked and impact point to closest bombing target is evaluated.
If true (default), all missile types are tracked and impact point to closest bombing target is evaluated.
If true (default), all rocket types are tracked and impact point to closest bombing target is evaluated.
Range script version.
Function(s)
Add all units of a group as bombing targets.
Defined in:
RANGE
Parameters:
Wrapper.Group#GROUP group
Group of bombing targets.
#number goodhitrange
Max distance from unit which is considered as a good hit.
#boolean randommove
If true, unit will move randomly within the range. Default is false.
Add a unit or static object as bombing target.
Defined in:
RANGE
Parameters:
Positionable (unit or static) of the strafe target.
#number goodhitrange
Max distance from unit which is considered as a good hit.
#boolean randommove
If true, unit will move randomly within the range. Default is false.
Add bombing target(s) to range.
Defined in:
RANGE
Parameters:
#table targetnames
Table containing names of unit or static objects serving as bomb targets.
#number goodhitrange
(Optional) Max distance from target unit (in meters) which is considered as a good hit. Default is 25 m.
#boolean randommove
If true, unit will move randomly within the range. Default is false.
Add new strafe pit.
For a strafe pit, hits from guns are counted. One pit can consist of several units. Note, an approach is only valid, if the player enters via a zone in front of the pit, which defined by boxlength and boxheading. Furthermore, the player must not be too high and fly in the direction of the pit to make a valid target apporoach.
Defined in:
RANGE
Parameters:
#table targetnames
Table of unit or static names defining the strafe targets. The first target in the list determines the approach zone (heading and box).
#number boxlength
(Optional) Length of the approach box in meters. Default is 3000 m.
#number boxwidth
(Optional) Width of the approach box in meters. Default is 300 m.
#number heading
(Optional) Approach heading in Degrees. Default is heading of the unit as defined in the mission editor.
#boolean inverseheading
(Optional) Take inverse heading (heading --> heading - 180 Degrees). Default is false.
#number goodpass
(Optional) Number of hits for a "good" strafing pass. Default is 20.
#number foulline
(Optional) Foul line distance. Hits from closer than this distance are not counted. Default 610 m = 2000 ft. Set to 0 for no foul line.
Add all units of a group as one new strafe target pit.
For a strafe pit, hits from guns are counted. One pit can consist of several units. Note, an approach is only valid, if the player enters via a zone in front of the pit, which defined by boxlength and boxheading. Furthermore, the player must not be too high and fly in the direction of the pit to make a valid target apporoach.
Defined in:
RANGE
Parameters:
Wrapper.Group#GROUP group
MOOSE group of unit names defining the strafe target pit. The first unit in the group determines the approach zone (heading and box).
#number boxlength
(Optional) Length of the approach box in meters. Default is 3000 m.
#number boxwidth
(Optional) Width of the approach box in meters. Default is 300 m.
#number heading
(Optional) Approach heading in Degrees. Default is heading of the unit as defined in the mission editor.
#boolean inverseheading
(Optional) Take inverse heading (heading --> heading - 180 Degrees). Default is false.
#number goodpass
(Optional) Number of hits for a "good" strafing pass. Default is 20.
#number foulline
(Optional) Foul line distance. Hits from closer than this distance are not counted. Default 610 m = 2000 ft. Set to 0 for no foul line.
Measures the foule line distance between two unit or static objects.
Defined in:
RANGE
Parameters:
#string namepit
Name of the strafe pit target object.
#string namefoulline
Name of the fould line distance marker object.
Return value:
#number:
Foul line distance in meters.
RANGE contructor.
Creates a new RANGE object.
Defined in:
RANGE
Parameter:
#string rangename
Name of the range. Has to be unique. Will we used to create F10 menu items etc.
Return value:
RANGE object.
Range event handler for event birth.
Range event handler for event hit.
Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun).
Set smoke color for marking bomb targets.
By default bomb targets are marked by red smoke.
Set bomb track threshold distance.
Bombs/rockets/missiles are only tracked if player-range distance is less than this distance. Default 25 km.
Defined in:
RANGE
Parameter:
#number distance
Threshold distance in km. Default 25 km.
Set time interval for tracking bombs.
A smaller time step increases accuracy but needs more CPU time.
Defined in:
RANGE
Parameter:
#number dt
Time interval in seconds. Default is 0.005 s.
Set max number of player results that are displayed.
Defined in:
RANGE
Parameter:
#number nmax
Number of results. Default is 10.
Set maximal strafing altitude.
Player entering a strafe pit above that altitude are not registered for a valid pass.
Defined in:
RANGE
Parameter:
#number maxalt
Maximum altitude AGL in meters. Default is 914 m= 3000 ft.
Set time how long (most) messages are displayed.
Defined in:
RANGE
Parameter:
#number time
Time in seconds. Default is 30 s.
Set messages to examiner.
The examiner will receive messages from all clients.
Defined in:
RANGE
Parameters:
#string examinergroupname
Name of the group of the examiner.
#boolean exclusively
If true, messages are send exclusively to the examiner, i.e. not to the clients.
Set range location.
If this is not done, one (random) unit position of the range is used to determine the center of the range.
Defined in:
RANGE
Parameter:
Core.Point#COORDINATE coordinate
Coordinate of the center of the range.
Set range radius.
Defines the area in which e.g. bomb impacts are smoked.
Defined in:
RANGE
Parameter:
#number radius
Radius in km. Default 5 km.
Set time delay between bomb impact and starting to smoke the impact point.
Defined in:
RANGE
Parameter:
#number delay
Time delay in seconds. Default is 3 seconds.
Set smoke color for marking strafe pit approach boxes.
By default strafe pit boxes are marked by white smoke.
Set smoke color for marking strafe targets.
By default strafe targets are marked by green smoke.
Initializes number of targets and location of the range.
Starts the event handlers.
Defined in:
RANGE
Enables tracking of all bomb types.
Note that this is the default setting.
Defined in:
RANGE
Enables tracking of all missile types.
Note that this is the default setting.
Defined in:
RANGE
Enables tracking of all rocket types.
Note that this is the default setting.
Defined in:
RANGE
Add menu commands for player.
Defined in:
RANGE
Parameter:
#string _unitName
Name of player unit.
Check if player is inside a strafing zone.
If he is, we start looking for hits. If he was and left the zone again, the result is stored.
Defined in:
RANGE
Parameter:
#string _unitName
Name of player unit.
Checks if a static object with a certain name exists.
It also added it to the MOOSE data base, if it is not already in there.
Defined in:
RANGE
Parameter:
#string name
Name of the potential static object.
Return value:
#boolean:
Returns true if a static with this name exists. Retruns false if a unit with this name exists. Returns nil if neither unit or static exist.
Start smoking a coordinate with a delay.
Defined in:
RANGE
Parameter:
#table _args
Argements passed.
Display bombing target locations to player.
Defined in:
RANGE
Parameter:
#string _unitname
Name of the player unit.
Display best bombing results of top 10 players.
Defined in:
RANGE
Parameter:
#string _unitName
Name of player unit.
Display message to group.
Defined in:
RANGE
Parameters:
Wrapper.Unit#UNIT _unit
Player unit.
#string _text
Message text.
#number _time
Duration how long the message is displayed.
#boolean _clear
Clear up old messages.
Display top 10 bombing run results of specific player.
Defined in:
RANGE
Parameter:
#string _unitName
Name of the player unit.
Display top 10 stafing results of a specific player.
Defined in:
RANGE
Parameter:
#string _unitName
Name of the player unit.
Report information like bearing and range from player unit to range.
Defined in:
RANGE
Parameter:
#string _unitname
Name of the player unit.
Report weather conditions at range.
Temperature, QFE pressure and wind data.
Defined in:
RANGE
Parameter:
#string _unitname
Name of the player unit.
Display top 10 strafing results of all players.
Defined in:
RANGE
Parameter:
#string _unitName
Name fo the player unit.
Display pit location and heading to player.
Defined in:
RANGE
Parameter:
#string _unitname
Name of the player unit.
Toggle status of flaring direct hits of range targets.
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Get the number of shells a unit currently has.
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Return value:
Number of shells left
Returns the unit of a player and the player name.
If the unit does not belong to a player, nil is returned.
Defined in:
RANGE
Parameter:
#string _unitName
Name of the player unit.
Return values:
Get max speed of controllable.
Defined in:
RANGE
Parameter:
Wrapper.Controllable#CONTROLLABLE controllable
Return value:
Maximum speed in km/h.
Illuminate targets.
Fires illumination bombs at one random bomb and one random strafe target at a random altitude between 400 and 800 m.
Defined in:
RANGE
Parameter:
#string _unitName
(Optional) Name of the player unit.
Mark targets on F10 map.
Defined in:
RANGE
Parameter:
#string _unitName
Name of the player unit.
Reset player statistics.
Defined in:
RANGE
Parameter:
#string _unitName
Name of the player unit.
Toggle status of time delay for smoking bomb impact points
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Toggle status of smoking bomb impact points.
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Mark bombing targets with smoke.
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Mark approach boxes of strafe targets with smoke.
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Mark strafing targets with smoke.
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Sets the flare color used to flare players direct target hits.
Defined in:
RANGE
Parameter:
Color Id.
Return value:
#string:
Color text.
Returns a string which consits of this callsign and the player name.
Defined in:
RANGE
Parameter:
#string unitname
Name of the player unit.
Sets the flare color used when player makes a direct hit on target.
Defined in:
RANGE
Parameters:
#string _unitName
Name of the player unit.
ID of flare color.
Sets the smoke color used to smoke players bomb impact points.
Defined in:
RANGE
Parameters:
#string _unitName
Name of the player unit.
ID of the smoke color.
Converts a smoke color id to text.
E.g. SMOKECOLOR.Blue --> "blue".
Defined in:
RANGE
Parameter:
Color Id.
Return value:
#string:
Color text.
Split string.
Cf http://stackoverflow.com/questions/1426954/split-string-in-lua
Defined in:
RANGE
Parameters:
#string str
Sting to split.
#string sep
Speparator for split.
Return value:
#table:
Split text.
General event handler.
Defined in:
RANGE
Parameter:
#table Event
DCS event table.
Field(s)
Bombs/rockets/missiles are only tracked if player-range distance is smaller than this threashold [m]. Default 25000 m.
Name of the Class.
If true, debug info is send as messages on the screen.
Default range parameters.
Table for monitoring which players already got an F10 menu.
Main radio menu.
Global list of all defined range names.
Indiviual player settings.
Color id used to smoke strafe pit approach boxes.
Time delay in seconds between impact of bomb and starting the smoke. Default 3 seconds.
Time [sec] messages to players are displayed. Default 30 sec.
Table containing the bombing results of each player.
Table of targets to bomb.
Time step [sec] used for tracking released bomb/rocket positions. Default 0.005 seconds.
If true, events are handled by MOOSE. If false, events are handled directly by DCS eventhandler. Default true.
If true, only the examiner gets messages. If false, clients and examiner get messages.
Name of the examiner group which should get all messages.
Some ID to identify who we are in output of the DCS.log file.
Maximum altitude AGL in meters at which illumination bombs are fired. Default is 1000 m.
Minimum altitude AGL in meters at which illumination bombs are fired. Default is 500 m.
Number of bombing targets.
Number of (player) results that a displayed. Default is 10.
Number of strafing targets.
Table for administration.
Name of the range.
Radius of range defining its total size for e.g. smoking bomb impact points and sending radio messages. Default 5 km.
MOOSE zone object of the range. For example, no bomb impacts are smoked if bombs fall outside of the range zone.
Distance from closest target up to which bomb hits are counted. Default 1000 m.
Table containing the strafing results of each player.
Table containing the current strafing target a player as assigned to.
Table of strafing targets.
Maximum altitude above ground for registering for a strafe run. Default is 914 m = 3000 ft.
If true (default), all bomb types are tracked and impact point to closest bombing target is evaluated.
If true (default), all missile types are tracked and impact point to closest bombing target is evaluated.
If true (default), all rocket types are tracked and impact point to closest bombing target is evaluated.
Range script version.
Function(s)
Clear the state of an object.
Defined in:
Parameters:
Object
The object that holds the Value set by the Key.
StateName
The key that is should be cleared.
Creation of a Birth Event.
Defined in:
Parameters:
DCS#Time EventTime
The time stamp of the event.
DCS#Object Initiator
The initiating object of the event.
#string IniUnitName
The initiating unit name.
place
subplace
Creation of a Crash Event.
Defined in:
Parameters:
DCS#Time EventTime
The time stamp of the event.
DCS#Object Initiator
The initiating object of the event.
Creation of a Dead Event.
Defined in:
Parameters:
DCS#Time EventTime
The time stamp of the event.
DCS#Object Initiator
The initiating object of the event.
Creation of a Remove Unit Event.
Defined in:
Parameters:
DCS#Time EventTime
The time stamp of the event.
DCS#Object Initiator
The initiating object of the event.
Creation of a Takeoff Event.
Defined in:
Parameters:
DCS#Time EventTime
The time stamp of the event.
DCS#Object Initiator
The initiating object of the event.
Log an exception which will be traced always.
Can be anywhere within the function logic.
Returns the event dispatcher
Trace a function call.
Must be at the beginning of the function logic.
Trace a function call level 2.
Must be at the beginning of the function logic.
Trace a function call level 3.
Must be at the beginning of the function logic.
Get the ClassID of the class instance.
Get the ClassName of the class instance.
Get the ClassName + ClassID of the class instance.
The ClassName + ClassID is formatted as '%s#%09d'.
Get the Class Event processing Priority.
The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.
This is the worker method to retrieve the Parent class.
Note that the Parent class must be passed to call the parent class method.
self:GetParent(self):ParentMethod()
Defined in:
Parameters:
#BASE Child
is the Child class from which the Parent class needs to be retrieved.
FromClass
Return value:
Get a Value given a Key from the Object.
Note that if the Object is destroyed, nillified or garbage collected, then the Values and Keys will also be gone.
Defined in:
Parameters:
Object
The object that holds the Value set by the Key.
Key
The key that is used to retrieve the value. Note that the key can be a #string, but it can also be any other type!
Return value:
The Value retrieved or nil if the Key was not found and thus the Value could not be retrieved.
Subscribe to a DCS Event.
Defined in:
Parameters:
Core.Event#EVENTS Event
#function EventFunction
(optional) The function to be called when the event occurs for the unit.
Return value:
Log an information which will be traced always.
Can be anywhere within the function logic.
This is the worker method to inherit from a parent class.
Defined in:
Parameters:
Child
is the Child class that inherits.
#BASE Parent
is the Parent class that the Child inherits from.
Return value:
Child
This is the worker method to check if an object is an (sub)instance of a class.
Examples:
ZONE:New( 'some zone' ):IsInstanceOf( ZONE ) will return true
ZONE:New( 'some zone' ):IsInstanceOf( 'ZONE' ) will return true
ZONE:New( 'some zone' ):IsInstanceOf( 'zone' ) will return true
ZONE:New( 'some zone' ):IsInstanceOf( 'BASE' ) will return true
ZONE:New( 'some zone' ):IsInstanceOf( 'GROUP' ) will return false
Defined in:
Parameter:
ClassName
is the name of the class or the class itself to run the check against
Return value:
#boolean:
Enquires if tracing is on (for the class).
BASE constructor.
This is an example how to use the BASE:New() constructor in a new class definition when inheriting from BASE.
function EVENT:New()
local self = BASE:Inherit( self, BASE:New() ) -- #EVENT
return self
end
Occurs when an object is completely destroyed.
initiator : The unit that is was destroyed.
Occurs when a ground unit captures either an airbase or a farp.
initiator : The unit that captured the base place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.
Occurs when any object is spawned into the mission.
initiator : The unit that was spawned
Occurs when any aircraft crashes into the ground and is completely destroyed.
initiator : The unit that has crashed
Occurs when an object is dead.
initiator : The unit that is dead.
Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected
Occurs when any aircraft shuts down its engines.
initiator : The unit that is stopping its engines.
Occurs when any aircraft starts its engines.
initiator : The unit that is starting its engines.
Occurs whenever an object is hit by a weapon.
initiator : The unit object the fired the weapon weapon: Weapon object that hit the target target: The Object that was hit.
Occurs when any system fails on a human controlled aircraft.
initiator : The unit that had the failure
Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed place: Object that the unit landed on.
Can be an Airbase Object, FARP, or Ships
Occurs when a mission ends
Occurs when a mission starts
Occurs when the pilot of an aircraft is killed.
Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane. initiator : The unit that the pilot has died in.
Occurs when any player assumes direct control of a unit.
initiator : The unit that is being taken control of.
Occurs when any player relieves control of a unit to the AI.
initiator : The unit that the player left.
Occurs when an aircraft connects with a tanker and begins taking on fuel.
initiator : The unit that is receiving fuel.
Occurs when an aircraft is finished taking fuel.
initiator : The unit that was receiving fuel.
Occurs when any unit stops firing its weapon.
Event will always correspond with a shooting start event. initiator : The unit that was doing the shooing.
Occurs when any unit begins firing a weapon that has a high rate of fire.
Most common with aircraft cannons (GAU-8), autocannons, and machine guns. initiator : The unit that is doing the shooing. target: The unit that is being targeted.
Occurs whenever any unit in a mission fires a weapon.
But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.
Occurs when an aircraft takes off from an airbase, farp, or ship.
initiator : The unit that tookoff place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships
Schedule a new time event.
Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.
Defined in:
Parameters:
#number Start
Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
#function SchedulerFunction
The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
#table ...
Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
Return value:
#number:
The ScheduleID of the planned schedule.
Schedule a new time event.
Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.
Defined in:
Parameters:
#number Start
Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
#number Repeat
Specifies the interval in seconds when the scheduler will call the event function.
#number RandomizeFactor
Specifies a randomization factor between 0 and 1 to randomize the Repeat.
#number Stop
Specifies the amount of seconds when the scheduler will be stopped.
#function SchedulerFunction
The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
#table ...
Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
Return value:
#number:
The ScheduleID of the planned schedule.
Stops the Schedule.
Defined in:
Parameter:
#function SchedulerFunction
The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
Set the Class Event processing Priority.
The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.
Set a state or property of the Object given a Key and a Value.
Note that if the Object is destroyed, nillified or garbage collected, then the Values and Keys will also be gone.
Defined in:
Parameters:
Object
The object that will hold the Value set by the Key.
Key
The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type!
Value
The value to is stored in the object.
Return value:
The Value set.
Trace a function logic level 1.
Can be anywhere within the function logic.
Trace a function logic level 2.
Can be anywhere within the function logic.
Trace a function logic level 3.
Can be anywhere within the function logic.
Trace all methods in MOOSE
Set tracing for a specific method of class
Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.
So tracing must be switched on manually in your mission if you are using Moose statically. When moose is loading dynamically (for moose class development), tracing is switched on by default.
Defined in:
Parameter:
#boolean TraceOnOff
Switch the tracing on or off.
Usage:
-- Switch the tracing On
BASE:TraceOnOff( true )
-- Switch the tracing Off
BASE:TraceOnOff( false )
UnSubscribe to a DCS event.
Trace a function call.
This function is private.
Defined in:
Parameters:
Arguments
A #table or any field.
DebugInfoCurrentParam
DebugInfoFromParam
Trace a function logic.
Defined in:
Parameters:
Arguments
A #table or any field.
DebugInfoCurrentParam
DebugInfoFromParam
TODO: Complete DCS#Event structure.
- The main event handling function... This function captures all events generated for the class.
@param #BASE self
@param DCS#Event event