Arma 3 Scripting

Command in Object Manipulation

createAgent

Also available as Markdown and JSON, or read the original wiki page.

Description

Creates an agent of the given type. An agent does not have a group or leader or the standard soldier FSM associated with it - for instance, an enemy soldier spawned as an agent has limited AI and will do nothing when fired upon - which can be useful to limit the amount of AI processing being done in a mission with very large numbers of "AI". Animals are also commonly created as agents.

Note

  • Players assigned to an agent using selectPlayer will be able to control the agent, operate weapons and other actions, but will not be able to access their inventory using the gear screen.
  • To create objects of type "Logic", use createUnit.

Syntax

createAgent [type, position, markers, placement, special]

Parameters:

Returns: Object

Examples

Example 1

private _agent = createAgent ["B_Soldier_F", getPosATL player, [], 0, "NONE"];

Example 2

private _agent = createAgent ["Snake_random_F", ASLToAGL getPosASL player, [], 0, "CAN_COLLIDE"]; // Creates a snake at player's feet

See also

agent · agents · isAgent · forEachMemberAgent · execFSM · BIS_fnc_execFSM

Community notes

Killzone_Kid

In Arma 3, default FSM is calling BIS_fnc_animalBehaviour script upon agent creation, which takes on some animal behavioural logic. The problem here is that it is almost impossible to make animal do what is told. Until now. Since Arma 3 v1.32 you can set BIS_fnc_animalBehaviour_disable variable on the agent at the moment of agent creation, to override the function.

tr = createTrigger ["EmptyDetector", player modelToWorld [0, 10, 0]];
tr setTriggerArea [5, 5, 0, true];
tr setTriggerActivation ["CIV", "PRESENT", true];
rabbits = [];
private "_r";
for "_i" from 1 to 10 do {
    _r = createAgent ["Rabbit_F", position tr, [], 0, "NONE"];
    _r setVariable ["BIS_fnc_animalBehaviour_disable", true];
    rabbits pushBack _r;
};
tr setTriggerStatements [
    "if (rabbits isEqualTo thisList) exitWith {
        _r = thisList select floor random count thisList;
        _r moveTo (_r modelToWorld [2.5 - random 5, 2.5 - random 5, 0]);
    };
    _esc = rabbits - thisList;
    doStop _esc;
    {_x moveTo position thisTrigger} forEach _esc;
    systemChat str [time, _esc];
    false",
    "",
    ""
];
Waffle SS.

Agents seem to use the same collision model that the player uses, unlike normal AI. Normal AI don't collide with objects, but agents are physically stopped by obstacles the same way players are. This also probably means agents cost more resources than normal AI.