ACE3/addons/common/functions/fnc_setHearingCapability.sqf

57 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-09-19 18:55:35 +00:00
/*
* Author: Glowbal
* Handle set volume calls. Will use the lowest available volume setting.
2015-01-16 23:21:47 +00:00
*
2015-09-19 18:55:35 +00:00
* Arguments:
* 0: id <STRING>
* 1: settings <NUMBER>
* 2: add [true] OR remove [false] (default: true) <BOOL>
2015-09-19 18:55:35 +00:00
*
* Return Value:
* None
*
* Example:
* ["earwax", 0.5, true] call ace_common_fnc_setHearingCapability
2015-09-20 13:52:40 +00:00
*
* Public: Yes
2015-01-16 23:21:47 +00:00
*/
#include "script_component.hpp"
params ["_id", "_setting", ["_add", true]];
2015-01-16 23:21:47 +00:00
private _exists = false;
private _lowestVolume = 1;
2015-01-16 23:21:47 +00:00
GVAR(setHearingCapabilityMap) = GVAR(setHearingCapabilityMap) select {
_x params ["_xID", "_xSetting"];
if (_id == _xID) then {
2015-01-18 19:09:19 +00:00
_exists = true;
if (_add) then {
_x set [1, _setting];
_lowestVolume = _lowestVolume min _setting;
true
2015-01-18 19:09:19 +00:00
} else {
false
2015-01-18 19:09:19 +00:00
};
} else {
_lowestVolume = _lowestVolume min _xSetting;
true
2015-01-18 19:09:19 +00:00
};
};
2015-01-16 23:21:47 +00:00
if (!_exists && _add) then {
_lowestVolume = _lowestVolume min _setting;
GVAR(setHearingCapabilityMap) pushBack [_id, _setting];
2015-01-16 23:21:47 +00:00
};
// in game sounds
0 fadeSound _lowestVolume;
0 fadeRadio _lowestVolume;
2018-01-02 13:57:19 +00:00
if (GVAR(allowFadeMusic)) then {
2017-06-29 14:04:32 +00:00
0 fadeMusic _lowestVolume;
};
2015-01-16 23:21:47 +00:00
// Set Radio mod variables.
ACE_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; };