Skip to content

Commit

Permalink
Weather - More permissive wind info indicator + auto-enabling when th…
Browse files Browse the repository at this point in the history
…rowing 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 <[email protected]>

* Improve Abort Checks on Keybind Statements

Co-Authored-By: Grim <[email protected]>

* Raise eyePos when inside Static Weapon

---------

Co-authored-by: Grim <[email protected]>
  • Loading branch information
mrschick and LinkIsGrim authored Mar 26, 2024
1 parent cee187a commit c88e1ab
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 5 deletions.
3 changes: 3 additions & 0 deletions addons/advanced_throwing/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
{
Expand Down
6 changes: 6 additions & 0 deletions addons/advanced_throwing/functions/fnc_exitThrowMode.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 9 additions & 0 deletions addons/advanced_throwing/functions/fnc_prepare.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions addons/advanced_throwing/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 10 additions & 0 deletions addons/advanced_throwing/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@
<Portuguese>Permite que arremessáveis fixados em objetos sejam pegos.</Portuguese>
<Czech>Zapíná schopnost zvednutí předmětů z objektů ke kterým jsou připnuté.</Czech>
</Key>
<Key ID="STR_ACE_Advanced_Throwing_EnableTempWindInfo_DisplayName">
<English>Show Temporary Wind Info</English>
<German>Zeige temporäre Windinformationen</German>
<Italian>Mostra informazioni sul vento temporaneamente</Italian>
</Key>
<Key ID="STR_ACE_Advanced_Throwing_EnableTempWindInfo_Description">
<English>Temporarily display Wind Info while throwing, to aid in placing smoke grenades effectively.</English>
<German>Zeige während des werfens Windinformationen an, um Rauchgranaten effektiver zu platzieren.</German>
<Italian>Mostra le informazioni sul vento durante il lancio di granate, facilitando il piazzamento ottimale di fumogeni.</Italian>
</Key>
<Key ID="STR_ACE_Advanced_Throwing_Prepare">
<English>Prepare/Change Throwable</English>
<Spanish>Preparar/Cambiar objetos lanzables</Spanish>
Expand Down
7 changes: 5 additions & 2 deletions addons/weather/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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);
Expand Down
18 changes: 15 additions & 3 deletions addons/weather/functions/fnc_displayWindInfo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -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);
};


Expand Down

0 comments on commit c88e1ab

Please sign in to comment.