2015-01-16 23:21:47 +00:00
|
|
|
/**
|
|
|
|
* fn_setHearingCapability.sqf
|
|
|
|
* @Descr: Handle set volume calls. Will use the lowest available volume setting.
|
|
|
|
* @Author: Glowbal
|
|
|
|
*
|
|
|
|
* @Arguments: [id STRING, settings NUMBER, add BOOL (Optional. True will add, false will remove. Default value is true)]
|
|
|
|
* @Return: nil
|
|
|
|
* @PublicAPI: true
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-05-14 18:06:06 +00:00
|
|
|
private ["_add", "_exists", "_map", "_lowestVolume"];
|
|
|
|
|
|
|
|
PARAMS_2(_id,_settings);
|
|
|
|
|
|
|
|
_add = true;
|
2015-01-16 23:21:47 +00:00
|
|
|
if (count _this > 2) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
_add = _this select 2;
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]];
|
|
|
|
|
|
|
|
_exists = false;
|
|
|
|
{
|
2015-01-18 19:09:19 +00:00
|
|
|
if (_id == _x select 0) exitWith {
|
|
|
|
_exists = true;
|
|
|
|
if (_add) then {
|
|
|
|
_x set [1, _settings];
|
|
|
|
} else {
|
|
|
|
_map set [_forEachIndex, 0];
|
|
|
|
_map = _map - [0];
|
|
|
|
};
|
|
|
|
};
|
2015-01-16 23:21:47 +00:00
|
|
|
} forEach _map;
|
|
|
|
|
|
|
|
if (!_exists && _add) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
_map pushBack [_id, _settings];
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
missionNamespace setVariable [QGVAR(setHearingCapabilityMap), _map];
|
|
|
|
|
|
|
|
// find lowest volume
|
|
|
|
_lowestVolume = 1;
|
|
|
|
{
|
2015-01-18 19:09:19 +00:00
|
|
|
_lowestVolume = (_x select 1) min _lowestVolume;
|
2015-01-16 23:21:47 +00:00
|
|
|
} forEach _map;
|
|
|
|
|
|
|
|
// in game sounds
|
|
|
|
0 fadeSound _lowestVolume;
|
|
|
|
0 fadeRadio _lowestVolume;
|
|
|
|
0 fadeMusic _lowestVolume;
|
|
|
|
|
|
|
|
// Set Radio mod variables.
|
|
|
|
player setVariable ["tf_globalVolume", _lowestVolume];
|
2015-04-14 21:58:19 +00:00
|
|
|
if (!isNil "acre_api_fnc_setGlobalVolume") then { [_lowestVolume^0.33] call acre_api_fnc_setGlobalVolume; };
|