From f196f53ca1546589fec01956dcda848e1c4df265 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:40:43 +0200 Subject: [PATCH] Make visual sensor mode black and white --- addons/spike/CfgAmmo.hpp | 4 ++-- addons/spike/XEH_postInit.sqf | 19 +++++++++++++++++++ addons/spike/functions/fnc_camera_init.sqf | 2 +- .../functions/fnc_camera_setViewMode.sqf | 15 +++++++++++---- addons/spike/functions/fnc_mapHelperDraw.sqf | 12 ++++++++++++ 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/addons/spike/CfgAmmo.hpp b/addons/spike/CfgAmmo.hpp index 9b1793ba689..2378dd4743e 100644 --- a/addons/spike/CfgAmmo.hpp +++ b/addons/spike/CfgAmmo.hpp @@ -81,8 +81,8 @@ class CfgAmmo { alwaysDesignate = 0; // always designate canStopDesignating = 0; - enabledThermalTypes[] = { "white_hot_black_cold", "black_hot_white_cold" }; - initialThermalType = "white_hot_black_cold"; + enabledThermalTypes[] = { "normal", "white_hot_black_cold", "black_hot_white_cold" }; + initialThermalType = "normal"; class reticle { titleRsc = "ACE_guidance_spike"; diff --git a/addons/spike/XEH_postInit.sqf b/addons/spike/XEH_postInit.sqf index be0a83d083e..956de65a2b2 100644 --- a/addons/spike/XEH_postInit.sqf +++ b/addons/spike/XEH_postInit.sqf @@ -21,4 +21,23 @@ if (hasInterface) then { GVAR(activeCamera) = objNull; GVAR(projectileHashMap) = createHashMap; // used in the seeker to get the namespace for the associated projectile GVAR(launcherWeapons) = createHashMap; // Used to quickly determine whether the current weapon is a Spike launcher + + // Define the B&W ppEffect for the visual seeker view mode + GVAR(ppEffectBW) = ppEffectCreate ["ColorCorrections", 1500]; + GVAR(ppEffectBW) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [1, 1, 1, 0], [0.33, 0.33, 0.33, 0]]; + GVAR(ppEffectBW) ppEffectCommit 0; + GVAR(ppEffectBW) ppEffectEnable false; + + // Stores launcher view mode, to auto-set the missile's post-launch + GVAR(visionMode) = "normal"; + ace_player addEventHandler ["VisionModeChanged", { + params ["", "_visionMode", "_TIindex"]; + + if (cameraView isNotEqualTo "GUNNER") exitWith {}; + + if (_visionMode == 2) then { // If thermal, add specific thermal submode to index + _visionMode = _TIindex + 1; + }; + GVAR(visionMode) = ["normal", "white_hot_black_cold", "black_hot_white_cold"] select _visionMode; + }]; }; diff --git a/addons/spike/functions/fnc_camera_init.sqf b/addons/spike/functions/fnc_camera_init.sqf index 91df5ff66e1..b025f5206e6 100644 --- a/addons/spike/functions/fnc_camera_init.sqf +++ b/addons/spike/functions/fnc_camera_init.sqf @@ -48,7 +48,7 @@ if (_designating) then { _activeCameraNamespace setVariable [QGVAR(reticleData), _reticleData]; _shooter setVariable [QGVAR(missileCamera), _activeCameraNamespace]; _activeCameraNamespace setVariable [QGVAR(shooter), _shooter]; -[_activeCameraNamespace, _initialThermalType] call FUNC(camera_setViewMode); +[_activeCameraNamespace, GVAR(visionMode)] call FUNC(camera_setViewMode); private _pos = getPosASL _projectile; diff --git a/addons/spike/functions/fnc_camera_setViewMode.sqf b/addons/spike/functions/fnc_camera_setViewMode.sqf index 5e7522efcea..9a3a797fe6a 100644 --- a/addons/spike/functions/fnc_camera_setViewMode.sqf +++ b/addons/spike/functions/fnc_camera_setViewMode.sqf @@ -20,6 +20,7 @@ params ["_cameraNamespace", "_viewMode"]; private _userInCamera = [] call FUNC(camera_userInCamera); if (_userInCamera) then { + GVAR(ppEffectBW) ppEffectEnable false; camUseNVG false; false setCamUseTI (_cameraNamespace getVariable [QGVAR(tiMode), 0]); }; @@ -29,11 +30,17 @@ if (_thermalMode > 1) then { if (_userInCamera) then { true setCamUseTI (_thermalMode - 2); }; -}; -if (_thermalMode == 1) then { - if (_userInCamera) then { - camUseNVG true; +} else { + if (_thermalMode == 1) then { + if (_userInCamera) then { + camUseNVG true; + }; + } else { + GVAR(ppEffectBW) ppEffectEnable true; }; }; _cameraNamespace setVariable [QGVAR(tiMode), _thermalMode - 2]; _cameraNamespace setVariable [QGVAR(tiModeString), _viewMode]; + +private _thermalIndex = (_cameraNamespace getVariable [QGVAR(thermalTypes), []]) findIf { _viewMode isEqualTo _x }; +_cameraNamespace setVariable [QGVAR(currentTIModeIndex), _thermalIndex]; diff --git a/addons/spike/functions/fnc_mapHelperDraw.sqf b/addons/spike/functions/fnc_mapHelperDraw.sqf index 4ff6e3f2cd0..4f9bd99cd3a 100644 --- a/addons/spike/functions/fnc_mapHelperDraw.sqf +++ b/addons/spike/functions/fnc_mapHelperDraw.sqf @@ -45,6 +45,17 @@ if (isNil QGVAR(arguments)) then { if (cameraView isEqualTo "GUNNER") then { GVAR(arguments) set [0, diag_frameNo]; + private _visionMode = currentVisionMode ace_player; + // If the current mode is normal, but thermal was cached, recover to normal. This happens when selecting a thermal mode, dropping and picking the launcher back up. + if (GVAR(visionMode) != "normal" && _visionMode == 0) then { GVAR(visionMode) = "normal"; }; + + // Toggle Black&White effect depending on vision mode + if (_visionMode == 0) then { + GVAR(ppEffectBW) ppEffectEnable true; + } else { + GVAR(ppEffectBW) ppEffectEnable false; + }; + __SPIKE_RETICLE ctrlShow true; GVAR(arguments) params ["", "_targetPosition"]; @@ -94,6 +105,7 @@ if (cameraView isEqualTo "GUNNER") then { __SPIKE_RETICLE ctrlCommit 0; } else { + GVAR(ppEffectBW) ppEffectEnable false; __SPIKE_RETICLE ctrlShow false; (__SPIKE_DISPLAY displayCtrl 241000) ctrlShow false; };