Jump to content
o5_

Move soldiers into vehicles of same group

Recommended Posts

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

 

 

Share this post


Link to post
Share on other sites

Hey George, thanks. I'm on my mobile and I'm having a hard time viewing the content in the link you sent. Is there a particular part that would benefit me? Again, thanks man.

Sent from my SM-G930F using Tapatalk

  • Like 1

Share this post


Link to post
Share on other sites

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;
};

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Amazing, just what I was looking for! Thanks!

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×