2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-18 04:07:29 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2017-12-06 19:15:33 +00:00
|
|
|
* Change the brightness of the unit's NVG.
|
2015-02-18 04:07:29 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit <OBJECT>
|
2016-01-29 00:19:02 +00:00
|
|
|
* 1: Change in brightness (1 or -1) <NUMBER>
|
2015-02-18 04:07:29 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-02-18 04:07:29 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, 1] call ace_nightvision_fnc_changeNVGBrightness
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-09-16 15:55:23 +00:00
|
|
|
params ["_player", "_changeInBrightness"];
|
2017-12-06 19:15:33 +00:00
|
|
|
TRACE_2("changeNVGBrightness",_player,_changeInBrightness);
|
2015-02-18 04:07:29 +00:00
|
|
|
|
2018-05-31 16:07:31 +00:00
|
|
|
private _effectsEnabled = GVAR(effectScaling) != 0;
|
|
|
|
private _defaultBrightness = [-3, 0] select _effectsEnabled;
|
2015-02-18 04:07:29 +00:00
|
|
|
|
2018-05-31 16:07:31 +00:00
|
|
|
private _brightness = _player getVariable [QGVAR(NVGBrightness), _defaultBrightness];
|
2017-12-06 19:15:33 +00:00
|
|
|
_brightness = ((_brightness + _changeInBrightness) min 0) max -6;
|
2015-02-18 04:07:29 +00:00
|
|
|
_player setVariable [QGVAR(NVGBrightness), _brightness, false];
|
|
|
|
|
2018-05-31 16:07:31 +00:00
|
|
|
// Display default setting as 0
|
|
|
|
[format [LLSTRING(NVGBrightness), _brightness - _defaultBrightness]] call EFUNC(common,displayTextStructured);
|
2015-02-18 04:07:29 +00:00
|
|
|
playSound "ACE_Sound_Click";
|
2017-12-06 19:15:33 +00:00
|
|
|
|
2018-05-31 16:07:31 +00:00
|
|
|
// Handle brightness only if effects are disabled
|
|
|
|
if (!_effectsEnabled) exitWith {
|
|
|
|
_brightness = linearConversion [-6, 0, _brightness, 0.4, 1.6, true];
|
|
|
|
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, _brightness, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
|
2017-12-17 19:09:41 +00:00
|
|
|
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
|
|
|
|
};
|
|
|
|
|
2018-05-31 16:07:31 +00:00
|
|
|
// Trigger full ppEffects update next time run in the PFEH
|
2017-12-06 19:15:33 +00:00
|
|
|
GVAR(nextEffectsUpdate) = -1;
|