ACE3/addons/nightvision/functions/fnc_changeNVGBrightness.sqf
Glowbal b489750d5b Minor optimizations using private, params, and isEqualType (#4323)
* Optimizations with private, params, and isEqualType

* Fixed tab being used instead of space

* Fixed tabs inserted by notepad++

* More usage of new private syntax and params

- changed a few checks for an array being empty to `_arr isEqualTo []`
rather than `count _arr == 0`
- added more uses of `private` on the same line as the variable is
declared
- added more uses of params to assign variables passed as parameters
- removed unnecessary parentheses
- removed several unnecessary variable declarations with private array
syntax

* clean up and formatting
2016-09-04 16:44:22 +02:00

35 lines
954 B
Plaintext

/*
* Author: commy2
* Change the brightness of the unit's NVG
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Change in brightness (1 or -1) <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [player, 1] call ace_nightvision_fnc_changeNVGBrightness
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_changeInBrightness"];
TRACE_2("params",_player,_changeInBrightness);
if (!hasInterface) exitWith {};
private _brightness = _player getVariable [QGVAR(NVGBrightness), 0];
_brightness = ((round (10 * _brightness + _changeInBrightness) / 10) min 0.5) max -0.5;
_player setVariable [QGVAR(NVGBrightness), _brightness, false];
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, (_brightness + 1), 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
[format [(localize LSTRING(NVGBrightness)), (_brightness * 10)]] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";