If I spawn a random group not knowing how many vehicles are in it or how many dismounted soldiers it has in it (assuming there are both), what's the easiest way (code) to mount all dismounted soldiers in vacant vehicles positions? Thanks for the help guys.
Sent from my SM-G930F using Tapatalk
Here is a simple script spawning vehicles & units for a group, and move units in free cargo (the vehicles spawn with their crew anyway, using bis_fnc_spawnGroup)
0 = [] spawn {
_assets = ["B_soldier_f","B_soldier_A_f","B_soldier_AAR_f","B_soldier_AAR_f","B_soldier_AR_f","B_soldier_AT_f","B_medic_f","B_truck_01_transport_F","B_LSV_01_armed_F","B_MBT_01_cannon_F"]; // or what you want
_spawnGrp = [];
For "_i" from 0 to (round random 30 max 8) do {
_spawnGrp pushBack (selectRandom _assets)
};
_grp = [ getMarkerPos "spawnHere", side player,_spawnGrp,[],[],[],[],[],180,false] call BIS_fnc_spawnGroup;
// interesting part for you:
//==========================
_vehs = [_grp,true] call BIS_fnc_groupVehicles;
_units = (units _grp select {isnull objectParent _x});
{
_unit = _x;
{if ( (_x emptyPositions "cargo") > 0) exitWith {_unit moveInCargo _x};nil} count _vehs;
nil
} count _units;
};