From 0d9bcdd708a90ca174518e20aec045313fa57dee Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 23 Sep 2023 14:00:04 -0500 Subject: [PATCH] Nightvision - Fix detecting if vehicle's turret has NVGs (#9421) Co-authored-by: Filip Maciejewski Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- .../functions/fnc_refreshGoggleType.sqf | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/addons/nightvision/functions/fnc_refreshGoggleType.sqf b/addons/nightvision/functions/fnc_refreshGoggleType.sqf index a03039d221..60ac627889 100644 --- a/addons/nightvision/functions/fnc_refreshGoggleType.sqf +++ b/addons/nightvision/functions/fnc_refreshGoggleType.sqf @@ -38,26 +38,10 @@ if ((alive ACE_player) && {isNull (ACE_controlledUAV select 0)}) then { if (cameraView != "GUNNER") exitWith {true}; // asume hmd usage outside of gunner view if ([ACE_player] call CBA_fnc_canUseWeapon) exitWith {true}; // FFV - if (ACE_player == (driver _currentVehicle)) exitWith { - !("NVG" in getArray (_vehConfig >> "ViewOptics" >> "visionMode")); - }; - private _result = true; - private _turret = ACE_player call CBA_fnc_turretPath; - private _turretConfig = [_currentVehicle, _turret] call CBA_fnc_getTurret; - - // Seems to cover things like the offroad technical - if ((isNumber (_turretConfig >> "optics")) && {(getNumber (_turretConfig >> "optics")) == 0}) exitWith {true}; - - private _turretConfigOpticsIn = _turretConfig >> "OpticsIn"; - if (isClass _turretConfigOpticsIn) then { - for "_index" from 0 to (count _turretConfigOpticsIn - 1) do { - if ("NVG" in getArray (_turretConfigOpticsIn select _index >> "visionMode")) exitWith {_result = false}; - }; - } else { - // No OpticsIn usualy means RCWS, still need to test on more vehicles - _result = false; - }; - _result + private _turret = _currentVehicle unitTurret ACE_player; // driver is [-1] + if (_turret isEqualTo []) exitWith { true }; + (_currentVehicle currentVisionMode _turret) params ["_turretVisionMode"]; + _turretVisionMode != 1 // if turret isn't giving nvg, then it must be unit's googles }) then { if ((cameraView == "GUNNER") && {currentWeapon ACE_player != ""} && {binocular ACE_player == currentWeapon ACE_player}) exitWith { TRACE_1("souce: binocular",binocular ACE_player); // Source is from player's binocular (Rangefinder/Vector21bNite)