Created
July 4, 2016 18:36
-
-
Save commy2/aa0a54ac3fd88be842e149c7521e95b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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