//Checks for wounded, adds them to an array, then has a random unit in that array cry out in pain. The wounded level is presently 0.2 (can be edited in the main if->then check below).;

_array = _this select 0;
_units = _this select 1;

_hurtArray = [];
_j= 0;

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

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

if (damage _curUnit > 0.2 && ! (_curUnit in _hurtArray) && alive _curUnit) then {_hurtArray = _hurtArray + [(_curUnit)]};
if (damage _curUnit < 0.2 && (_curUnit in _hurtArray) OR !alive _curUnit && _curUnit in _hurtArray) then {_hurtArray = _hurtArray - [(_curUnit)]};
_o= count _hurtArray;

	while {_o > 0} do 
	{
	private ["_Sounds", "_unit", "_random1", "_random2"];
	_Sounds = (call _Array) select 0;
	_random2 = floor (random (count _Sounds));
	_random1 = floor (random (count _hurtArray));
	_unit = _hurtArray select _random1;
	if (_unit !=Player && (alive _unit) && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
	sleep ((random 5) + RUG_DSAI_CycleTime);
	_o = _o - 1;
	};

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