From edb76ffae4f584f38d833d4ed8087adbcdfbd703 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Wed, 7 Oct 2015 20:11:07 +0200 Subject: [PATCH 1/5] Initial commit --- addons/nightvision/ACE_Settings.hpp | 8 +++++ addons/nightvision/CfgVehicles.hpp | 24 ++++++++++++++ addons/nightvision/UI/Icon_Module_ca.paa | Bin 0 -> 5625 bytes addons/nightvision/XEH_postInitClient.sqf | 12 +++++-- addons/nightvision/XEH_preInit.sqf | 2 ++ addons/nightvision/config.cpp | 1 + .../nightvision/functions/fnc_handleNVGs.sqf | 31 ++++++++++++++++++ .../nightvision/functions/fnc_initModule.sqf | 21 ++++++++++++ addons/nightvision/stringtable.xml | 18 +++++++++- .../Icon_Module_Nightvision_ca.png | Bin 0 -> 552 bytes 10 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 addons/nightvision/ACE_Settings.hpp create mode 100644 addons/nightvision/UI/Icon_Module_ca.paa create mode 100644 addons/nightvision/functions/fnc_handleNVGs.sqf create mode 100644 addons/nightvision/functions/fnc_initModule.sqf create mode 100644 extras/assets/icons/Icon_Module_png/Icon_Module_Nightvision_ca.png diff --git a/addons/nightvision/ACE_Settings.hpp b/addons/nightvision/ACE_Settings.hpp new file mode 100644 index 0000000000..d6d52bab10 --- /dev/null +++ b/addons/nightvision/ACE_Settings.hpp @@ -0,0 +1,8 @@ +class ACE_Settings { + class GVAR(disableNVGsWithSights) { + displayName = CSTRING(DisableNVGsWithSights_DisplayName); + description = CSTRING(DisableNVGsWithSights_description); + typeName = "BOOL"; + value = 1; + }; +}; diff --git a/addons/nightvision/CfgVehicles.hpp b/addons/nightvision/CfgVehicles.hpp index 84e7105f0b..8b489ad64f 100644 --- a/addons/nightvision/CfgVehicles.hpp +++ b/addons/nightvision/CfgVehicles.hpp @@ -14,4 +14,28 @@ class CfgVehicles { MACRO_ADDITEM(ACE_NVG_Wide,6); }; }; + + class ACE_Module; + class GVAR(ModuleSettings): ACE_Module { + scope = 2; + displayName = CSTRING(Module_DisplayName); + icon = QUOTE(PATHTOF(UI\Icon_Module_ca.paa)); + category = "ACE"; + function = QUOTE(FUNC(initModule)); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + author = "BaerMitUmlaut"; + class Arguments { + class disableNVGsWithSights { + displayName = CSTRING(DisableNVGsWithSights_DisplayName); + description = CSTRING(DisableNVGsWithSights_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + class ModuleDescription { + description = CSTRING(Module_Description); + }; + }; }; diff --git a/addons/nightvision/UI/Icon_Module_ca.paa b/addons/nightvision/UI/Icon_Module_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..556adaf30ca22a622587b0deedcc0a48d0b9f127 GIT binary patch literal 5625 zcmeHLO-x)>6h3eICP1VNX=cRoBU3x8wu`#3lC;PpMqm;NB+hL}42i&^8U@0Ju5e!M zf|wW?$7o#G5aYteg#~JcCDWKRkeGH$9fBBZkwpd3gf?Y(e&^o%D7@h}w8UC3Gmrbd zd+zzW=iYPf_?`Ot+Ssf0XKPI&T3J~+Cvi({BVz}RaeeLUb&L&s8NX3i*JPn@!#)i{Qh2n$a98NbrZTA8pV4z4pVm zk%kYXJc`9)7*0f@Nri=i&f;8q*r1L0ua{>fUED0?d+aCj zh4EoI7MfT7b~snR1|QGi_c8uY(N!!I=3zO`G3T8x2iH8j0$u~!{51B$G;F8#J^g9$&Z&`&c~85 ze}u~pu-88b{stBA2!CGkbq)ME{-u8r{yF|#M+~6cyNmUZ4A#=~{#W{7yFi|de<>f^ zKS%!V<-y;(^4EWjo*ll{-%l5o;r19GFY$hkCS|_BehgKmQ=OSq#jkpQnnqUQNsVzL z{JUGpko;e)2T}lXF#5w@~{}CFa_=_j0AEreX47jAvUHTRSf^h zIu|N#eRb(4e$V+`jXpWgs-ElJv#IXWtiR#+=hOpUd%c*B*DM@}-;@4f>wN*l!{KF# zg|Mhv#*eB;5I?b75+6Fie1MH|&-i|Ot^oPKtxrNwi01AGSO;k*aLb(2z1-V1D={48 zwSPN&bEbZUV};u)U&&wLxuv1T%y5N_N8~FmS@yLR^rSk=QXLOi8xacmX^s-EwsJqT zj4R0T0nNPjmL8YGdHiI>eF5$bUek0|^^D`(8S0ewp&}EnOk=pNU1LL({|V#u_(u8q zQ9Gl=bDkaT>FvsL_(FT$-|vlb-?8|?veQ}a4RAn9tnGpyRPXEgvFzlPK6(B<3H#r; ze5yTzEy~*a5#LkO(YIX88!|#Do^a&zcntXD89pD*NqPh4WmOu6zu2YM&lIIi1AUXD ziXYcEk9xiS=eM;7yz%(7;V{xQnPiV4EaMA5X!9+Jsl80&P|mf@2EFrFrAtqYbr}tZ z3$pXxpD~JNcsv*khU9o)ffT*G_7a~Y3JYP6#TVAgr$uKA`C!Y}UdeBhYY(m|wk*4F zO$o9+)Sq?b6?7+V(OR7aV{xaEMpCgGOJa+iAMd-=is=fj$R zFv#=Q%i9>c=>cg}(r=4D(*83nrcWKz$BKyUaK82j_GV{(OO%5yntSu8ZlLz~g zxAip_XzHGjkUd9)(){m%Kbt=z)+O3m3nvd{j)yM4yR z_$d&6w9<~#*0k8>y3rn6iVrUJ)UcT*TG)<{97%n8LYW<6`pQhxA(#N&QF~eG3kF41 zbpnQ>GTrk+G^&mf6A9Bwe`vbnJi|)k%+U0}qR>-Kmi*Rw#d&t%j;l}j+SS&>jx)sa zxYP?*BNgjq6&!cZkQt^0kQ4E?t(yBWa52Rt2#9eiy?h?T8uO1E-d{`dDWAi8_C(8( zvp3$wZc-D6tYcqXJoC;f{)HwI&lS9u + * + * Return Value: + * None + * + * Example: + * [player] call ace_nightvision_fnc_disableNVGs + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_unit"]; + +if (GVAR(disableNVGsWithSights) && {(vehicle _unit == _unit) || {isTurnedOut _unit}}) then { + if ((cameraView == "GUNNER") && {currentVisionMode _unit > 0}) then { + _unit action ["NVGogglesOff", _unit]; + GVAR(reenableNVGs) = true; + } else { + if (GVAR(reenableNVGs) && {cameraView != "GUNNER"}) then { + _unit action ["NVGoggles", _unit]; + GVAR(reenableNVGs) = false; + }; + }; +}; diff --git a/addons/nightvision/functions/fnc_initModule.sqf b/addons/nightvision/functions/fnc_initModule.sqf new file mode 100644 index 0000000000..6831a29edf --- /dev/null +++ b/addons/nightvision/functions/fnc_initModule.sqf @@ -0,0 +1,21 @@ +/* + * Author: BaerMitUmlaut + * Initializes the settings for the disable NVGs in sight module. + * + * Arguments: + * 0: Module + * + * Return Value: + * None + * + * Example: + * [_module] call ace_nightvision_fnc_initModule + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_module"]; + +[_module, QGVAR(disableNVGsWithSights), "disableNVGsWithSights"] call EFUNC(common,readSettingFromModule); diff --git a/addons/nightvision/stringtable.xml b/addons/nightvision/stringtable.xml index 050945d5d8..b6e35147f9 100644 --- a/addons/nightvision/stringtable.xml +++ b/addons/nightvision/stringtable.xml @@ -133,5 +133,21 @@ Diminuir Luminosidade do EVN Riduci la luminosità dell'NVG + + Nightvision + Nachtsicht + + + Settings for night vision. + Einstellungen für Nachtsichtgeräte. + + + Disable NVGs in scope + Deakt. NVGs mit Visier + + + Blocks the usage of night vision goggles whilst aiming down the sight. + Blockiert das Benutzen von Nachtsichtbrillen beim Benutzen des Visiers. + - \ No newline at end of file + diff --git a/extras/assets/icons/Icon_Module_png/Icon_Module_Nightvision_ca.png b/extras/assets/icons/Icon_Module_png/Icon_Module_Nightvision_ca.png new file mode 100644 index 0000000000000000000000000000000000000000..975a4126f39aa4ad307c9aded3c0ce906da572f7 GIT binary patch literal 552 zcmV+@0@wYCP)!9q(58zG>vx3W#+BUt!O7QTRum5tb1Xdy(gRgfSe z1Vi%MY!O0YOwKO5n=>B-a-Hn_ncEp+l0=4>nGHYA%6?vUmxvq}Aa((gMRI1ePRuR9 ze+`8cqIoXXQ@{oA8jyKPCRyjUr+}wGwc4OZKv8o*^eHf_czF#@(YHaL1YH2fah!;; zm`;A)1zZ3Zz;PU>(DVAfq?`19LsCytUy{Y({GleZQALML(xs%Ap<7$h&Y1V^>2FR7 z8-)W!r~|LS^3c-*;2O9BR)AxmIc4U!FtgLDhW2)v$04*UI|-WEGjI@SW^ECQ+<8C* z^eb5dMg&NJuaSB%3%fuE_y)Q_&&&ofMZqMRW4`Ao?K)4AHcJr!>4nwOuCSi5w)em) zur=njcQdP(Ju+I#kI&LXz!VYQa)=Cou9?+*AyQ@mB(-w-^#OiDKAdFiXc0xQ>ut~n zp>m|aS%C8cGkdJ^IiL|3=AFuR0ZH4yZJ?Qtq6A0+ov#BABSOxz5V`Y}*rKy=OVK$+ qh<7dSIF3_B{7+J`M}P|uy8yr9XgTsPFU7_H0000 Date: Thu, 8 Oct 2015 11:31:29 +0200 Subject: [PATCH 2/5] Fix for BI bug, FFV support --- .../nightvision/functions/fnc_handleNVGs.sqf | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/addons/nightvision/functions/fnc_handleNVGs.sqf b/addons/nightvision/functions/fnc_handleNVGs.sqf index 093d3728ac..ca05f5ac94 100644 --- a/addons/nightvision/functions/fnc_handleNVGs.sqf +++ b/addons/nightvision/functions/fnc_handleNVGs.sqf @@ -18,14 +18,17 @@ params ["_unit"]; -if (GVAR(disableNVGsWithSights) && {(vehicle _unit == _unit) || {isTurnedOut _unit}}) then { - if ((cameraView == "GUNNER") && {currentVisionMode _unit > 0}) then { - _unit action ["NVGogglesOff", _unit]; - GVAR(reenableNVGs) = true; - } else { - if (GVAR(reenableNVGs) && {cameraView != "GUNNER"}) then { - _unit action ["NVGoggles", _unit]; - GVAR(reenableNVGs) = false; +if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then { + (assignedVehicleRole _unit) params ["_role", "_turretPath"]; + if ((vehicle _unit == _unit) || {isTurnedOut _unit} || {_role == "cargo" && {!(isNil "_turretPath")}}) then { + if ((cameraView == "GUNNER") && {currentVisionMode _unit > 0}) then { + _unit action ["NVGogglesOff", _unit]; + GVAR(reenableNVGs) = true; + } else { + if (GVAR(reenableNVGs) && {cameraView != "GUNNER"}) then { + _unit action ["NVGoggles", _unit]; + GVAR(reenableNVGs) = false; + }; }; }; }; From 2fe53431c7a00d0b14782b6c5ce0419eb1424ad9 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 8 Oct 2015 19:29:30 +0200 Subject: [PATCH 3/5] Split event handlers --- addons/nightvision/XEH_postInitClient.sqf | 4 +-- addons/nightvision/XEH_preInit.sqf | 3 +- ...leNVGs.sqf => fnc_onCameraViewChanged.sqf} | 11 +++---- .../functions/fnc_onVisionModeChanged.sqf | 29 +++++++++++++++++++ 4 files changed, 39 insertions(+), 8 deletions(-) rename addons/nightvision/functions/{fnc_handleNVGs.sqf => fnc_onCameraViewChanged.sqf} (63%) create mode 100644 addons/nightvision/functions/fnc_onVisionModeChanged.sqf diff --git a/addons/nightvision/XEH_postInitClient.sqf b/addons/nightvision/XEH_postInitClient.sqf index 894fe00ee4..accc1872be 100644 --- a/addons/nightvision/XEH_postInitClient.sqf +++ b/addons/nightvision/XEH_postInitClient.sqf @@ -32,12 +32,12 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0; ["playerInventoryChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); ["playerVisionModeChanged", { _this call FUNC(updatePPEffects); - _this call FUNC(handleNVGs); + _this call FUNC(onVisionModeChanged); }] call EFUNC(common,addEventHandler); ["zeusDisplayChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); ["cameraViewChanged", { _this call FUNC(updatePPEffects); - _this call FUNC(handleNVGs); + _this call FUNC(onCameraViewChanged); }] call EFUNC(common,addEventHandler); ["playerVehicleChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); ["playerTurretChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); diff --git a/addons/nightvision/XEH_preInit.sqf b/addons/nightvision/XEH_preInit.sqf index ab9995c745..ed02b9524e 100644 --- a/addons/nightvision/XEH_preInit.sqf +++ b/addons/nightvision/XEH_preInit.sqf @@ -4,8 +4,9 @@ ADDON = false; PREP(blending); PREP(changeNVGBrightness); -PREP(handleNVGs); PREP(initModule); +PREP(onCameraViewChanged); +PREP(onVisionModeChanged); PREP(updatePPEffects); ADDON = true; diff --git a/addons/nightvision/functions/fnc_handleNVGs.sqf b/addons/nightvision/functions/fnc_onCameraViewChanged.sqf similarity index 63% rename from addons/nightvision/functions/fnc_handleNVGs.sqf rename to addons/nightvision/functions/fnc_onCameraViewChanged.sqf index ca05f5ac94..adc221c06d 100644 --- a/addons/nightvision/functions/fnc_handleNVGs.sqf +++ b/addons/nightvision/functions/fnc_onCameraViewChanged.sqf @@ -1,31 +1,32 @@ /* * Author: BaerMitUmlaut - * Disables NVGs when the player aims down his sight. + * Disables/re-enables NVGs when the player starts/stops aiming down his sight. * * Arguments: * 0: Unit + * 1: New camera view * * Return Value: * None * * Example: - * [player] call ace_nightvision_fnc_disableNVGs + * [player, "GUNNER"] call ace_nightvision_fnc_onCameraViewChanged * * Public: No */ #include "script_component.hpp" -params ["_unit"]; +params ["_unit", "_cameraView"]; if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then { (assignedVehicleRole _unit) params ["_role", "_turretPath"]; if ((vehicle _unit == _unit) || {isTurnedOut _unit} || {_role == "cargo" && {!(isNil "_turretPath")}}) then { - if ((cameraView == "GUNNER") && {currentVisionMode _unit > 0}) then { + if ((_cameraView == "GUNNER") && {currentVisionMode _unit > 0}) then { _unit action ["NVGogglesOff", _unit]; GVAR(reenableNVGs) = true; } else { - if (GVAR(reenableNVGs) && {cameraView != "GUNNER"}) then { + if (GVAR(reenableNVGs) && {_cameraView != "GUNNER"}) then { _unit action ["NVGoggles", _unit]; GVAR(reenableNVGs) = false; }; diff --git a/addons/nightvision/functions/fnc_onVisionModeChanged.sqf b/addons/nightvision/functions/fnc_onVisionModeChanged.sqf new file mode 100644 index 0000000000..d14e504dc8 --- /dev/null +++ b/addons/nightvision/functions/fnc_onVisionModeChanged.sqf @@ -0,0 +1,29 @@ +/* + * Author: BaerMitUmlaut + * Disables turning on NVGs while the player aims down his sight. + * + * Arguments: + * 0: Unit + * 1: New vision mode + * + * Return Value: + * None + * + * Example: + * [player, 1] call ace_nightvision_fnc_onVisionModeChanged + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_unit", "_visionMode"]; + +if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then { + (assignedVehicleRole _unit) params ["_role", "_turretPath"]; + if ((vehicle _unit == _unit) || {isTurnedOut _unit} || {_role == "cargo" && {!(isNil "_turretPath")}}) then { + if ((cameraView == "GUNNER") && {_visionMode > 0}) then { + _unit action ["NVGogglesOff", _unit]; + }; + }; +}; From a1d72b81bf47b6b275a18c285bbbf192cc945acd Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Wed, 28 Oct 2015 17:13:05 +0100 Subject: [PATCH 4/5] Switch to unit namespace, added !hasHatch condition --- addons/nightvision/XEH_postInitClient.sqf | 2 -- .../functions/fnc_onCameraViewChanged.sqf | 15 +++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/nightvision/XEH_postInitClient.sqf b/addons/nightvision/XEH_postInitClient.sqf index accc1872be..e7c1ec9bc5 100644 --- a/addons/nightvision/XEH_postInitClient.sqf +++ b/addons/nightvision/XEH_postInitClient.sqf @@ -70,5 +70,3 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0; }, {false}, [209, [false, false, true]], false] call cba_fnc_addKeybind; //PageDown + ALT - -GVAR(reenableNVGs) = false; diff --git a/addons/nightvision/functions/fnc_onCameraViewChanged.sqf b/addons/nightvision/functions/fnc_onCameraViewChanged.sqf index adc221c06d..5384d6924c 100644 --- a/addons/nightvision/functions/fnc_onCameraViewChanged.sqf +++ b/addons/nightvision/functions/fnc_onCameraViewChanged.sqf @@ -20,15 +20,18 @@ params ["_unit", "_cameraView"]; if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then { - (assignedVehicleRole _unit) params ["_role", "_turretPath"]; - if ((vehicle _unit == _unit) || {isTurnedOut _unit} || {_role == "cargo" && {!(isNil "_turretPath")}}) then { - if ((_cameraView == "GUNNER") && {currentVisionMode _unit > 0}) 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") && {currentVisionMode _unit == 1}) then { _unit action ["NVGogglesOff", _unit]; - GVAR(reenableNVGs) = true; + _unit setVariable [QGVAR(reenableNVGs), true]; } else { - if (GVAR(reenableNVGs) && {_cameraView != "GUNNER"}) then { + if (_unit getVariable [QGVAR(reenableNVGs), false] && {_cameraView != "GUNNER"}) then { _unit action ["NVGoggles", _unit]; - GVAR(reenableNVGs) = false; + _unit setVariable [QGVAR(reenableNVGs), false]; }; }; }; From 7d7aa5b67f1a748a2a3c6a1defe3d8c20436ddd4 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Wed, 28 Oct 2015 17:15:46 +0100 Subject: [PATCH 5/5] !hasHatch condition part 2 --- addons/nightvision/functions/fnc_onVisionModeChanged.sqf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/nightvision/functions/fnc_onVisionModeChanged.sqf b/addons/nightvision/functions/fnc_onVisionModeChanged.sqf index d14e504dc8..64f77a69bc 100644 --- a/addons/nightvision/functions/fnc_onVisionModeChanged.sqf +++ b/addons/nightvision/functions/fnc_onVisionModeChanged.sqf @@ -20,8 +20,11 @@ params ["_unit", "_visionMode"]; if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then { - (assignedVehicleRole _unit) params ["_role", "_turretPath"]; - if ((vehicle _unit == _unit) || {isTurnedOut _unit} || {_role == "cargo" && {!(isNil "_turretPath")}}) 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]; };