From c88e1abd0e925acbb3b1c7d0c40f642d3ff51e7b Mon Sep 17 00:00:00 2001
From: Fabio Schick <58027418+mrschick@users.noreply.github.com>
Date: Tue, 26 Mar 2024 13:59:48 +0100
Subject: [PATCH] Weather - More permissive wind info indicator + auto-enabling
when throwing grenades (#9820)
* More permissive displaying of Wind Info
* Temporary Wind Info while throwing Grenades
* Add Temporary Wind Info Setting
* Safer reading of EGVAR from addon that may not be loaded
* Show Wind Info only in Static Vehicles
* Improve Exclusion Check
Co-Authored-By: Grim <69561145+LinkIsGrim@users.noreply.github.com>
* Improve Abort Checks on Keybind Statements
Co-Authored-By: Grim <69561145+LinkIsGrim@users.noreply.github.com>
* Raise eyePos when inside Static Weapon
---------
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
---
addons/advanced_throwing/XEH_postInit.sqf | 3 +++
.../functions/fnc_exitThrowMode.sqf | 6 ++++++
.../functions/fnc_prepare.sqf | 9 +++++++++
addons/advanced_throwing/initSettings.inc.sqf | 8 ++++++++
addons/advanced_throwing/stringtable.xml | 10 ++++++++++
addons/weather/XEH_postInit.sqf | 7 +++++--
.../weather/functions/fnc_displayWindInfo.sqf | 18 +++++++++++++++---
7 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/addons/advanced_throwing/XEH_postInit.sqf b/addons/advanced_throwing/XEH_postInit.sqf
index 96b0fbb09b4..1fc9400e996 100644
--- a/addons/advanced_throwing/XEH_postInit.sqf
+++ b/addons/advanced_throwing/XEH_postInit.sqf
@@ -7,6 +7,9 @@ GVAR(ammoEventHandlers) = createHashMap;
// Exit on HC
if (!hasInterface) exitWith {};
+// Temporary Wind Info indication
+GVAR(tempWindInfo) = false;
+
// Ammo/Magazines look-up hash for correctness of initSpeed
GVAR(ammoMagLookup) = call CBA_fnc_createNamespace;
{
diff --git a/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf b/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf
index 744a6d7aae3..3b88564eaee 100644
--- a/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf
+++ b/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf
@@ -53,6 +53,12 @@ _unit setVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT];
// Remove controls hint (check if ever enabled is inside the function)
call EFUNC(interaction,hideMouseHint);
+// Hide wind info after throw, if it was temporarily enabled for the throw
+if (GVAR(tempWindInfo)) then {
+ EGVAR(weather,WindInfo) = false;
+ GVAR(tempWindInfo) = false;
+};
+
// Remove throw action
[_unit, "DefaultAction", _unit getVariable [QGVAR(throwAction), -1]] call EFUNC(common,removeActionEventHandler);
diff --git a/addons/advanced_throwing/functions/fnc_prepare.sqf b/addons/advanced_throwing/functions/fnc_prepare.sqf
index 070870879b1..7926c2c8649 100644
--- a/addons/advanced_throwing/functions/fnc_prepare.sqf
+++ b/addons/advanced_throwing/functions/fnc_prepare.sqf
@@ -18,6 +18,15 @@
params ["_unit"];
TRACE_1("params",_unit);
+// Temporarily enable wind info, to aid in throwing smoke grenades effectively
+if (
+ GVAR(enableTempWindInfo) &&
+ {!(missionNamespace getVariable [QEGVAR(weather,WindInfo), false])}
+) then {
+ [] call EFUNC(weather,displayWindInfo);
+ GVAR(tempWindInfo) = true;
+};
+
// Select next throwable if one already in hand
if (_unit getVariable [QGVAR(inHand), false]) exitWith {
TRACE_1("inHand",_unit);
diff --git a/addons/advanced_throwing/initSettings.inc.sqf b/addons/advanced_throwing/initSettings.inc.sqf
index d4ebe149185..d8396637c57 100644
--- a/addons/advanced_throwing/initSettings.inc.sqf
+++ b/addons/advanced_throwing/initSettings.inc.sqf
@@ -40,3 +40,11 @@ private _category = format ["ACE %1", localize LSTRING(Category)];
true,
1
] call CBA_fnc_addSetting;
+
+[
+ QGVAR(enableTempWindInfo), "CHECKBOX",
+ [LSTRING(EnableTempWindInfo_DisplayName), LSTRING(EnableTempWindInfo_Description)],
+ _category,
+ true,
+ 0
+] call CBA_fnc_addSetting;
diff --git a/addons/advanced_throwing/stringtable.xml b/addons/advanced_throwing/stringtable.xml
index ec2354a2c03..a79fe7d0a4c 100644
--- a/addons/advanced_throwing/stringtable.xml
+++ b/addons/advanced_throwing/stringtable.xml
@@ -185,6 +185,16 @@
Permite que arremessáveis fixados em objetos sejam pegos.
Zapíná schopnost zvednutí předmětů z objektů ke kterým jsou připnuté.
+
+ Show Temporary Wind Info
+ Zeige temporäre Windinformationen
+ Mostra informazioni sul vento temporaneamente
+
+
+ Temporarily display Wind Info while throwing, to aid in placing smoke grenades effectively.
+ Zeige während des werfens Windinformationen an, um Rauchgranaten effektiver zu platzieren.
+ Mostra le informazioni sul vento durante il lancio di granate, facilitando il piazzamento ottimale di fumogeni.
+
Prepare/Change Throwable
Preparar/Cambiar objetos lanzables
diff --git a/addons/weather/XEH_postInit.sqf b/addons/weather/XEH_postInit.sqf
index 51350226e1a..98909dc2d40 100644
--- a/addons/weather/XEH_postInit.sqf
+++ b/addons/weather/XEH_postInit.sqf
@@ -1,10 +1,12 @@
#include "script_component.hpp"
GVAR(WindInfo) = false;
+
["ACE3 Common", QGVAR(WindInfoKey), localize LSTRING(WindInfoKeyToggle),
{
// Conditions: canInteract
- if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
+ if !([ACE_player, ACE_player, ["isNotDragging", "isNotCarrying", "isNotSitting", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
+ if !(isNull objectParent ACE_player || {objectParent ACE_player isKindOf "StaticWeapon"}) exitWith {false};
// Statement
[] call FUNC(displayWindInfo);
@@ -15,7 +17,8 @@ GVAR(WindInfo) = false;
["ACE3 Common", QGVAR(WindInfoKey_hold), localize LSTRING(WindInfoKeyHold),
{
// Conditions: canInteract
- if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
+ if !([ACE_player, ACE_player, ["isNotDragging", "isNotCarrying", "isNotSitting", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
+ if !(isNull objectParent ACE_player || {objectParent ACE_player isKindOf "StaticWeapon"}) exitWith {false};
// Statement
[] call FUNC(displayWindInfo);
diff --git a/addons/weather/functions/fnc_displayWindInfo.sqf b/addons/weather/functions/fnc_displayWindInfo.sqf
index 23a87ecbf4f..aeb7d580ae9 100644
--- a/addons/weather/functions/fnc_displayWindInfo.sqf
+++ b/addons/weather/functions/fnc_displayWindInfo.sqf
@@ -35,7 +35,13 @@ TRACE_1("Starting Wind Info PFEH",GVAR(WindInfo));
disableSerialization;
params ["", "_pfID"];
- if ((!GVAR(WindInfo)) || {!([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith))}) exitWith {
+ // Allow wind indicator inside static weapons
+ private _playerInStaticWeapon = objectParent ACE_Player isKindOf "StaticWeapon";
+
+ if (
+ (!GVAR(WindInfo)) ||
+ {!([ACE_player, ACE_player, ["notOnMap", "isNotDragging", "isNotCarrying", "isNotSitting"]] call EFUNC(common,canInteractWith)) && !(_playerInStaticWeapon)}
+ ) exitWith {
TRACE_1("Ending Wind Info PFEH",GVAR(WindInfo));
GVAR(WindInfo) = false;
(["RscWindIntuitive"] call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
@@ -45,12 +51,18 @@ TRACE_1("Starting Wind Info PFEH",GVAR(WindInfo));
//Keeps the display open:
(["RscWindIntuitive"] call BIS_fnc_rscLayer) cutRsc ["RscWindIntuitive", "PLAIN", 1, false];
+ private _playerEyePos = eyePos ACE_Player;
+ if (_playerInStaticWeapon) then {
+ // Raise eyePos by 1 meter if player is in a static weapon, to prevent wind from being blocked by the open vehicle
+ _playerEyePos = _playerEyePos vectorAdd [0, 0, 1];
+ };
+
private _windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
// With wind gradient
- [eyePos ACE_player, true, true, true] call FUNC(calculateWindSpeed);
+ [_playerEyePos, true, true, true] call FUNC(calculateWindSpeed);
} else {
// Without wind gradient
- [eyePos ACE_player, false, true, true] call FUNC(calculateWindSpeed);
+ [_playerEyePos, false, true, true] call FUNC(calculateWindSpeed);
};