mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Nightvision - Enable setting NVG effects scale mid-mission (#6627)
* Enable setting NVG effects scale mid-mission * Add fired EHs only when nvg is active
This commit is contained in:
parent
80879da241
commit
01787312cc
@ -26,23 +26,17 @@ GVAR(ppeffectBlur) = -1;
|
||||
TRACE_4("settingsInitialized",GVAR(disableNVGsWithSights),GVAR(fogScaling),GVAR(noiseScaling),GVAR(effectScaling));
|
||||
|
||||
["visionMode", LINKFUNC(onVisionModeChanged), false] call CBA_fnc_addPlayerEventHandler;
|
||||
|
||||
// handle only brightness if effects are disabled
|
||||
if (GVAR(effectScaling) == 0) exitWith {
|
||||
GVAR(ppEffectNVGBrightness) = ppEffectCreate ["ColorCorrections", 1236];
|
||||
GVAR(ppEffectNVGBrightness) ppEffectForceInNVG true;
|
||||
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, (-3+3)/5 + 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
|
||||
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
|
||||
};
|
||||
|
||||
["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_firedPlayer", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler;
|
||||
["ace_firedPlayerVehicle", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler;
|
||||
|
||||
// handle only brightness if effects are disabled
|
||||
GVAR(ppEffectNVGBrightness) = ppEffectCreate ["ColorCorrections", 1236];
|
||||
GVAR(ppEffectNVGBrightness) ppEffectForceInNVG true;
|
||||
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, (-3+3)/5 + 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
|
||||
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
|
||||
GVAR(ppEffectNVGBrightness) ppEffectEnable (GVAR(effectScaling) == 0);
|
||||
|
||||
addMissionEventHandler ["Loaded", { // Restart UI vars on mission load
|
||||
if (GVAR(running)) then {
|
||||
|
@ -19,24 +19,6 @@
|
||||
params ["_unit", "_visionMode"];
|
||||
TRACE_2("onVisionModeChanged",_unit,_visionMode);
|
||||
|
||||
// handle only brightness if effects are disabled
|
||||
if (GVAR(effectScaling) == 0) exitWith {
|
||||
GVAR(ppEffectNVGBrightness) ppEffectEnable (_visionMode == 1);
|
||||
};
|
||||
|
||||
// Start PFEH when entering night vision mode:
|
||||
if (_visionMode == 1) then {
|
||||
if (GVAR(PFID) == -1) then {
|
||||
GVAR(running) = true;
|
||||
[true] call FUNC(setupDisplayEffects);
|
||||
[] call FUNC(refreshGoggleType);
|
||||
GVAR(PFID) = [LINKFUNC(pfeh), 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Fade in from black when turning nvg on
|
||||
QGVAR(turnOnEffect) cutText ["", "BLACK IN", 2.5];
|
||||
};
|
||||
};
|
||||
|
||||
// Handle disableNVGsWithSights setting:
|
||||
if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then {
|
||||
if ((vehicle _unit == _unit)
|
||||
@ -49,3 +31,26 @@ if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Handle only brightness if effects are disabled
|
||||
if (GVAR(effectScaling) == 0) exitWith {
|
||||
GVAR(ppEffectNVGBrightness) ppEffectEnable (_visionMode == 1);
|
||||
};
|
||||
|
||||
// Start PFEH when entering night vision mode:
|
||||
if (_visionMode == 1) then {
|
||||
if (GVAR(PFID) == -1) then {
|
||||
GVAR(running) = true;
|
||||
[true] call FUNC(setupDisplayEffects);
|
||||
[] call FUNC(refreshGoggleType);
|
||||
GVAR(PFID) = [LINKFUNC(pfeh), 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
GVAR(firedEHs) = [
|
||||
["ace_firedPlayer", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler,
|
||||
["ace_firedPlayerVehicle", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler
|
||||
];
|
||||
TRACE_1("Added fired EHs",GVAR(firedEHs));
|
||||
|
||||
// Fade in from black when turning nvg on
|
||||
QGVAR(turnOnEffect) cutText ["", "BLACK IN", 2.5];
|
||||
};
|
||||
};
|
||||
|
@ -21,6 +21,10 @@ if ((currentVisionMode ACE_player) != 1) exitWith {
|
||||
[false] call FUNC(setupDisplayEffects);
|
||||
[GVAR(PFID)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(PFID) = -1;
|
||||
(missionNamespace getVariable [QGVAR(firedEHs), []]) params [["_firedPlayerID", -1], ["_firedPlayerVehicleID", -1]];
|
||||
TRACE_2("removing fired EHs",_firedPlayerID,_firedPlayerVehicleID);
|
||||
["ace_firedPlayer", _firedPlayerID] call CBA_fnc_removeEventHandler,
|
||||
["ace_firedPlayerVehicle", _firedPlayerVehicleID] call CBA_fnc_removeEventHandler,
|
||||
};
|
||||
if (EGVAR(common,OldIsCamera)) exitWith {
|
||||
if (GVAR(running)) then {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
TRACE_1("refreshGoggleType",_this);
|
||||
|
||||
if (!GVAR(running)) exitWith {};
|
||||
if (!GVAR(running) || {GVAR(effectScaling) == 0}) exitWith {};
|
||||
|
||||
// Defaults (good for most vehicles/binoculars)
|
||||
private _borderImage = "";
|
||||
|
@ -6,17 +6,51 @@
|
||||
localize LSTRING(Category),
|
||||
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
|
||||
true, // isGlobal
|
||||
{[QGVAR(effectScaling), _this] call EFUNC(common,cbaSettings_settingChanged)},
|
||||
true // Needs mission restart
|
||||
{
|
||||
TRACE_1("effectScaling setting changed",_this);
|
||||
GVAR(ppEffectNVGBrightness) ppEffectEnable (
|
||||
(GVAR(effectScaling) == 0) && {currentVisionMode ACE_player == 1}
|
||||
);
|
||||
|
||||
if (GVAR(effectScaling) == 0) then {
|
||||
// Destroy PFH & PP effects
|
||||
GVAR(running) = false;
|
||||
[false] call FUNC(setupDisplayEffects);
|
||||
[GVAR(PFID)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(PFID) = -1;
|
||||
GVAR(nextEffectsUpdate) = -1;
|
||||
(missionNamespace getVariable [QGVAR(firedEHs), []]) params [["_firedPlayerID", -1], ["_firedPlayerVehicleID", -1]];
|
||||
TRACE_2("removing fired EHs",_firedPlayerID,_firedPlayerVehicleID);
|
||||
["ace_firedPlayer", _firedPlayerID] call CBA_fnc_removeEventHandler,
|
||||
["ace_firedPlayerVehicle", _firedPlayerVehicleID] call CBA_fnc_removeEventHandler,
|
||||
} else {
|
||||
// Start PFH if scaling was previously set to 0
|
||||
if ((currentVisionMode ACE_player == 1) && {!GVAR(running)}) then {
|
||||
GVAR(running) = true;
|
||||
[true] call FUNC(setupDisplayEffects);
|
||||
[] call FUNC(refreshGoggleType);
|
||||
|
||||
if (!isMultiplayer && {!isNull findDisplay 49}) then {
|
||||
// Prevent duplicate effects when paused
|
||||
GVAR(nextEffectsUpdate) = CBA_missionTime + 0.1;
|
||||
};
|
||||
|
||||
GVAR(PFID) = [LINKFUNC(pfeh), 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
GVAR(firedEHs) = [
|
||||
["ace_firedPlayer", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler,
|
||||
["ace_firedPlayerVehicle", LINKFUNC(onFiredPlayer)] call CBA_fnc_addEventHandler
|
||||
];
|
||||
TRACE_1("Added fired EHs",GVAR(firedEHs));
|
||||
};
|
||||
};
|
||||
}
|
||||
] call CBA_settings_fnc_init;
|
||||
[
|
||||
QGVAR(fogScaling), "SLIDER",
|
||||
[LSTRING(fogScaling_DisplayName), LSTRING(fogScaling_Description)],
|
||||
localize LSTRING(Category),
|
||||
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
|
||||
true, // isGlobal
|
||||
{[QGVAR(fogScaling), _this] call EFUNC(common,cbaSettings_settingChanged)},
|
||||
true // Needs mission restart
|
||||
true // isGlobal
|
||||
] call CBA_settings_fnc_init;
|
||||
|
||||
[
|
||||
@ -24,8 +58,7 @@
|
||||
[LSTRING(noiseScaling_DisplayName), LSTRING(noiseScaling_Description)],
|
||||
localize LSTRING(Category),
|
||||
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
|
||||
true, // isGlobal
|
||||
{[QGVAR(noiseScaling), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
true // isGlobal
|
||||
] call CBA_settings_fnc_init;
|
||||
|
||||
[
|
||||
@ -33,8 +66,7 @@
|
||||
[LSTRING(aimDownSightsBlur_DisplayName)],
|
||||
localize LSTRING(Category),
|
||||
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
|
||||
true, // isGlobal
|
||||
{[QGVAR(aimDownSightsBlur), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
true // isGlobal
|
||||
] call CBA_settings_fnc_init;
|
||||
|
||||
[
|
||||
@ -42,8 +74,7 @@
|
||||
[LSTRING(DisableNVGsWithSights_DisplayName), LSTRING(DisableNVGsWithSights_description)],
|
||||
localize LSTRING(Category),
|
||||
false, // default value
|
||||
true, // isGlobal
|
||||
{[QGVAR(disableNVGsWithSights), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
true // isGlobal
|
||||
] call CBA_settings_fnc_init;
|
||||
|
||||
[
|
||||
@ -51,6 +82,5 @@
|
||||
[LSTRING(shutterEffects_DisplayName), LSTRING(shutterEffects_description)],
|
||||
localize LSTRING(Category),
|
||||
true, // default value
|
||||
false, // isGlobal
|
||||
{[QGVAR(shutterEffects), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
false // isGlobal
|
||||
] call CBA_settings_fnc_init;
|
||||
|
@ -34,11 +34,3 @@ class CfgWeapons {
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
## 2. Events
|
||||
|
||||
To change night vision settings with code use:
|
||||
|
||||
`ace_nightvision_fogScaling = 0.5;` // More is more fog.
|
||||
|
||||
`ace_nightvision_effectScaling = 0.5;` // More is more apparent effects.
|
||||
|
Loading…
Reference in New Issue
Block a user