Skip to content

Instantly share code, notes, and snippets.

@commy2
Created July 4, 2016 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save commy2/aa0a54ac3fd88be842e149c7521e95b0 to your computer and use it in GitHub Desktop.
Save commy2/aa0a54ac3fd88be842e149c7521e95b0 to your computer and use it in GitHub Desktop.
// by commy2
params ["_group", "_position"];
private _index = currentWaypoint _group;
_group enableAttack false;
private _units = units _group;
private _staticWeapons = _position nearObjects ["StaticWeapon", 50] select {_x emptyPositions "gunner" > 0};
private _buildings = (_position nearObjects ["Building", 50]) apply {_x buildingPos -1} select {count _x > 0};
{
if (count _staticWeapons > 0 && {random 1 < 0.31}) then {
_x assignAsGunner (_staticWeapons deleteAt 0);
[_x] orderGetIn true;
} else {
if (count _buildings > 0 && {random 1 < 0.93}) then {
private _building = selectRandom _buildings;
private _position = _building deleteAt (floor random count _building);
// If building positions are all taken, remove from possible buildings
if (_building isEqualTo []) then {
_buildings = _buildings select {count _x > 0};
};
_x setUnitPos "UP";
// doMoveAndStay
[_x, _position] spawn {
params ["_unit", "_position"];
_unit doMove _position;
waitUntil {unitReady _unit};
doStop _unit;
};
} else {
_x doMove _position;
};
};
} forEach _units;
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment