diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua
index 2194704de..8ecade729 100644
--- a/Moose Development/Moose/Functional/RAT.lua
+++ b/Moose Development/Moose/Functional/RAT.lua
@@ -1,19 +1,44 @@
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---- **Functional** -- Create random airtraffic in your missions.
+--- **Functional** - Create random airtraffic in your missions.
--
-- 
--
-- ====
--
--- The documentation of the RAT class can be found further in this document.
+-- The aim of the RAT class is to fill the empty DCS world with randomized air traffic and bring more life to your airports.
+--
+-- In particular, it is designed to spawn AI air units at random airports. These units will be assigned a random flight path to another random airport on the map.
+--
+-- Even the mission designer will not know where aircraft will be spawned and which route they follow.
+--
+-- ## Features
+--
+-- * Very simple interface. Just one unit and two lines of Lua code needed to fill your map.
+-- * High degree of randomization. Aircraft will spawn at random airports, have random routes and random destinations.
+-- * Specific departure and/or destination airports can be chosen.
+-- * Departure and destination airports can be restricted by coalition.
+-- * Planes and helicopters supported. Helicopters can also be send to FARPs and ships.
+-- * Units can also be spawned in air within pre-defined zones of the map.
+-- * Aircraft will be removed when they arrive at their destination (or get stuck on the ground).
+-- * When a unit is removed a new unit with a different flight plan is respawned.
+-- * Aircraft can report their status during the route.
+-- * All of the above can be customized by the user if necessary.
+-- * All current (Caucasus, Nevada, Normandy) and future maps are supported.
+--
+-- The RAT class creates an entry in the F10 menu which allows to
+--
+-- * Create new groups on-the-fly, i.e. at run time within the mission,
+-- * Destroy specific groups (e.g. if they get stuck or damaged and block a runway),
+-- * Request the status of all RAT aircraft or individual groups,
+-- * Place markers at waypoints on the F10 map for each group.
+--
+-- Note that by its very nature, this class is suited best for civil or transport aircraft. However, it also works perfectly fine for military aircraft of any kind.
+--
+-- More of the documentation include some simple examples can be found further down this page.
--
-- ====
--
-- # Demo Missions
---
--- ### [RAT Demo Missions source code](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/SPA%20-%20Spawning)
---
--- ### [RAT Demo Missions, only for beta testers](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SPA%20-%20Spawning)
--
-- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases)
--
@@ -24,74 +49,192 @@
-- ### [RAT YouTube Channel](https://www.youtube.com/playlist?list=PL7ZUrU4zZUl1jirWIo4t4YxqN-HxjqRkL)
--
-- ===
--- ====
--
-- ### Author: **[funkyfranky](https://forums.eagle.ru/member.php?u=115026)**
--
--- ### Contributions: **Sven Van de Velde ([FlightControl](https://forums.eagle.ru/member.php?u=89536))**
+-- ### Contributions: **Sven van de Velde ([FlightControl](https://forums.eagle.ru/member.php?u=89536))**
--
-- ====
-- @module Rat
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
--- TODO: Add description.
-
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
---- RAT class
+--- RAT class
-- @type RAT
--- @field #string ClassName Name of the Class
--- @field #boolean debug
--- @field #number spawndelay
--- @field #number spawninterval
--- @field #number coalition
--- @field #string category
--- @field #string friendly
--- @field #table ctable
--- @field #table aircraft
--- @field #number Vcruisemax
--- @field #number Vclimb
--- @field #number AlphaDescent
--- @field #string roe
--- @field #string rot
--- @field #string takeoff
--- @field #number mindist
--- @field #number maxdist
--- @field #table airports_map
--- @field #table airports
--- @field #boolean random_departure
--- @field #boolean random_destination
--- @field #table departure_zones
--- @field #table departure_ports
--- @field #table destination_ports
--- @field #table ratcraft
--- @field #boolean reportstatus
--- @field #number statusinterval
--- @field #boolean placemarkers
--- @field #number FLuser
--- @field #number FLminuser
--- @field #number FLmaxuser
--- @field #boolean commute
--- @field #boolean continuejourney
--- @field #number alive
--- @field #boolean f10menu
--- @field #table Menu
--- @field #string SubMenuName
--- @field #boolean respawn_after_landing
--- @field #number respawn_delay
--- @field #table markerids
--- @field #table RAT
+-- @field #string ClassName Name of the Class.
+-- @field #boolean debug Turn debug messages on or off.
+-- @field #number spawndelay Delay time in seconds before first spawning happens.
+-- @field #number spawninterval Interval between spawning units/groups. Note that we add a randomization of 50%.
+-- @field #number coalition Coalition of spawn group template.
+-- @field #string category Category of aircarft: "plane" or "heli".
+-- @field #string friendly Possible departure/destination airport: all=blue+red+neutral, same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red.
+-- @field #table ctable Table with the valid coalitons from choice self.friendly.
+-- @field #table aircraft Table which holds the basic aircraft properties (speed, range, ...).
+-- @field #number Vcruisemax Max cruise speed in m/s (250 m/s = 900 km/h = 486 kt) set by user.
+-- @field #number Vclimb Default climb rate in ft/min.
+-- @field #number AlphaDescent Default angle of descenti in degrees. A value of 3.6 follows the 3:1 rule of 3 miles of travel and 1000 ft descent.
+-- @field #string roe ROE of spawned groups, default is weapon hold (this is a peaceful class for civil aircraft or ferry missions). Possible: "hold", "return", "free".
+-- @field #string rot ROT of spawned groups, default is no reaction. Possible: "noreaction", "passive", "evade".
+-- @field #string takeoff Takeoff type. 0=coldorhot.
+-- @field #number mindist Min distance from departure to destination in meters. Default 5 km.
+-- @field #number maxdist Max distance from departure to destination in meters. Default 5000 km.
+-- @field #table airports_map All airports available on current map (Caucasus, Nevada, Normandy, ...).
+-- @field #table airports All airports of friedly coalitions.
+-- @field #boolean random_departure By default a random friendly airport is chosen as departure.
+-- @field #boolean random_destination By default a random friendly airport is chosen as destination.
+-- @field #table departure_zones Array containing the names of the departure zones.
+-- @field #table departure_ports Array containing the names of the destination airports.
+-- @field #table destination_ports Array containing the names of the destination airports.
+-- @field #table ratcraft Array with the spawned RAT aircraft.
+-- @field #number Tinactive Time in seconds after which inactive units will be destroyed. Default is 180 seconds.
+-- @field #boolean reportstatus Aircraft report status.
+-- @field #number statusinterval Intervall between status checks (and reports if enabled).
+-- @field #boolean placemarkers Place markers of waypoints on F10 map.
+-- @field #number FLuser Flight level set by users explicitly.
+-- @field #number FLminuser Minimum flight level set by user.
+-- @field #number FLmaxuser Maximum flight level set by user.
+-- @field #boolean commute Aircraft commute between departure and destination, i.e. when respawned the departure airport becomes the new destiation.
+-- @field #boolean continuejourney Aircraft will continue their journey, i.e. get respawned at their destination with a new random destination.
+-- @field #number ngroups Number of groups to be spawned in total.
+-- @field #number alive Number of groups which are alive.
+-- @field #boolean f10menu Add an F10 menu for RAT.
+-- @field #table Menu F10 menu items for this RAT object.
+-- @field #string SubMenuName Submenu name for RAT object.
+-- @field #boolean respawn_at_landing Respawn aircraft the moment they land rather than at engine shutdown.
+-- @field #number respawn_delay Delay in seconds until repawn happens after landing.
+-- @field #table markerids Array with marker IDs.
-- @extends Functional.Spawn#SPAWN
---- # RAT class, extends @{Spawn#SPAWN}
+---# RAT class, extends @{Spawn#SPAWN}
+-- The RAT class implements an easy to use way to randomly fill your map with AI aircraft.
--
--- The RAT class allows to easily create random air traffic in your missions.
--
-
-
---- RAT class
--- @field #RAT RAT
+-- ## Airport Selection
+--
+-- 
+--
+-- ### Default settings:
+--
+-- * By default, aircraft are spawned at airports of their own coalition (blue or red) or neutral airports.
+-- * Destination airports are by default also of neutral or of the same coalition as the template group of the spawned aircraft.
+-- * Possible destinations are restricted by their distance to the departure airport. The maximal distance depends on the max range of spawned aircraft type and its initial fuel amount.
+--
+-- ### The default behavior can be changed:
+--
+-- * A specific departure and/or destination airport can be chosen.
+-- * Valid coalitions can be set, e.g. only red, blue or neutral, all three „colours“.
+-- * It is possible to start in air within a zone defined in the mission editor or within a zone above an airport of the map.
+--
+-- ## Flight Plan
+--
+-- 
+--
+-- * A general flight plan has five main airborn segments: Climb, cruise, descent, holding and final approach.
+-- * Events monitored during the flight are: birth, engine-start, take-off, landing and engine-shutdown.
+-- * The default flight level (FL) is set to ~FL200, i.e. 20000 feet ASL but randomized for each aircraft.
+-- Service ceiling of aircraft type is into account for max FL as well as the distance between departure and destination.
+-- * Maximal distance between destination and departure airports depends on range and initial fuel of aircraft.
+-- * Climb rate is set to a moderate value of ~1500 ft/min.
+-- * The standard descent rate follows the 3:1 rule, i.e. 1000 ft decent per 3 miles of travel. Hence, angle of descent is ~3.6 degrees.
+-- * A holding point is randomly selected at a distance between 5 and 10 km away from destination airport.
+-- * The altitude of theholding point is ~1200 m AGL. Holding patterns might or might not happen with variable duration.
+-- * If an aircraft is spawned in air, the procedure omitts taxi and take-off and starts with the climb/cruising part.
+-- * All values are randomized for each spawned aircraft.
+--
+-- ## Mission Editor Setup
+--
+-- 
+--
+-- Basic mission setup is very simple and essentially a three step process:
+--
+-- * Place your aircraft **anywhere** on the map. It really does not matter where you put it.
+-- * Give the group a good name. In the example above the group is named "RAT_YAK".
+-- * Activate the "LATE ACTIVATION" tick box. Note that this aircraft will not be spawned itself but serves a template for each RAT aircraft spawned when the mission starts.
+--
+-- Voilà, your already done!
+--
+-- Optionally, you can set a specific livery for the aircraft or give it some weapons.
+-- However, the aircraft will by default not engage any enemies. Think of them as beeing on a peaceful or ferry mission.
+--
+-- ## Basic Lua Script
+--
+-- 
+--
+-- The basic Lua script for one template group consits of two simple lines as shown in the picture above.
+--
+-- * **Line 2** creates a new RAT object "yak". The only required parameter for the constructor @{#RAT.New}() is the name of the group as defined in the mission editor. In this example it is "RAT_YAK".
+-- * **Line 5** trigger the command to spawn the aircraft. The (optional) parameter for the @{#RAT.Spawn}() function is the number of aircraft to be spawned of this object.
+-- By default each of these aircraft gets a random departure airport anywhere on the map and a random destination airport, which lies within range of the of the selected aircraft type.
+--
+-- In this simple example aircraft are respawned with a completely new flightplan when they have reached their destination airport.
+-- The "old" aircraft is despawned (destroyed) after it has shut-down its engines and a new aircraft of the same type is spawned at a random departure airport anywhere on the map.
+-- Hence, the default flight plan for a RAT aircraft will be: Fly from airport A to B, get respawned at C and fly to D, get respawned at E and fly to F, ...
+-- This ensures that you always have a constant number of AI aircraft on your map.
+--
+-- ## Examples
+--
+-- Here are a few examples, how you can modify the default settings of RAT class objects.
+--
+-- ### Specify Departure and Destinations
+--
+-- 
+--
+-- In the picture above you find a few possibilities how to modify the default behaviour to spawn at random airports and fly to random destinations.
+--
+-- In particular, you can specify fixed departure and/or destination airports. This is done via the @{#RAT.SetDeparture}() or @{#RAT.SetDestination}() functions, respectively.
+--
+-- * If you only fix a specific departure airport via @{#RAT.SetDeparture}() all aircraft will be spawned at that airport and get random destination airports.
+-- * If you only fix the destination airport via @{#RAT.SetDestination}(), aircraft a spawned at random departure airports but will all fly to the destination airport.
+-- * If you fix departure and destination airports, aircraft will only travel from between those airports.
+-- When the aircraft reaches its destination, it will be respawned at its departure and fly again to its destination.
+--
+-- There is also an option that allows aircraft to "continue their journey" from their destination. This is achieved by the @{#RAT.ContinueJourney}() function.
+-- In that case, when the aircraft arrives at its first destination it will be respawned at that very airport and get a new random destination.
+-- So the flight plan in this case would be: Fly from airport A to B, then from B to C, then from C to D, ...
+--
+-- It is also possible to make aircraft "commute" between two airports, i.e. flying from airport A to B and then back from B to A, etc.
+-- This can be done by the @{#RAT.Commute}() function. Note that if no departure or destination airports are specified, the first departure and destination are chosen randomly.
+-- Then the aircraft will fly back and forth between those two airports indefinetly.
+--
+--
+-- ### Spawn in Air
+--
+-- 
+--
+-- Aircraft can also be spawned in air rather than at airports on the ground. This is done by setting @{#RAT.SetTakeoff}() to "air".
+--
+-- By default, aircraft are spawned randomly above airports of the map.
+--
+-- The @{#RAT.SetDeparture}() option can be used to specify zones, which have been defined in the mission editor as departure zones.
+-- Aircraft will then be spawned at a random point within the zone or zones.
+--
+-- Note that @{#RAT.SetDeparture}() also accepts airport names. For an air takeoff these are treated like zones with a radius of XX kilometers.
+-- Again, aircraft are spawned at random points within these zones around the airport.
+--
+-- ### Misc Options
+--
+-- 
+--
+-- The default "takeoff" type of RAT aircraft is that they are spawned with hot or cold engines.
+-- The choice is random, so 50% of aircraft will be spawned with hot engines while the other 50% will be spawned with cold engines.
+-- This setting can be changed using the @{#RAT.SetTakeoff}() function. The possible parameters for starting on ground are:
+--
+-- * @{#RAT.SetTakeoff}("cold"), which means that all aircraft are spawned with their engines off,
+-- * @{#RAT.SetTakeoff}("hot"), which means that all aircraft are spawned with their engines on,
+-- * @{#RAT.SetTakeoff}("runway"), which means that all aircraft are spawned already at the runway ready to takeoff.
+-- Note that in this case the default spawn intervall is set to 180 seconds in order to avoid aircraft jamms on the runway. Generally, this takeoff at runways should be used with care and problems are to be expected.
+--
+--
+-- The options @{#RAT.SetMinDistance}() and @{#RAT.SetMaxDistance}() can be used to restrict the range from departure to destination. For example
+--
+-- * @{#RAT.SetMinDistance}(100) will cause only random destination airports to be selected which are **at least** 100 km away from the departure airport.
+-- * @{#RAT.SetMaxDistance}(150) will allow only destination airports which are **less than** 150 km away from the departure airport.
+--
+--
+-- Certain other options like the flight level can also be specified. However, note that this might not be a good idea for random departures and/or destinations.
+-- For example the random route might be too short to reach that altitude, which would result in very high climb and descent rates or strange flight plans.
+--
+--
+-- @field #RAT
RAT={
ClassName = "RAT", -- Name of class: RAT = Random Air Traffic.
debug=false, -- Turn debug messages on or off.
@@ -102,7 +245,7 @@ RAT={
friendly = "same", -- Possible departure/destination airport: all=blue+red+neutral, same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red.
ctable = {}, -- Table with the valid coalitons from choice self.friendly.
aircraft = {}, -- Table which holds the basic aircraft properties (speed, range, ...).
- Vcruisemax=250, -- Max cruise speed in m/s (250 m/s = 900 km/h = 486 kt).
+ Vcruisemax=nil, -- Max cruise speed in set by user.
Vclimb=1500, -- Default climb rate in ft/min.
AlphaDescent=3.6, -- Default angle of descenti in degrees. A value of 3.6 follows the 3:1 rule of 3 miles of travel and 1000 ft descent.
roe = "hold", -- ROE of spawned groups, default is weapon hold (this is a peaceful class for civil aircraft or ferry missions). Possible: "hold", "return", "free".
@@ -118,15 +261,17 @@ RAT={
departure_ports={}, -- Array containing the names of the departure airports.
destination_ports={}, -- Array containing the names of the destination airports.
ratcraft={}, -- Array with the spawned RAT aircraft.
+ Tinactive=180, -- Time in seconds after which inactive units will be destroyed. Default is 180 seconds.
reportstatus=false, -- Aircraft report status.
statusinterval=30, -- Intervall between status checks (and reports if enabled).
placemarkers=false, -- Place markers of waypoints on F10 map.
FLminuser=nil, -- Minimum flight level set by user.
- FLmaxuser=nil, -- Minimum flight level set by user.
+ FLmaxuser=nil, -- Maximum flight level set by user.
FLuser=nil, -- Flight level set by users explicitly.
commute=false, -- Aircraft commute between departure and destination, i.e. when respawned the departure airport becomes the new destiation.
continuejourney=false, -- Aircraft will continue their journey, i.e. get respawned at their destination with a new random destination.
alive=0, -- Number of groups which are alive.
+ ngroups=nil, -- Number of groups to be spawned in total.
f10menu=true, -- Add an F10 menu for RAT.
Menu={}, -- F10 menu items for this RAT object.
SubMenuName=nil, -- Submenu name for RAT object.
@@ -138,14 +283,16 @@ RAT={
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Categories of the RAT class.
--- @field #RAT cat
+-- @list cat
+-- @field #string plane Plane.
+-- @field #string heli Heli.
RAT.cat={
- plane="plane",
- heli="heli",
+ plane="plane", --plane
+ heli="heli", --hallo
}
--- RAT waypoint type.
--- @field #RAT wp
+-- @list wp
RAT.wp={
coldorhot=0,
air=1,
@@ -160,7 +307,7 @@ RAT.wp={
}
--- RAT friendly coalitions.
--- @field #RAT coal
+-- @list coal
RAT.coal={
same="same",
sameonly="sameonly",
@@ -173,7 +320,7 @@ RAT.coal={
}
--- RAT unit conversions.
--- @field #RAT unit
+-- @list unit
RAT.unit={
ft2meter=0.305,
kmh2ms=0.278,
@@ -183,7 +330,7 @@ RAT.unit={
}
--- RAT rules of engagement.
--- @field #RAT ROE
+-- @list ROE
RAT.ROE={
weaponhold="hold",
weaponfree="free",
@@ -191,7 +338,7 @@ RAT.ROE={
}
--- RAT reaction to threat.
--- @field #RAT ROT
+-- @list ROT
RAT.ROT={
evade="evade",
passive="passive",
@@ -199,16 +346,16 @@ RAT.ROT={
}
--- Running number of placed markers on the F10 map.
--- @field #RAT markerid
+-- @field #number markerid
RAT.markerid=0
--- Main F10 menu.
--- @field #RAT MenuF10
+-- @field #string MenuF10
RAT.MenuF10=nil
---- Some ID to identify where we are
--- #string myid
-myid="RAT | "
+--- Some ID to identify who we are in output of the DCS.log file.
+-- @field #string id
+RAT.id="RAT | "
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -237,7 +384,7 @@ myid="RAT | "
--TODO: Check out uncontrolled spawning.
--TODO: Check aircraft spawning in air at Sochi after third aircraft was spawned.
--TODO: Improve despawn after stationary. Might lead to despawning if many aircraft spawn at the same time.
---TODO: Check why birth event is not handled.
+--TODO: Check why birth event is not handled. ==> Seems to be okay if it is called _OnBirth rather than _OnBirthday. Dont know why actually!?
--TODO: Improve behaviour when no destination or departure airports were found. Leads to crash, e.g. 1184: attempt to get length of local 'destinations' (a nil value)
--TODO: Check cases where aircraft get shot down. Respawn?
--TODO: Handle the case where more than 10 RAT objects are spawned. Likewise, more than 10 groups of one object. Causes problems with the number of menu items!
@@ -253,7 +400,7 @@ myid="RAT | "
function RAT:New(groupname)
-- Welcome message.
- env.info(myid.."Creating new RAT object from template: "..groupname)
+ env.info(RAT.id.."Creating new RAT object from template: "..groupname)
-- Inherit SPAWN clase.
local self=BASE:Inherit(self, SPAWN:New(groupname)) -- #RAT
@@ -293,54 +440,64 @@ end
function RAT:Spawn(naircraft)
-- Number of aircraft to spawn. Default is one.
- naircraft=naircraft or 1
+ self.ngroups=naircraft or 1
-- Set the coalition table based on choice of self.coalition and self.friendly.
self:_SetCoalitionTable()
-- Get all airports of this map beloning to friendly coalition(s).
self:_GetAirportsOfCoalition()
+
+ -- Set submenuname if it has not been set by user.
+ if not self.SubMenuName then
+ self.SubMenuName=self.SpawnTemplatePrefix
+ end
+ -- Check if submenu already exsits.
+ if self.f10menu then
+ if self.Menu[self.SubMenuName] then
+ self.SubMenuName=self.SubMenuName.." 01"
+ end
+ end
-- debug message
local text=string.format("\n******************************************************\n")
- text=text..string.format("Spawning %i aircraft from template %s of type %s.\n", naircraft, self.SpawnTemplatePrefix, self.aircraft.type)
- text=text..string.format("Takeoff type: %i\n", self.takeoff)
+ text=text..string.format("Spawning %i aircraft from template %s of type %s.\n", self.ngroups, self.SpawnTemplatePrefix, self.aircraft.type)
+ text=text..string.format("Category: %s\n", self.category)
text=text..string.format("Friendly coalitions: %s\n", self.friendly)
text=text..string.format("Number of airports on map : %i\n", #self.airports_map)
text=text..string.format("Number of friendly airports: %i\n", #self.airports)
+ text=text..string.format("Min dist to destination: %4.1f\n", self.mindist)
+ text=text..string.format("Max dist to destination: %4.1f\n", self.maxdist)
+ text=text..string.format("Takeoff type: %i\n", self.takeoff)
text=text..string.format("Commute: %s\n", tostring(self.commute))
text=text..string.format("Journey: %s\n", tostring(self.continuejourney))
text=text..string.format("Spawn delay: %4.1f\n", self.spawndelay)
text=text..string.format("Spawn interval: %4.1f\n", self.spawninterval)
- text=text..string.format("Category: %s\n", self.category)
- text=text..string.format("Vcruisemax: %4.1f\n", self.Vcruisemax)
- text=text..string.format("Vclimb: %4.1f\n", self.Vclimb)
- text=text..string.format("Vcruisemax: %4.1f\n", self.Vcruisemax)
- text=text..string.format("AlphaDescent: %4.2f\n", self.AlphaDescent)
+ text=text..string.format("Respawn after landing: %s\n", tostring(self.respawn_at_landing))
+ text=text..string.format("Respawn delay: %s\n", tostring(self.respawn_delay))
text=text..string.format("ROE: %s\n", tostring(self.roe))
text=text..string.format("ROT: %s\n", tostring(self.rot))
- text=text..string.format("Min dist: %4.1f\n", self.mindist)
- text=text..string.format("Max dist: %4.1f\n", self.maxdist)
- text=text..string.format("Report status: %s\n", tostring(self.reportstatus))
- text=text..string.format("Status interval: %4.1f\n", self.statusinterval)
- text=text..string.format("Place markers: %s\n", tostring(self.placemarkers))
+ text=text..string.format("Vclimb: %4.1f\n", self.Vclimb)
+ text=text..string.format("AlphaDescent: %4.2f\n", self.AlphaDescent)
+ text=text..string.format("Vcruisemax: %s\n", tostring(self.Vcruisemax))
text=text..string.format("FLuser: %s\n", tostring(self.Fluser))
text=text..string.format("FLminuser: %s\n", tostring(self.Flminuser))
text=text..string.format("FLmaxuser: %s\n", tostring(self.Flmaxuser))
- text=text..string.format("Respawn after landing: %s\n", tostring(self.respawn_after_landing))
- text=text..string.format("Respawn delay: %s\n", tostring(self.respawn_delay))
- -- @field #number FLminuser
+ text=text..string.format("Place markers: %s\n", tostring(self.placemarkers))
+ text=text..string.format("Report status: %s\n", tostring(self.reportstatus))
+ text=text..string.format("Status interval: %4.1f\n", self.statusinterval)
+ text=text..string.format("Time inactive: %4.1f\n", self.Tinactive)
+ text=text..string.format("Create F10 menu : %s\n", tostring(self.f10menu))
+ text=text..string.format("F10 submenu name: %s\n", self.SubMenuName)
text=text..string.format("******************************************************\n")
- env.info(myid..text)
-
+ env.info(RAT.id..text)
-- Create submenus.
if self.f10menu then
- self.SubMenuName=self.SpawnTemplatePrefix
self.Menu[self.SubMenuName]=MENU_MISSION:New(self.SubMenuName, RAT.MenuF10)
self.Menu[self.SubMenuName]["groups"]=MENU_MISSION:New("Groups", self.Menu[self.SubMenuName])
MENU_MISSION_COMMAND:New("Spawn new group", self.Menu[self.SubMenuName], self._SpawnWithRoute, self)
- MENU_MISSION_COMMAND:New("Delete markers", self.Menu[self.SubMenuName], self._DeleteMarkers, self, self.markerids)
+ MENU_MISSION_COMMAND:New("Delete markers", self.Menu[self.SubMenuName], self._DeleteMarkers, self)
MENU_MISSION_COMMAND:New("Status report", self.Menu[self.SubMenuName], self.Status, self, true)
end
@@ -351,8 +508,8 @@ function RAT:Spawn(naircraft)
if self.takeoff==RAT.wp.runway then
dt=math.max(dt, 180)
end
- local Tstop=Tstart+dt*(naircraft-1)
- SCHEDULER:New(nil, self._SpawnWithRoute, {self}, Tstart, dt, 0.1, Tstop)
+ local Tstop=Tstart+dt*(self.ngroups-1)
+ SCHEDULER:New(nil, self._SpawnWithRoute, {self}, Tstart, dt, 0.0, Tstop)
-- Status check and report scheduler.
SCHEDULER:New(nil, self.Status, {self}, Tstart+1, self.statusinterval)
@@ -529,14 +686,22 @@ end
-- @param #number delay (Optional) Delay in seconds until respawn happens after landing. Default is 180 seconds.
function RAT:RespawnAfterLanding(delay)
delay = delay or 180
- self.respawn_after_landing=true
+ self.respawn_at_landing=true
self.respawn_delay=delay
end
+--- Set the time after which inactive groups will be destroyed. Default is 180 seconds.
+-- @param #RAT self
+-- @param #number time Time in seconds.
+function RAT:TimeDestroyInactive(time)
+ self.Tinactive=time
+end
+
--- Set the maximum cruise speed of the aircraft.
-- @param #RAT self
-- @param #number speed Speed in km/h.
function RAT:SetMaxCruiseSpeed(speed)
+ -- Convert to m/s.
self.Vcruisemax=speed/3.6
end
@@ -569,7 +734,7 @@ end
--- Set reaction to threat (ROT). Default is no reaction, i.e. aircraft will simply ignore all enemies.
-- @param #RAT self
--- @param #string rot "noreaction = no reactino, "passive" = passive defence, "evade" = weapons free.
+-- @param #string rot "noreaction" = no reaction to threats, "passive" = passive defence, "evade" = evade enemy attacks.
function RAT:SetROT(rot)
if rot=="passive" then
self.rot=RAT.ROT.passive
@@ -581,7 +746,7 @@ function RAT:SetROT(rot)
end
--- Set minimum distance between departure and destination. Default is 5 km.
--- Minimum distance should not be smaller than ~500(?) meters to ensure that departure and destination are different.
+-- Minimum distance should not be smaller than maybe ~500 meters to ensure that departure and destination are different.
-- @param #RAT self
-- @param #number dist Distance in km.
function RAT:SetMinDistance(dist)
@@ -662,7 +827,7 @@ function RAT:_InitAircraft(DCSgroup)
local DCScategory=DCSgroup:getCategory()
local DCStype=DCSunit:getTypeName()
- -- Ddescriptors table of unit.
+ -- Descriptors table of unit.
if self.debug then
self:E({"DCSdesc", DCSdesc})
end
@@ -674,7 +839,7 @@ function RAT:_InitAircraft(DCSgroup)
self.category=RAT.cat.heli
else
self.category="other"
- env.error(myid.."Group of RAT is neither airplane nor helicopter!")
+ env.error(RAT.id.."Group of RAT is neither airplane nor helicopter!")
end
-- Get type of aircraft.
@@ -721,7 +886,7 @@ function RAT:_InitAircraft(DCSgroup)
text=text..string.format("Ceiling = %6.1f km = FL%3.0f\n", self.aircraft.ceiling/1000, self.aircraft.ceiling/RAT.unit.FL2m)
text=text..string.format("FL cruise = %6.1f km = FL%3.0f\n", self.aircraft.FLcruise/1000, self.aircraft.FLcruise/RAT.unit.FL2m)
text=text..string.format("******************************************************\n")
- env.info(myid..text)
+ env.info(RAT.id..text)
end
@@ -737,18 +902,27 @@ end
-- @param #string _destination (Optional) Name of destination airbase.
function RAT:_SpawnWithRoute(_departure, _destination)
+ -- Check that we don't already have more groups than we initally wanted.
+ if self.alive > self.ngroups then
+ return
+ end
+
-- Set takeoff type.
local _takeoff=self.takeoff
if self.takeoff==RAT.wp.coldorhot then
local temp={RAT.wp.cold, RAT.wp.hot}
_takeoff=temp[math.random(2)]
- env.info(myid.."Random takeoff type: ".._takeoff)
end
- env.info(myid.."Takeoff type: ".._takeoff)
+ env.info(RAT.id.."Takeoff type: ".._takeoff)
-- Set flight plan.
local departure, destination, waypoints = self:_SetRoute(_takeoff, _departure, _destination)
+ -- Return nil if we could not find a departure destination or waypoints
+ if not (departure and destination and waypoints) then
+ return nil
+ end
+
-- Modify the spawn template to follow the flight plan.
self:_ModifySpawnTemplate(waypoints)
@@ -774,14 +948,17 @@ function RAT:_SpawnWithRoute(_departure, _destination)
if group:InAir() then
self.ratcraft[self.SpawnIndex]["Tground"]=nil
self.ratcraft[self.SpawnIndex]["Pground"]=nil
+ self.ratcraft[self.SpawnIndex]["Tlastcheck"]=nil
else
self.ratcraft[self.SpawnIndex]["Tground"]=timer.getTime()
self.ratcraft[self.SpawnIndex]["Pground"]=group:GetCoordinate()
+ self.ratcraft[self.SpawnIndex]["Tlastcheck"]=timer.getTime()
end
-- Initial and current position. For calculating the travelled distance.
self.ratcraft[self.SpawnIndex]["P0"]=group:GetCoordinate()
self.ratcraft[self.SpawnIndex]["Pnow"]=group:GetCoordinate()
self.ratcraft[self.SpawnIndex]["Distance"]=0
+
-- Each aircraft gets its own takeoff type and randomized route.
self.ratcraft[self.SpawnIndex]["takeoff"]=_takeoff
self.ratcraft[self.SpawnIndex]["random_departure"]=self.random_departure
@@ -805,10 +982,11 @@ function RAT:_SpawnWithRoute(_departure, _destination)
-- F10/RAT/
Defender :
This table contains the targets detected during patrol.
-Contains the counter how many units are currently alive
-Provides a coordinate string of the point, based on a coordinate format system: * Uses default settings in COORDINATE.
+Provides a coordinate string of the point, based on the A2A coordinate format system.
+Provides a coordinate string of the point, based on the A2G coordinate format system.
Provides a coordinate string of the point, based on the A2A coordinate format system.
+ +Wrapper.Controllable#CONTROLLABLE Controllable :
Core.Settings#SETTINGS Settings :
#string: +The coordinate Text in the configured coordinate system.
+ +Provides a coordinate string of the point, based on the A2G coordinate format system.
+ +Wrapper.Controllable#CONTROLLABLE Controllable :
Core.Settings#SETTINGS Settings :
#string: +The coordinate Text in the configured coordinate system.
+ +RatThe documentation of the RAT class can be found further in this document.
+The aim of the RAT class is to fill the empty DCS world with randomized air traffic and bring more life to your airports.
+ +In particular, it is designed to spawn AI air units at random airports. These units will be assigned a random flight path to another random airport on the map.
+ +Even the mission designer will not know where aircraft will be spawned and which route they follow.
+ +The RAT class creates an entry in the F10 menu which allows to
+ +Note that by its very nature, this class is suited best for civil or transport aircraft. However, it also works perfectly fine for military aircraft of any kind.
RAT class
-Some ID to identify where we are
-The RAT class implements an easy to use way to randomly fill your map with AI aircraft.
Default angle of descenti in degrees. A value of 3.6 follows the 3:1 rule of 3 miles of travel and 1000 ft descent.
Name of the Class
+Name of the Class.
Maximum flight level set by user.
Minimum flight level set by user.
Flight level set by users explicitly.
F10 menu items for this RAT object.
Place markers of waypoints on the F10 map.
-Submenu name for RAT object.
+Set the time after which inactive groups will be destroyed.
+Time in seconds after which inactive units will be destroyed. Default is 180 seconds.
Default climb rate in ft/min.
Max cruise speed in m/s (250 m/s = 900 km/h = 486 kt) set by user.
Table which holds the basic aircraft properties (speed, range, ...).
All airports of friedly coalitions.
All airports available on current map (Caucasus, Nevada, Normandy, ...).
Number of groups which are alive.
RAT categories.
+Category of aircarft: "plane" or "heli".
Coalition of spawn group template.
Aircraft commute between departure and destination, i.e. when respawned the departure airport becomes the new destiation.
Aircraft will continue their journey, i.e. get respawned at their destination with a new random destination.
Table with the valid coalitons from choice self.friendly.
Turn debug messages on or off.
Array containing the names of the destination airports.
Array containing the names of the departure zones.
Array containing the names of the destination airports.
Add an F10 menu for RAT.
Possible departure/destination airport: all=blue+red+neutral, same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red.
+Some ID to identify who we are in output of the DCS.log file.
Array with marker IDs.
Max distance from departure to destination in meters. Default 5000 km.
Min distance from departure to destination in meters. Default 5 km.
Place markers of waypoints on F10 map.
By default a random friendly airport is chosen as departure.
By default a random friendly airport is chosen as destination.
Array with the spawned RAT aircraft.
Aircraft report status.
Respawn aircraft the moment they land rather than at engine shutdown.
Delay in seconds until repawn happens after landing.
ROE of spawned groups, default is weapon hold (this is a peaceful class for civil aircraft or ferry missions). Possible: "hold", "return", "free".
ROT of spawned groups, default is no reaction. Possible: "noreaction", "passive", "evade".
Delay time in seconds before first spawning happens.
Interval between spawning units/groups. Note that we add a randomization of 50%.
Intervall between status checks (and reports if enabled).
Takeoff type. 0=coldorhot.
RAT class
+The RAT class implements an easy to use way to randomly fill your map with AI aircraft.
-Some ID to identify where we are
-


Basic mission setup is very simple and essentially a three step process:
+ +Voilà, your already done!
+ +Optionally, you can set a specific livery for the aircraft or give it some weapons. +However, the aircraft will by default not engage any enemies. Think of them as beeing on a peaceful or ferry mission.
+ +
The basic Lua script for one template group consits of two simple lines as shown in the picture above.
+ +In this simple example aircraft are respawned with a completely new flightplan when they have reached their destination airport. +The "old" aircraft is despawned (destroyed) after it has shut-down its engines and a new aircraft of the same type is spawned at a random departure airport anywhere on the map. +Hence, the default flight plan for a RAT aircraft will be: Fly from airport A to B, get respawned at C and fly to D, get respawned at E and fly to F, ... +This ensures that you always have a constant number of AI aircraft on your map.
+ +Here are a few examples, how you can modify the default settings of RAT class objects.
+ +
In the picture above you find a few possibilities how to modify the default behaviour to spawn at random airports and fly to random destinations.
+ +In particular, you can specify fixed departure and/or destination airports. This is done via the RAT.SetDeparture() or RAT.SetDestination() functions, respectively.
+ +There is also an option that allows aircraft to "continue their journey" from their destination. This is achieved by the RAT.ContinueJourney() function. +In that case, when the aircraft arrives at its first destination it will be respawned at that very airport and get a new random destination. +So the flight plan in this case would be: Fly from airport A to B, then from B to C, then from C to D, ...
+ +It is also possible to make aircraft "commute" between two airports, i.e. flying from airport A to B and then back from B to A, etc. +This can be done by the RAT.Commute() function. Note that if no departure or destination airports are specified, the first departure and destination are chosen randomly. +Then the aircraft will fly back and forth between those two airports indefinetly.
+ + +
Aircraft can also be spawned in air rather than at airports on the ground. This is done by setting RAT.SetTakeoff() to "air".
+ +By default, aircraft are spawned randomly above airports of the map.
+ +The RAT.SetDeparture() option can be used to specify zones, which have been defined in the mission editor as departure zones. +Aircraft will then be spawned at a random point within the zone or zones.
+ +Note that RAT.SetDeparture() also accepts airport names. For an air takeoff these are treated like zones with a radius of XX kilometers. +Again, aircraft are spawned at random points within these zones around the airport.
+ +
The default "takeoff" type of RAT aircraft is that they are spawned with hot or cold engines. +The choice is random, so 50% of aircraft will be spawned with hot engines while the other 50% will be spawned with cold engines. +This setting can be changed using the RAT.SetTakeoff() function. The possible parameters for starting on ground are:
+ +The options RAT.SetMinDistance() and RAT.SetMaxDistance() can be used to restrict the range from departure to destination. For example
+ +Certain other options like the flight level can also be specified. However, note that this might not be a good idea for random departures and/or destinations. +For example the random route might be too short to reach that altitude, which would result in very high climb and descent rates or strange flight plans.
+ +RATRAT class
+Default angle of descenti in degrees. A value of 3.6 follows the 3:1 rule of 3 miles of travel and 1000 ft descent.
Name of the Class
+Name of the Class.
Maximum flight level set by user.
Minimum flight level set by user.
Flight level set by users explicitly.
F10 menu items for this RAT object.
Default is 5 km. -Minimum distance should not be smaller than ~500(?) meters to ensure that departure and destination are different.
+Minimum distance should not be smaller than maybe ~500 meters to ensure that departure and destination are different.#string rot :
-"noreaction = no reactino, "passive" = passive defence, "evade" = weapons free.
Submenu name for RAT object.
+Set the time after which inactive groups will be destroyed.
+ + +Default is 180 seconds.
+ +#number time :
+Time in seconds.
Time in seconds after which inactive units will be destroyed. Default is 180 seconds.
Default climb rate in ft/min.
Max cruise speed in m/s (250 m/s = 900 km/h = 486 kt) set by user.
Table which holds the basic aircraft properties (speed, range, ...).
All airports of friedly coalitions.
All airports available on current map (Caucasus, Nevada, Normandy, ...).
Number of groups which are alive.
RAT categories.
+Category of aircarft: "plane" or "heli".
Coalition of spawn group template.
Aircraft commute between departure and destination, i.e. when respawned the departure airport becomes the new destiation.
Aircraft will continue their journey, i.e. get respawned at their destination with a new random destination.
Table with the valid coalitons from choice self.friendly.
Turn debug messages on or off.
Array containing the names of the destination airports.
Array containing the names of the departure zones.
Array containing the names of the destination airports.
Add an F10 menu for RAT.
Possible departure/destination airport: all=blue+red+neutral, same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red.
Some ID to identify who we are in output of the DCS.log file.
+ +Array with marker IDs.
Max distance from departure to destination in meters. Default 5000 km.
Min distance from departure to destination in meters. Default 5 km.
Place markers of waypoints on F10 map.
By default a random friendly airport is chosen as departure.
By default a random friendly airport is chosen as destination.
Array with the spawned RAT aircraft.
Aircraft report status.
Respawn aircraft the moment they land rather than at engine shutdown.
Delay in seconds until repawn happens after landing.
ROE of spawned groups, default is weapon hold (this is a peaceful class for civil aircraft or ferry missions). Possible: "hold", "return", "free".
ROT of spawned groups, default is no reaction. Possible: "noreaction", "passive", "evade".
Delay time in seconds before first spawning happens.
Interval between spawning units/groups. Note that we add a randomization of 50%.
Intervall between status checks (and reports if enabled).
Takeoff type. 0=coldorhot.
Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.
+Overwrite unit names by default with group name.
-Gets the ID of the Task
+Gets the Information of the Task
Gets the Information of the Task
+ +#string TaskInfo :
+The key and title of the task information.
#string: +TaskInfoText The Task info text.
+ +Wrapper.Group#GROUP TaskGroup :