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-17 20:32:34 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-08-08 00:26:09 +00:00
|
|
|
private ["_sound", "_position", "_soundCount"];
|
|
|
|
|
|
|
|
params ["_unit", "_weapon"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
_sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");
|
|
|
|
|
|
|
|
if (count _sound == 0) exitWith {
|
2015-05-15 13:41:41 +00:00
|
|
|
playSound "ACE_Sound_Click";
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// add file extension
|
2015-06-04 08:39:43 +00:00
|
|
|
if ({(toLower (_sound select 0) find _x == (count toArray (_sound select 0) - count toArray _x) - 1)} count [".wav", ".ogg", ".wss"] == 0) then {
|
2015-05-15 13:41:41 +00:00
|
|
|
_sound set [0, (_sound select 0) + ".wss"];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// add default volume, pitch and distance
|
2015-08-08 00:26:09 +00:00
|
|
|
_soundCount = count _sound;
|
|
|
|
if (_soundCount < 2) then {_sound pushBack 1};
|
|
|
|
if (_soundCount < 3) then {_sound pushBack 1};
|
|
|
|
if (_soundCount < 4) then {_sound pushBack 0};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-04-03 22:26:27 +00:00
|
|
|
_position = _unit modelToWorldVisual (_unit selectionPosition "RightHand");
|
2015-01-11 16:42:31 +00:00
|
|
|
_position set [2, (_position select 2) + ((getPosASLW _unit select 2) - (getPosATL _unit select 2) max 0)];
|
|
|
|
|
2015-08-08 00:26:09 +00:00
|
|
|
_sound params ["_filename", "_volume", "_soundPitch", "_distance"]
|
|
|
|
playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance];
|