diff --git a/addons/scopes/XEH_postInit.sqf b/addons/scopes/XEH_postInit.sqf index e93c7ef3dc..651d522027 100644 --- a/addons/scopes/XEH_postInit.sqf +++ b/addons/scopes/XEH_postInit.sqf @@ -1,42 +1,115 @@ /* - * Author: KoffeinFlummi + * Author: KoffeinFlummi and CAA-Picard * - * Initializes vars needed for scope adjustment and watches for scope changes. + * Watches for scope changes. + * Defines key bindings * - * Arguments: - * None - * - * Return Value: - * None */ - #include "script_component.hpp" -GVAR(fadeScript) = scriptNull; +if !(hasInterface) exitWith {}; // show overlay after changing weapon/optic 0 spawn { - _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; - while {True} do { - waitUntil {[ACE_player, 0,0] call FUNC(canAdjustScope)}; - _layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false]; - sleep 3; - _layer cutFadeOut 2; + _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; + while {True} do { + waitUntil {[ACE_player, 0,0] call FUNC(canAdjustScope)}; + _layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false]; + sleep 3; + _layer cutFadeOut 2; - _weapon = currentWeapon ACE_player; - _optics = [ACE_player] call FUNC(getOptics); - waitUntil {sleep 0.05; !(_optics isEqualTo ([ACE_player] call FUNC(getOptics))) or (currentWeapon ACE_player != _weapon)}; - }; + _weapon = currentWeapon ACE_player; + _optics = [ACE_player] call FUNC(getOptics); + waitUntil {sleep 0.05; !(_optics isEqualTo ([ACE_player] call FUNC(getOptics))) or (currentWeapon ACE_player != _weapon)}; + }; }; // instantly hide when scoping in 0 spawn { - _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; - while {True} do { + _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; + while {True} do { waitUntil {sleep 0.05; cameraView == "GUNNER"}; if !(isNull GVAR(fadeScript)) then { - terminate GVAR(fadeScript); + terminate GVAR(fadeScript); + }; + _layer cutText ["", "PLAIN", 0]; }; - _layer cutText ["", "PLAIN", 0]; - }; }; + + +// Add keybinds +["ACE3", + localize "STR_ACE_Scopes_AdjustUp", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + [ACE_player] call FUNC(inventoryCheck); + if !([ACE_player, 0, 0.1] call FUNC(canAdjustScope)) exitWith {false}; + + // Statement + [ACE_player, 0, 0.1] call FUNC(adjustScope); + true + }, + [201, [false, false, false]], + false, + "keydown" +] call cba_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_Scopes_AdjustDown", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + [ACE_player] call FUNC(inventoryCheck); + if !([ACE_player, 0, -0.1] call FUNC(canAdjustScope)) exitWith {false}; + + // Statement + [ACE_player, 0, -0.1] call FUNC(adjustScope); + true + }, + [209, [false, false, false]], + false, + "keydown" +] call cba_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_Scopes_AdjustLeft", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + [ACE_player] call FUNC(inventoryCheck); + if !([ACE_player, -0.1, 0] call FUNC(canAdjustScope)) exitWith {false}; + + // Statement + [ACE_player, -0.1, 0] call FUNC(adjustScope); + true + }, + [209, [false, true, false]], + false, + "keydown" +] call cba_fnc_registerKeybind; + +["ACE3", + localize "adjustScopeRight", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + [ACE_player] call FUNC(inventoryCheck); + if !([ACE_player, 0.1, 0] call FUNC(canAdjustScope)) exitWith {false}; + + // Statement + [ACE_player, 0.1, 0] call FUNC(adjustScope); + true + }, + [201, [false, true, false]], + false, + "keydown" +] call cba_fnc_registerKeybind; diff --git a/addons/scopes/XEH_preInit.sqf b/addons/scopes/XEH_preInit.sqf index 7cd5d3ca1a..cc83dd6332 100644 --- a/addons/scopes/XEH_preInit.sqf +++ b/addons/scopes/XEH_preInit.sqf @@ -6,3 +6,5 @@ PREP(firedEH); PREP(getOptics); PREP(hideZeroing); PREP(inventoryCheck); + +GVAR(fadeScript) = scriptNull; diff --git a/addons/scopes/config.cpp b/addons/scopes/config.cpp index 7592ef06e9..9d2ddbeacb 100644 --- a/addons/scopes/config.cpp +++ b/addons/scopes/config.cpp @@ -13,39 +13,9 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" + #include "CfgSounds.hpp" + #include "CfgWeapons.hpp" -class ACE_Default_Keys { - class adjustScopeUp { - displayName = "$STR_ACE_Scopes_AdjustUp"; - condition = QUOTE([_player] call FUNC(inventoryCheck); [ARR_3(_player, 0, 0.1)] call FUNC(canAdjustScope);); - statement = QUOTE([ARR_3(_player, 0, 0.1)] call FUNC(adjustScope);); - allowHolding = 1; - key = 201; - shift = 0; - control = 0; - alt = 0; - }; - class adjustScopeDown: adjustScopeUp { - displayName = "$STR_ACE_Scopes_AdjustDown"; - condition = QUOTE([_player] call FUNC(inventoryCheck); [ARR_3(_player, 0, -0.1)] call FUNC(canAdjustScope);); - statement = QUOTE([ARR_3(_player, 0, -0.1)] call FUNC(adjustScope);); - key = 209; - }; - class adjustScopeLeft: adjustScopeUp { - displayName = "$STR_ACE_Scopes_AdjustLeft"; - condition = QUOTE([_player] call FUNC(inventoryCheck); [ARR_3(_player, -0.1, 0)] call FUNC(canAdjustScope);); - statement = QUOTE([ARR_3(_player, -0.1, 0)] call FUNC(adjustScope);); - key = 209; - control = 1; - }; - class adjustScopeRight: adjustScopeLeft { - displayName = "$STR_ACE_Scopes_AdjustRight"; - condition = QUOTE([_player] call FUNC(inventoryCheck); [ARR_3(_player, 0.1, 0)] call FUNC(canAdjustScope);); - statement = QUOTE([ARR_3(_player, 0.1, 0)] call FUNC(adjustScope);); - key = 201; - }; -}; - #include "RscTitles.hpp"