PZAI is an AI modification library that uses the server's Headless Client to increase performance and extend the functionality of the editor. Unlike independent mods such as LAMBS, it relies on scripts inside the TCS Framework.
Due to this, almost everything about the AI's behaviour is customizable when using PZAI.
Using PZAI disables the majority of LAMBS behaviours, so test your mission extensively to get a feel for the AI.
In the mission's root folder, the scripts for PZAI are located in TCS/headless_ai/headless_ai
(sic). In this document, the Headless AI Folder refers to this folder.
Once you've place some units on the map, place a Game Logic (Under Modules, Objects search game logic then select the one on the bottom) and give it a variable name. Select all the units in the group that you want to put on headless, and sync them to the game logic.
If the group includes vehicles, both the vehicle and all of its crew must be synced. One way to do this is to click the vehicle which will show icons for the crew, then holding left ctrl and clicking the icons to select them. Failure to do this correctly will result in the vehicle promptly launching to the moon upon spawning.
Upon spawning the units will begin executing any waypoints you've given them. If there are no waypoints, they will simply patrol in a circle.
To spawn units, simply use the code ["logicName"] call PZAI_fnc_SpawnArray;
, where logicName is the variable name of the game logic you placed earlier.
Part of the versatility of Headless AI is that you can use this code snipper where ever and whenever. Place it in the On Activation field of a trigger, or write a complicated script that randomly chooses between spawning a tank or a helicopter - the limit is only your imagination and scripting prowess.
Although we've set up Headless AI in the editor, nothing will happen if you launch the mission now. This is because we need to edit headless_ai/settings.sqf
. Open the file and locate the variable GVAR(ArrayObjects)
. You need to fill this array with the variable names of your game logics, as in this example:
The array GVAR(InitialSpawn)
should contain any game logic names that you wish to spawn on mission start. Putting the game logic names in this array tells the script that you want these units to be run using Headless AI. The other two variables allow you to have a randomized initial spawn.
Headless AI will only work if the server has a headless client connected. If the test server does not have a headless client, inform a TCS admin.
Now launch your mission in singleplayer and the PZAI script should work. Take note: nothing will spawn in local multiplayer (since there are no headless clients), but in singleplayer everything will work like it does on the server. Make sure you test your AI behaviour on the test server as well.
PZAI has a multitude of options to customize how your AI behaves. If you go to the settings.sqf
file, you can scroll down to see the options. Here we give a brief description of some of their effects.
Sets the AI's maximum distance to spot players. There’s no hard limit, but think carefully about the type of mission you want while changing this.
Sets the time on the headless client to be different than the time in game. We all know how frustratingly dumb Arma AI can be at night without NVGs, where they can’t see you when you can see them easily. With this, you can set them to see like whatever time it is you enter. I recommend setting it to an evening hour so they can’t see perfectly, but aren’t completely blind.
Sets how far away the AI can hear gunshots from. Be careful with setting this though, if they hear shots from far out they could start migrating from the objective to investigate.
Sets how far away AI will back each other up from. For example, if an AI squad is getting overrun and the distance is set to 1500, they could call for help from a tank 1200 meters away.
Similar to RadioDistance, but this is just for reinforcing objectives under attack. If an AI squad sees a TCS blob incoming, they can call other squads over to defend the area they’re tasked with guarding. QRF_Distance is just an additional setting if you have a dedicated QRF that can come in faster. Say the QRF spawns 800 meters away and you have guys spawned guarding an objective 1km away, you can ensure only the dedicated QRF shows up.
If you have units guarding a location, they will abandon their posts to reinforce their allies. To avoid this, turn down the reinforce distance, or give defenders a hold waypoint.
Keep this to false to enable AI flanking. Squads will attempt to flank you (use WaypointDistance setting to determine how far they can flank). Be advised in large squads, the AI squad leader sometimes attempts to break off fire teams to flank.
In headless_ai/settings
there are further configuration options. You can modify the AI's skill level in skill.hpp
and the vehicle view distance in sight.hpp
. The commander module does not work very well, so you should avoid using it.
AI Tasks are like scripted waypoints that you can give units instead of the traditional waypoints. The below table will describe some of the important ones. When it says to put something in the group init it means to put it in the Composition: Init of the group, not the individual unit inits.
Otherwise, you put the code snippet in the individual unit init fields.
Here are the available headless scripts:
Sets the AI in a special mode that creates invisible target over players heads when spotted. AI fires fully automatic at this target (can also easily wound/kill player while doing this). Great for a suppressive effect. Does disable the AI from moving.
Code Snippet: [this, "task", "bunker"] call PZAI_fnc_setInit;
Placed in: Group Init.
If you want just one unit in a group to use Bunker, (such as a tank gunner) you can use:
Code Snippet: [this, "bunker", true] call PZAI_fnc_setInit;
Placed in: Unit Init.
Makes sure aircraft spawning in the sky don’t fall to their deaths upon spawning.
Code Snippet: [this, "flying", true, "flyInHeight", height] call PZAI_fnc_setInit;
Replace height with the altitude you want the aircraft to have.
Placed in: Unit Init (of the aircraft).
Forces the unit to stand still.
Code Snippet: [this, "task", "stationary"] call PZAI_fnc_setInit;
Placed in: Group Init
Force the unit's stance.
UP = Standing
MIDDLE = Crouching
DOWN = Prone
Code Snippet: [this, "stance", "UP"] call PZAI_fnc_setInit; [this, "stance", "MIDDLE"] call PZAI_fnc_setInit;
Placed in: Either Init
Adds stationary and stance together. Good for when you want to do your own building garrisons with guys looking out the windows, etc…
UP = Standing
MIDDLE = Crouching
DOWN = Prone
Code Snippet: [this, "stance", "STANCE", "task", "stationary"] call PZAI_fnc_setInit;
Placed in: Group Init