Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACE nightvision edits, ffv nvg overlay fix #6635

Closed
wants to merge 3 commits into from
Closed
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
18 changes: 15 additions & 3 deletions addons/nightvision/functions/fnc_pfeh.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ if (!GVAR(running)) then {
// Scale Border / Hex
BEGIN_COUNTER(borderScaling);
private _scale = (call EFUNC(common,getZoom)) * 1.12513;
if (GVAR(source) == "gun-hmd") then {
_scale = _scale * 1.2;
};
if (!(GVAR(defaultPositionBorder) isEqualTo [])) then {
// Prevents issues when "zooming out" on ultra wide monitors - The square mask would be narrower than the screen
if (((GVAR(defaultPositionBorder) select 2) * _scale) < safeZoneW) then {
Expand Down Expand Up @@ -88,7 +91,11 @@ if (CBA_missionTime < GVAR(nextEffectsUpdate)) then {
if (currentWeapon ACE_player == primaryWeapon ACE_player) exitWith {_blurFinal = _blurFinal * linearConversion [0, 1, GVAR(aimDownSightsBlur), 1, ST_NVG_CAMERA_BLUR_SIGHTS_RIFLE]}; // Rifles are bad
if (currentWeapon ACE_player == handgunWeapon ACE_player) exitWith {_blurFinal = _blurFinal * linearConversion [0, 1, GVAR(aimDownSightsBlur), 1, ST_NVG_CAMERA_BLUR_SIGHTS_PISTOL]}; // Pistols aren't so bad
};


//Modify blur if using HMDs while on open sight mounted weapon, i.e. techy, M2 turret from RHS.
if (GVAR(source) == "gun-hmd") then {_blurFinal = _blurFinal * linearConversion [0, 1, GVAR(aimDownSightsBlur), 1, ST_NVG_CAMERA_BLUR_SIGHTS_RIFLE]};


// Scale general effects based on ace_nightvision_effectScaling setting
private _radialBlurPower = 0.0025 * GVAR(effectScaling);
_brightFinal = linearConversion [0, 1, GVAR(effectScaling), 1, _brightFinal];
Expand Down Expand Up @@ -144,8 +151,13 @@ if (CBA_missionTime < GVAR(nextEffectsUpdate)) then {

// Modify local fog:
if (GVAR(fogScaling) > 0) then {
if (((vehicle ACE_player) != ACE_player) && {(vehicle ACE_player) isKindOf "Air"}) then { // For flying in particular, can refine nicer later.
_fogApply = _fogApply * ST_NVG_AIR_FOG_MULTIPLIER;
switch GVAR(source) do {
case "air" : {_fogApply = _fogApply * GVAR(airFogMultiplier);};
case "bino" : {_fogApply = _fogApply * GVAR(binoFogMultiplier);};
case "car" : {_fogApply = _fogApply * GVAR(carFogMultiplier);};
case "static" : {_fogApply = _fogApply * GVAR(staticFogMultiplier);};
case "tank" : {_fogApply = _fogApply * GVAR(tankFogMultiplier);};
default {};
};
_fogApply = linearConversion [0, 1, GVAR(priorFog) select 0, (GVAR(fogScaling) * _fogApply), 1]; // mix in old fog if present
GVAR(nvgFog) = [_fogApply, 0, 0];
Expand Down
156 changes: 122 additions & 34 deletions addons/nightvision/functions/fnc_refreshGoggleType.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,14 @@ private _nvgGen = 3;
private _blurRadius = -1;

if (alive ACE_player) then {
if (((vehicle ACE_player) == ACE_player) || {
// Test if we are using player's nvg or if sourced from vehicle:

private _currentVehicle = vehicle ACE_player;
private _vehConfig = configFile >> "CfgVehicles" >> (typeOf _currentVehicle);

if (cameraView != "GUNNER") exitWith {true}; // asume hmd usage outside of gunner view

if (ACE_player == (driver _currentVehicle)) exitWith {
!("NVG" in getArray (_vehConfig >> "ViewOptics" >> "visionMode"));
};
private _result = true;
private _turret = ACE_player call CBA_fnc_turretPath;
private _turretConfig = [_currentVehicle, _turret] call CBA_fnc_getTurret;

// Seems to cover things like the offroad technical
if ((isNumber (_turretConfig >> "optics")) && {(getNumber (_turretConfig >> "optics")) == 0}) exitWith {true};

private _turretConfigOpticsIn = _turretConfig >> "OpticsIn";
if (isClass _turretConfigOpticsIn) then {
for "_index" from 0 to (count _turretConfigOpticsIn - 1) do {
if ("NVG" in getArray (_turretConfigOpticsIn select _index >> "visionMode")) exitWith {_result = false};
};
} else {
// No OpticsIn usualy means RCWS, still need to test on more vehicles
_result = false;
};
_result
}) then {
if ((cameraView == "GUNNER") && {currentWeapon ACE_player != ""} && {binocular ACE_player == currentWeapon ACE_player}) exitWith {
private _vehicle = vehicle ACE_player;
if (_vehicle == ACE_player) exitWith {
if ((cameraView == "GUNNER") && {currentWeapon _unit != ""} && {binocular ACE_player == currentWeapon ACE_player}) exitWith {
TRACE_1("souce: binocular",binocular ACE_player); // Source is from player's binocular (Rangefinder/Vector21bNite)
private _config = configFile >> "CfgWeapons" >> (binocular ACE_player);
if (isNumber (_config >> QGVAR(generation))) then {_nvgGen = getNumber (_config >> QGVAR(generation));};
GVAR(source) = "bino";
};

TRACE_1("source: hmd",GVAR(playerHMD)); // Source is player's HMD (or possibly a NVG scope, but no good way to detect that)
GVAR(source) = "hmd";
private _config = configFile >> "CfgWeapons" >> GVAR(playerHMD);
if (!isClass _config) exitWith {};

Expand All @@ -74,14 +46,126 @@ if (alive ACE_player) then {
if (isNumber (_config >> QGVAR(bluRadius))) then {_blurRadius = getNumber (_config >> QGVAR(bluRadius));};
};
if (isNumber (_config >> QGVAR(generation))) then {_nvgGen = getNumber (_config >> QGVAR(generation));};
};

if (_vehicle isKindOf "Air") exitWith {
TRACE_1("source: vehicle - defaults",typeOf _vehicle);
GVAR(source) = "air";
};

if (_vehicle isKindOf "Tank") exitWith {
if (cameraView == "GUNNER") then {
if ([ACE_player] call CBA_fnc_isTurnedOut) then {
if ((currentWeapon ACE_player != "") && {binocular ACE_player == currentWeapon ACE_player}) then {
TRACE_1("souce: binocular",binocular ACE_player);
GVAR(source) = "bino";
} else {
TRACE_1("source: hmd",GVAR(playerHMD));
GVAR(source) = "hmd";
};
} else {
GVAR(source) = "tank";
TRACE_1("source: vehicle - defaults",typeOf _vehicle);
};
} else {
TRACE_1("source: hmd",GVAR(playerHMD));
GVAR(source) = "hmd";
};
};

//If nothing else has exited by now, player must be in some other vehicle like a static weapon/car.
//Check camera view. If not in gunner, use hmds.
if (cameraView == "GUNNER") then {
//Check for turned out, using binos/personal nvgs.
if ([ACE_player] call CBA_fnc_isTurnedOut) then {
if ((currentWeapon ACE_player != "") && {binocular ACE_player == currentWeapon ACE_player}) then {
TRACE_1("souce: binocular",binocular ACE_player);
GVAR(source) = "bino";
} else {
TRACE_1("source: hmd",GVAR(playerHMD));
GVAR(source) = "hmd";
};
} else {

private _turret = ACE_player call CBA_fnc_turretPath;
private _turretConfig = [_vehicle, _turret] call CBA_fnc_getTurret;

//Check if turret has its own source of NV. If not, use hmds. Used for techies.
if ((isNumber (_turretConfig >> "optics")) && {(getNumber (_turretConfig >> "optics")) == 0}) exitWith {
GVAR(source) = "gun-hmd";
TRACE_1("source: hmd on turret",GVAR(playerHMD));
};
//If static weapon, check if turret has built in nightvision. To work out when player is using HMD NV, e.g. m2 browning machinegun static weapon.
if (_vehicle iskindof "StaticWeapon") exitWith {
if ((isArray (_turretConfig >> "OpticsIn" >> "ViewOptics" >> "VisionMode")) && {("NVG" in (getarray (_turretConfig >> "OpticsIn" >> "ViewOptics" >> "VisionMode")))} ) then {
GVAR(source) = "static";
TRACE_1("source: static - defaults",typeOf _vehicle);
} else {
GVAR(source) = "gun-hmd";
TRACE_1("source: hmd on turret",GVAR(playerHMD));
};

};
if (_vehicle iskindof "Car") exitWith {
GVAR(source) = "car";
TRACE_1("source: car",typeOf _vehicle);
};
TRACE_1("source: undefined vehicle - defaults",typeOf _vehicle);
};
} else {
TRACE_1("source: vehicle - defaults",typeOf vehicle ACE_player);
TRACE_1("source: hmd",GVAR(playerHMD));
GVAR(source) = "hmd";
};
};

//Note: Don't care about car/static/UAV sources at this time, only used for identifying them in the fnc_pfeh.sqf for fog multiplier. They have their own overlays.
switch GVAR(source) do {
case "hmd" : {
private _config = configFile >> "CfgWeapons" >> GVAR(playerHMD);
if (!isClass _config) exitWith {};
// Only use border if there is no modelOptics
if ((getText (_config >> "modelOptics")) == "") then {
_borderImage = getText (_config >> QGVAR(border));
_eyeCups = ((getNumber (_config >> QGVAR(eyeCups))) == 1);
_hideHex = (getNumber (_config >> QGVAR(hideHex))) == 1;
if (isNumber (_config >> QGVAR(bluRadius))) then {_blurRadius = getNumber (_config >> QGVAR(bluRadius));};
};
if (isNumber (_config >> QGVAR(generation))) then {_nvgGen = getNumber (_config >> QGVAR(generation));};
};
//Differentiated here so can scale nvg overlay and detect turret ironsight blurring in fnc_pfeh.sqf.
case "gun-hmd" : {
private _config = configFile >> "CfgWeapons" >> GVAR(playerHMD);
if (!isClass _config) exitWith {};
if ((getText (_config >> "modelOptics")) == "") then {
_borderImage = getText (_config >> QGVAR(border));
_eyeCups = ((getNumber (_config >> QGVAR(eyeCups))) == 1);
_hideHex = (getNumber (_config >> QGVAR(hideHex))) == 1;
if (isNumber (_config >> QGVAR(bluRadius))) then {_blurRadius = getNumber (_config >> QGVAR(bluRadius));};
};
if (isNumber (_config >> QGVAR(generation))) then {_nvgGen = getNumber (_config >> QGVAR(generation));};
};
case "bino" : {
private _config = configFile >> "CfgWeapons" >> (binocular ACE_player);
if (!isClass _config) exitWith {};
if (isNumber (_config >> QGVAR(generation))) then {_nvgGen = getNumber (_config >> QGVAR(generation));};
_borderImage = getText (_config >> QGVAR(border));
};
case "air" : {
private _config = configFile >> "CfgWeapons" >> GVAR(playerHMD);
_borderImage = getText (_config >> QGVAR(border));
_eyeCups = ((getNumber (_config >> QGVAR(eyeCups))) == 1);
_hideHex = (getNumber (_config >> QGVAR(hideHex))) == 1;
if (isNumber (_config >> QGVAR(bluRadius))) then {_blurRadius = getNumber (_config >> QGVAR(bluRadius));};
if (isNumber (_config >> QGVAR(generation))) then {_nvgGen = getNumber (_config >> QGVAR(generation));};
};
};




#ifdef DEBUG_MODE_FULL
systemChat format ["NVG Refresh - Border: %1", _borderImage];
systemChat format ["NVG Source: %1",GVAR(source)];
systemChat format ["EyeCups: %1, HideHex %2, NVGen: %3, BluRadius: %4", _eyeCups, _hideHex, _nvgGen, _blurRadius];
#endif

Expand All @@ -90,6 +174,10 @@ GVAR(nvgGeneration) = _nvgGen;

// Setup border and hex image based on NVG config:
private _scale = (call EFUNC(common,getZoom)) * 1.12513;
//Forced a bit of nvg overlay scaling when player in turret ironsight but using their hmd.
if (GVAR(source) == "gun-hmd") then {
_scale = _scale * 1.2;
};

private _borderImageCtrl = (uiNamespace getVariable QGVAR(titleDisplay)) displayCtrl 1001;
private _trippleHeadLeft = (uiNamespace getVariable QGVAR(titleDisplay)) displayCtrl 1002;
Expand Down
45 changes: 45 additions & 0 deletions addons/nightvision/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,48 @@
false, // isGlobal
{[QGVAR(shutterEffects), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_settings_fnc_init;

[
QGVAR(airFogMultiplier), "SLIDER",
[LSTRING(airFogMultiplier_DisplayName),LSTRING(airFogMultiplier_Description)],
localize LSTRING(Category),
[0,1,0.5,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal
{[QGVAR(airFogMultiplier), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_settings_fnc_init;

[
QGVAR(binoFogMultiplier), "SLIDER",
[LSTRING(binoFogMultiplier_DisplayName),LSTRING(binoFogMultiplier_Description)],
localize LSTRING(Category),
[0,1,0.5,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal
{[QGVAR(binoFogMultiplier), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_settings_fnc_init;

[
QGVAR(carFogMultiplier), "SLIDER",
[LSTRING(carFogMultiplier_DisplayName),LSTRING(carFogMultiplier_Description)],
localize LSTRING(Category),
[0,1,0.5,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal
{[QGVAR(carFogMultiplier), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_settings_fnc_init;

[
QGVAR(staticFogMultiplier), "SLIDER",
[LSTRING(staticFogMultiplier_DisplayName),LSTRING(staticFogMultiplier_Description)],
localize LSTRING(Category),
[0,1,0.5,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal
{[QGVAR(staticFogMultiplier), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_settings_fnc_init;

[
QGVAR(tankFogMultiplier), "SLIDER",
[LSTRING(tankFogMultiplier_DisplayName),LSTRING(tankFogMultiplier_Description)],
localize LSTRING(Category),
[0,1,0.5,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal
{[QGVAR(tankFogMultiplier), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_settings_fnc_init;
30 changes: 30 additions & 0 deletions addons/nightvision/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,36 @@
<Chinesesimp>枪械开火时产生瞬间快门效果</Chinesesimp>
<Chinese>槍開火時瞬間產生快門效果</Chinese>
<Italian>Effetto lampeggiante dato dal lampo dello sparo</Italian>
</Key>
<Key ID="STR_ACE_NightVision_airFogMultiplier_DisplayName">
<English>Air Fog Multiplier</English>
</Key>
<Key ID="STR_ACE_NightVision_airFogMultiplier_Description">
<English>Fog multiplier when in plane/helicopter.</English>
</Key>
<Key ID="STR_ACE_NightVision_binoFogMultiplier_DisplayName">
<English>Binoculars Fog Multiplier</English>
</Key>
<Key ID="STR_ACE_NightVision_binoFogMultiplier_Description">
<English>Fog multiplier when looking through NV capable binoculars.</English>
</Key>
<Key ID="STR_ACE_NightVision_carFogMultiplier_DisplayName">
<English>Car Fog Multiplier</English>
</Key>
<Key ID="STR_ACE_NightVision_carFogMultiplier_Description">
<English>Fog multiplier when in NV capable car turret.</English>
</Key>
<Key ID="STR_ACE_NightVision_staticFogMultiplier_DisplayName">
<English>Static Weapon Fog Multiplier</English>
</Key>
<Key ID="STR_ACE_NightVision_staticFogMultiplier_Description">
<English>Fog multiplier when in NV capable static weapon.</English>
</Key>
<Key ID="STR_ACE_NightVision_tankFogMultiplier_DisplayName">
<English>Tank Fog Multiplier</English>
</Key>
<Key ID="STR_ACE_NightVision_tankFogMultiplier_Description">
<English>Fog multiplier when in NV capable tank turret.</English>
</Key>
</Package>
</Project>