Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Convert selected units (or all units if none selected) into High Command squads
- and name them Squad-1, Squad-2, Squad-3, etc.
- Paste into Debug Console and run on SERVER or via Global Exec.
- */
- private _selected = [];
- private _unitsToUse = [];
- // Try to get currently selected units from curator/editor-style selection context
- if (!isNil "get3DENSelected") then {
- _selected = get3DENSelected "object";
- _selected = _selected select { _x isKindOf "CAManBase" };
- };
- // Fallback: if no selected units, use all units
- _unitsToUse = if (_selected isNotEqualTo []) then {
- _selected
- } else {
- allUnits
- };
- // Keep only alive human/AI soldier units
- _unitsToUse = _unitsToUse select {
- alive _x && { _x isKindOf "CAManBase" }
- };
- if (_unitsToUse isEqualTo []) exitWith {
- hint "No valid units found.";
- };
- // Build unique group list from chosen units
- private _groups = [];
- {
- private _grp = group _x;
- if !(isNull _grp) then {
- if !(_grp in _groups) then {
- _groups pushBack _grp;
- };
- };
- } forEach _unitsToUse;
- if (_groups isEqualTo []) exitWith {
- hint "No valid groups found.";
- };
- // Find a High Command commander
- private _hcCommander = player;
- // If player can't host HC, try to create the module logic linkage won't work by script alone.
- // So this assumes the player already has HC access.
- if (isNull _hcCommander) exitWith {
- hint "No valid HC commander found.";
- };
- private _index = 1;
- private _added = 0;
- {
- private _grp = _x;
- private _grpName = format ["Squad-%1", _index];
- // Set group ID shown in UI/map
- _grp setGroupIdGlobal [_grpName];
- // Add group to player's High Command
- _hcCommander hcSetGroup [_grp];
- _index = _index + 1;
- _added = _added + 1;
- } forEach _groups;
- hint format ["Added %1 group(s) to High Command.", _added];
Advertisement
Add Comment
Please, Sign In to add comment