2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-08 00:26:09 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Play weapon firemode change sound.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Weapon <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [ACE_player, currentWeapon ACE_player] call ace_safemode_fnc_playChangeFiremodeSound
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-08-08 00:26:09 +00:00
|
|
|
params ["_unit", "_weapon"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-27 06:28:55 +00:00
|
|
|
if (_sound isEqualTo []) exitWith {
|
2015-05-15 13:41:41 +00:00
|
|
|
playSound "ACE_Sound_Click";
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-09-27 06:28:55 +00:00
|
|
|
// get position where to play the sound (position of the weapon)
|
2021-10-10 13:37:05 +00:00
|
|
|
private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand");
|
2015-09-27 06:28:55 +00:00
|
|
|
|
|
|
|
_sound params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]];
|
|
|
|
|
|
|
|
if (_filename == "") exitWith {
|
|
|
|
playSound "ACE_Sound_Click";
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-09-27 06:28:55 +00:00
|
|
|
// add file extension .wss as default
|
|
|
|
if !(toLower (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then {
|
|
|
|
_filename = format ["%1.wss", _filename];
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-08-08 00:26:09 +00:00
|
|
|
playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance];
|