Comment "Checks for fired weapon. In case of thrown grenade, always shout appropriate array. Otherwise sometimes shout. Must compile-loadfile the array every time, sadly.";

_eventHandler = _this select 0;
_arraystring1 = _this select 1;
_unit = _EventHandler select 0;
_weapon = _EventHandler select 1;

if (((vehicle Player) distance (vehicle _unit)) > RUG_DSAI_TerminalDistance) exitWith {};

_randomChance = random 100;
sleep 0.2;
if (_weapon !="Throw" OR _randomChance < 90 OR (_unit distance Player) > RUG_DSAI_TerminalDistance) exitWith {};

_ArrayString = "RUG_DSAI\" + _arrayString1;

_Array = compile loadFile _arrayString;

sleep 0.5;


if (_weapon == "Throw") exitWith 
{
	private ["_Sounds", "_random1", "_random2"];
	_Sounds = (call _Array) select 1;	
	_random2 = floor (random (count _Sounds));
	if (_unit !=Player && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
};

sleep 1;

if (_weapon !="Throw" && _randomChance > 90) exitWith
{
	private ["_Sounds", "_random1", "_random2"];
	_Sounds = (call _Array) select 2;	
	_random2 = floor (random (count _Sounds));
	if (_unit !=Player && vehicle _unit == _unit) then {_unit say (_Sounds select _random2)};
};