Module Rat

  • Functional - (R2.2) - Create random airtraffic in your missions.

Banner Image


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 radio 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

MOOSE - ALL Demo Missions

MOOSE - RAT Demo Missions


YouTube Channel

MOOSE YouTube Channel

MOOSE - RAT - Random Air Traffic


Author: funkyfranky

Contributions: FlightControl


Global(s)

RAT

RAT class, extends Core.Spawn#SPAWN

The RAT class implements an easy to use way to randomly fill your map with AI aircraft.

RATMANAGER

RATMANAGER class, extends Core.Base#BASE

The RATMANAGER class manages spawning of multiple RAT objects in a very simple way.

Type RAT

RAT.ATC

RAT ATC.

RAT:ATC_Clearance(n)

Max number of planes that get landing clearance of the RAT ATC.

RAT:ATC_Delay(time)

Delay between granting landing clearance for simultanious landings.

RAT:ATC_Messages(switch)

Turn messages from ATC on or off.

RAT.ATCswitch

Enable/disable ATC if set to true/false.

RAT:ActivateUncontrolled(maxactivated, delay, delta, frand)

Activate uncontrolled aircraft.

RAT:AddFriendlyAirportsToDepartures()

Add all friendly airports to the list of possible departures.

RAT:AddFriendlyAirportsToDestinations()

Add all friendly airports to the list of possible destinations

RAT.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.

RAT:ChangeAircraft(actype)

Change aircraft type.

RAT:CheckOnRunway(switch)

Check if aircraft have accidentally been spawned on the runway.

RAT:CheckOnTop(switch)

Check if aircraft have accidentally been spawned on top of each other.

RAT.ClassName

Name of the Class.

RAT:ClearForLanding(name)

Clear flight for landing.

RAT:Commute()

Aircraft will commute between their departure and destination airports or zones.

RAT:ContinueJourney()

Aircraft will continue their journey from their destination.

RAT.Debug

Turn debug messages on or off.

RAT:Debugmode()

Enable debug mode.

RAT:DestinationZone()

Destinations are treated as zones.

RAT:EnableATC(switch)

Enable ATC, which manages the landing queue for RAT aircraft if they arrive simultaniously at the same airport.

RAT:ExcludedAirports(ports)

Airports, FARPs and ships explicitly excluded as departures and destinations.

RAT.FLcruise

Cruise altitude of aircraft. Default FL200 for planes and F005 for helos.

RAT.FLmaxuser

Maximum flight level set by user.

RAT.FLminuser

Minimum flight level set by user.

RAT.FLuser

Flight level set by users explicitly.

RAT:Immortal()

Aircraft are immortal.

RAT:Invisible()

Aircraft are invisible.

RAT:Livery(skins)

Set livery of aircraft.

RAT.Menu

F10 menu items for this RAT object.

RAT.MenuF10

Main F10 menu.

RAT:MenuName(name)

Set the name of the F10 submenu.

RAT.Ndeparture_Airports

Number of departure airports set via SetDeparture().

RAT.Ndeparture_Zones

Number of departure zones set via SetDeparture.

RAT.Ndestination_Airports

Number of destination airports set via SetDestination().

RAT.Ndestination_Zones

Number of destination zones set via SetDestination().

RAT:New(groupname, alias)

Create a new RAT object.

RAT:NoRespawn()

Aircraft will not get respawned when they finished their route.

RAT:ParkingSpotDB(switch)

Put parking spot coordinates in a data base for future use of aircraft.

RAT:PlaceMarkers(switch)

Place markers of waypoints on the F10 map.

RAT.ROE

RAT rules of engagement.

RAT.ROT

RAT reaction to threat.

RAT:RadioFrequency(frequency)

Set radio frequency.

RAT:RadioMenuOFF()

Radio menu Off.

RAT:RadioMenuON()

Radio menu On.

RAT:RadioModulation(modulation)

Set radio modulation.

RAT:RadioOFF()

Disable Radio.

RAT:RadioON()

Enable Radio.

RAT:RespawnAfterCrashOFF()

Aircraft will not be respawned after they crashed or get shot down.

RAT:RespawnAfterCrashON()

Aircraft will be respawned after they crashed or get shot down.

RAT:RespawnAfterLanding(delay)

Make aircraft respawn the moment they land rather than at engine shut down.

RAT:RespawnAfterTakeoff()

Aircraft will be respawned directly after take-off.

RAT:RespawnInAirAllowed()

If aircraft cannot be spawned on parking spots, it is allowed to spawn them in air above the same airport.

RAT:RespawnInAirNotAllowed()

If aircraft cannot be spawned on parking spots, it is NOT allowed to spawn them in air.

RAT:ReturnZone()

Aircraft will fly to a random point within a zone and then return to its departure airport or zone.

RAT:SetAISkill(skill)

Set skill of AI aircraft.

RAT:SetClimbRate(rate)

Set the climb rate.

RAT:SetCoalition(friendly)

Set the friendly coalitions from which the airports can be used as departure and destination.

RAT:SetCoalitionAircraft(color)

Set coalition of RAT group.

RAT:SetCountry(id)

Set country of RAT group.

RAT:SetCruiseAltitude(alt)

Set cruising altitude.

RAT:SetDeparture(departurenames)

Set possible departure ports.

RAT:SetDeparturesFromZone(zone)

Include all airports which lie in a zone as possible destinations.

RAT:SetDescentAngle(angle)

Set the angle of descent.

RAT:SetDestination(destinationnames)

Set name of destination airports or zones for the AI aircraft.

RAT:SetDestinationsFromZone(zone)

Include all airports which lie in a zone as possible destinations.

RAT:SetFL(FL)

Set flight level.

RAT:SetFLcruise(FL)

Set flight level of cruising part.

RAT:SetFLmax(FL)

Set max flight level.

RAT:SetFLmin(FL)

Set min flight level.

RAT:SetMaxCruiseAltitude(alt)

Set max cruising altitude above sea level.

RAT:SetMaxCruiseSpeed(speed)

Set the maximum cruise speed of the aircraft.

RAT:SetMaxDistance(dist)

Set maximum distance between departure and destination.

RAT:SetMaxRespawnTriedWhenSpawnedOnRunway(n)

Number of tries to respawn an aircraft in case it has accitentally been spawned on runway.

RAT:SetMinCruiseAltitude(alt)

Set min cruising altitude above sea level.

RAT:SetMinDistance(dist)

Set minimum distance between departure and destination.

RAT:SetOnboardNum(tailnumprefix, zero)

Set onboard number prefix.

RAT:SetParkingID(id)

Set parking id of aircraft.

RAT:SetROE(roe)

Set rules of engagement (ROE).

RAT:SetROT(rot)

Set reaction to threat (ROT).

RAT:SetRespawnDelay(delay)

Sets the delay between despawning and respawning aircraft.

RAT:SetSpawnDelay(delay)

Set the delay before first group is spawned.

RAT:SetSpawnInterval(interval)

Set the interval between spawnings of the template group.

RAT:SetTakeoff(type)

Set takeoff type.

RAT:Spawn(naircraft)

Triggers the spawning of AI aircraft.

RAT.SpawnUnControlled
RAT:Status(message, forID)

Report status of RAT groups.

RAT:StatusReports(switch)

Aircraft report status update messages along the route.

RAT.SubMenuName

Submenu name for RAT object.

RAT:TimeDestroyInactive(time)

Set the time after which inactive groups will be destroyed.

RAT.Tinactive

Time in seconds after which inactive units will be destroyed. Default is 300 seconds.

RAT:Uncontrolled()

Spawn aircraft in uncontrolled state.

RAT.Vclimb

Default climb rate in ft/min.

RAT.Vcruisemax

Max cruise speed in m/s (250 m/s = 900 km/h = 486 kt) set by user.

RAT:_ATCAddFlight(name, dest)

Adds andd initializes a new flight after it was spawned.

RAT:_ATCCheck()

Main ATC function.

RAT:_ATCClearForLanding(airport, flight)

Giving landing clearance for aircraft by setting user flag.

RAT:_ATCDelFlight(t, entry)

Deletes a flight from ATC lists after it landed.

RAT:_ATCFlightLanded(name)

Takes care of organisational stuff after a plane has landed.

RAT:_ATCInit(airports_map)

Initializes the ATC arrays and starts schedulers.

RAT:_ATCQueue()

Creates a landing queue for all flights holding at airports.

RAT:_ATCRegisterFlight(name, time)

Registers a flight once it is near its holding point at the final destination.

RAT:_ATCStatus()

ATC status report about flights.

RAT:_ActivateUncontrolled()

Randomly activates an uncontrolled aircraft.

RAT:_AddFriendlyAirports(ports)

Add names of all friendly airports to possible departure or destination airports if they are not already in the list.

RAT:_AddParkingSpot(airbase, group)

Adds a parking spot at an airport when it has been used by a spawned RAT aircraft to the RAT parking data base.

RAT:_AirportExists(name)

Test if an airport exists on the current map.

RAT:_AnticipatedGroupName(index)

Anticipated group name from alias and spawn index.

RAT:_CheckConsistency()

Function checks consistency of user input and automatically adjusts parameters if necessary.

RAT:_CheckOnRunway(unit, airport)

Function to check whether an aircraft is on the runway.

RAT:_CheckOnTop(group)

Find aircraft that have accidentally been spawned on top of each other.

RAT:_CommandImmortal(group, switch)

Set RAT group to be (im-)mortal.

RAT:_CommandInvisible(group, switch)

Set RAT group to (in-)visible for other AI forces.

RAT:_CommandStartUncontrolled(group)

Start uncontrolled aircraft group.

RAT:_Course(a, b)

Determine the heading from point a to point b.

RAT:_CreateEventDead(EventTime, Initiator)

Create a Dead event.

RAT:_Debug(switch)

Turn debug messages on or off.

RAT:_DeleteMarkers()

Delete all markers on F10 map.

RAT:_Despawn(group)

Despawn unit.

RAT:_Destroy(group)

Destroys the RAT DCS group and all of its DCS units.

RAT:_Excluded(port)

Check if airport is excluded from possible departures and destinations.

RAT:_FindParkingSpot(airbase)

Seach an unoccupied parking spot at a specific airport in the RAT parking data base.

RAT:_GetAirportsInZone(zone)

Find airports within a zone.

RAT:_GetAirportsOfCoalition()

Get all "friendly" airports of the current map.

RAT:_GetAirportsOfMap()

Get all airports of the current map.

RAT:_GetLife(group)

Get (relative) life of first unit of a group.

RAT:_GetObjectSize(unit)

Get aircraft dimensions length, width, height.

RAT:_Heading(course)

Determine the heading for an aircraft to be entered in the route template.

RAT:_InitAircraft(DCSgroup)

Initialize basic parameters of the aircraft based on its (template) group in the mission editor.

RAT:_IsFriendly(port)

Check if airport is friendly, i.e.

RAT:_MinDistance(alpha, beta, ha, hb)

Calculate minimum distance between departure and destination for given minimum flight level and climb/decent rates.

RAT:_ModifySpawnTemplate(waypoints, livery, spawnplace)

Modifies the template of the group to be spawned.

RAT:_NameInList(liste, name)

Check if a name/string is in a list or not.

RAT:_OnBirth(EventData)

Function is executed when a unit is spawned.

RAT:_OnCrash(EventData)

Function is executed when a unit crashes.

RAT:_OnDead(EventData)

Function is executed when a unit is dead.

RAT:_OnDeadOrCrash(EventData)

Function is executed when a unit is dead or crashes.

RAT:_OnEngineShutdown(EventData)

Function is executed when a unit shuts down its engines.

RAT:_OnEngineStartup(EventData)

Function is executed when a unit starts its engines.

RAT:_OnHit(EventData)

Function is executed when a unit is hit.

RAT:_OnLand(EventData)

Function is executed when a unit lands.

RAT:_OnTakeoff(EventData)

Function is executed when a unit takes off.

RAT:_PickDeparture(takeoff)

Set the departure airport of the AI.

RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)

Pick destination airport or zone depending on departure position.

RAT:_PlaceMarkers(waypoints, index)

Place markers of the waypoints.

RAT._Random_Gaussian(x0, sigma, xmin, xmax, self)

Generate Gaussian pseudo-random numbers.

RAT:_Randomize(value, fac, lower, upper)

Randomize a value by a certain amount.

RAT:_Respawn(group)

Respawn a group.

RAT:_Routeinfo(waypoints, comment)

Provide information about the assigned flightplan.

RAT:_SetCoalitionTable()

Create a table with the valid coalitions for departure and destination airports.

RAT:_SetMarker(text, wp, index)

Set a marker visible for all on the F10 map.

RAT:_SetROE(group, roe)

Set ROE for a group.

RAT:_SetROT(group, rot)

Set ROT for a group.

RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)

Set the route of the AI plane.

RAT:_SetStatus(group, status)

Set status of group.

RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _livery, _waypoint, _lastpos, _nrespawn)

Spawn the AI aircraft with a route.

RAT:_SpawnWithRouteTimer(arg)

Delayed spawn function called by scheduler.

RAT:_TaskFunction(FunctionString, ...)

Task function.

RAT:_TaskHolding(P1, Altitude, Speed, Duration)

Orbit at a specified position at a specified alititude with a specified speed.

RAT:_Waypoint(index, description, Type, Coord, Speed, Altitude, Airport)

Create a waypoint that can be used with the Route command.

RAT._WaypointFunction(group, rat, wp)

Function which is called after passing every waypoint.

RAT:_ZoneExists(name)

Test if a trigger zone defined in the mission editor exists.

RAT.activate_delay

Delay in seconds before first uncontrolled group is activated. Default is 5 seconds.

RAT.activate_delta

Time interval in seconds between activation of uncontrolled groups. Default is 5 seconds.

RAT.activate_frand

Randomization factor of time interval (activate_delta) between activating uncontrolled groups. Default is 0.

RAT.activate_max

Maximum number of uncontrolled aircraft, which will be activated at the same time. Default is 1.

RAT.activate_uncontrolled

If true, uncontrolled are activated randomly after certain time intervals.

RAT.actype
RAT.addfriendlydepartures

Add all friendly airports to departures.

RAT.addfriendlydestinations

Add all friendly airports to destinations.

RAT.aircraft

Table which holds the basic aircraft properties (speed, range, ...).

RAT.airports

All airports of friedly coalitions.

RAT.airports_map

All airports available on current map (Caucasus, Nevada, Normandy, ...).

RAT.alias

Alias for spawned group.

RAT.alive

Number of groups which are alive.

RAT.cat
RAT.category

Category of aircarft: "plane" or "heli".

RAT.checkonrunway

Aircraft are checked if they were accidentally spawned on the runway. Default is true.

RAT.checkontop

Aircraft are checked if they were accidentally spawned on top of another unit. Default is true.

RAT.coal

RAT friendly coalitions.

RAT.coalition

Coalition of spawn group template.

RAT.commute

Aircraft commute between departure and destination, i.e. when respawned the departure airport becomes the new destiation.

RAT.continuejourney

Aircraft will continue their journey, i.e. get respawned at their destination with a new random destination.

RAT.country

Country of spawn group template.

RAT.ctable

Table with the valid coalitons from choice self.friendly.

RAT.departure_Azone

Zone containing the departure airports.

RAT.departure_ports

Array containing the names of the destination airports or zones.

RAT.destination_Azone

Zone containing the destination airports.

RAT.destination_ports

Array containing the names of the destination airports or zones.

RAT.destinationzone

Destination is a zone and not an airport.

RAT.excluded_ports

Array containing the names of explicitly excluded airports.

RAT.f10menu

If true, add an F10 radiomenu for RAT. Default is false.

RAT.frequency

Radio frequency used by the RAT groups.

RAT.friendly

Possible departure/destination airport: all=blue+red+neutral, same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red.

RAT.id

Some ID to identify who we are in output of the DCS.log file.

RAT.immortal

If true, aircraft are spawned as immortal.

RAT.invisible

If true aircraft are set to invisible for other AI forces.

RAT.landing

Landing type. Determines if we actually land at an airport or treat it as zone.

RAT.livery

Livery of the aircraft set by user.

RAT.markerid

Running number of placed markers on the F10 map.

RAT.markerids

Array with marker IDs.

RAT.maxdist

Max distance from departure to destination in meters. Default 5000 km.

RAT.mindist

Min distance from departure to destination in meters. Default 5 km.

RAT.modulation

Ratio modulation. Either "FM" or "AM".

RAT.ngroups

Number of groups to be spawned in total.

RAT.norespawn

Aircraft will not be respawned after they have finished their route.

RAT.onboardnum

Sets the onboard number prefix. Same as setting "TAIL #" in the mission editor.

RAT.onboardnum0

(Optional) Starting value of the automatically appended numbering of aircraft within a flight. Default is 1.

RAT.parking

RAT parking spots data base.

RAT.parking_id

String with a special parking ID for the aircraft.

RAT.placemarkers

Place markers of waypoints on F10 map.

RAT.radio

If true/false disables radio messages from the RAT groups.

RAT.random_departure

By default a random friendly airport is chosen as departure.

RAT.random_destination

By default a random friendly airport is chosen as destination.

RAT.ratcraft

Array with the spawned RAT aircraft.

RAT.rbug_maxretry

Number of respawn retries (on ground) at other airports if a group gets accidentally spawned on the runway. Default is 3.

RAT.reportstatus

Aircraft report status.

RAT.respawn_after_crash

Aircraft will be respawned after a crash, e.g. when they get shot down.

RAT.respawn_after_takeoff

Aircraft will be respawned directly after take-off.

RAT.respawn_at_landing

Respawn aircraft the moment they land rather than at engine shutdown.

RAT.respawn_delay

Delay in seconds until a repawn happens.

RAT.respawn_inair

Aircraft are allowed to spawned in air if they cannot be respawned on ground because there is not free parking spot. Default is true.

RAT.return_zones

Array containing the names of the return zones.

RAT.returnzone

Zone where aircraft will fly to before returning to their departure airport.

RAT.roe

ROE of spawned groups, default is weapon hold (this is a peaceful class for civil aircraft or ferry missions). Possible: "hold", "return", "free".

RAT.rot

ROT of spawned groups, default is no reaction. Possible: "noreaction", "passive", "evade".

RAT.skill

Skill of AI.

RAT.spawndelay

Delay time in seconds before first spawning happens.

RAT.spawninitialized

If RAT:Spawn() was already called this RAT object is set to true to prevent users to call it again.

RAT.spawninterval

Interval between spawning units/groups. Note that we add a randomization of 50%.

RAT.status

RAT aircraft status.

RAT.statusinterval

Intervall between status checks (and reports if enabled).

RAT.takeoff

Takeoff type. 0=coldorhot.

RAT.templategroup

Group serving as template for the RAT aircraft.

RAT.uncontrolled

If true aircraft are spawned in uncontrolled state and will only sit on their parking spots. They can later be activated.

RAT.unit

RAT unit conversions.

RAT.useparkingdb

Parking spots are added to data base once an aircraft has used it. These spots can later be used by other aircraft. Default is true.

RAT.version

RAT version.

RAT.waypointdescriptions

Table with strings for waypoint descriptions of markers.

RAT.waypointstatus

Table with strings of waypoint status.

RAT.wp

RAT waypoint type.

Type RATMANAGER

RATMANAGER:Add(ratobject, min)

Adds a RAT object to the RAT manager.

RATMANAGER.ClassName

Name of the Class.

RATMANAGER.Debug

If true, be more verbose on output in DCS.log file.

RATMANAGER:New(ntot)

Creates a new RATMANAGER object.

RATMANAGER:SetTcheck(dt)

Sets the time interval between checks of alive RAT groups.

RATMANAGER:Start(delay)

Starts the RAT manager and spawns the initial random number RAT groups for each RAT object.

RATMANAGER:Stop(delay)

Stops the RAT manager.

RATMANAGER.Tcheck

Time interval between checking of alive groups.

RATMANAGER:_Count()

Counts the number of alive RAT objects.

RATMANAGER:_Manage()

Manager function.

RATMANAGER:_RollDice(nrat, ntot, min, alive)

Rolls the dice for the number of necessary spawns.

RATMANAGER:_Start()

Instantly starts the RAT manager and spawns the initial random number RAT groups for each RAT object.

RATMANAGER:_Stop()

Instantly stops the RAT manager by terminating its scheduler.

RATMANAGER.alive

Number of currently alive groups.

RATMANAGER.id

Some ID to identify who we are in output of the DCS.log file.

RATMANAGER.manager

Scheduler managing the RAT objects.

RATMANAGER.managerid

Managing scheduler id.

RATMANAGER.min

Minimum number of RAT groups alive.

RATMANAGER.name

Name (alias) of RAT object.

RATMANAGER.nrat

Number of RAT objects.

RATMANAGER.ntot

Total number of active RAT groups.

RATMANAGER.rat

Array holding RAT objects etc.

Global(s)

#RAT RAT

RAT class, extends Core.Spawn#SPAWN

The RAT class implements an easy to use way to randomly fill your map with AI aircraft.

Airport Selection

Process

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

Process

  • A general flight plan has five main airborne 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

Process

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

Process

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

Process

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

Process

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

Process

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.

Process

By default planes get a cruise altitude of ~20,000 ft ASL. The actual altitude is sampled from a Gaussian distribution. The picture shows this distribution if one would spawn 1000 planes. As can be seen most planes get a cruising alt of around FL200. Other values are possible but less likely the further away one gets from the expectation value.

The expectation value, i.e. the altitude most aircraft get, can be set with the function RAT.SetFLcruise(). It is possible to restrict the minimum cruise altitude by RAT.SetFLmin() and the maximum cruise altitude by RAT.SetFLmax()

The cruise altitude can also be given in meters ASL by the functions RAT.SetCruiseAltitude(), RAT.SetMinCruiseAltitude() and RAT.SetMaxCruiseAltitude().

For example:

  • RAT.SetFLcruise(300) will cause most planes fly around FL300.
  • RAT.SetFLmin(100) restricts the cruising alt such that no plane will fly below FL100. Note that this automatically changes the minimum distance from departure to destination. That means that only destinations are possible for which the aircraft has had enought time to reach that flight level and descent again.
  • RAT.SetFLmax(200) will restrict the cruise alt to maximum FL200, i.e. no aircraft will travel above this height.
#RATMANAGER RATMANAGER

RATMANAGER class, extends Core.Base#BASE

The RATMANAGER class manages spawning of multiple RAT objects in a very simple way.

It is created by the RATMANAGER.New() contructor. RAT objects with different "tasks" can be defined as usual. However, they must not be spawned via the RAT.Spawn() function.

Instead, these objects can be added to the manager via the RATMANAGER.Add(ratobject, min) function, where the first parameter "ratobject" is the #RAT object, while the second parameter "min" defines the minimum number of RAT aircraft of that object, which are alive at all time.

The #RATMANAGER must be started by the RATMANAGER.Start(startime) function, where the optional argument "startime" specifies the delay time in seconds after which the manager is started and the spawning beginns. If desired, the #RATMANAGER can be stopped by the RATMANAGER.Stop(stoptime) function. The parameter "stoptime" specifies the time delay in seconds after which the manager stops. When this happens, no new aircraft will be spawned and the population will eventually decrease to zero.

Example

In this example, three different #RAT objects are created (but not spawned manually). The #RATMANAGER takes care that at least five aircraft of each type are alive and that the total number of aircraft spawned is 25. The #RATMANAGER is started after 30 seconds and stopped after two hours.

local a10c=RAT:New("RAT_A10C", "A-10C managed")
a10c:SetDeparture({"Batumi"})

local f15c=RAT:New("RAT_F15C", "F15C managed")
f15c:SetDeparture({"Sochi-Adler"})
f15c:DestinationZone()
f15c:SetDestination({"Zone C"})

local av8b=RAT:New("RAT_AV8B", "AV8B managed")
av8b:SetDeparture({"Zone C"})
av8b:SetTakeoff("air")
av8b:DestinationZone()
av8b:SetDestination({"Zone A"})

local manager=RATMANAGER:New(25)
manager:Add(a10c, 5)
manager:Add(f15c, 5)
manager:Add(av8b, 5)
manager:Start(30)
manager:Stop(7200)

Type Rat

Type RAT

Extends Core.Spawn#SPAWN

  • RAT class

Field(s)

#table RAT.ATC

RAT ATC.

RAT:ATC_Clearance(n)

Max number of planes that get landing clearance of the RAT ATC.

This setting effects all RAT objects and groups!

Parameter

  • #number n : Number of aircraft that are allowed to land simultaniously. Default is 2.

RAT:ATC_Delay(time)

Delay between granting landing clearance for simultanious landings.

This setting effects all RAT objects and groups!

Parameter

  • #number time : Delay time when the next aircraft will get landing clearance event if the previous one did not land yet. Default is 240 sec.

RAT:ATC_Messages(switch)

Turn messages from ATC on or off.

Default is on. This setting effects all RAT objects and groups!

Parameter

  • #boolean switch : Enable (true) or disable (false) messages from ATC.

#boolean RAT.ATCswitch

Enable/disable ATC if set to true/false.

RAT:ActivateUncontrolled(maxactivated, delay, delta, frand)

Activate uncontrolled aircraft.

Parameters

  • #number maxactivated : Maximal numnber of activated aircraft. Absolute maximum will be the number of spawned groups. Default is 1.

  • #number delay : Time delay in seconds before (first) aircraft is activated. Default is 1 second.

  • #number delta : Time difference in seconds before next aircraft is activated. Default is 1 second.

  • #number frand : Factor [0,...,1] for randomization of time difference between aircraft activations. Default is 0, i.e. no randomization.

RAT:AddFriendlyAirportsToDepartures()

Add all friendly airports to the list of possible departures.

RAT:AddFriendlyAirportsToDestinations()

Add all friendly airports to the list of possible destinations

#number RAT.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.

RAT:ChangeAircraft(actype)

Change aircraft type.

This is a dirty hack which allows to change the aircraft type of the template group. Note that all parameters like cruise speed, climb rate, range etc are still taken from the template group which likely leads to strange behaviour.

Parameter

  • #string actype : Type of aircraft which is spawned independent of the template group. Use with care and expect problems!

RAT:CheckOnRunway(switch)

Check if aircraft have accidentally been spawned on the runway.

If so they will be removed immediatly.

Parameter

  • #boolean switch : If true, check is performed. If false, this check is omitted.

RAT:CheckOnTop(switch)

Check if aircraft have accidentally been spawned on top of each other.

If yes, they will be removed immediately.

Parameter

  • #boolean switch : If true, check is performed. If false, this check is omitted.

#string RAT.ClassName

Name of the Class.

RAT:ClearForLanding(name)

Clear flight for landing.

Sets tigger value to 1.

Parameter

  • #string name : Name of flight to be cleared for landing.

RAT:Commute()

Aircraft will commute between their departure and destination airports or zones.

RAT:ContinueJourney()

Aircraft will continue their journey from their destination.

This means they are respawned at their destination and get a new random destination.

#boolean RAT.Debug

Turn debug messages on or off.

RAT:Debugmode()

Enable debug mode.

More output in dcs.log file and onscreen messages to all.

RAT:DestinationZone()

Destinations are treated as zones.

Aircraft will not land but rather be despawned when they reach a random point in the zone.

RAT:EnableATC(switch)

Enable ATC, which manages the landing queue for RAT aircraft if they arrive simultaniously at the same airport.

Parameter

  • #boolean switch : Enable ATC (true) or Disable ATC (false). No argument means ATC enabled.

RAT:ExcludedAirports(ports)

Airports, FARPs and ships explicitly excluded as departures and destinations.

Parameter

  • #string ports : Name or table of names of excluded airports.

#number RAT.FLcruise

Cruise altitude of aircraft. Default FL200 for planes and F005 for helos.

#number RAT.FLmaxuser

Maximum flight level set by user.

#number RAT.FLminuser

Minimum flight level set by user.

#number RAT.FLuser

Flight level set by users explicitly.

RAT:Immortal()

Aircraft are immortal.

RAT:Invisible()

Aircraft are invisible.

RAT:Livery(skins)

Set livery of aircraft.

If more than one livery is specified in a table, the actually used one is chosen randomly from the selection.

Parameter

  • #table skins : Name of livery or table of names of liveries.

#table RAT.Menu

F10 menu items for this RAT object.

#string RAT.MenuF10

Main F10 menu.

RAT:MenuName(name)

Set the name of the F10 submenu.

Default is the name of the template group.

Parameter

  • #string name : Submenu name.

#number RAT.Ndeparture_Airports

Number of departure airports set via SetDeparture().

#number RAT.Ndeparture_Zones

Number of departure zones set via SetDeparture.

#number RAT.Ndestination_Airports

Number of destination airports set via SetDestination().

#number RAT.Ndestination_Zones

Number of destination zones set via SetDestination().

RAT:New(groupname, alias)

Create a new RAT object.

Parameters

  • #string groupname : Name of the group as defined in the mission editor. This group is serving as a template for all spawned units.

  • #string alias : (Optional) Alias of the group. This is and optional parameter but must(!) be used if the same template group is used for more than one RAT object.

Return values

  1. #RAT: Object of RAT class.

  2. #nil: If the group does not exist in the mission editor.

Usages:

  • yak1:RAT("RAT_YAK") will create a RAT object called "yak1". The template group in the mission editor must have the name "RAT_YAK".
  • yak2:RAT("RAT_YAK", "Yak2") will create a RAT object "yak2". The template group in the mission editor must have the name "RAT_YAK" but the group will be called "Yak2" in e.g. the F10 menu.
RAT:NoRespawn()

Aircraft will not get respawned when they finished their route.

RAT:ParkingSpotDB(switch)

Put parking spot coordinates in a data base for future use of aircraft.

Parameter

  • #boolean switch : If true, parking spots are memorized. This is also the default setting.

RAT:PlaceMarkers(switch)

Place markers of waypoints on the F10 map.

Default is off.

Parameter

  • #boolean switch : true=yes, false=no.

#table RAT.ROE

RAT rules of engagement.

#table RAT.ROT

RAT reaction to threat.

RAT:RadioFrequency(frequency)

Set radio frequency.

Parameter

  • #number frequency : Radio frequency.

RAT:RadioMenuOFF()

Radio menu Off.

This is the default setting.

RAT:RadioMenuON()

Radio menu On.

Default is off.

RAT:RadioModulation(modulation)

Set radio modulation.

Default is AM.

Parameter

  • #string modulation : Either "FM" or "AM". If no value is given, modulation is set to AM.

RAT:RadioOFF()

Disable Radio.

Overrules the ME setting.

RAT:RadioON()

Enable Radio.

Overrules the ME setting.

RAT:RespawnAfterCrashOFF()

Aircraft will not be respawned after they crashed or get shot down.

RAT:RespawnAfterCrashON()

Aircraft will be respawned after they crashed or get shot down.

This is the default behavior.

RAT:RespawnAfterLanding(delay)

Make aircraft respawn the moment they land rather than at engine shut down.

Parameter

  • #number delay : (Optional) Delay in seconds until respawn happens after landing. Default is 180 seconds. Minimum is 0.5 seconds.

RAT:RespawnAfterTakeoff()

Aircraft will be respawned directly after take-off.

RAT:RespawnInAirAllowed()

If aircraft cannot be spawned on parking spots, it is allowed to spawn them in air above the same airport.

Note that this is also the default behavior.

RAT:RespawnInAirNotAllowed()

If aircraft cannot be spawned on parking spots, it is NOT allowed to spawn them in air.

This has only impact if aircraft are supposed to be spawned on the ground (and not in a zone).

RAT:ReturnZone()

Aircraft will fly to a random point within a zone and then return to its departure airport or zone.

RAT:SetAISkill(skill)

Set skill of AI aircraft.

Default is "High".

Parameter

  • #string skill : Skill, options are "Average", "Good", "High", "Excellent" and "Random". Parameter is case insensitive.

RAT:SetClimbRate(rate)

Set the climb rate.

This automatically sets the climb angle.

Parameter

  • #number rate : Climb rate in ft/min. Default is 1500 ft/min. Minimum is 100 ft/min. Maximum is 15,000 ft/min.

RAT:SetCoalition(friendly)

Set the friendly coalitions from which the airports can be used as departure and destination.

Parameter

  • #string friendly : "same"=own coalition+neutral (default), "sameonly"=own coalition only, "neutral"=all neutral airports. Default is "same", so aircraft will use airports of the coalition their spawn template has plus all neutral airports.

Usages:

  • yak:SetCoalition("neutral") will spawn aircraft randomly on all neutral airports.
  • yak:SetCoalition("sameonly") will spawn aircraft randomly on airports belonging to the same coalition only as the template.
RAT:SetCoalitionAircraft(color)

Set coalition of RAT group.

You can make red templates blue and vice versa.

Parameter

  • #string color : Color of coalition, i.e. "red" or blue".

RAT:SetCountry(id)

Set country of RAT group.

This overrules the coalition settings.

Parameter

  • #number id : DCS country enumerator ID. For example country.id.USA or country.id.RUSSIA.

RAT:SetCruiseAltitude(alt)

Set cruising altitude.

This is still be checked for consitancy with selected route and prone to radomization.

Parameter

  • #number alt : Cruising altitude ASL in meters.

RAT:SetDeparture(departurenames)

Set possible departure ports.

This can be an airport or a zone defined in the mission editor.

Parameter

  • #string departurenames : Name or table of names of departure airports or zones.

Usages:

  • RAT:SetDeparture("Sochi-Adler") will spawn RAT objects at Sochi-Adler airport.
  • RAT:SetDeparture({"Sochi-Adler", "Gudauta"}) will spawn RAT aircraft radomly at Sochi-Adler or Gudauta airport.
  • RAT:SetDeparture({"Zone A", "Gudauta"}) will spawn RAT aircraft in air randomly within Zone A, which has to be defined in the mission editor, or within a zone around Gudauta airport. Note that this also requires RAT:takeoff("air") to be set.
RAT:SetDeparturesFromZone(zone)

Include all airports which lie in a zone as possible destinations.

Parameter

  • Core.Zone#ZONE zone : Zone in which the destination airports lie. Has to be a MOOSE zone.

RAT:SetDescentAngle(angle)

Set the angle of descent.

Default is 3.6 degrees, which corresponds to 3000 ft descent after one mile of travel.

Parameter

  • #number angle : Angle of descent in degrees. Minimum is 0.5 deg. Maximum 50 deg.

RAT:SetDestination(destinationnames)

Set name of destination airports or zones for the AI aircraft.

Parameter

  • #string destinationnames : Name of the destination airport or table of destination airports.

Usage:

RAT:SetDestination("Krymsk") makes all aircraft of this RAT oject fly to Krymsk airport.
RAT:SetDestinationsFromZone(zone)

Include all airports which lie in a zone as possible destinations.

Parameter

  • Core.Zone#ZONE zone : Zone in which the departure airports lie. Has to be a MOOSE zone.

RAT:SetFL(FL)

Set flight level.

Setting this value will overrule all other logic. Aircraft will try to fly at this height regardless.

Parameter

  • #number FL : Fight Level in hundrets of feet. E.g. FL200 = 20000 ft ASL.

RAT:SetFLcruise(FL)

Set flight level of cruising part.

This is still be checked for consitancy with selected route and prone to radomization. Default is FL200 for planes and FL005 for helicopters.

Parameter

  • #number FL : Flight level in hundrets of feet. E.g. FL200 = 20000 ft ASL.

RAT:SetFLmax(FL)

Set max flight level.

Setting this value will overrule all other logic. Aircraft will try to fly at less than this FL regardless.

Parameter

  • #number FL : Maximum Fight Level in hundrets of feet.

RAT:SetFLmin(FL)

Set min flight level.

Setting this value will overrule all other logic. Aircraft will try to fly at higher than this FL regardless.

Parameter

  • #number FL : Maximum Fight Level in hundrets of feet.

RAT:SetMaxCruiseAltitude(alt)

Set max cruising altitude above sea level.

Parameter

  • #number alt : Altitude ASL in meters.

RAT:SetMaxCruiseSpeed(speed)

Set the maximum cruise speed of the aircraft.

Parameter

  • #number speed : Speed in km/h.

RAT:SetMaxDistance(dist)

Set maximum distance between departure and destination.

Default is 5000 km but aircarft range is also taken into account automatically.

Parameter

  • #number dist : Distance in km.

RAT:SetMaxRespawnTriedWhenSpawnedOnRunway(n)

Number of tries to respawn an aircraft in case it has accitentally been spawned on runway.

Parameter

  • #number n : Number of retries. Default is 3.

RAT:SetMinCruiseAltitude(alt)

Set min cruising altitude above sea level.

Parameter

  • #number alt : Altitude ASL in meters.

RAT:SetMinDistance(dist)

Set minimum distance between departure and destination.

Default is 5 km. Minimum distance should not be smaller than maybe ~500 meters to ensure that departure and destination are different.

Parameter

  • #number dist : Distance in km.

RAT:SetOnboardNum(tailnumprefix, zero)

Set onboard number prefix.

Same as setting "TAIL #" in the mission editor. Note that if you dont use this function, the values defined in the template group of the ME are taken.

Parameters

  • #string tailnumprefix : String of the tail number prefix. If flight consists of more than one aircraft, two digits are appended automatically, i.e. 001, 002, ...

  • #number zero : (Optional) Starting value of the automatically appended numbering of aircraft within a flight. Default is 0.

RAT:SetParkingID(id)

Set parking id of aircraft.

Parameter

  • #string id : Parking ID of the aircraft.

RAT:SetROE(roe)

Set rules of engagement (ROE).

Default is weapon hold. This is a peaceful class.

Parameter

  • #string roe : "hold" = weapon hold, "return" = return fire, "free" = weapons free.

RAT:SetROT(rot)

Set reaction to threat (ROT).

Default is no reaction, i.e. aircraft will simply ignore all enemies.

Parameter

  • #string rot : "noreaction" = no reaction to threats, "passive" = passive defence, "evade" = evade enemy attacks.

RAT:SetRespawnDelay(delay)

Sets the delay between despawning and respawning aircraft.

Parameter

  • #number delay : Delay in seconds until respawn happens. Default is 1 second. Minimum is 1 second.

RAT:SetSpawnDelay(delay)

Set the delay before first group is spawned.

Parameter

  • #number delay : Delay in seconds. Default is 5 seconds. Minimum delay is 0.5 seconds.

RAT:SetSpawnInterval(interval)

Set the interval between spawnings of the template group.

Parameter

  • #number interval : Interval in seconds. Default is 5 seconds. Minimum is 0.5 seconds.

RAT:SetTakeoff(type)

Set takeoff type.

Starting cold at airport, starting hot at airport, starting at runway, starting in the air. Default is "takeoff-coldorhot". So there is a 50% chance that the aircraft starts with cold engines and 50% that it starts with hot engines.

Parameter

  • #string type : Type can be "takeoff-cold" or "cold", "takeoff-hot" or "hot", "takeoff-runway" or "runway", "air".

Usages:

  • RAT:Takeoff("hot") will spawn RAT objects at airports with engines started.
  • RAT:Takeoff("cold") will spawn RAT objects at airports with engines off.
  • RAT:Takeoff("air") will spawn RAT objects in air over random airports or within pre-defined zones. 
RAT:Spawn(naircraft)

Triggers the spawning of AI aircraft.

Note that all additional options should be set before giving the spawn command.

Parameter

  • #number naircraft : (Optional) Number of aircraft to spawn. Default is one aircraft.

Usage:

yak:Spawn(5) will spawn five aircraft. By default aircraft will spawn at neutral and red airports if the template group is part of the red coaliton.
#boolean RAT.SpawnUnControlled

This is used in the SPAWN:SpawnWithIndex() function. Some values are overwritten there!

RAT:Status(message, forID)

Report status of RAT groups.

Parameters

  • #boolean message : (Optional) Send message with report to all if true.

  • #number forID : (Optional) Send message only for this ID.

RAT:StatusReports(switch)

Aircraft report status update messages along the route.

Parameter

  • #boolean switch : Swtich reports on (true) or off (false). No argument is on.

#string RAT.SubMenuName

Submenu name for RAT object.

RAT:TimeDestroyInactive(time)

Set the time after which inactive groups will be destroyed.

Parameter

  • #number time : Time in seconds. Default is 600 seconds = 10 minutes. Minimum is 60 seconds.

#number RAT.Tinactive

Time in seconds after which inactive units will be destroyed. Default is 300 seconds.

RAT:Uncontrolled()

Spawn aircraft in uncontrolled state.

Aircraft will only sit at their parking spots. They can be activated randomly by the RAT:ActivateUncontrolled() function.

#number RAT.Vclimb

Default climb rate in ft/min.

#number RAT.Vcruisemax

Max cruise speed in m/s (250 m/s = 900 km/h = 486 kt) set by user.

RAT:_ATCAddFlight(name, dest)

Adds andd initializes a new flight after it was spawned.

Parameters

  • #string name : Group name of the flight.

  • #string dest : Name of the destination airport.

RAT:_ATCCheck()

Main ATC function.

Updates the landing queue of all airports and inceases holding time for all flights.

RAT:_ATCClearForLanding(airport, flight)

Giving landing clearance for aircraft by setting user flag.

Parameters

  • #string airport : Name of destination airport.

  • #string flight : Group name of flight, which gets landing clearence.

RAT:_ATCDelFlight(t, entry)

Deletes a flight from ATC lists after it landed.

Parameters

  • #table t : Table.

  • #string entry : Flight name which shall be deleted.

RAT:_ATCFlightLanded(name)

Takes care of organisational stuff after a plane has landed.

Parameter

  • #string name : Group name of flight.

RAT:_ATCInit(airports_map)

Initializes the ATC arrays and starts schedulers.

Parameter

  • #table airports_map : List of all airports of the map.

RAT:_ATCQueue()

Creates a landing queue for all flights holding at airports.

Aircraft with longest holding time gets first permission to land.

RAT:_ATCRegisterFlight(name, time)

Registers a flight once it is near its holding point at the final destination.

Parameters

  • #string name : Group name of the flight.

  • #number time : Time the fight first registered.

RAT:_ATCStatus()

ATC status report about flights.

RAT:_ActivateUncontrolled()

Randomly activates an uncontrolled aircraft.

RAT:_AddFriendlyAirports(ports)

Add names of all friendly airports to possible departure or destination airports if they are not already in the list.

Parameter

  • #table ports : List of departure or destination airports/zones that will be added.

RAT:_AddParkingSpot(airbase, group)

Adds a parking spot at an airport when it has been used by a spawned RAT aircraft to the RAT parking data base.

This is mainly to circumvent (not perfectly) the DCS parking spot bug.

Parameters

RAT:_AirportExists(name)

Test if an airport exists on the current map.

Parameter

  • #string name :

Return value

#boolean: True if airport exsits, false otherwise.

RAT:_AnticipatedGroupName(index)

Anticipated group name from alias and spawn index.

Parameter

  • #number index : Spawnindex of group if given or self.SpawnIndex+1 by default.

Return value

#string: Name the group will get after it is spawned.

RAT:_CheckConsistency()

Function checks consistency of user input and automatically adjusts parameters if necessary.

RAT:_CheckOnRunway(unit, airport)

Function to check whether an aircraft is on the runway.

Parameters

  • Wrapper.Unit#UNIT unit : The unit to be checked.

  • #string airport : The name of the airport we want to check.

Return value

#boolean: True if aircraft is on the runway and on the ground.

RAT:_CheckOnTop(group)

Find aircraft that have accidentally been spawned on top of each other.

Parameter

Return value

#boolean: True if group was destroyed because it was on top of another unit. False if otherwise.

RAT:_CommandImmortal(group, switch)

Set RAT group to be (im-)mortal.

Parameters

  • Wrapper.Group#GROUP group : Group to be set (im-)mortal.

  • #boolean switch : True enables immortality, false disables it.

RAT:_CommandInvisible(group, switch)

Set RAT group to (in-)visible for other AI forces.

Parameters

  • Wrapper.Group#GROUP group : Group to be set (in)visible.

  • #boolean switch : If true, the group is invisible. If false the group will be visible.

RAT:_CommandStartUncontrolled(group)

Start uncontrolled aircraft group.

Parameter

RAT:_Course(a, b)

Determine the heading from point a to point b.

Parameters

Return value

#number: Heading/angle in degrees.

RAT:_CreateEventDead(EventTime, Initiator)

Create a Dead event.

Parameters

RAT:_Debug(switch)

Turn debug messages on or off.

Default is off.

Parameter

  • #boolean switch : Turn debug on=true or off=false. No argument means on.

RAT:_DeleteMarkers()

Delete all markers on F10 map.

RAT:_Despawn(group)

Despawn unit.

Unit gets destoyed and group is set to nil. Index of ratcraft array is taken from spawned group name.

Parameter

RAT:_Destroy(group)

Destroys the RAT DCS group and all of its DCS units.

Note that this raises a DEAD event at run-time. So all event listeners will catch the DEAD event of this DCS group.

Parameter

RAT:_Excluded(port)

Check if airport is excluded from possible departures and destinations.

Parameter

  • #string port : Name of airport, FARP or ship to check.

Return value

#boolean: true if airport is excluded and false otherwise.

RAT:_FindParkingSpot(airbase)

Seach an unoccupied parking spot at a specific airport in the RAT parking data base.

Parameter

Return value

Core.Point#COORDINATE: Coordinate of the parking spot.

RAT:_GetAirportsInZone(zone)

Find airports within a zone.

Parameter

Return value

list Table with airport names that lie within the zone.

RAT:_GetAirportsOfCoalition()

Get all "friendly" airports of the current map.

RAT:_GetAirportsOfMap()

Get all airports of the current map.

RAT:_GetLife(group)

Get (relative) life of first unit of a group.

Parameter

Return value

#number: Life of unit in percent.

RAT:_GetObjectSize(unit)

Get aircraft dimensions length, width, height.

Parameter

Return value

#number: Size, i.e. max(length,width) of unit.

RAT:_Heading(course)

Determine the heading for an aircraft to be entered in the route template.

Parameter

  • #number course : The course between two points in degrees.

Return value

#number: heading Heading in rad.

RAT:_InitAircraft(DCSgroup)

Initialize basic parameters of the aircraft based on its (template) group in the mission editor.

Parameter

RAT:_IsFriendly(port)

Check if airport is friendly, i.e.

belongs to the right coalition.

Parameter

  • #string port : Name of airport, FARP or ship to check.

Return value

#boolean: true if airport is friendly and false otherwise.

RAT:_MinDistance(alpha, beta, ha, hb)

Calculate minimum distance between departure and destination for given minimum flight level and climb/decent rates.

Parameters

  • #number alpha : Angle of climb [rad].

  • #number beta : Angle of descent [rad].

  • #number ha : Height difference between departure and cruise altiude.

  • #number hb : Height difference between cruise altitude and destination.

Return values

  1. #number: d1 Minimum distance for climb phase to reach cruise altitude.

  2. #number: d2 Minimum distance for descent phase to reach destination height.

  3. #number: dtot Minimum total distance to climb and descent.

RAT:_ModifySpawnTemplate(waypoints, livery, spawnplace)

Modifies the template of the group to be spawned.

In particular, the waypoints of the group's flight plan are copied into the spawn template. This allows to spawn at airports and also land at other airports, i.e. circumventing the DCS "landing bug".

Parameters

  • #table waypoints : The waypoints of the AI flight plan.

  • #string livery : (Optional) Livery of the aircraft. All members of a flight will get the same livery.

  • Core.Point#COORDINATE spawnplace : (Optional) Place where spawning should happen. If not present, first waypoint is taken.

RAT:_NameInList(liste, name)

Check if a name/string is in a list or not.

Parameters

  • #table liste : List of names to be checked.

  • #string name : Name to be checked for.

RAT:_OnBirth(EventData)

Function is executed when a unit is spawned.

Parameter

RAT:_OnCrash(EventData)

Function is executed when a unit crashes.

Parameter

RAT:_OnDead(EventData)

Function is executed when a unit is dead.

Parameter

RAT:_OnDeadOrCrash(EventData)

Function is executed when a unit is dead or crashes.

Parameter

RAT:_OnEngineShutdown(EventData)

Function is executed when a unit shuts down its engines.

Parameter

  • EventData :

RAT:_OnEngineStartup(EventData)

Function is executed when a unit starts its engines.

Parameter

RAT:_OnHit(EventData)

Function is executed when a unit is hit.

Parameter

RAT:_OnLand(EventData)

Function is executed when a unit lands.

Parameter

RAT:_OnTakeoff(EventData)

Function is executed when a unit takes off.

Parameter

RAT:_PickDeparture(takeoff)

Set the departure airport of the AI.

If no airport name is given explicitly an airport from the coalition is chosen randomly. If takeoff style is set to "air", we use zones around the airports or the zones specified by user input.

Parameter

  • #number takeoff : Takeoff type.

Return values

  1. Wrapper.Airbase#AIRBASE: Departure airport if spawning at airport.

  2. Core.Zone#ZONE: Departure zone if spawning in air.

RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)

Pick destination airport or zone depending on departure position.

Parameters

  • Wrapper.Airbase#AIRBASE departure : Departure airport or zone.

  • Core.Point#COORDINATE q : Coordinate of the departure point.

  • #number minrange : Minimum range to q in meters.

  • #number maxrange : Maximum range to q in meters.

  • #boolean random : Destination is randomly selected from friendly airport (true) or from destinations specified by user input (false).

  • #number landing : Number indicating whether we land at a destination airport or fly to a zone object.

Return value

Wrapper.Airbase#AIRBASE: destination Destination airport or zone.

RAT:_PlaceMarkers(waypoints, index)

Place markers of the waypoints.

Note we assume a very specific number and type of waypoints here.

Parameters

  • #table waypoints : Table with waypoints.

  • #number index : Spawn index of group.

RAT._Random_Gaussian(x0, sigma, xmin, xmax, self)

Generate Gaussian pseudo-random numbers.

Parameters

  • #number x0 : Expectation value of distribution.

  • #number sigma : (Optional) Standard deviation. Default 10.

  • #number xmin : (Optional) Lower cut-off value.

  • #number xmax : (Optional) Upper cut-off value.

  • self :

Return value

#number: Gaussian random number.

RAT:_Randomize(value, fac, lower, upper)

Randomize a value by a certain amount.

Parameters

  • #number value : The value which should be randomized

  • #number fac : Randomization factor.

  • #number lower : (Optional) Lower limit of the returned value.

  • #number upper : (Optional) Upper limit of the returned value.

Return value

#number: Randomized value.

Usages:

  • _Randomize(100, 0.1) returns a value between 90 and 110, i.e. a plus/minus ten percent variation.
  • _Randomize(100, 0.5, nil, 120) returns a value between 50 and 120, i.e. a plus/minus fivty percent variation with upper bound 120.
RAT:_Respawn(group)

Respawn a group.

Parameter

RAT:_Routeinfo(waypoints, comment)

Provide information about the assigned flightplan.

Parameters

  • #table waypoints : Waypoints of the flight plan.

  • #string comment : Some comment to identify the provided information.

Return value

#number: total Total route length in meters.

RAT:_SetCoalitionTable()

Create a table with the valid coalitions for departure and destination airports.

RAT:_SetMarker(text, wp, index)

Set a marker visible for all on the F10 map.

Parameters

  • #string text : Info text displayed at maker.

  • #table wp : Position of marker coming in as waypoint, i.e. has x, y and alt components.

  • #number index : Spawn index of group.

RAT:_SetROE(group, roe)

Set ROE for a group.

Parameters

RAT:_SetROT(group, rot)

Set ROT for a group.

Parameters

RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)

Set the route of the AI plane.

Due to DCS landing bug, this has to be done before the unit is spawned.

Parameters

  • #number takeoff : Takeoff type. Could also be air start.

  • #number landing : Landing type. Could also be a destination in air.

  • Wrapper.Airport#AIRBASE _departure : (Optional) Departure airbase.

  • Wrapper.Airport#AIRBASE _destination : (Optional) Destination airbase.

  • #table _waypoint : Initial waypoint.

Return values

  1. Wrapper.Airport#AIRBASE: Departure airbase.

  2. Wrapper.Airport#AIRBASE: Destination airbase.

  3. #table: Table of flight plan waypoints.

  4. #nil: If no valid departure or destination airport could be found.

RAT:_SetStatus(group, status)

Set status of group.

Parameters

RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _livery, _waypoint, _lastpos, _nrespawn)

Spawn the AI aircraft with a route.

Sets the departure and destination airports and waypoints. Modifies the spawn template. Sets ROE/ROT. Initializes the ratcraft array and group menu.

Parameters

  • #string _departure : (Optional) Name of departure airbase.

  • #string _destination : (Optional) Name of destination airbase.

  • #number _takeoff : Takeoff type id.

  • #number _landing : Landing type id.

  • #string _livery : Livery to use for this group.

  • #table _waypoint : First waypoint to be used (for continue journey, commute, etc).

  • Core.Point#COORDINATE _lastpos : (Optional) Position where the aircraft will be spawned.

  • #number _nrespawn : Number of already performed respawn attempts (e.g. spawning on runway bug).

Return value

#number: Spawn index.

RAT:_SpawnWithRouteTimer(arg)

Delayed spawn function called by scheduler.

Parameter

  • #table arg : Parameters: arg.self, arg.departure, arg.destination, arg.takeoff, arg.landing, arg.livery, arg.lastwp, arg.lastpos

RAT:_TaskFunction(FunctionString, ...)

Task function.

Parameters

  • #string FunctionString : Name of the function to be called.

  • ... :

RAT:_TaskHolding(P1, Altitude, Speed, Duration)

Orbit at a specified position at a specified alititude with a specified speed.

Parameters

  • Dcs.DCSTypes#Vec2 P1 : The point to hold the position.

  • #number Altitude : The altitude ASL at which to hold the position.

  • #number Speed : The speed flying when holding the position in m/s.

  • #number Duration : Duration of holding pattern in seconds.

Return value

Dcs.DCSTasking.Task#Task: DCSTask

RAT:_Waypoint(index, description, Type, Coord, Speed, Altitude, Airport)

Create a waypoint that can be used with the Route command.

Parameters

  • #number index : Running index of waypoints. Starts with 1 which is normally departure/spawn waypoint.

  • #string description : Descrition of Waypoint.

  • #number Type : Type of waypoint.

  • Core.Point#COORDINATE Coord : 3D coordinate of the waypoint.

  • #number Speed : Speed in m/s.

  • #number Altitude : Altitude in m.

  • Wrapper.Airbase#AIRBASE Airport : Airport of object to spawn.

Return value

#table: Waypoints for DCS task route or spawn template.

RAT._WaypointFunction(group, rat, wp)

Function which is called after passing every waypoint.

Info on waypoint is given and special functions are executed.

Parameters

  • Core.Group#GROUP group : Group of aircraft.

  • #RAT rat : RAT object.

  • #number wp : Waypoint index. Running number of the waypoints. Determines the actions to be executed.

RAT:_ZoneExists(name)

Test if a trigger zone defined in the mission editor exists.

Parameter

  • #string name :

Return value

#boolean: True if zone exsits, false otherwise.

#number RAT.activate_delay

Delay in seconds before first uncontrolled group is activated. Default is 5 seconds.

#number RAT.activate_delta

Time interval in seconds between activation of uncontrolled groups. Default is 5 seconds.

#number RAT.activate_frand

Randomization factor of time interval (activate_delta) between activating uncontrolled groups. Default is 0.

#number RAT.activate_max

Maximum number of uncontrolled aircraft, which will be activated at the same time. Default is 1.

#boolean RAT.activate_uncontrolled

If true, uncontrolled are activated randomly after certain time intervals.

RAT.actype
#boolean RAT.addfriendlydepartures

Add all friendly airports to departures.

#boolean RAT.addfriendlydestinations

Add all friendly airports to destinations.

#table RAT.aircraft

Table which holds the basic aircraft properties (speed, range, ...).

#table RAT.airports

All airports of friedly coalitions.

#table RAT.airports_map

All airports available on current map (Caucasus, Nevada, Normandy, ...).

#string RAT.alias

Alias for spawned group.

#number RAT.alive

Number of groups which are alive.

#table RAT.cat
#string RAT.category

Category of aircarft: "plane" or "heli".

#boolean RAT.checkonrunway

Aircraft are checked if they were accidentally spawned on the runway. Default is true.

#boolean RAT.checkontop

Aircraft are checked if they were accidentally spawned on top of another unit. Default is true.

#table RAT.coal

RAT friendly coalitions.

#number RAT.coalition

Coalition of spawn group template.

#boolean RAT.commute

Aircraft commute between departure and destination, i.e. when respawned the departure airport becomes the new destiation.

#boolean RAT.continuejourney

Aircraft will continue their journey, i.e. get respawned at their destination with a new random destination.

#number RAT.country

Country of spawn group template.

#table RAT.ctable

Table with the valid coalitons from choice self.friendly.

Core.Zone#ZONE RAT.departure_Azone

Zone containing the departure airports.

#table RAT.departure_ports

Array containing the names of the destination airports or zones.

Core.Zone#ZONE RAT.destination_Azone

Zone containing the destination airports.

#table RAT.destination_ports

Array containing the names of the destination airports or zones.

#boolean RAT.destinationzone

Destination is a zone and not an airport.

#table RAT.excluded_ports

Array containing the names of explicitly excluded airports.

#boolean RAT.f10menu

If true, add an F10 radiomenu for RAT. Default is false.

#number RAT.frequency

Radio frequency used by the RAT groups.

#string RAT.friendly

Possible departure/destination airport: all=blue+red+neutral, same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red.

#string RAT.id

Some ID to identify who we are in output of the DCS.log file.

#boolean RAT.immortal

If true, aircraft are spawned as immortal.

#boolean RAT.invisible

If true aircraft are set to invisible for other AI forces.

#number RAT.landing

Landing type. Determines if we actually land at an airport or treat it as zone.

#string RAT.livery

Livery of the aircraft set by user.

#number RAT.markerid

Running number of placed markers on the F10 map.

#table RAT.markerids

Array with marker IDs.

#number RAT.maxdist

Max distance from departure to destination in meters. Default 5000 km.

#number RAT.mindist

Min distance from departure to destination in meters. Default 5 km.

#string RAT.modulation

Ratio modulation. Either "FM" or "AM".

#number RAT.ngroups

Number of groups to be spawned in total.

#boolean RAT.norespawn

Aircraft will not be respawned after they have finished their route.

#string RAT.onboardnum

Sets the onboard number prefix. Same as setting "TAIL #" in the mission editor.

#number RAT.onboardnum0

(Optional) Starting value of the automatically appended numbering of aircraft within a flight. Default is 1.

#table RAT.parking

RAT parking spots data base.

#string RAT.parking_id

String with a special parking ID for the aircraft.

#boolean RAT.placemarkers

Place markers of waypoints on F10 map.

#boolean RAT.radio

If true/false disables radio messages from the RAT groups.

#boolean RAT.random_departure

By default a random friendly airport is chosen as departure.

#boolean RAT.random_destination

By default a random friendly airport is chosen as destination.

#table RAT.ratcraft

Array with the spawned RAT aircraft.

#number RAT.rbug_maxretry

Number of respawn retries (on ground) at other airports if a group gets accidentally spawned on the runway. Default is 3.

#boolean RAT.reportstatus

Aircraft report status.

#boolean RAT.respawn_after_crash

Aircraft will be respawned after a crash, e.g. when they get shot down.

#boolean RAT.respawn_after_takeoff

Aircraft will be respawned directly after take-off.

#boolean RAT.respawn_at_landing

Respawn aircraft the moment they land rather than at engine shutdown.

#number RAT.respawn_delay

Delay in seconds until a repawn happens.

#boolean RAT.respawn_inair

Aircraft are allowed to spawned in air if they cannot be respawned on ground because there is not free parking spot. Default is true.

#table RAT.return_zones

Array containing the names of the return zones.

#boolean RAT.returnzone

Zone where aircraft will fly to before returning to their departure airport.

#string RAT.roe

ROE of spawned groups, default is weapon hold (this is a peaceful class for civil aircraft or ferry missions). Possible: "hold", "return", "free".

#string RAT.rot

ROT of spawned groups, default is no reaction. Possible: "noreaction", "passive", "evade".

#string RAT.skill

Skill of AI.

#number RAT.spawndelay

Delay time in seconds before first spawning happens.

#boolean RAT.spawninitialized

If RAT:Spawn() was already called this RAT object is set to true to prevent users to call it again.

#number RAT.spawninterval

Interval between spawning units/groups. Note that we add a randomization of 50%.

#table RAT.status

RAT aircraft status.

#number RAT.statusinterval

Intervall between status checks (and reports if enabled).

#number RAT.takeoff

Takeoff type. 0=coldorhot.

Core.Group#GROUP RAT.templategroup

Group serving as template for the RAT aircraft.

#boolean RAT.uncontrolled

If true aircraft are spawned in uncontrolled state and will only sit on their parking spots. They can later be activated.

#table RAT.unit

RAT unit conversions.

#boolean RAT.useparkingdb

Parking spots are added to data base once an aircraft has used it. These spots can later be used by other aircraft. Default is true.

#table RAT.version

RAT version.

#table RAT.waypointdescriptions

Table with strings for waypoint descriptions of markers.

#table RAT.waypointstatus

Table with strings of waypoint status.

#table RAT.wp

RAT waypoint type.

Type RATMANAGER

Extends Core.Base#BASE

  • RATMANAGER class

Field(s)

RATMANAGER:Add(ratobject, min)

Adds a RAT object to the RAT manager.

Parameter min specifies the limit how many RAT groups are at least alive.

Parameters

  • #RAT ratobject : RAT object to be managed.

  • #number min : Minimum number of groups for this RAT object. Default is 1.

#string RATMANAGER.ClassName

Name of the Class.

#boolean RATMANAGER.Debug

If true, be more verbose on output in DCS.log file.

RATMANAGER:New(ntot)

Creates a new RATMANAGER object.

Parameter

  • #number ntot : Total number of RAT flights.

Return value

#RATMANAGER: RATMANAGER object

RATMANAGER:SetTcheck(dt)

Sets the time interval between checks of alive RAT groups.

Default is 30 seconds.

Parameter

  • #number dt : Time interval in seconds.

RATMANAGER:Start(delay)

Starts the RAT manager and spawns the initial random number RAT groups for each RAT object.

Parameter

  • #number delay : Time delay in seconds after which the RAT manager is started. Default is 5 seconds.

RATMANAGER:Stop(delay)

Stops the RAT manager.

Parameter

  • #number delay : Delay in seconds before the manager is stopped. Default is 1 second.

#number RATMANAGER.Tcheck

Time interval between checking of alive groups.

RATMANAGER:_Count()

Counts the number of alive RAT objects.

RATMANAGER:_Manage()

Manager function.

Calculating the number of current groups and respawning new groups if necessary.

RATMANAGER:_RollDice(nrat, ntot, min, alive)

Rolls the dice for the number of necessary spawns.

Parameters

  • #number nrat : Number of RAT objects.

  • #number ntot : Total number of RAT flights.

  • #table min : Minimum number of groups for each RAT object.

  • #table alive : Number of alive groups of each RAT object.

RATMANAGER:_Start()

Instantly starts the RAT manager and spawns the initial random number RAT groups for each RAT object.

RATMANAGER:_Stop()

Instantly stops the RAT manager by terminating its scheduler.

#table RATMANAGER.alive

Number of currently alive groups.

#string RATMANAGER.id

Some ID to identify who we are in output of the DCS.log file.

Core.Scheduler#SCHEDULER RATMANAGER.manager

Scheduler managing the RAT objects.

#number RATMANAGER.managerid

Managing scheduler id.

#table RATMANAGER.min

Minimum number of RAT groups alive.

#string RATMANAGER.name

Name (alias) of RAT object.

#number RATMANAGER.nrat

Number of RAT objects.

#number RATMANAGER.ntot

Total number of active RAT groups.

#table RATMANAGER.rat

Array holding RAT objects etc.