ACE3/addons/nightvision/functions/fnc_onCameraViewChanged.sqf

42 lines
1.3 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-10-07 18:11:07 +00:00
/*
* Author: BaerMitUmlaut
2015-10-08 17:29:30 +00:00
* Disables/re-enables NVGs when the player starts/stops aiming 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 camera view <STRING>
2015-10-07 18:11:07 +00:00
*
* Return Value:
* None
*
* Example:
2015-10-08 17:29:30 +00:00
* [player, "GUNNER"] call ace_nightvision_fnc_onCameraViewChanged
2015-10-07 18:11:07 +00:00
*
* Public: No
*/
2015-10-08 17:29:30 +00:00
params ["_unit", "_cameraView"];
TRACE_2("onCameraViewChanged",_unit,_cameraView);
// Refresh goggle effect (e.g. switching to vehicle's NVG)
call FUNC(refreshGoggleType);
2015-10-07 18:11:07 +00:00
2015-10-08 09:31:29 +00:00
if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then {
if ((isNull objectParent _unit)
|| {isTurnedOut _unit}
|| {!([_unit] call EFUNC(common,hasHatch))
&& {[_unit] call EFUNC(common,getTurretIndex) in ([vehicle _unit] call EFUNC(common,getTurretsFFV))}
}) then {
if ((_cameraView == "GUNNER") && {currentVisionMode _unit == 1}) then {
2015-10-08 09:31:29 +00:00
_unit action ["NVGogglesOff", _unit];
_unit setVariable [QGVAR(reenableNVGs), true];
2015-10-08 09:31:29 +00:00
} else {
if (_unit getVariable [QGVAR(reenableNVGs), false] && {_cameraView != "GUNNER"}) then {
2015-10-08 09:31:29 +00:00
_unit action ["NVGoggles", _unit];
_unit setVariable [QGVAR(reenableNVGs), false];
2015-10-08 09:31:29 +00:00
};
2015-10-07 18:11:07 +00:00
};
};
};