A guide to AI - Global-Conflicts-ArmA/gc-reforger-missions GitHub Wiki
Introduction
When creating COOP or COTVT missions, it is important to have a decent understanding of how the AI of Arma Reforger works.
This guide aims to give you an elementary understanding of how AI operates, of course while simplifying or leaving out many things.
[!WARNING] Be advised that as development of the game continues, some of the things mentioned may change.
Group vs. agent
It is useful to think about AI on two basic levels - group level, and character (agent) level.
An AI group consists of multiple spawned characters, usually defined in its character array.
The core purpose of the group is to assign individual tasks (goals) to its member agents, in order to accomplish the groups overall objective.
[!IMPORTANT] An AI group has three control modes: Idle, Following waypoints and Autonomous (combat movement).
Waypoints
Waypoints are used to explicitly assign overall objectives to the group.
As indicated before, group combat itself is not related to waypoints, and instead an alternate form of behavior that the AI engages in over (meaning while ignoring) waypoints.
Instead, waypoints define non-combat objectives, like moving to a location, seeking out an enemy with the purpose of destroying him in combat, or establishing a defensive perimeter in preparation of combat.
An AI group can only follow one waypoint at a time, remaining ones are waiting in queue until the current one is completed.
[!TIP] Waypoints can be assigned to groups, either in the entity properties (static waypoints) or at runtime (like using the framework instruction). Waypoint prefabs are found under ArmaReforger/Waypoints/Prefabs/.
These are the most important shared attributes of all waypoints:
Attribute | Explanation |
---|---|
AI Behavior Tree | BT that defines functionality / logic of the waypoint |
AI Behavior Tree Move To | BT that defines how the AI moves to this waypoint (Move.bt=Run, Patrol.bt=Walk) |
Completion Radius | Radius of the waypoint - note that this radius may be used in different ways depending on the BT |
Priority Level | How important the AI considers executing this waypoint over entering combat |
Class-specific attributes | Waypoints may have additional attributes based on waypoint type |
If you want to learn how a waypoint works, you would open and inspect the specified AI behavior tree. While a single BT rarely defines all behavior related to following a waypoint (more on that in the next chapter), it should give you a high level overview of what the objective entails.
The following table gives a brief description of the most important waypoint prefabs:
Waypoint Prefab | Description |
---|---|
AIWaypoint_Move | The group moves into the radius of the waypoint, at running speed |
AIWaypoint_ForcedMove | Same as move, but with maximum priority to always ignore combat |
AIWaypoint_Patrol | Same as move, but at walking speed |
AIWaypoint_Cycle | The group keeps executing all specified waypoints in a loop |
AIWaypoint_Defend | Agents spread out and take positions within the radius, also manning turrets |
AIWaypoint_Wait | The group does nothing and waits until the given time has expired |
AIWaypoint_Attack | The group moves to a hostile group or entity specified by name with the purpose of destroying it |
AIWaypoint_SearchAndDestroy | The group searches for hostiles within the waypoint radius, then holds it for a given amount of time |
AIWaypoint_Scout | Same as SearchAndDestroy |
AIWaypoint_GetInNearest | The group enters the nearest vehicle and waits for some time |
AIWaypoint_GetIn | The group enters a vehicle specified by name and waits |
AIWaypoint_GetOut | The group dismounts from the current vehicle |
There are several more waypoints, but most of them are either usually unimportant for mission making or very slight variations of already explained waypoints.
Group activities and agent behaviors
While the focus of waypoint BTs is defining state/completion logic or sending group goal messages, most parts of actual group behavior are usually defined in corresponding Activity BTs.
For example, WP_Heal.bt just (a) handles completion logic and (b) sends an initial heal goal message to the group, which then reacts to the message by starting ActivityHeal.bt.
Only ActivityHeal.bt defines how the group should go about healing the given character. For healing, this involves (a) choosing a medic, (b) deploying smoke and (c) sending a heal goal message to the chosen medic agent.
When the chosen medic receives this agent level goal message, it reacts by running the lowest level BT (referred to as agent behavior), MedicHeal.bt, which instructs the AI to (a) move to the target, (b) position itself to the injured characters side and (c) finally treat the target.
[!TIP] For this reason, if you want to gain a deeper understanding of what a waypoint does, you should also look at the associated Group Activity BT found in AI/BehaviorTrees/Chimera/Group/, and the related Agent Behavior BT found in AI/BehaviorTrees/Chimera/Soldier/.
To summarize, a waypoint BT commonly defines completion or state logic and sends a goal message to the group, which in turn runs its own Activity BT that may send goal messages to individual agents that then respond by performing related tasks outlined in the corresponding agent behavior BT.
[!IMPORTANT] Of course, such activity and agent BTs are not exclusively triggered by waypoints, but may also be started autonomously - like when a group member is injured during combat.
Additional notes
- AUTONOMOUS (combat movement) mode only defines group level combat movement, not soldier level combat. For example, AI groups assigned to defend waypoints will remain in FOLLOWING_WAYPOINT mode (to control its agents positions) when attacked, with soldiers engaging in combat individually. Rather, AUTONOMOUS mode is about planning a freely fighting groups movement, meaning one that abandoned its waypoint or never had one.
Authors: Til