Arma 3
Better Static AI Script
This topic has been locked
Swiftcore  [developer] 6 Dec, 2024 @ 11:08pm
[OUTDATED] Script for editor
EDIT: Method for using this script in the editor has changed, read main description for details.

Paste the following code into the group init of whatever group you want to use this script on. You can get to the group init by double clicking on the transparent symbol that hovers over the squad in the editor.

Setting the squad leader to crouch will make the squad crouch instead of stand, which is good for utilizing low cover like sandbags and low walls.


private _nearestUnit = leader this; private _targetUnit = this; if (unitPos _nearestUnit == "MIDDLE") then { _targetUnit setVariable ["upStance", "MIDDLE", true]; _targetUnit setVariable ["downStance", "DOWN", true]; } else { _targetUnit setVariable ["upStance", "UP", true]; _targetUnit setVariable ["downStance", "MIDDLE", true]; }; if(isnil "fnc_swSuppress") then { fnc_swSuppress = { params ["_unit"]; private _standStance = group _unit getVariable "upStance"; private _layStance = group _unit getVariable "downStance"; _unit setUnitPos _layStance; waitUntil{sleep 1; getSuppression _unit < 0.1}; _unit setUnitPos _standStance; }; }; if(isnil "fnc_swSquadDepletedAction") then { fnc_swSquadDepletedAction = { params ["_group"]; private _layStance = _group getVariable "downStance"; { _r = [1, 3] call BIS_fnc_randomInt; if (_r > 1) then { _x removeAllEventHandlers "Suppressed"; _x setUnitPos _layStance; [_x] join grpnull; _x disableAI "AUTOTARGET"; }; } forEach units _group; }; }; {_x addEventHandler ["Suppressed", { params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"]; private _supval = getSuppression _unit; private _distance = _unit distance _shooter; if( _supval > 0.2 && _distance > 30) then { [_unit] spawn fnc_swSuppress; }; }]; private _standStance = group _x getVariable "upStance"; _x setUnitPos _standStance; _x disableAI "PATH"; } forEach units _targetUnit; _targetUnit setVariable ["initCount", count units _targetUnit, true]; _targetUnit addEventHandler ["UnitKilled", { params ["_group", "_unit", "_killer", "_instigator", "_useEffects"]; private _unitCount = _group getVariable "initCount"; private _newUnitCount = { alive _x } count units _group; if (_newUnitCount <= _unitCount/2) then { _group removeEventHandler [_thisEvent, _thisEventHandler]; [_group] call fnc_swSquadDepletedAction; }; }];

If you do end up using this script in your missions I'd appreciate it if you subscribed/favorited/upvoted this script. It's good for visibility and seeing numbers go up gives me the good brain chemicals.
Last edited by Swiftcore; 8 Dec, 2024 @ 9:28pm