2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-08-04 01:08:21 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2015-09-27 12:55:36 +00:00
|
|
|
* Play weapon firemode change sound.
|
2015-08-04 01:08:21 +00:00
|
|
|
*
|
2015-08-08 12:40:23 +00:00
|
|
|
* Arguments:
|
2015-08-04 01:08:21 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Weapon <STRING>
|
|
|
|
*
|
2015-08-08 12:40:23 +00:00
|
|
|
* Return Value:
|
2015-08-04 01:08:21 +00:00
|
|
|
* None
|
2015-08-08 12:40:23 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, currentWeapon player] call ace_weaponselect_fnc_playChangeFiremodeSound
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-08-04 01:08:21 +00:00
|
|
|
*/
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-08-04 01:08:21 +00:00
|
|
|
params ["_unit", "_weapon"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-27 12:55:36 +00:00
|
|
|
if (_sound isEqualTo []) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-27 12:55:36 +00:00
|
|
|
// get position where to play the sound (position of the weapon)
|
2016-01-06 21:42:02 +00:00
|
|
|
private _position = AGLToASL (_unit modelToWorldVisual (_unit selectionPosition "RightHand"));
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-27 12:55:36 +00:00
|
|
|
_sound params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-27 12:55:36 +00:00
|
|
|
if (_filename == "") exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-27 12:55:36 +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-09-27 12:55:36 +00:00
|
|
|
playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance];
|