2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-10-07 18:11:07 +00:00
|
|
|
/*
|
2017-12-06 19:15:33 +00:00
|
|
|
* Author: BaerMitUmlaut, Dslyecxi, PabstMirror
|
2015-10-08 17:29:30 +00:00
|
|
|
* Disables turning on NVGs while the player aims down his sight.
|
2015-10-07 18:11:07 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
2015-10-08 17:29:30 +00:00
|
|
|
* 1: New vision mode <NUMBER>
|
2015-10-07 18:11:07 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-10-08 17:29:30 +00:00
|
|
|
* [player, 1] call ace_nightvision_fnc_onVisionModeChanged
|
2015-10-07 18:11:07 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-10-08 17:29:30 +00:00
|
|
|
params ["_unit", "_visionMode"];
|
2017-12-06 19:15:33 +00:00
|
|
|
TRACE_2("onVisionModeChanged",_unit,_visionMode);
|
|
|
|
|
2019-12-11 16:38:43 +00:00
|
|
|
// Handle disableNVGsWithSights setting:
|
|
|
|
if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then {
|
|
|
|
if ((vehicle _unit == _unit)
|
|
|
|
|| {isTurnedOut _unit}
|
|
|
|
|| {!([_unit] call EFUNC(common,hasHatch))
|
|
|
|
&& {[_unit] call EFUNC(common,getTurretIndex) in ([vehicle _unit] call EFUNC(common,getTurretsFFV))}
|
|
|
|
}) then {
|
|
|
|
if ((cameraView == "GUNNER") && {_visionMode > 0}) then {
|
|
|
|
_unit action ["NVGogglesOff", _unit];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Handle only brightness if effects are disabled
|
2017-12-17 19:09:41 +00:00
|
|
|
if (GVAR(effectScaling) == 0) exitWith {
|
|
|
|
GVAR(ppEffectNVGBrightness) ppEffectEnable (_visionMode == 1);
|
|
|
|
};
|
|
|
|
|
2017-12-06 19:15:33 +00:00
|
|
|
// Start PFEH when entering night vision mode:
|
|
|
|
if (_visionMode == 1) then {
|
|
|
|
if (GVAR(PFID) == -1) then {
|
|
|
|
GVAR(running) = true;
|
|
|
|
[true] call FUNC(setupDisplayEffects);
|
|
|
|
[] call FUNC(refreshGoggleType);
|
|
|
|
GVAR(PFID) = [LINKFUNC(pfeh), 0, []] call CBA_fnc_addPerFrameHandler;
|
2019-12-11 16:38:43 +00:00
|
|
|
GVAR(firedEHs) = [
|
|
|
|
["ace_firedPlayer", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler,
|
|
|
|
["ace_firedPlayerVehicle", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler
|
|
|
|
];
|
|
|
|
TRACE_1("Added fired EHs",GVAR(firedEHs));
|
2017-12-06 19:15:33 +00:00
|
|
|
|
|
|
|
// Fade in from black when turning nvg on
|
|
|
|
QGVAR(turnOnEffect) cutText ["", "BLACK IN", 2.5];
|
|
|
|
};
|
|
|
|
};
|