2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-07-07 00:31:06 +00:00
|
|
|
/*
|
|
|
|
* Author: esteldunedain
|
2017-11-29 19:36:48 +00:00
|
|
|
* Plays a sound defined in CfgSounds using playSound3D, with global effect.
|
2016-07-07 00:31:06 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Sound class <STRING>
|
|
|
|
* 1: Position ASL <ARRAY>
|
2017-11-29 19:36:48 +00:00
|
|
|
* 2: Volume <NUMBER> (default: from sound config)
|
|
|
|
* 3: Distance <NUMBER> (default: from sound config)
|
2016-07-07 00:31:06 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2017-11-29 19:36:48 +00:00
|
|
|
* ["hint", getPosASL player, 5, 5] call ace_common_fnc_playConfigSound3D
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
2016-07-07 00:31:06 +00:00
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_soundClass", "_posASL", "_volume", "_distance"];
|
|
|
|
|
2017-11-29 19:36:48 +00:00
|
|
|
private _sound = getArray (configFile >> "CfgSounds" >> _soundClass >> "sound");
|
|
|
|
if (_sound isEqualTo []) exitWith {
|
2024-02-05 17:04:24 +00:00
|
|
|
ERROR_1("CfgSounds class [%1] does not exist or contains empty sound array",_soundClass);
|
2016-07-07 00:31:06 +00:00
|
|
|
};
|
2017-11-29 19:36:48 +00:00
|
|
|
TRACE_2("sound",_soundClass,_sound);
|
|
|
|
|
|
|
|
_sound params ["_fileName", "_cfgVolume", "_pitch", ["_cfgDistance", 0]];
|
|
|
|
|
|
|
|
ISNILS(_volume,_cfgVolume);
|
|
|
|
ISNILS(_distance,_cfgDistance);
|
2016-07-07 00:31:06 +00:00
|
|
|
|
|
|
|
// Strip the first \ from the filename
|
2017-11-29 19:36:48 +00:00
|
|
|
_fileName = _fileName select [1];
|
|
|
|
|
|
|
|
// add file extension .wss as default
|
2024-03-07 21:08:13 +00:00
|
|
|
if !(toLowerANSI (_fileName select [count _fileName - 4]) in [".wav", ".ogg", ".wss"]) then {
|
2017-11-29 19:36:48 +00:00
|
|
|
ADD(_fileName,".wss");
|
|
|
|
};
|
|
|
|
TRACE_5("vars",_fileName,_posASL,_volume,_pitch,_distance);
|
2016-07-07 00:31:06 +00:00
|
|
|
|
|
|
|
playSound3D [_fileName, objNull, false, _posASL, _volume, _pitch, _distance];
|