Skip to content

Commit d1d12fb

Browse files
LinkIsGrimjohnb432
andauthored
Night Vision - Use slotItemChanged event (#9782)
* Night Vision - Use slotItemChanged event * update header * Run on ACE_player instead of all units * Update XEH_postInit.sqf --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
1 parent 12c4d89 commit d1d12fb

File tree

4 files changed

+41
-28
lines changed

4 files changed

+41
-28
lines changed

addons/nightvision/XEH_PREP.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PREP(initModule);
44
PREP(nonDedicatedFix);
55
PREP(onCameraViewChanged);
66
PREP(onFiredPlayer);
7-
PREP(onLoadoutChanged);
7+
PREP(onSlotItemChanged);
88
PREP(onVisionModeChanged);
99
PREP(pfeh);
1010
PREP(refreshGoggleType);

addons/nightvision/XEH_postInit.sqf

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@ GVAR(isUsingMagnification) = false;
3030
TRACE_4("settingsInitialized",GVAR(disableNVGsWithSights),GVAR(fogScaling),GVAR(noiseScaling),GVAR(effectScaling));
3131

3232
["visionMode", LINKFUNC(onVisionModeChanged), false] call CBA_fnc_addPlayerEventHandler;
33-
["loadout", LINKFUNC(onLoadoutChanged), true] call CBA_fnc_addPlayerEventHandler;
3433
["cameraView", LINKFUNC(onCameraViewChanged), true] call CBA_fnc_addPlayerEventHandler;
3534
["vehicle", LINKFUNC(refreshGoggleType), false] call CBA_fnc_addPlayerEventHandler;
3635
["turret", LINKFUNC(refreshGoggleType), true] call CBA_fnc_addPlayerEventHandler;
3736
["ACE_controlledUAV", LINKFUNC(refreshGoggleType)] call CBA_fnc_addEventHandler;
3837

38+
["unit", {
39+
// Call manually to update existing value
40+
[] call FUNC(refreshGoggleType);
41+
}, true] call CBA_fnc_addPlayerEventHandler;
42+
43+
[QGVAR(slotItemChanged), "SlotItemChanged", LINKFUNC(onSlotItemChanged)] call CBA_fnc_addBISPlayerEventHandler;
44+
3945
// handle only brightness if effects are disabled
4046
GVAR(ppEffectNVGBrightness) = ppEffectCreate ["ColorCorrections", 1236];
4147
GVAR(ppEffectNVGBrightness) ppEffectForceInNVG true;
@@ -97,4 +103,3 @@ WARNING("Debug mouse wheel action enabled, this should NOT be in a final release
97103
};
98104
}] call CBA_fnc_addDisplayHandler;
99105
#endif
100-

addons/nightvision/functions/fnc_onLoadoutChanged.sqf

-25
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "..\script_component.hpp"
2+
/*
3+
* Author: Dslyecxi, PabstMirror, LinkIsGrim
4+
* Refreshes nvg effect if switching NVG goggles.
5+
*
6+
* Arguments:
7+
* 0: Unit <OBJECT>
8+
* 1: Slot item <STRING>
9+
* 2: Slot number <NUMBER>
10+
* 3: Item assigned <BOOL>
11+
*
12+
* Return Value:
13+
* None
14+
*
15+
* Example:
16+
* [player, "ACE_NVG_Wide", 616, true] call ace_nightvision_fnc_onSlotItemChanged
17+
*
18+
* Public: No
19+
*/
20+
21+
params ["_unit", "_item", "_slot", "_assign"];
22+
TRACE_4("onSlotItemChanged",_unit,_item,_slot,_assign);
23+
24+
if (_slot != TYPE_HMD) exitWith {};
25+
26+
if (!_assign) exitWith {
27+
GVAR(playerHMD) = "";
28+
};
29+
30+
if (_item != GVAR(playerHMD)) then {
31+
GVAR(playerHMD) = _item;
32+
[] call FUNC(refreshGoggleType);
33+
};

0 commit comments

Comments
 (0)