DCS task controlledTask

From DCS World Wiki - Hoggitworld.com
Revision as of 01:04, 21 September 2023 by Grimes (talk | contribs) (Created page with "{{Template:DCS_tasking |tName= ControlledTask |vNum= 1.1 |type= Main task |for= Airplanes, Helicopters, Ships, Ground Vehicles |desc= A controlled task is a task that has...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Task: ControlledTask Added with: 1.1
Hierarchy: Scripting Root > Tasks > Main task > ControlledTask
Tasking Type: Main task
For: Airplanes, Helicopters, Ships, Ground Vehicles
Available Under: All
Description: A controlled task is a task that has start and/or stop conditions that will be used as a condition to start or stop the task.

Start conditions are executed only once when the task is reached in the task queue. If the conditions are not met the task will be skipped.

Stop Conditions are executed at a high rate

Can be used with any task in DCS. Note that options and commands do *NOT* have stopConditions. These tasks are executed immediately and take "no time" to run.

Format: This task needs to be in the following format.
ControlledTask= { 
 id = 'ControlledTask', 
 params = { 
     task = {
        taskToExecute
     },
     condition = {
     },
     stopCondition = {
     },
 } 
}

Required parameters: task : Any task to be executed

condition : Table of start conditions required to exist for the task to execute

stopCondition : Table of stop conditions that will end the task once met.


Optional Parameters:

time : Time in seconds since mission start. A value of 3600 would be a condition of 1 hour into the mission

condition : string lua code that is executed. Requires return true for the condition to execute

  if targetsKilled > 8 then return true end 

userFlag : string or number of a user flag. By default checks if the flag is true/ isn't 0.

userFlagValue : boolean required if you want to check if the flag is false.

Start Condition Only:

probability : number 0-100 chance of the task executing. Is only checked once.


Stop Condition Only

lastWaypoint : number of the last waypoint that if the AI reach it will stop the task

duration : number duration in seconds that the task will run for.

Enumerators:
Examples: The following will have a 70% chance of executing the task "timedOrbit" which if executed will run for 15 minutes.
   local timedOrbit = {
     id = "ControlledTask",
     params =  {
       task = {
         id = 'Orbit', 
         params = { 
           pattern = 'Circle',
           point = mist.utils.makeVec2(mist.getAvgPos(mist.makeUnitTable({'[g]arty'}))),
           speed = 200,
           altitude = 8000,
          },
          condition = {
            probability = 70,
          },
          stopCondition = {
             duration = 900,
          }, 
        },
     }
     Group.getByName('Reaper'):getController():pushTask(timedOrbit)
Notes: See article Mission Editor: AI Tasking for more information on how AI tasking is handled within DCS.
Task List: Task Wrappers: mission, ComboTask, ControlledTask, WrappedAction


Tasks: AttackGroup, AttackUnit, Bombing, Strafing, CarpetBombing, AttackMapObject, BombingRunway, orbit, refueling, land, follow, followBigFormation, escort, Embarking, fireAtPoint, hold, FAC_AttackGroup, EmbarkToTransport, DisembarkFromTransport, CargoTransportation, goToWaypoint, groundEscort, RecoveryTanker

En-route Tasks: engageTargets, engageTargetsInZone, engageGroup, engageUnit, awacs, tanker, ewr, FAC_engageGroup, FAC

Commands: script, setCallsign, setFrequency, setFrequencyForUnit, switchWaypoint, stopRoute, switchAction, setInvisible, setImmortal, setUnlimitedFuel, activateBeacon, deactivateBeacon, activateICLS, deactivateICLS, eplrs, start, transmitMessage, stopTransmission, smoke_on_off, ActivateLink4, deactivateLink4, activateACLS, deactivateACLS, LoadingShip

Options: ROE, Reaction To Threat, Radar Using, Flare Using, Formation, RTB On Bingo, silence, Disperse on Attack, Alarm State, RTB on Out of Ammo, ECM Using, Prohibit AA, Prohibit Jettison, Prohibit Afterburner, Prohibit AG, Missile Attack Range, Prohibit WP Pass Report, Engage Air Weapons, Option Radio Usage Contact, Option Radio Usage Engage, Option Radio Usage Kill, AC Engagement Range Restriction, jett tanks if empty, forced attack, Altitude Restriction for AAA Min, restrict targets, Altitude Restriction for AAA Max, Prefer Vertical, Evasion Of ARM, Formation Interval