HomeALiVE 3Docs
Menu
Donate

ALiVE.OS · ALiVE 3 Development

Script Snippets

Short SQF examples for driving ALiVE 3 from your own mission scripts, each one run on a dedicated server first.

Scripting reference · ALiVE 3

ALiVE 3 is in active development. This briefing describes work in progress, and the behaviour it covers is subject to change as testing continues. Check the changelog at the foot of the page for what has moved recently.

On this page

Overview

Using these snippets

These are short scripts you can drop into a mission to drive ALiVE from SQF. Each one says where it runs and which modules it needs. The Scripting Overview explains the calls behind them.

Every snippet here was run on a dedicated server before it went on this page. More are being added as they're checked.

Scripting overview →Event Reference →

Profiles

Profiles

Needs Virtual AI System

Spawn a group as profiles and send it somewhere

Creates a CfgGroups group as virtual profiles at one marker and gives it a move waypoint to another.

Runs onServerNeedsVirtual AI System

if (!isServer) exitWith {};
waitUntil {!isNil "ALIVE_profileSystemInit"};

private _spawnPos = getMarkerPos "grp_spawn";
private _destPos  = getMarkerPos "grp_dest";

// "OIA_InfSquad" is a CfgGroups class of faction OPF_F.
// 4th argument false = place the group exactly at _spawnPos.
// true (the default) lets ALiVE pick a good spot nearby when it spawns.
private _profiles = ["OIA_InfSquad", _spawnPos, random 360, false, "OPF_F"] call ALIVE_fnc_createProfilesFromGroupConfig;

private _waypoint = [_destPos, 0, "MOVE"] call ALIVE_fnc_createProfileWaypoint;
{
    if ((_x select 2 select 5) == "entity") then {
        [_x, "addWaypoint", _waypoint] call ALIVE_fnc_profileEntity;
    };
} forEach _profiles;
  • The old wiki's fourth argument meant the opposite, so a true copied from ALiVE 2 code now means 'pick a good spot'.
  • The faction is the fifth argument; ALiVE looks the class up as OPF_F_OIA_InfSquad.

Detect virtual units in a trigger area

A trigger condition that is true while any virtualised OPFOR group, spawned or not, is within 50 m of the trigger.

Runs onServer Only triggerNeedsVirtual AI System

// Trigger condition (tick Server Only in the trigger's attributes)
count ([getPosATL thisTrigger, 50, ["EAST", "entity"]] call ALIVE_fnc_getNearProfiles) > 0

// Virtualised OPFOR vehicles within 500 m instead
count ([getPosATL thisTrigger, 500, ["EAST", "vehicle"]] call ALIVE_fnc_getNearProfiles) > 0
  • The query reads server-side data, so the trigger must be Server Only or the condition is false on clients.

Turn Zeus or script-spawned units into profiles

Every minute, hands any live unit or vehicle that is not yet profiled to the virtual AI system.

Runs onServerNeedsVirtual AI System

if (isServer) then {
    [] spawn {
        waitUntil {!isNil "ALIVE_profileSystemInit"};
        while {true} do {
            sleep 60;
            [] call ALiVE_fnc_createProfilesFromUnitsRuntime;
        };
    };
};
  • It leaves players, Combat Support assets and anything flagged ALIVE_profileIgnore or ALIVE_Convoy alone.

Keep a hand-placed group out of the virtual AI system

Marks a group (and a lone vehicle) so ALiVE never turns it into a profile or despawns it.

Runs onAny machine (init field) or server scriptNeedsVirtual AI System

// In the group leader's init field:
(group this) setVariable ["ALIVE_profileIgnore", true, true];

// For a lone vehicle, mark the vehicle itself:
this setVariable ["ALIVE_profileIgnore", true, true];

Check whether a profiled unit still exists

Looks a profile up by the ID stored on a spawned unit and answers whether it is still registered.

Runs onServerNeedsVirtual AI System

MyMission_fnc_profileExists = {
    params ["_profileID"];
    private _profile = [ALIVE_profileHandler, "getProfile", _profileID] call ALIVE_fnc_profileHandler;
    !isNil "_profile"
};

// A spawned unit or vehicle carries its profile ID:
private _id = _unit getVariable ["profileID", ""];
if ([_id] call MyMission_fnc_profileExists) then { /* still in play */ };
  • The old wiki's ALiVE_sysProfile global doesn't exist; the handler is ALIVE_profileHandler, and getProfile is one of its operations.

Count profiles by side

Reads how many virtual groups and vehicles each side has, for a debug line or a scoring condition.

Runs onServerNeedsVirtual AI System

if (isServer) then {
    private _bySide = [ALIVE_profileHandler, "profilesBySide"] call ALIVE_fnc_hashGet;
    private _east = count ([_bySide, "EAST"] call ALIVE_fnc_hashGet);
    private _west = count ([_bySide, "WEST"] call ALIVE_fnc_hashGet);
    private _guer = count ([_bySide, "GUER"] call ALIVE_fnc_hashGet);
    private _civ  = count ([_bySide, "CIV"]  call ALIVE_fnc_hashGet);
    diag_log format ["Profiles - OPFOR %1, BLUFOR %2, Independent %3, Civilian %4", _east, _west, _guer, _civ];
};
  • Counts include vehicle profiles as well as groups.

Find nearby vehicle profiles of one kind

Asks whether any virtualised enemy helicopters are within 2 km of a position, without spawning anything.

Runs onServerNeedsVirtual AI System

private _pos = getMarkerPos "base";
private _nearHelis = [_pos, 2000, ["EAST", "vehicle", "Helicopter"]] call ALIVE_fnc_getNearProfiles;
if (count _nearHelis > 0) then {
    diag_log "Enemy helicopter activity near the base";
};
  • The third selector slot is the vehicle kind ALiVE recorded when it made the profile, such as Helicopter, Plane, Car or Tank.

Make profiles spawn around an object, not just players

Adds any object to the list of spawn sources so virtual units near it spawn in even with no player nearby.

Runs onServerNeedsVirtual AI System

if (isServer) then {
    waitUntil {!isNil "ALiVE_SpawnSources"};
    ALiVE_SpawnSources pushBackUnique myForwardBase;   // any object

    // When you delete the object, take it out again:
    // ALiVE_SpawnSources = ALiVE_SpawnSources - [myForwardBase];
};
  • Nothing prunes the list, so remove an object before you delete it.

Put a placed group into a placed vehicle

Turns an editor-placed group and an empty vehicle into profiles that belong together, so the men ride in the vehicle whenever it spawns.

Runs onServerNeedsVirtual AI System

[myLeader, myVehicle] spawn ALiVE_fnc_createProfileVehicleAssignment;
  • Use spawn, not call: the function waits for the virtual AI system to be ready.
  • Both are turned into profiles if they aren't already, so the live units are replaced straight away and spawn again as usual when a player is near.
  • Needs a development build from 24 Sep 2026 (ee5bfc11) or later. Before that, the group and the vehicle were profiled separately and the men never got in.

Run your own init on every spawned unit

Uses CBA's extended init handler so every man that spawns, including ALiVE's, runs your script.

Runs onEvery machine (config)NeedsCBA

// description.ext
class Extended_Init_EventHandlers {
    class Man {
        init = "_this call (compile preprocessFileLineNumbers 'my_unit_init.sqf')";
    };
};

// my_unit_init.sqf
params ["_unit"];
if (isPlayer _unit) exitWith {};   // player persistence restores the player's own gear
if (side _unit == west) then {
    // change loadout here
};
  • Skip players: anything you add to a player is re-applied on top of what player persistence restores.

← Back to the list

Commanders

Commanders

Needs Military AI Commander

Give the AI commander a custom objective

Registers a position as a military objective with one side's commander, or with every commander.

Runs onServerNeedsMilitary AI Commander

// One side. Fire it from a trigger's activation (Server Only) or initServer.sqf.
["EAST", "addObjective", ["my_base_obj", getMarkerPos "my_base", 150, "MIL", 200]] call ALiVE_fnc_OPCOM;

// Every commander:
{
    [_x, "addObjective", ["my_base_obj", getMarkerPos "my_base", 150, "MIL", 200]] call ALiVE_fnc_OPCOM;
} forEach OPCOM_instances;
  • Arguments: id, position, size in metres, "MIL" or "CIV", priority (higher is more urgent).
  • A side reaches the first commander of that side. With two commanders on one side, use a faction or the loop.
  • Don't give a marker the same name as the objective id; ALiVE takes such markers over.
  • With Persistent on, the commander saves this objective and loads it back. Calling it again at every start is safe: the same id at the same position hands back the objective already there, and the same id at a different position is added as a second objective under that id. Dev builds before 27 Sep 2026 (64918448) gave the commander the objective twice if you called it at every start.
  • Call it after the commander has started; it may take a few cycles to act.
  • Dev builds from late April to late September 2026 ignored the side form. Use the loop there.

Order the commander to take, hold or scout a position

Queues a one-off recon, capture, defend or reserve order at a position for one side's commander.

Runs onServerNeedsMilitary AI Commander

private _opcom = [nil, "findOPCOMByAllegiance", "EAST"] call ALiVE_fnc_OPCOM;
[_opcom, "addTask", ["capture", getMarkerPos "target", []]] call ALiVE_fnc_OPCOM;
  • The empty third element lets the commander choose the groups; pass profile IDs to name them.
  • Ignored, with a line in the RPT, if the operation is not one of the four or the commander's TACOM is not running yet.

Send a group on a timed ambush or search and destroy

Hands groups to a commander as a one-off ambush or search-and-destroy order at a place, and gives them back to the commander after the time you set.

Runs onServerNeedsMilitary AI Commander (Invasion or Occupation), Virtual AI System

if (!isServer) exitWith {};
waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};

private _opcom = [nil, "findOPCOMByAllegiance", "EAST"] call ALiVE_fnc_OPCOM;
private _site = getMarkerPos "ambush_site";

// A squad of the commander's own faction, made as profiles 300 m from the site
private _profiles = ["OIA_InfSquad", _site getPos [300, random 360], 0, true, "OPF_F"] call ALIVE_fnc_createProfilesFromGroupConfig;
private _groupIDs = (_profiles select {(_x select 2 select 5) == "entity"}) apply {[_x, "profileID"] call ALIVE_fnc_hashGet};

// "ambush" or "sad", the place, the groups (profile IDs), seconds before the commander takes them back
[_opcom, "addTimedTask", ["ambush", _site, _groupIDs, 900]] call ALiVE_fnc_OPCOM;
  • "ambush": the groups go to the place, hide and hold fire, and open fire when an enemy comes within 80 m or they are already fighting. "sad": they search and destroy within 150 m, weapons free, then stay there.
  • When the time is up (600 s if you leave it out) their orders are cleared, they go back to their usual combat mode and the commander uses them again.
  • Any of the commander's groups will do: pass their profile IDs and they are taken off whatever they were doing.
  • Returns the order's internal objective. Any type but "sad" or "ambush", or an empty group list, does nothing.
  • The command tablet doesn't offer these orders for an insurgency commander.

Tell a commander to take or hold a place

Adds an objective at the front of a commander's list and says whether to take it or hold it, as a player's map marker does.

Runs onServerNeedsMilitary AI Commander

if (!isServer) exitWith {};
waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};

private _opcom = [nil, "findOPCOMByAllegiance", "EAST"] call ALiVE_fnc_OPCOM;

// id, position, size, type, priority, state, cluster, commander id, made by a player, put it first
private _objective = [_opcom, "addObjective", ["hold_the_bridge", getMarkerPos "bridge", 150, "MIL", 200,
    "unassigned", "none", [_opcom, "opcomID", ""] call ALiVE_fnc_hashGet, false, true]] call ALiVE_fnc_OPCOM;

// "hold": attack it while only the enemy is there, defend it otherwise
// "take": attack it until only this side is there; the key then goes back to ""
[_objective, "playerIntent", "hold"] call ALiVE_fnc_hashSet;
  • The commander applies it each time it reviews its objectives, counting forces within 500 m.
  • A taken objective becomes an ordinary one: the key goes back to "" and the commander holds it or not as it judges.
  • "Made by a player" true would count it against the command tablet's limit on player objectives, so leave it false.
  • The last argument true puts it at the front of the list, so it is the commander's first pick among objectives in the same state.
  • addObjective called again with the same id and place returns the objective already there.

Tell a side's commanders where the enemy is

Marks the enemy groups around one or more places as seen by one side's AI commanders for the next 30 minutes, and reads back what a commander knows.

Runs onAnywhere for the report (a client's call is passed to the server); the server for the readNeedsMilitary AI Commander, Virtual AI System

waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};

// The side to tell, then the places. Any machine: a client's call is passed to the server.
// Here EAST's commanders are tipped off about the players' camp.
["report", "EAST", [getMarkerPos "player_camp"]] call ALIVE_fnc_taskKnownEnemy;

// Only the server can read what a commander knows: [profile IDs, last known positions]
if (isServer) then {
    private _opcom = [nil, "findOPCOMByAllegiance", "EAST"] call ALiVE_fnc_OPCOM;
    ([_opcom, "knownEnemy"] call ALiVE_fnc_OPCOM) params ["_ids", "_positions"];
};
  • Every enemy group within 150 m of each place counts as seen, and the place itself is kept as known too.
  • It is what the commander's Tasks Only Against Known Enemy and Reinforcements Match the Enemy settings go by, and C2ISTAR's Tasks Only Against Known Enemy.
  • With an HVT manhunt running, the same report narrows the search near it.
  • The list also holds an entry per reported place, named report_<x>_<y>.

Change a commander's starting force size

Overwrites the eight force-type counts one commander started with, which Military Logistics reads when it sizes reinforcements.

Runs onServerNeedsMilitary AI Commander

{
    if (([_x, "side", ""] call ALIVE_fnc_hashGet) == "WEST") then {
        // infantry, motorised, mechanised, armoured, air, sea, artillery, AAA
        [_x, "startForceStrength", [12, 4, 2, 2, 0, 0, 1, 1]] call ALIVE_fnc_hashSet;
    };
} forEach OPCOM_instances;

// Or nudge one type (Infantry, Motorized, Mechanized, Armored, Air, Sea, Artillery or AAA):
["WEST", "Infantry", 5] call ALIVE_fnc_OPCOMIncrementStartForceStrength;
  • The order is the commander's own. The old wiki listed artillery and AAA before air and sea.
  • The increment and decrement helpers use the same order as the array, so "Air", "Sea", "Artillery" and "AAA" each move their own slot (the other four names are "Infantry", "Motorized", "Mechanized" and "Armored"). Dev builds before 27 Sep 2026 (3b4fa76d) sent those last four to each other's slots, so +1 Air changed the artillery count there.

Read who holds each objective

Every 30 seconds asks, for every objective of every commander, whether WEST controls it right now.

Runs onServerNeedsMilitary AI Commander

[] spawn {
    waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};
    waitUntil {!isNil "OPCOM_instances" && {count OPCOM_instances > 0}};
    while {true} do {
        {
            private _objectives = [_x, "objectives", []] call ALiVE_fnc_hashGet;
            {
                if ([_x, "WEST", 300, false] call ALiVE_fnc_isHeldObjective) then {
                    // WEST controls this objective right now
                };
            } forEach _objectives;
        } forEach OPCOM_instances;
        sleep 30;
    };
};
  • Capture and defend events describe orders; they do not fire when an objective quietly changes hands, which is why ownership is polled.

Send a player to the nearest fight

Moves the player's group into the nearest group on an attack order, or opens the map to pick one of the commander's attack objectives and joins the group sent to take it.

Runs onClientNeedsMilitary AI Commander

// Nearest group on an attack order ("defending" for a defence)
[player, "attacking"] spawn ALiVE_fnc_OPCOMjoinNearestGroup;

// Or pick an objective on the map
[player, "attacking"] call ALiVE_fnc_OPCOMJoinObjective;

// As an action on an object:
this addAction ["Select assault mission", {[_this select 1, "attacking"] call ALiVE_fnc_OPCOMJoinObjective}];
  • Both find the player's commander by the player's faction; a faction no commander owns does nothing.
  • The player's group joins that AI group, and its AI leader stays in charge. If the group is riding in a vehicle, the map pick puts the players in its cargo.
  • The map pick marks the attack objectives and waits for a click near one. It moves the group straight to the section taking it; there's no parachute drop.

Find what a commander is attacking or holding

Lists the objective positions a faction's commander has in one state, and names its top objective among the states you give.

Runs onServerNeedsMilitary AI Commander

if (!isServer) exitWith {};

// Positions of every objective BLU_F's commander holds in reserve
private _reserve = ["BLU_F", "reserve"] call ALIVE_fnc_OPCOMpositions;

// The id of WEST's most important objective it is attacking, or "" if none
private _target = ["WEST", ["attack", "attacking"]] call ALIVE_fnc_OPCOMgetHighestPrioObjective;
  • States: idle, attack, attacking, defend, defending, reserve, reserving.
  • The first takes a faction, the second a side string (WEST, EAST, GUER).

Flash the commanders' objectives on the map

Draws every AI Commander objective, and any live insurgent installation, on every player's map for about a minute, then fades them out.

Runs onAnywhere (a client call is sent to the server)NeedsMilitary AI Commander

// Every commander, every objective
call ALIVE_fnc_OPCOMToggleInstallations;

// Only within 500 m of the player, for the commander of side east
[getPos player, 500, east] call ALIVE_fnc_OPCOMToggleInstallations;
  • Despite the name it doesn't switch anything off: each call draws the markers again and they fade on their own.
  • Given a side, it can also mark where that commander's high value target was last seen.

← Back to the list

Support and logistics

Support and logistics

Needs Military Logistics, Player Combat Support, Military Placement (Civ. Obj.)

Add a CAS, transport or artillery asset by script

Creates a Combat Support asset with its crew and radio callsign after the mission has started.

Runs onServerNeedsPlayer Combat Support

if (isServer) then {
    waitUntil {!isNil "NEO_radioLogic" && {NEO_radioLogic getVariable ["init", false]}};

    // CAS: position, direction, class, callsign, code run on spawn, height
    ["CAS", [getMarkerPos "cas_spawn", 60, "B_Heli_Attack_01_F", "Phantom 1", "", "0"]] call ALiVE_fnc_combatSupportAdd;

    // TRANSPORT: ... height, allow slingloading, number of slingload boxes
    ["TRANSPORT", [getMarkerPos "trn_spawn", 60, "B_Heli_Transport_01_F", "Victor 1", "", "0", true, 3]] call ALiVE_fnc_combatSupportAdd;

    // ARTY: position, class, callsign, number of guns, rounds, code
    ["ARTY", [getMarkerPos "arty_spawn", "B_MBT_01_arty_F", "Sholef", 2, [["HE", 20], ["SMOKE", 10], ["ILLUM", 10]], ""]] call ALiVE_fnc_combatSupportAdd;
};
  • The side comes from the vehicle class; callsigns are stored upper-case.
  • Height is a string, as the Eden attribute is.

Remove a Combat Support asset by script

Deletes an asset and its crew by side, type and callsign, for example when a task ends.

Runs onServerNeedsPlayer Combat Support

["WEST", "CAS", "PHANTOM 1"] call ALiVE_fnc_combatSupportRemove;
["WEST", "TRANSPORT", "VICTOR 1"] call ALiVE_fnc_combatSupportRemove;
  • Match the callsign in upper case; the side is the side string of the asset.

Give one support asset its own replacement time

Sets how long a Combat Support asset takes to be replaced when it is lost, and how many times, apart from the module's shared settings.

Runs onServerNeedsPlayer Combat Support

if (isServer) then {
    waitUntil {!isNil "NEO_radioLogic" && {NEO_radioLogic getVariable ["init", false]}};

    ["CAS", [getMarkerPos "cas_spawn", 60, "B_Heli_Attack_01_F", "Phantom 1", "", "0"]] call ALiVE_fnc_combatSupportAdd;

    // "KIND|CALLSIGN" (CAS, TRANS, GROUND or ARTY, then the callsign in capitals) ->
    // [seconds before it's replaced, how many times]. -1 in either keeps the Combat Support
    // module's own value; 0 times means it's never replaced.
    ALiVE_CS_respawnReg set ["CAS|PHANTOM 1", [60, 1]];
};
  • The replacement is built where the asset first stood, after the time, and counts down its own number; the module's shared limit for that kind is left alone.
  • An asset placed in Eden with its own Respawn Time or Limit fills its entry at the start; one added by script has no entry until you set it.
  • Set it on the server after the asset is added. It works for assets from the Eden modules too: use the callsign shown in the radio menu.

Read and change a faction's force pool

Adds 20 to BLUFOR's reinforcement pool once Military Logistics is running.

Runs onServerNeedsMilitary Logistics

if (isServer) then {
    waitUntil {!isNil "ALIVE_MLGlobalRegistry" && {count (([ALIVE_MLGlobalRegistry, "modules"] call ALIVE_fnc_hashGet) select 1) > 0}};
    private _pool = [ALIVE_globalForcePool, "BLU_F", 0] call ALIVE_fnc_hashGet;
    [ALIVE_globalForcePool, "BLU_F", _pool + 20] call ALIVE_fnc_hashSet;
};
  • The third argument to hashGet is the default when the faction has no entry yet.

Spawn a garrisoned composition by script

Drops a small military fort at a position and profiles two OPFOR infantry groups and one motorised group around it.

Runs onServerNeedsVirtual AI System

if (isServer) then {
    waitUntil {!isNil "ALIVE_profileSystemInit"};
    [
        getMarkerPos "fob_1", "Military", "Fort", "OPF_F", "Small",
        2,   // infantry groups
        1,   // motorised groups
        0, 0, 0
    ] call ALIVE_fnc_spawnRandomPopulatedComposition;
};
  • Type is Civilian, Military or Guerrilla; ALiVE matches category and size as part of the composition's class name.
  • If no composition matches, ALiVE logs a warning and spawns nothing.

Choose which compositions roadblocks use

Limits the roadblocks Military Placement (Civ. Obj.) builds to a list of compositions, when the module's own Roadblock Compositions picker is empty.

Runs onServer, before Civilian Placement starts (initServer.sqf)NeedsMilitary Placement (Civ. Obj.)

// Class names from ALiVE's own composition set (Military > CheckpointsBarricadesSmall)
ALiVE_compositions_roadblocks = ["CheckpointSandbags1", "CheckpointTower"];
  • Only used when the module's Roadblock Compositions picker is empty; the picker wins otherwise.
  • Each roadblock takes one name from the list at random. A name ALiVE can't find sends that roadblock back to its usual checkpoints.

Build a roadblock where you want one

Puts up to five roadblocks on the roads around the edge of a circle (a ring from 10 m inside the radius to 20 m outside it) centred on a position, using ALiVE's checkpoint compositions.

Runs onServerNeedsMilitary Placement (Civ. Obj.)

if (!isServer) exitWith {};

// centre, radius, how many (up to 5)
private _roads = [getMarkerPos "checkpoint", 250, 2] call ALiVE_fnc_createRoadblock;

// Optional: debug, then the compositions to choose from
// [getMarkerPos "checkpoint", 200, 1, false, "CheckpointSandbags1,CheckpointTower"] call ALiVE_fnc_createRoadblock;
  • Returns the road pieces it built on. A road within 100 m of another roadblock, or with no room for the composition, is skipped. Roadblocks go on the edge of the circle, not near its centre. The function works out whose roadblock it is from the groups within the radius of the centre; with none it builds nothing and logs "Unable to find a dominant faction". To name the faction yourself, pass it as the seventh argument: [getMarkerPos "checkpoint", 250, 2, false, "", 1, "OPF_F"] call ALiVE_fnc_createRoadblock.

Let players take apart a roadblock

Builds a roadblock players can dismantle once the area is clear, or adds the same action to a composition ALiVE has already spawned.

Runs onServerNeedsMilitary Placement (Civ. Obj.) or Civilian Placement, for the roadblock compositions

if (!isServer) exitWith {};
waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};

// As "Build a roadblock where you want one", with the last argument true. Centre, radius, how many,
// debug, compositions, patrol, faction, spawn code, run it once, dismantle
[getMarkerPos "checkpoint", 250, 1, false, "", 1, "", "", true, true] call ALiVE_fnc_createRoadblock;

// The same for a composition ALiVE already spawned: its centre, the radius it covers, and the word
// players see ("Dismantle the fortifications")
[getMarkerPos "my_bunker", 30, "fortifications"] call ALIVE_fnc_addDismantleAction;
  • About 5 s later a traffic cone stands beside it with a 15 s hold action. Players see it within 8 m of the cone, and only with no enemy within 60 m.
  • Finishing it removes the composition and its saved copy. The guards and the parked vehicle are left.
  • addDismantleAction only removes compositions ALiVE spawned and saved within the radius.
  • Leave the faction "" and the guards come from whoever holds the area.

← Back to the list

Civilians

Civilians

Needs Civilian Placement, Civilian Population

Turn a captured insurgent into civilian goodwill

Lowers the civilian hostility towards BLUFOR of the town around a prison whenever an ACE-captured unit is brought there.

Runs onServerNeedsCivilian Placement, Civilian Population, ACE (for the capture event)

if (isServer) then {
    waitUntil {!isNil "ALIVE_clusterHandler"};

    // ACE raises this when a unit is handcuffed or released
    ["ace_captiveStatusChanged", {
        params ["_unit", "_state"];
        if (_state && {_unit inArea prison_area}) then {
            [getPos _unit, ["WEST"], -10] call ALIVE_fnc_updateSectorHostility;
        };
    }] call CBA_fnc_addEventHandler;
};
  • The hostility change is ALiVE's; the event is ACE's. Without ACE the handler never fires.
  • It only changes towns a Civilian Placement module has registered, in the 1 km map square the position falls in, so use a point inside the town.
  • Sides are the side strings ALiVE uses: WEST, EAST, GUER.

Make one civilian angrier or calmer

Moves a single civilian's hostility up or down, the same way aid, irritation and wounds do.

Runs onServer (a call elsewhere is passed to the server)NeedsCivilian Population

// Positive angers, negative calms. The result stays between 0 and 100; 30 is calm.
private _now = [_civ, 25] call ALIVE_fnc_civSetHostility;
  • Returns the new value on the server, and nothing on other machines.
  • A mission that limits remoteExec with CfgRemoteExec must allow ALIVE_fnc_civSetHostility for client calls.

Hand a crate of food and water to a town

Gives a container of water and rations to the nearest town, easing its hostility towards one side, with no C2ISTAR task and no player needed.

Runs onServer (a call elsewhere is passed to the server)NeedsCivilian Population with Aid Crate on (the default), Civilian Placement

if (!isServer) exitWith {};
waitUntil {!isNil "ALIVE_civilianPopulationSystem" && {[ALIVE_civilianPopulationSystem, "startupComplete", false] call ALiVE_fnc_hashGet}};

// A crate with at least 10 of the Civilian Population module's water and ration items in it
private _crate = "B_supplyCrate_F" createVehicle getMarkerPos "aid_drop";
clearWeaponCargoGlobal _crate; clearMagazineCargoGlobal _crate;
clearItemCargoGlobal _crate; clearBackpackCargoGlobal _crate;
_crate addItemCargoGlobal ["ALiVE_Waterbottle", 10];
_crate addItemCargoGlobal ["ALiVE_Humrat", 10];

// Later, once it's there (from a trigger, say): hand it to the town within 200 m, from WEST
private _result = ["handover", [_crate, "WEST", objNull]] call ALiVE_fnc_aidCrate;
// "delivered", or why not: "toofew", "notown", "cooldown", "disabled" or "gone"
  • It's worth 5, plus 1 for every 5 items, up to the module's Aid Crate Max Effect: hostility to the giving side falls by that across the town's map sector and rises for the other sides, and the town's civilians calm down a little.
  • Only the food and water are taken; the crate is deleted once it's empty.
  • A town, and the towns within 1500 m of it, take one crate per Aid Crate Cooldown (1800 s by default).
  • ACE water and MREs count too. Pass a player instead of objNull and his side is used, he must be within 50 m and he gets the message.

← Back to the list

Saving your own data

Saving your own data

Needs ALiVE Data

Save your own value with ALiVE's persistence

Keeps a campaign counter across saves by storing it in ALiVE's mission data.

Runs onServerNeedsALiVE Data

if (isServer) then {
    waitUntil {!isNil "ALiVE_sys_data" && {ALiVE_sys_data getVariable ["startupComplete", false]}};

    // restore, or seed on the first run
    private _day = ["campaign_day"] call ALiVE_fnc_getData;
    if (isNil "_day") then { _day = 1; };

    // later, when a day passes
    _day = _day + 1;
    ["campaign_day", _day] call ALiVE_fnc_setData;
};
  • Save Mission Time doesn't matter here: your values are written and read back whenever ALiVE Data is saving, and that setting only decides whether the date comes back.
  • They go to disk with the rest of the campaign when an admin uses SERVER SAVE AND EXIT, and on each autosave when the Data module's Autosave is on.
  • A value whose text form is 10000 characters or more is refused, and setData returns false.

← Back to the list

Events

Events

Needs ALiVE Required or Virtual AI System

React to an ALiVE event

Registers a listener that is called whenever the commander's forces complete a capture order on an objective.

Runs onServerNeedsALiVE (Required) and a Military AI Commander

// initServer.sqf
[] spawn {
    waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};
    MyMission_fnc_captureListener = compile preprocessFileLineNumbers "captureListener.sqf";
    myCaptureListener = [nil, "create", ["MyMission_fnc_captureListener"]] call MyMission_fnc_captureListener;
};

// captureListener.sqf
params ["_logic", "_operation", "_args"];
private "_result";
switch (_operation) do {
    case "create": {
        _args params ["_functionName"];
        private _logic = [[["class", _functionName]]] call ALiVE_fnc_hashCreate;
        private _listenerID = [ALiVE_eventLog, "addListener", [_logic, ["OPCOM_CAPTURE"]]] call ALiVE_fnc_eventLog;
        [_logic, "listenerID", _listenerID] call ALiVE_fnc_hashSet;
        _result = _logic;
    };
    case "handleEvent": {
        private _type = [_args, "type"] call ALiVE_fnc_hashGet;
        private _data = [_args, "data"] call ALiVE_fnc_hashGet;
        if (_type == "OPCOM_CAPTURE") then {
            _data params ["_side", "_objective"];
            private _pos = [_objective, "center"] call ALiVE_fnc_hashGet;
            // react here
        };
    };
};
if (!isNil "_result") then {_result} else {nil};
  • Every event and its data is listed on the Event Reference page.
  • Unregister with [ALiVE_eventLog, "removeListener", _listenerID] call ALiVE_fnc_eventLog.

← Back to the list

Start-up and pausing

Start-up and pausing

Needs The modules you name

Wait for ALiVE before touching it

The one line to put at the top of any script that reads an ALiVE global or calls an ALiVE function.

Runs onAny machineNeedsALiVE (Required)

waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};
// ALiVE_eventLog and the placement, CQB, commander and Player Options modules you placed have started from here.
// Other modules can still be starting: for the Virtual AI System, a force pool or your saved data, wait on their own signals too (see the Scripting Overview)
  • Set by the Required module once the placement, CQB, commander and Player Options modules you placed have started, and published, so clients can wait on it too. Other modules can still be starting then.

Pause and resume ALiVE modules

Stops the virtual AI system, the commanders, civilians and logistics in place, then starts them again.

Runs onServer (forwards itself from a client)Needsthe modules named

waitUntil {!isNil "ALiVE_REQUIRE_INITIALISED"};   // scheduled script, e.g. initServer.sqf
// Military Logistics and Civilian Population finish starting after that: wait for any that are placed
waitUntil {sleep 1; (entities "Module_F" select {typeOf _x in ["ALiVE_mil_logistics", "ALiVE_amb_civ_population"]}) findIf {isNil {_x getVariable "handler"} && {isNil {_x getVariable "class"}}} < 0};
["ALIVE_SYS_PROFILE", "ALIVE_MIL_OPCOM", "ALIVE_AMB_CIV_POPULATION", "ALIVE_MIL_LOGISTICS"] call ALiVE_fnc_pauseModule;

// later
["ALIVE_SYS_PROFILE", "ALIVE_MIL_OPCOM", "ALIVE_AMB_CIV_POPULATION", "ALIVE_MIL_LOGISTICS"] call ALiVE_fnc_unPauseModule;
  • Names are module class names and case doesn't matter; ALiVE skips a name with no placed module. You can call it from a scheduled script (initServer.sqf, or spawn) or from a module's init field: ALiVE waits for each named module to finish starting, up to 10 minutes, before pausing it.
  • Military Logistics and Civilian Population finish starting after ALiVE does, so the second wait is there for them: pausing either one earlier throws a script error and leaves it running.
  • Resuming doesn't start a commander set to Hold Until Go: only Start the war on the tablet does, or [nil, "go", "name"] call ALiVE_fnc_OPCOM on the server.

Pause the AI when the last player leaves

Pauses the commander and the virtual AI system when the server empties and resumes them when someone joins.

Runs onServer (initServer.sqf)NeedsVirtual AI System, Military AI Commander

["idlePause", "onPlayerDisconnected", {
    // The player who is leaving still counts at this moment, so look again shortly after
    [] spawn {
        sleep 10;
        if (count (allPlayers - entities "HeadlessClient_F") == 0) then {
            ["ALIVE_SYS_PROFILE", "ALIVE_MIL_OPCOM"] call ALiVE_fnc_pauseModule;
        };
    };
}] call BIS_fnc_addStackedEventHandler;

["idleResume", "onPlayerConnected", {
    [] spawn { ["ALIVE_SYS_PROFILE", "ALIVE_MIL_OPCOM"] call ALiVE_fnc_unPauseModule; };
}] call BIS_fnc_addStackedEventHandler;
  • Inside onPlayerDisconnected the player who is leaving still counts as a player, so a check made there never finds the server empty. That's why it waits 10 seconds.
  • Headless clients aren't counted, so a server with one still pauses.
  • onPlayerConnected also fires for the server itself when the mission starts; resuming then does no harm.

← Back to the list

Player FOBs

Player FOBs

Needs Player FOBs

Choose what players can build at a FOB

Takes items off the FOB build list, adds others, or fixes a price, from the mission's description.ext.

Runs ondescription.ext (or a mod's config)NeedsPlayer FOBs

class CfgALiVEFOBBuildables {
    blacklist[] = {"Land_Razorwire_F"};      // never offered
    whitelist[] = {"Land_Pallets_F"};        // offered, priced as a fortification
    // only[] = {"Land_BagFence_Short_F"};   // if set, the list is exactly these
    class Land_HBarrier_5_F { cost = 11; };   // a fixed price, 1 to 100000
};
  • The mission's class wins over a mod's.
  • A price that isn't a whole number from 1 to 100000 is refused with a warning in the RPT, and the worked-out price is used.
  • The module's Never Build and Also Build fields add to the same two lists, and its Build Only These field adds to only[]. With only[] set, the FOB Arsenal (when its setting is on) and each FOB type's extras are still offered, and so is everything in whitelist[] and Also Build, gear included. blacklist[] and Never Build beat both.

Turn your own objects into FOB kits, crates or a Field HQ

Makes any object a FOB kit, a supply crate with the amount you give, or a Field HQ where players collect kits and crates.

Runs onServer, after Player FOBs has startedNeedsPlayer FOBs

if (!isServer) exitWith {};
waitUntil {!isNil "ALiVE_sup_fob" && {ALiVE_sup_fob getVariable ["startupComplete", false]}};

["tag", [kitBox, "KIT", true]] call ALiVE_fnc_fobOps;        // true, or a side string such as "WEST" for that side only
["tag", [supplyBox, "CRATE", 250]] call ALiVE_fnc_fobOps;    // 250 supply
["tag", [hqBuilding, "HQ", true]] call ALiVE_fnc_fobOps;
  • Each call returns true, or false for an unknown kind.
  • Objects synced to the Player FOBs module become Field HQs without any script.
  • The placeable FOB Kit and FOB Supply Crate (ALiVE_FOB_Kit, ALiVE_FOB_SupplyCrate) are tagged for you, from Eden, Zeus or the tablet.

← Back to the list

Rally points

Rally points

Needs Rally Points

Add a rally point by script

Makes an object a rally point players can travel to and from, with a name, for one side or for any.

Runs onAnywhere (a client's call is passed to the server, which keeps the list)NeedsRally Points module, for the action players use (the function works without it, but nobody gets the action)

// In init.sqf, or the object's init field:
if (isServer) then {
    ["add", [myFlag, "Charlie", "WEST"]] call ALiVE_fnc_rallyPoint;
};

// To take it off the list again:
// ["remove", [myFlag]] call ALiVE_fnc_rallyPoint;
  • The name is optional: leave it "" and the object's ALiVE_rallyName variable is used, else the nearest place's name.
  • The side is "ANY" (default), "WEST", "EAST" or "GUER": who may use it.
  • A removed object stays off the list even if it matches Rally Point Classes.

Let enemies overrun a rally point you added

Takes a scripted rally point off the list once enemies have stood near it for the time you give.

Runs onServerNeedsRally Points module (it runs the check)

if (isServer) then {
    waitUntil {!isNil "ALiVE_rallyLogic"};
    ["add", [myFlag, "Charlie", "WEST"]] call ALiVE_fnc_rallyPoint;

    // Lost once enemies have been within the module's Enemy Radius for 120 s. The flag stays standing.
    myFlag setVariable ["ALiVE_rallyOverrun", 120];
};
  • The module looks every 5 s, using its Enemy Radius (at least 50 m); ALiVE's virtual groups count as enemies too.
  • It needs a side: an "ANY" point is never overrun.
  • Points the module finds itself (synced or by class) use its Placed Rally Point Overrun Time; the variable overrides that, and 0 keeps one safe.
  • Players of the side are told the point was overrun. Add it again with "add" to bring it back.

Send a player to a rally point by script

Moves a player there, with their group's nearby AI if they lead it, the way Travel does; force skips the enemy check and the wait.

Runs onAnywhere (it runs where the player is local)NeedsRally Points module or rally points added by script

// From a trigger, an addAction or the debug console:
["travel", [player, myFlag, true]] call ALiVE_fnc_rallyPoint;

// Without force, the module's Enemy Check and wait apply,
// and the player is told if the trip is refused:
// ["travel", [player, myFlag, false]] call ALiVE_fnc_rallyPoint;
  • The destination can be an object, a position, or a row from ["list", [player]] call ALiVE_fnc_rallyPoint.
  • ["list", [player]] gives the rally points that player may use: [[name, posASL, object, FOB id], ...].

← Back to the list

Tasks

Tasks

Needs Player Command/Control (C2ISTAR)

Give a player group only the task types that suit it

Limits a player group's automatic C2ISTAR tasks to the types you list, so a helicopter crew gets air tasks and a ground squad gets ground tasks.

Runs onAnywhere (the group variable is broadcast)NeedsPlayer Command/Control (C2ISTAR) with automatic tasks on

// In the group leader's init field:
group this setVariable ["ALiVE_taskTypes", ["CAS", "OCA", "DCA"], true];

// To let the group have every type again:
// group this setVariable ["ALiVE_taskTypes", nil, true];
  • Use the names from the C2ISTAR module's task list (for example DestroyInfantry, Assassination, CAS); case doesn't matter.
  • Constant tasks and their retries keep to the list; Strategic orders pass over a group whose list leaves that order out.
  • A group with no list gets every type, as before.

← Back to the list

Worth knowing

Before you use them

  • Most snippets run on the server, so put them in initServer.sqf or keep the isServer guard they already have.
  • Snippets that wait on ALIVE_profileSystemInit must run on the server, because ALiVE never publishes that flag to clients.
  • If a snippet doesn't behave as described on a newer build, raise it on the issue tracker with your RPT.

Something here wrong or missing? Please raise it on the ALiVE issue tracker on GitHub, with your RPT log. Each snippet was run on a dedicated server before it went on this page; if one stops working on a newer build, that is worth reporting.

Changelog

Updates to this page

  • First published.