//Checks if the unit is a leader of an 'under formation' or not (i.e. has been sent to some other location). If you want the unit to say something even when engaging alone, or when moving somewhere alone, just change the number in the line that says (count formationMembers _unit) > 1 to 0, and the unit will say its sound whenever it leaves the main group formation.; 

_unit = _this select 0;
_array = _this select 1;


while {alive _unit && RUG_DSAI_TerminalDistance != -1} do
{

	if (isFormationLeader _unit && (count formationMembers _unit) > 1 && (_unit distance Player) < RUG_DSAI_TerminalDistance) then
	{
	private ["_Sounds", "_random1", "_random2"];
	_Sounds = (call _Array) select 3;	
	_random2 = floor (random (count _Sounds));
	if (_unit !=Player && _unit !=(leader _unit) && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
	sleep (random 5) + 5;
	waitUntil {!isFormationLeader _unit};
	};
sleep 2;
if (RUG_DSAI_TerminalDistance == -1) exitWith {};
};