_Array = _this select 0;
_units = _this select 1;

_j = 0;

while {{alive _x} count _units > 0 && RUG_DSAI_TerminalDistance != -1} do 

{
_i = {alive _x} count _units;
_curUnit = _units select _j;


	if ((behaviour (leader _curUnit) == "SAFE")) then 
	{
	private ["_Sounds", "_random2", "_unit"];
	_Sounds = (call _Array) select 0;
	_random2 = floor (random (count _Sounds));
	_unit = _curUnit;
	if (_unit !=Player && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
	sleep (random (RUG_DSAI_CycleTime * 2));
	};
	if ((behaviour (leader _curUnit) == "AWARE")) then 
	{
	private ["_Sounds", "_random2", "_unit"];
	_Sounds = (call _Array) select 1;
	_random2 = floor (random (count _Sounds));
	_unit = _curUnit;
	if (_unit !=Player && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
	sleep (random (RUG_DSAI_CycleTime * 2));
	};
	if ((behaviour (leader _curUnit) == "COMBAT")) then 
	{
	private ["_Sounds", "_random2", "_unit"];
	_Sounds = (call _Array) select 2;
	_random2 = floor (random (count _Sounds));
	_unit = _curUnit;
	if (_unit !=Player && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
	sleep (random (RUG_DSAI_CycleTime * 1));
	};
	if ((behaviour (leader _curUnit) == "STEALTH")) then 
	{
	private ["_Sounds", "_random2", "_unit"];
	_Sounds = (call _Array) select 3;
	_random2 = floor (random (count _Sounds));
	_unit = _curUnit;
	if (_unit !=Player && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
	sleep (random (RUG_DSAI_CycleTime * 4));
	};

if (_j < _i) then {_j = _j + 1} else {_j = 0};
sleep (RUG_DSAI_CycleTime + 0.1);
};

