/* Author: LAxemann Description: Plays a boltSnap sound on the first shot of a burst to simulate the sound of weapons operating from an open bolt. Parameters: params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"; Returns: Nothing */ params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; if ((_unit distance SPE_camPos) >= 30) exitWith {}; private _lastFired = _unit getVariable ["SPE_simpleOpenBolt_lastShot",0]; if (((time - _lastFired) >= 0.2) || (_mode == "Single")) then { private _sound = getText (configFile >> "CfgWeapons" >> _weapon >> "SPE_boltSnapSound"); if (_sound != "") then { private _player = call SPE_fnc_findPlayer; private _inVehicle = ((vehicle _player) != _player); private _isGunner = (_player == _gunner); if ((_isGunner) && (cameraView in ["INTERNAL","GUNNER"])) then { if (_inVehicle) then { playSound [_sound,2]; } else { playSound _sound; }; } else { private _rhand = _gunner selectionPosition "RightHandMiddle1"; private _posStart = _gunner modelToWorld _rhand; private _dummy = createVehicleLocal ["#particlesource", _posStart, [], 0, "CAN_COLLIDE"]; _dummy attachTo [_gunner,[0,0,0],"RightHandMiddle1"]; _dummy say3D _sound; [{ params ["_dummy"]; deleteVehicle _dummy; }, [_dummy],3] call SPE_fnc_waitAndExecute; }; }; }; _unit setVariable ["SPE_simpleOpenBolt_lastShot",time];