Skip to content

Singleplayer AI Tuning Guide

rayswaynl edited this page Jul 18, 2026 · 1 revision

Singleplayer AI Tuning Guide

This is a practical Arma 2 OA guide for a local singleplayer mission or a small local test scenario. It does not prescribe WASP server settings. Keep one behavior mod in charge of a behavior family, make one change at a time, and test the result with the same difficulty profile and unit loadout.

The wider AI cookbook research cluster is useful for ideas, not authority. The recipes below were retained only where the command shape is OA-era valid and agrees with current mission usage or the OA reference material. In particular, do not substitute Arma 3-only checkVisibility or array-form reveal examples.

Start With Acquisition, Not Fire Rate

An AI that appears to have an instant reaction often acquired the target too quickly; it is not necessarily executing a firing command too quickly. Separate these levers:

Lever What it changes First adjustment
spotDistance How well a unit finds/maintains a target at range. Lower it before lowering weapon accuracy.
spotTime How quickly a unit reacts after seeing/hearing a threat. Lower it for a slower first response.
knowsAbout Current knowledge of a particular target. Use it as a threshold, not as a global difficulty knob.
reveal Grants knowledge of one target. Use only in a small, local, range-bounded assist.

WASP demonstrates both ends of the scale: town defenders receive bounded per-subskill values in Common/Functions/Common_CreateTownUnits.sqf:181-193, while the deliberately dangerous GUER patrol path sets spotDistance and spotTime to 1 in Common/Functions/Common_RunSidePatrol.sqf:68-82. Those are mission-specific roles, not a recommended SP default.

A cheap local reveal assist

Use this only for a scripted sentry/spotter that is local to the machine running the code. Run it on a slow cadence such as every 2–5 seconds, not every frame. The short range and nearTargets list keep the loop bounded.

private ["_observer", "_contact"];

_observer = _this select 0;
if (!local _observer || {!alive _observer}) exitWith {};

{
    _contact = _x select 0;
    if (!isNull _contact && {alive _contact} && {(side _contact) != (side _observer)}) then {
        if ((_observer knowsAbout _contact) < 1.5) then {
            _observer reveal _contact;
        };
    };
} forEach (_observer nearTargets 120);

This is a deliberately narrow awareness nudge, not an all-seeing sensor. Do not replace 120 with map-wide distance, iterate allUnits, run it per-frame, or use reveal [_target, _accuracy]: that array form is an Arma 3 trap for this OA mission. If the unit still reacts too sharply after this loop is absent, tune spotTime and spotDistance first.

Flatten CfgAISkill Before Stacking More AI Mods

CfgAISkill maps raw subskill input to the effective subskill. A steep curve creates large behavioral differences from small mission or mod values; a flatter curve makes different unit classes feel more consistent. Put a single tested override in a small config addon, load it by itself first, and keep a backup so it can be removed in one step.

Illustrative contrast for a less spiky SP baseline:

// Steep: a small raw-skill difference remains a large effective difference.
class CfgAISkill {
    spotDistance[] = {0, 0.15, 1, 1.00};
    spotTime[]     = {0, 0.15, 1, 1.00};
};

// Flatter: preserve ordering, narrow the effective spotting range.
class CfgAISkill {
    spotDistance[] = {0, 0.35, 1, 0.55};
    spotTime[]     = {0, 0.40, 1, 0.60};
    aimingAccuracy[] = {0, 0.04, 1, 0.22};
};

The four numbers are two input/output points: { inputLow, outputLow, inputHigh, outputHigh }. The example intentionally leaves aiming steadier than spotting: reducing accuracy does not solve premature detection, while reducing spotting alone can make AI feel blind. Test one curve at a time with a fixed squad and terrain; keep setSkill role overrides small because they still feed through the config curve.

The OA skill command lists spotDistance, spotTime, aimingAccuracy, aimingSpeed, courage, commanding and related subskills. The official CfgAISkill description explains the interpolation behavior; treat its Arma 3 presentation as syntax background only, then validate the result in OA before distributing it. skill command reference | CfgAISkill reference

CQB Recipe: Brief, Scripted and Reversible

For a breach or room-clearing set piece, scripting can temporarily prevent the normal danger FSM from pulling a unit away from the intended sequence. Keep the scope short, make the group aggressive, move one unit through real building positions, then restore normal control.

private ["_group", "_house", "_unit", "_pos", "_i"];

_group = _this select 0;
_house = _this select 1;

_group setCombatMode "RED";
_group allowFleeing 0;

{
    _x disableAI "FSM";
    _x forceSpeed 2;
} forEach units _group;

_i = 0;
{
    _unit = _x;
    _pos = _house buildingPos _i;
    if (count _pos > 0) then {
        _unit doMove _pos;
        waitUntil {sleep 0.25; !alive _unit || {_unit distance _pos < 3}};
    };
    _i = _i + 1;
} forEach units _group;

{
    _x forceSpeed -1;
    _x enableAI "FSM";
} forEach units _group;

Use a timeout around each waitUntil in production content, and abort/restore if the group or building is deleted. allowFleeing 0 disables fleeing for an AI-led group; it does not make human-led players obey it. forceSpeed is deliberately reset to -1, and the FSM is re-enabled even on an abort path. This recipe sequences positions; it does not guarantee that every building model has usable positions or that the AI will clear rooms intelligently.

Fix Mod Error Spam at One Owner Boundary

Stacking behavior mods can register overlapping event handlers, each with its own timing and locality assumptions. More handlers do not make the AI smarter; they make duplicate work, races and RPT diagnosis harder. Pick one primary behavior/skill mod, retain only a small compatibility patch with a named failure, and remove the rest before deciding that the mission is at fault.

The worked WASP example is PR #798, now merged: ASR AI's fired handler slept before its reveal pass. If its shooter died and the mission garbage-collected the corpse during that sleep, the mod later reached reveal [_shooter, _k] with a stale shooter. The earlier entry-only guard could not catch a post-sleep race. Common/Functions/Common_AsrFiredGuard.sqf:24-150 instead replaces the handler once per machine, re-checks after the sleep, restores the mod's re-entrancy state and no-ops when ASR is absent. It is a specific compatibility patch, not a reason to layer ASR, Zeus, full SLX and another skill-config addon together.

For an SP mod mix:

  1. Reproduce with the base mission and no AI mod.
  2. Add one primary AI mod and record the first error window.
  3. Add only a narrowly scoped patch with a named source/error match.
  4. Do not add a second mod that owns the same skills, danger FSM or group tasking.

See AI mods and pathfinding reference for the same single-owner rule in the commander/HC context.

Squad Size: Fewer Groups Often Feels Smarter

Larger squads reduce group/FSM/waypoint overhead and are easier to control, but can look clumsy indoors and concentrate casualties. Smaller squads manoeuvre and clear better, but multiply leaders, pathfinding and scheduled work. For SP, begin with 6–8 infantry per active group, use a second group only when it has a distinct job, and reduce active groups before adding another AI overhaul.

WASP's AI commander material is useful when the question becomes command-scale rather than a local SP encounter: AI headless and performance, Commander-team driver, and AI commander execution loop. Those pages cover locality, group ownership and long-running commander behavior; do not copy their large-scale defaults blindly into a singleplayer mission.

Quick Test Loop

  1. Fix difficulty/profile settings, load order, map, squad count and weather.
  2. Test spotting without a reveal loop; then add the bounded loop alone.
  3. Test one CfgAISkill curve with no other skill mod active.
  4. Test the CQB recipe in three representative buildings and confirm the restore path after a casualty.
  5. Read the RPT from the test window; solve the first reproducible error before adding another mod.

Main map: Home | AI route: AI/headless/performance | OA command safety: Arma 2 OA agent traps

Sidebar

Clone this wiki locally