{"name":"BIS_fnc_EXP_camp_balanceGroup","title":"BIS fnc EXP camp balanceGroup","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_EXP_camp_balanceGroup","revid":379562,"updated":"2026-10-31T13:53:31Z","groups":["Campaign"],"status":"ok","games":{"arma3":"1.62"},"since":"arma3 1.62","arma3_since":"1.62","description":"Reduces the size of a group depending on the number of connected players, assuming the Apex campaign's maximum of 4 players.\nThe 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.\n\nThe function shows an error and does nothing if the group is null, has no living, non-fleeing unit, or has fewer than *minCount* units.\n\nThe Apex campaign missions call it from `initServer.sqf` and their mission flow FSMs, always as `[_group, 2, true]`.\n\n> [!NOTE]\n> 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).","syntaxes":[{"syntax":"[group, minCount, excludeVehicleRoles] call BIS_fnc_EXP_camp_balanceGroup","params":[{"name":"group","type":"Group","description":"the group to balance","type_expr":"Group"},{"name":"minCount","type":"Number","optional":true,"default":"1","description":"the number of units the group must keep","type_expr":"Number","text":"minCount: Number - (Optional, default 1) the number of units the group must keep"},{"name":"excludeVehicleRoles","type":"Boolean","optional":true,"default":"true","description":"true to never delete units that are the driver, gunner or commander of a vehicle","type_expr":"Boolean","text":"excludeVehicleRoles: Boolean - (Optional, default true) true to never delete units that are the driver, gunner or commander of a vehicle"}],"returns":{"type":"Nothing","type_expr":"Nothing"}}],"examples":[{"text":"```sqf\n// on the server, as in the Apex campaign\n{\n    [_x, 2, true] call BIS_fnc_EXP_camp_balanceGroup;\n} forEach [BIS_grp_AA_1, BIS_grp_AA_2, BIS_grp_AA_3];\n```","code":["// on the server, as in the Apex campaign\n{\n\t[_x, 2, true] call BIS_fnc_EXP_camp_balanceGroup;\n} forEach [BIS_grp_AA_1, BIS_grp_AA_2, BIS_grp_AA_3];"]}],"see_also":["BIS_fnc_listPlayers","deleteVehicle"]}