Night Vision - Use slotItemChanged event

This commit is contained in:
LinkIsGrim 2024-02-08 19:17:05 -03:00
parent ee79decb45
commit d64f0f30f3
4 changed files with 35 additions and 28 deletions

View File

@ -4,7 +4,7 @@ PREP(initModule);
PREP(nonDedicatedFix);
PREP(onCameraViewChanged);
PREP(onFiredPlayer);
PREP(onLoadoutChanged);
PREP(onSlotItemChanged);
PREP(onVisionModeChanged);
PREP(pfeh);
PREP(refreshGoggleType);

View File

@ -27,12 +27,13 @@ GVAR(isUsingMagnification) = false;
TRACE_4("settingsInitialized",GVAR(disableNVGsWithSights),GVAR(fogScaling),GVAR(noiseScaling),GVAR(effectScaling));
["visionMode", LINKFUNC(onVisionModeChanged), false] call CBA_fnc_addPlayerEventHandler;
["loadout", LINKFUNC(onLoadoutChanged), true] call CBA_fnc_addPlayerEventHandler;
["cameraView", LINKFUNC(onCameraViewChanged), true] call CBA_fnc_addPlayerEventHandler;
["vehicle", LINKFUNC(refreshGoggleType), false] call CBA_fnc_addPlayerEventHandler;
["turret", LINKFUNC(refreshGoggleType), true] call CBA_fnc_addPlayerEventHandler;
["ACE_controlledUAV", LINKFUNC(refreshGoggleType)] call CBA_fnc_addEventHandler;
["CAManBase", "SlotItemChanged", LINKFUNC(onSlotItemChanged)] call CBA_fnc_addClassEventHandler;
// handle only brightness if effects are disabled
GVAR(ppEffectNVGBrightness) = ppEffectCreate ["ColorCorrections", 1236];
GVAR(ppEffectNVGBrightness) ppEffectForceInNVG true;
@ -94,4 +95,3 @@ WARNING("Debug mouse wheel action enabled, this should NOT be in a final release
};
}] call CBA_fnc_addDisplayHandler;
#endif

View File

@ -1,25 +0,0 @@
#include "..\script_component.hpp"
/*
* Author: Dslyecxi, PabstMirror
* Refreshes nvg effect if switching NVG goggles.
*
* Arguments:
* 0: Player <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_nightvision_fnc_onLoadoutChanged
*
* Public: No
*/
params ["_player"];
TRACE_1("onLoadoutChange",_player);
private _newHMD = hmd _player;
if (_newHMD != GVAR(playerHMD)) then {
GVAR(playerHMD) = _newHMD;
[] call FUNC(refreshGoggleType);
};

View File

@ -0,0 +1,32 @@
#include "..\script_component.hpp"
/*
* Author: Dslyecxi, PabstMirror
* Refreshes nvg effect if switching NVG goggles.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Slot item <STRING>
* 2: Slot number <NUMBER>
* 3: Item assigned <BOOL>
*
* Return Value:
* None
*
* Example:
* [player] call ace_nightvision_fnc_onSlotItemChanged
*
* Public: No
*/
params ["_unit", "_item", "_slot", "_assign"];
TRACE_4("onSlotItemChange",_unit,_item,_slot,_assign);
if (_unit != ACE_player || _slot != TYPE_HMD) exitWith {};
if (!_assign) exitWith {
GVAR(playerHMD) = "";
};
if (_item != GVAR(playerHMD)) then {
GVAR(playerHMD) = _item;
[] call FUNC(refreshGoggleType);
};