Arma 3 Scripting

BIS_fnc_EXP_camp_balanceGroup

  • Arma 3 v1.62

Function · Markdown · JSON · original wiki page

Description

Reduces the size of a group depending on the number of connected players, assuming the Apex campaign's maximum of 4 players. The wanted unit count is ceil (unitCount * playerCount / 4) (players counted with BIS_fnc_listPlayers). The last minCount max (unitCount - wantedCount) units of the group are selected for deletion, skipping the group leader and, if excludeVehicleRoles is true, units that are the driver, gunner or commander of their vehicle; skipped units are not replaced by others. The selected units are deleted with deleteVehicle (units in a vehicle are first moved to [-100, -100, 0] ASL), stopping as soon as the group has minCount units or fewer.

The function shows an error and does nothing if the group is null, has no living, non-fleeing unit, or has fewer than minCount units.

The Apex campaign missions call it from initServer.sqf and their mission flow FSMs, always as [_group, 2, true].

Note

Because minCount is also the smallest number of units selected for deletion, a group with more than minCount units loses units even when 4 players are connected (unless the selected units are all skipped).

Syntax

[group, minCount, excludeVehicleRoles] call BIS_fnc_EXP_camp_balanceGroup

Parameters:

Returns: Nothing

Examples

Example 1

// on the server, as in the Apex campaign
{
    [_x, 2, true] call BIS_fnc_EXP_camp_balanceGroup;
} forEach [BIS_grp_AA_1, BIS_grp_AA_2, BIS_grp_AA_3];

See also

BIS_fnc_listPlayers · deleteVehicle