Headless AI: Tasks - Global-Conflicts-ArmA/Olsen-Framework-Arma-3 GitHub Wiki

Tasks

Tasks are missions/actions that you can assign to groups of AI that affect behaviour and responses. Tasks are set for groups via the PZAI_fnc_setInit function in the group init. Some responses require task positions or a radius for the group task to work properly. Requirements for tasks are listed in their task descriptions.

Patrol

Patrol is the default task if no assigned task or waypoints have been detected for the group. Groups on patrol will choose a random spot within a radius of their taskPos, defaulted to their spawn location, and will continue moving in formation to random spots within this radius until they are under contact. Groups patrolling near buildings have a chance of searching within them.

  • taskPos = position which the patrol radius emanates from (defaults to group spawn position)
  • taskRadius = radius of the patrol area (default 30)
[this, "task", "PATROL", "taskPos", getPos hillLogicObject, "taskRadius", 200] call PZAI_fnc_setInit

Perimeter Patrol

Perimeter Patrol is the same as the patrol task except waypoints are chosen along the outside radius of the area selected, meaning that the group will patrol around the perimeter of the area chosen instead of random points throughout it.

  • taskPos = position which the patrol radius emanates from (defaults to group spawn position)
  • taskRadius = radius of the patrol area (default 30)
[this, "task", "PERIMPATROL", "taskPos", getPos hillLogicObject, "taskRadius", 200] call PZAI_fnc_setInit

Sentry

Sentry has the group move back and forth between their start position and a waypoint at their set taskPos. If no taskPos is set, they go to a waypoint the taskRadius distance in front of them and back until contact.

  • taskPos = position that the group patrols to before cycling back to their spawn position
  • taskRadius = distance of the sentry waypoint from spawn pos (default 30)
[this, "task", "SENTRY", "taskPos", getPos hillLogicObject, "taskRadius", 200] call PZAI_fnc_setInit

Stationary

Stationary tasks set the group still, disabling their pathing while letting the AI rotate and chance stances. This is ideal for hand placing AI within buildings or fortifications to create entrenched enemies.

[this, "task", "STATIONARY"] call PZAI_fnc_setInit

Defend

Defend will detect occupyable buildings and set the AI group members within building positions via the garrison task. If no buildings are found, it will switch to the Defend task and the AI will look for cover objects, or at least set into a defensive formation.

  • taskPos = position that the group defends from
  • taskRadius = distance of search function for buildings, as well as the max search area for cover objects if in defend task.
[this, "task", "DEFEND", "taskPos", getPos townLogicObject, "taskRadius", 150] call PZAI_fnc_setInit

Attack

Attack will direct the AI to attack the taskPos position provided.

  • taskPos = position that the group attacks
  • taskRadius = radius completion of the attack waypoint
[this, "task", "ATTACK", "taskPos", getPos townLogicObject, "taskRadius", 25] call PZAI_fnc_setInit

Assault

Assault will direct the AI to attack the taskPos position provided in a more aggressive manner towards a directed enemy position. AI will continue at full speed until they detect enemy within their AssaultEngageDistance or they reach their taskRadius distance from their taskPos.

  • taskPos = position that the group assaults
  • taskRadius = radius completion of the assault task, at which distance the AI will go to a regular attack task
  • AssaultEngageDistance = distance at which the AI will respond to fire or enemy detection and start an assault, otherwise fire and enemy detection is ignored and AI will continue towards taskPos
[this, "task", "ASSAULT", "taskPos", getPos townLogicObject, "taskRadius", 25, "AssaultEngageDistance", 200] call PZAI_fnc_setInit

Loiter

Loiter will have the AI choose random actions of loitering, resting, casually patrolling, to simulate a relaxed loitering posture.

[this, "task", "LOITER"] call PZAI_fnc_setInit

Bunker

Bunker is a special task for an entrenched group that you want to extend the range at which it fires at enemies, as well as tailor the frequency and accuracy of fire.

  • note - for stationary task groups single members can be set to bunker mode in their unit init:
[this, "Bunker", true] call PZAI_fnc_setInit

Bunker accuracy, spotting, and fire behaviour can be globally set in the modules\headless_ai\settings\bunker.hpp file, or set individually in the unit init.

  • bunkerDistance = max distance at which the bunker AI can fire (default 1200)
  • aimedAdjust = accuracy of the unit (default 0.999)
  • AimConeAdjust = cone adjustment (default 0.975)
  • AimDistAdjust = distance adjustment (default 0.00024)
[this, "task", "BUNKER"] call PZAI_fnc_setInit

vehCargo

Defines a group as cargo passengers for the vehicle they are synchronized with. This is typically used for deliberate assaults with transport vehicles like IFVs or Trucks. Target vehicle should crew which is also linked with Headless AI. To have the group follow up with a task, use the nextTask parameter.

Target: GROUP Input: Boolean

Ensure that the crew is synced to a gamelogic, their vehicle is synced to a gamelogic, and the crew and vehicle are synced. Then, ensure your cargo group is synced to the game logic, and to the vehicle that will be carrying them. At this point, place them inside of their carrying vehicle.

Examples

[this, "vehCargo", true, "nextTask", "ASSAULT", "taskPos", getPos assault_position_game_logic] call PZAI_fnc_setInit;

DROPOFF

Instructs a vehicle to disembark assigned passenger units at the defined location. Will NOT disembark crewmembers from the vehicle.

Target: GROUP Input: taskpos Position,

Examples

[this, "task", "DROPOFF", "taskPos", getpos town_qrf_1_assault] call PZAI_fnc_setInit;

Task Modifiers

taskCompRadius

Defines the radius by which a task may be completed. For example, when a unit with a dropoff order intersects the circumference of the circle with the given radius, the order will be considered complete.

Inputs: Integer

Examples

[this, "task", "DROPOFF", "taskPos", getpos town_qrf_1_assault, "taskCompRadius", 250] call PZAI_fnc_setInit;

taskPos

Used for tasks which require a positional modifier.

Inputs: Position

Examples

[this, "task", "DROPOFF", "taskPos", getpos town_qrf_1_assault, ] call PZAI_fnc_setInit;

Stance

Forces infantry to maintain the given certain stance, even when being shot at

Inputs: Stance String: UP MIDDLE DOWN AUTO

Examples

[this, "stance", "UP"] call PZAI_fnc_setInit;
// Or when making stationary units
[this, "stance", "UP", "task", "stationary"] call PZAI_fnc_setInit;