From 7b8414acde8f5cd9e3e32bf7a09b4f0081e2c392 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:44:15 +0200 Subject: [PATCH] Bring component up to date, use user EH instead --- addons/pronelauncher/$PBOPREFIX$ | 2 +- addons/pronelauncher/CfgEventHandlers.hpp | 15 +--- addons/pronelauncher/CfgMovesMaleSdr.hpp | 8 +-- addons/pronelauncher/XEH_PREP.hpp | 1 - addons/pronelauncher/XEH_postInit.sqf | 70 +++++++++++++++++++ addons/pronelauncher/XEH_preInit.sqf | 11 --- addons/pronelauncher/XEH_preStart.sqf | 3 - .../pronelauncher/functions/fnc_onKeyDown.sqf | 57 --------------- .../functions/script_component.hpp | 1 - addons/pronelauncher/script_component.hpp | 4 +- 10 files changed, 78 insertions(+), 94 deletions(-) delete mode 100644 addons/pronelauncher/XEH_PREP.hpp delete mode 100644 addons/pronelauncher/XEH_preInit.sqf delete mode 100644 addons/pronelauncher/XEH_preStart.sqf delete mode 100644 addons/pronelauncher/functions/fnc_onKeyDown.sqf delete mode 100644 addons/pronelauncher/functions/script_component.hpp diff --git a/addons/pronelauncher/$PBOPREFIX$ b/addons/pronelauncher/$PBOPREFIX$ index 11f5b2fa4b..e7ea0fb878 100644 --- a/addons/pronelauncher/$PBOPREFIX$ +++ b/addons/pronelauncher/$PBOPREFIX$ @@ -1 +1 @@ -z\ace\addons\prone_launcher \ No newline at end of file +z\ace\addons\pronelauncher diff --git a/addons/pronelauncher/CfgEventHandlers.hpp b/addons/pronelauncher/CfgEventHandlers.hpp index becf395052..9cc1b0427b 100644 --- a/addons/pronelauncher/CfgEventHandlers.hpp +++ b/addons/pronelauncher/CfgEventHandlers.hpp @@ -1,18 +1,5 @@ - -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - }; -}; - class Extended_PostInit_EventHandlers { class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); + init = QUOTE(call COMPILE_SCRIPT(XEH_postInit)); }; }; diff --git a/addons/pronelauncher/CfgMovesMaleSdr.hpp b/addons/pronelauncher/CfgMovesMaleSdr.hpp index c46fef7a96..5f4d8c207b 100644 --- a/addons/pronelauncher/CfgMovesMaleSdr.hpp +++ b/addons/pronelauncher/CfgMovesMaleSdr.hpp @@ -3,7 +3,7 @@ class CfgMovesMaleSdr: CfgMovesBasic { class TransAnimBase; class AmovPpneMstpSrasWlnrDnon; class States { - //Prone Stopped Launcher + // Prone Stopped Launcher class ACE_LauncherProne: AmovPpneMstpSrasWlnrDnon { variantsAI[] = {}; variantsPlayer[] = {}; @@ -49,7 +49,7 @@ class CfgMovesMaleSdr: CfgMovesBasic { "Campaign_Base", 0.02 }; }; - //Prone Stopped Launcher Turn Left + // Prone Stopped Launcher Turn Left class AmovPpneMstpSrasWlnrDnon_turnL: AmovPpneMstpSrasWlnrDnon { actions = "ACE_LauncherProneActions"; aimPrecision = 5; @@ -60,7 +60,7 @@ class CfgMovesMaleSdr: CfgMovesBasic { "AmovPpneMstpSrasWlnrDnon", 0.02 }; }; - //Prone Stopped Launcher Turn Right + // Prone Stopped Launcher Turn Right class AmovPpneMstpSrasWlnrDnon_turnR: AmovPpneMstpSrasWlnrDnon { actions = "ACE_LauncherProneActions"; aimPrecision = 5; @@ -71,7 +71,7 @@ class CfgMovesMaleSdr: CfgMovesBasic { "AmovPpneMstpSrasWlnrDnon", 0.02 }; }; - //Prone Stopped Launcher -> Standing Stopped Launcher + // Prone Stopped Launcher -> Standing Stopped Launcher //class AmovPpneMstpSrasWlnrDnon_AmovPercMstpSrasWlnrDnon: TransAnimBase { // actions = "LauncherStandActions"; // duty = 2; diff --git a/addons/pronelauncher/XEH_PREP.hpp b/addons/pronelauncher/XEH_PREP.hpp deleted file mode 100644 index c8ac82cd23..0000000000 --- a/addons/pronelauncher/XEH_PREP.hpp +++ /dev/null @@ -1 +0,0 @@ -PREP(onKeyDown); diff --git a/addons/pronelauncher/XEH_postInit.sqf b/addons/pronelauncher/XEH_postInit.sqf index 421c54b49f..29d13abdf4 100644 --- a/addons/pronelauncher/XEH_postInit.sqf +++ b/addons/pronelauncher/XEH_postInit.sqf @@ -1 +1,71 @@ #include "script_component.hpp" + +addUserActionEventHandler ["Stand", "Activate", { // Stand (toggle) + if ((!alive ACE_player) || {!(isNull objectParent ACE_player)}) exitWith {}; + + private _launcherWeapon = secondaryWeapon ACE_player; + + if ((_launcherWeapon == "") || {currentWeapon ACE_player != _launcherWeapon}) exitwith {}; + + if ((stance ACE_player) == "PRONE") then { + TRACE_1("stand toggle",stance ACE_player); + ACE_player playMoveNow "AmovPpneMstpSrasWlnrDnon_AmovPknlMstpSrasWlnrDnon"; + ACE_player playMove "AmovPknlMstpSrasWlnrDnon_AmovPercMstpSrasWlnrDnon"; + }; +}]; + +addUserActionEventHandler ["Crouch", "Activate", { // Crouch (toggle) + if ((!alive ACE_player) || {!(isNull objectParent ACE_player)}) exitWith {}; + + private _launcherWeapon = secondaryWeapon ACE_player; + + if ((_launcherWeapon == "") || {currentWeapon ACE_player != _launcherWeapon}) exitwith {}; + + if ((stance ACE_player) == "PRONE") then { + TRACE_1("crouch toggle",stance ACE_player); + ACE_player playMoveNow "AmovPpneMstpSrasWlnrDnon_AmovPknlMstpSrasWlnrDnon"; + }; +}]; + +addUserActionEventHandler ["Prone", "Activate", { // Prone (toggle) + if ((!alive ACE_player) || {!(isNull objectParent ACE_player)}) exitWith {}; + + private _launcherWeapon = secondaryWeapon ACE_player; + + if ((_launcherWeapon == "") || {currentWeapon ACE_player != _launcherWeapon}) exitwith {}; + + TRACE_1("prone toggle",stance ACE_player); + + // Make unit go prone (resets if key is pressed, so need to redo animation) + ACE_player playMoveNow "ACE_LauncherProne"; +}]; + +addUserActionEventHandler ["MoveUp", "Activate", { // (X) Crouch / Stand Up + if ((!alive ACE_player) || {!(isNull objectParent ACE_player)}) exitWith {}; + + private _launcherWeapon = secondaryWeapon ACE_player; + + if ((_launcherWeapon == "") || {currentWeapon ACE_player != _launcherWeapon}) exitwith {}; + + if ((stance ACE_player) == "PRONE") then { + TRACE_1("moveUp from prone",stance ACE_player); + ACE_player playMoveNow "AmovPpneMstpSrasWlnrDnon_AmovPknlMstpSrasWlnrDnon"; + }; +}]; + +addUserActionEventHandler ["MoveDown", "Activate", { // (Z) Go Prone / Stand Up + if ((!alive ACE_player) || {!(isNull objectParent ACE_player)}) exitWith {}; + + private _launcherWeapon = secondaryWeapon ACE_player; + + if ((_launcherWeapon == "") || {currentWeapon ACE_player != _launcherWeapon}) exitwith {}; + + if ((stance ACE_player) == "PRONE") then { + TRACE_1("moveDown from prone",stance ACE_player); + ACE_player playMoveNow "AmovPpneMstpSrasWlnrDnon_AmovPknlMstpSrasWlnrDnon"; + ACE_player playMove "AmovPknlMstpSrasWlnrDnon_AmovPercMstpSrasWlnrDnon"; + } else { + TRACE_1("moveDown from non-prone",stance ACE_player); + ACE_player playMoveNow "ACE_LauncherProne"; + }; +}]; diff --git a/addons/pronelauncher/XEH_preInit.sqf b/addons/pronelauncher/XEH_preInit.sqf deleted file mode 100644 index 4ef3276177..0000000000 --- a/addons/pronelauncher/XEH_preInit.sqf +++ /dev/null @@ -1,11 +0,0 @@ -#include "script_component.hpp" - -ADDON = false; - -PREP_RECOMPILE_START; -#include "XEH_PREP.hpp" -PREP_RECOMPILE_END; - -["KeyDown", {_this call FUNC(onKeyDown)}] call CBA_fnc_addDisplayHandler; - -ADDON = true; diff --git a/addons/pronelauncher/XEH_preStart.sqf b/addons/pronelauncher/XEH_preStart.sqf deleted file mode 100644 index 022888575e..0000000000 --- a/addons/pronelauncher/XEH_preStart.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "script_component.hpp" - -#include "XEH_PREP.hpp" diff --git a/addons/pronelauncher/functions/fnc_onKeyDown.sqf b/addons/pronelauncher/functions/fnc_onKeyDown.sqf deleted file mode 100644 index b6ceafffa0..0000000000 --- a/addons/pronelauncher/functions/fnc_onKeyDown.sqf +++ /dev/null @@ -1,57 +0,0 @@ -#include "script_component.hpp" -/* - * Author: PiZZADOX, Jonpas - * Handles keyDown EH for overriding engine stance changes when in AT launcher stance. - * - * Arguments: - * 0: Control - * 1: Key - * 2: Shift - * 3: Ctrl - * 4: Alt - * - * Return Value: - * None - * - * Example: - * [control, 5, false, true, false] call ace_pronelauncher_fnc_onKeyDown - * - * Public: No - */ - -params ["", "_key"]; - -if !(isNull objectParent ACE_player) exitWith {false}; -private _launcherWeapon = secondaryWeapon ACE_player; -if (_launcherWeapon isEqualTo "") exitwith {false}; -if (currentWeapon ACE_player != _launcherWeapon) exitWith {false}; - -private _stance = stance ACE_player; -private _keysMoveDown = actionKeys "moveDown"; -private _keysMoveUp = actionKeys "moveUp"; -private _keysProne = actionKeys "Prone"; -private _keysCrouch = actionKeys "Crouch"; -private _keysStand = actionKeys "Stand"; - -if (_stance in ["STAND", "CROUCH"] && {(_key in _keysMoveDown) || (_key in _keysProne)}) exitWith { - ACE_player playMoveNow "ACE_LauncherProne"; - true -}; - -if (_stance isEqualTo "PRONE") exitWith { - if (_key in _keysProne) exitWith { - true - }; - if ((_key in _keysCrouch) || (_key in _keysMoveUp)) exitWith { - ACE_player playMoveNow "AmovPpneMstpSrasWlnrDnon_AmovPknlMstpSrasWlnrDnon"; - true - }; - if ((_key in _keysMoveDown) || (_key in _keysStand)) exitWith { - ACE_player playMoveNow "AmovPpneMstpSrasWlnrDnon_AmovPknlMstpSrasWlnrDnon"; - ACE_player playMove "AmovPknlMstpSrasWlnrDnon_AmovPercMstpSrasWlnrDnon"; - true - }; - false -}; - -false diff --git a/addons/pronelauncher/functions/script_component.hpp b/addons/pronelauncher/functions/script_component.hpp deleted file mode 100644 index 7e7f35d933..0000000000 --- a/addons/pronelauncher/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\ace\addons\pronelauncher\script_component.hpp" diff --git a/addons/pronelauncher/script_component.hpp b/addons/pronelauncher/script_component.hpp index 6f7c683043..b645bfebe1 100644 --- a/addons/pronelauncher/script_component.hpp +++ b/addons/pronelauncher/script_component.hpp @@ -3,8 +3,8 @@ #include "\z\ace\addons\main\script_mod.hpp" #define DEBUG_MODE_FULL -#define DISABLE_COMPILE_CACHE -#define ENABLE_PERFORMANCE_COUNTERS +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_PRONELAUNCHER #define DEBUG_MODE_FULL