Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/nightvision/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ PREP(onVisionModeChanged);
PREP(pfeh);
PREP(refreshGoggleType);
PREP(scaleCtrl);
PREP(scotopicEffects);
PREP(setupDisplayEffects);
PREP(statTextStatement_NVGeneration);
20 changes: 19 additions & 1 deletion addons/nightvision/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ GVAR(ppeffectRadialBlur) = -1;
GVAR(ppeffectColorCorrect) = -1;
GVAR(ppeffectBlur) = -1;

GVAR(scotopicCC) = -1;

GVAR(isUsingMagnification) = false;

["CBA_settingsInitialized", {
TRACE_4("settingsInitialized",GVAR(disableNVGsWithSights),GVAR(fogScaling),GVAR(noiseScaling),GVAR(effectScaling));
TRACE_5("settingsInitialized",GVAR(disableNVGsWithSights),GVAR(fogScaling),GVAR(noiseScaling),GVAR(effectScaling),GVAR(scotopicEffects));

["visionMode", LINKFUNC(onVisionModeChanged), false] call CBA_fnc_addPlayerEventHandler;
["loadout", LINKFUNC(onLoadoutChanged), true] call CBA_fnc_addPlayerEventHandler;
Expand All @@ -46,7 +48,23 @@ GVAR(isUsingMagnification) = false;
[false] call FUNC(setupDisplayEffects);
[true] call FUNC(setupDisplayEffects);
};
if (GVAR(scotopicCC) > -1) then {
ppEffectDestroy GVAR(scotopicCC);
GVAR(scotopicCC) = ppEffectCreate ["colorCorrections", 1502];
GVAR(scotopicCC) ppEffectForceInNVG false;
};
}];

if (GVAR(scotopicEffects)) then {
GVAR(scoTestToggle) = true;
["test", "test", "test", {
GVAR(scoTestToggle) = !GVAR(scoTestToggle);
}, {false}, [0x21, [false, false, false]], false] call CBA_fnc_addKeybind; // F Key

GVAR(scotopicCC) = ppEffectCreate ["colorCorrections", 1502];
GVAR(scotopicCC) ppEffectForceInNVG false;
[0] call FUNC(scotopicEffects); // self-loops
};
}] call CBA_fnc_addEventHandler;


Expand Down
54 changes: 54 additions & 0 deletions addons/nightvision/functions/fnc_scotopicEffects.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Adjusts color and luminosity when in dark conditions.
* Simulates rod and cones vision by decreasing color intensity when dark.
*
* Arguments:
* 0: Last Intensity <NUMBER>
*
* Return Value:
* None
*
* Example:
* [0] call ace_nightvision_fnc_scotopicEffects
*
* Public: No
*/
#define TIME_INTERVAL 0.333
private _unit = ACE_player;

if (EGVAR(common,OldIsCamera) || {!alive _unit} || {currentVisionMode _unit != 0}) exitWith {
GVAR(scotopicCC) ppEffectEnable false;
[FUNC(scotopicEffects), [0], 0.1] call CBA_fnc_waitAndExecute;
};

(getLightingAt _unit) params ["", "_ambientLight", "", "_dynamiclight"];
private _light = _ambientLight + 2 * _dynamiclight;

#ifdef DEBUG_MODE_FULL
systemChat format ["[%1, %2] = %3", [_ambientLight,1,1] call CBA_fnc_formatNumber, [_dynamiclight,1,1] call CBA_fnc_formatNumber, _light];
#endif

if ((_light > 50) && {(param [0, 0]) == 0}) exitWith { // make sure we've faded out before disabling
GVAR(scotopicCC) ppEffectEnable false;
// if it's day, we can go to sleep for a long while (won't be responsive to scripted-skipTime)
[FUNC(scotopicEffects), [0], [TIME_INTERVAL, 60] select (_ambientLight > 100)] call CBA_fnc_waitAndExecute;
};

private _intensity = if (_light > 5) then {
linearConversion [5, 50, _light, 0.3, 0, true]; // Mesopic
} else {
linearConversion [0, 6, _light, 0.6, 0.3, true]; // Scotopic
};

#ifdef DEBUG_MODE_FULL
systemChat format ["@%1", _intensity];
#endif

GVAR(scotopicCC) ppEffectEnable GVAR(scoTestToggle); // true;
// "players like the night blue"
GVAR(scotopicCC) ppEffectAdjust [1,1,0,[1,1,1,0],[_intensity*.95,_intensity*.95,_intensity*1.1,1-_intensity],[0.15, 1.0, 1.50, 1]];
GVAR(scotopicCC) ppEffectCommit TIME_INTERVAL;

[FUNC(scotopicEffects), [_intensity], TIME_INTERVAL] call CBA_fnc_waitAndExecute;
8 changes: 8 additions & 0 deletions addons/nightvision/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,11 @@
true, // default value
false // isGlobal
] call CBA_fnc_addSetting;

[
QGVAR(scotopicEffects), "CHECKBOX",
[LSTRING(scotopicEffects_DisplayName), LSTRING(scotopicEffects_description)],
localize LSTRING(Category),
false, // default value
true // isGlobal
] call CBA_fnc_addSetting;
6 changes: 6 additions & 0 deletions addons/nightvision/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -538,5 +538,11 @@
<Polish>Gen %1</Polish>
<German>Gen %1</German>
</Key>
<Key ID="STR_ACE_NightVision_scotopicEffects_DisplayName">
<English>Scotopic Effects</English>
</Key>
<Key ID="STR_ACE_NightVision_scotopicEffects_description">
<English>Adjusts color and luminosity when in dark conditions. Simulates rod and cones vision by decreasing color intensity when dark.</English>
</Key>
</Package>
</Project>