_who = _this
_nameWho = name _who
_sideWho = side _who
_typeWho = typeOf _who

@ alive _who
? _typeWho == "SoldierGPilot" : _who removeWeapon "NVGoggles"
~(random 1)
_who setBehaviour "COMBAT"
_who setCombatMode "RED"
~(random 1)

#LOOP
_rdm = (random MarkerCount)
_rdm = _rdm - (_rdm mod 1)
_nextPos = (Markers select _rdm)
_modx = 2.5
? (random 1) < 0.5 : _modx = -2.5
_mody = 2.5
? (random 1) < 0.5 : _mody = -2.5
_who move [(getMarkerPos _nextPos select 0)+_modx, (getMarkerPos _nextPos select 1)+_mody]
~0.5
@ unitReady _who || !alive _who
? !alive _who : goto "DEAD"
~(random 1)
_who setUnitPos "DOWN"
~(random 1)+3
#TURN
? !alive _who : goto "DEAD"
_who setFormDir (random 360)
~(random 1)+4
? (random 1) < 0.5 : goto "TURN"
_who setUnitPos "AUTO"
~(random 1)+1
? alive _who : goto "LOOP"

#DEAD
AllUnits = AllUnits - [_this]
_joinGroup = ECP_Server
_spawnMarker = ""
? _sideWho == EAST : _joinGroup = GroupEast; _spawnMarker = "SPAWNEAST"
? _sideWho == RESISTANCE : _joinGroup = GroupRes; _spawnMarker = "SPAWNRES"
? _sideWho == WEST : _joinGroup = GroupWest; _spawnMarker = "SPAWNWEST"
_start = getMarkerPos _spawnMarker
_typeWho createUnit [_start, _joinGroup, "", 0.6, "Private"]
_member = (units _joinGroup) select 1
[_member] join grpNull
_grp = group _member
AllUnits = AllUnits + [_member]
? (count AllGroups == 0) : AllGroups = [_grp]
? (!(_grp in AllGroups)) : AllGroups = AllGroups + [_grp]
_member exec "ai.sqs"
exit
