From 944cb68b9511f20765f0dec58ea276628ed98be2 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 2 Apr 2019 10:42:54 +0200 Subject: [PATCH 1/8] Add trigger options to weapon events --- addons/events/XEH_postInit.sqf | 20 ++++++++++++++++++++ addons/events/XEH_preInit.sqf | 1 + addons/events/fnc_weaponEvents.sqf | 22 ++++++++++++++++++---- addons/events/initSettings.sqf | 12 ++++++++++++ addons/events/stringtable.xml | 27 +++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 addons/events/initSettings.sqf diff --git a/addons/events/XEH_postInit.sqf b/addons/events/XEH_postInit.sqf index 63c36253c..3142e5fc3 100644 --- a/addons/events/XEH_postInit.sqf +++ b/addons/events/XEH_postInit.sqf @@ -66,3 +66,23 @@ if (isServer) then { }; }; }] call CBA_fnc_addEventHandler; + +// trigger pressed +// using display EH due to better reliance compared to inputAction +["MouseButtonDown", { + params ["", "_key"]; + + // TODO Support non-LMB (?) + if (_key == 0) { + CBA_triggerPressed = true; + }; +}] call CBA_fnc_addDisplayHandler; + +["MouseButtonUp", { + params ["", "_key"]; + + // TODO Support non-LMB (?) + if (_key == 0) { + CBA_triggerPressed = false; + }; +}] call CBA_fnc_addDisplayHandler; diff --git a/addons/events/XEH_preInit.sqf b/addons/events/XEH_preInit.sqf index 13af78d8e..74fe1c2f3 100644 --- a/addons/events/XEH_preInit.sqf +++ b/addons/events/XEH_preInit.sqf @@ -25,6 +25,7 @@ if (isServer) then { }; #include "backwards_comp.sqf" +#include "initSettings.sqf" ADDON = true; diff --git a/addons/events/fnc_weaponEvents.sqf b/addons/events/fnc_weaponEvents.sqf index a3ae9670a..556af2dd5 100644 --- a/addons/events/fnc_weaponEvents.sqf +++ b/addons/events/fnc_weaponEvents.sqf @@ -77,11 +77,14 @@ if (!_isEmpty || _onEmpty) then { _optic = _weapon; }; + private _trigger = CBA_triggerPressed; + [{ params [ "_unit", "_weapon", "_muzzle", "_optic", "_handAction", "_sound", "_soundSource", - "_expectedMagazineCount", "_time", "_delay" + "_expectedMagazineCount", "_time", "_delay", + "_trigger" ]; // exit if unit switched weapon @@ -90,8 +93,18 @@ if (!_isEmpty || _onEmpty) then { // exit if unit started reloading if (count magazines _unit != _expectedMagazineCount) exitWith {true}; - // while in gunner view, keep waiting - if (cameraView == "GUNNER" && _optic != "") exitWith { + // mode 0: while in gunner view, keep waiting + // mode 1: while holding trigger, keep waiting + // mode 2: while holding trigger and not pressing it, keep waiting + private _wait = (GVAR(weaponEventMode) == 0 && cameraView == "GUNNER" && _optic != "") || + {GVAR(weaponEventMode) == 1 && CBA_triggerPressed} || + {GVAR(weaponEventMode) == 2 && (_trigger || !CBA_triggerPressed)}; + + if (_wait) exitWith { + if (GVAR(weaponEventMode) == 2) then { + _trigger = CBA_triggerPressed; + }; + _this set [8, CBA_missionTime]; _unit setWeaponReloadingTime [_unit, _muzzle, 1]; false @@ -112,6 +125,7 @@ if (!_isEmpty || _onEmpty) then { }, {}, [ _unit, _weapon, _muzzle, _optic, _handAction, _sound, call _fnc_soundSource, - _expectedMagazineCount, CBA_missionTime, _delay + _expectedMagazineCount, CBA_missionTime, _delay, + _trigger ]] call CBA_fnc_waitUntilAndExecute; }; diff --git a/addons/events/initSettings.sqf b/addons/events/initSettings.sqf new file mode 100644 index 000000000..b41d22bf6 --- /dev/null +++ b/addons/events/initSettings.sqf @@ -0,0 +1,12 @@ +[ + QGVAR(weaponEventMode), + "LIST", + [LLSTRING(WeaponEventMode), LLSTRING(WeaponEventModeTooltip)], + LLSTRING(Category), + [[0, 1, 2], [ + [LLSTRING(WeaponEventModeOptic), LLSTRING(WeaponEventModeOpticTooltip)], // Exit optic view + [LLSTRING(WeaponEventModeTriggerRelease), LLSTRING(WeaponEventModeTriggerReleaseTooltip)], // Stop holding trigger + [LLSTRING(WeaponEventModeTriggerPress), LLSTRING(WeaponEventModeTriggerPressTooltip)] // Click trigger again + ], 0], + 2 +] call CBA_settings_fnc_init; diff --git a/addons/events/stringtable.xml b/addons/events/stringtable.xml index a119c12c0..9559dab8d 100644 --- a/addons/events/stringtable.xml +++ b/addons/events/stringtable.xml @@ -12,5 +12,32 @@ Community Base Addons - Zdarzenia Community Base Addons - Durumlar + + CBA Events + + + Weapon Event Mode + + + Mode of bolting or pumping weapons supporting Weapon Animations Framework. + + + Leave Optics View + + + Bolt or rack weapon by leaving optics view. + + + Release Trigger + + + Bolt or rack weapon by releasing trigger (hold trigger to prevent immediate action). + + + Press Trigger + + + Bolt or rack weapon by pressing the trigger again. + From a25f09723c1d6b6f0040f07d3825c47d7bc03979 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 2 Apr 2019 10:47:14 +0200 Subject: [PATCH 2/8] Fix trigger not being set for next PFH run --- addons/events/fnc_weaponEvents.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/events/fnc_weaponEvents.sqf b/addons/events/fnc_weaponEvents.sqf index 556af2dd5..1a0516d26 100644 --- a/addons/events/fnc_weaponEvents.sqf +++ b/addons/events/fnc_weaponEvents.sqf @@ -102,7 +102,7 @@ if (!_isEmpty || _onEmpty) then { if (_wait) exitWith { if (GVAR(weaponEventMode) == 2) then { - _trigger = CBA_triggerPressed; + _this set [9, CBA_triggerPressed]; }; _this set [8, CBA_missionTime]; From fcf8f96f9fe243f873a9115f3918f9e0bc03977e Mon Sep 17 00:00:00 2001 From: jonpas Date: Thu, 4 Apr 2019 18:11:16 +0200 Subject: [PATCH 3/8] Set default weapon event to trigger release --- addons/events/initSettings.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/events/initSettings.sqf b/addons/events/initSettings.sqf index b41d22bf6..1ec52d6a1 100644 --- a/addons/events/initSettings.sqf +++ b/addons/events/initSettings.sqf @@ -7,6 +7,6 @@ [LLSTRING(WeaponEventModeOptic), LLSTRING(WeaponEventModeOpticTooltip)], // Exit optic view [LLSTRING(WeaponEventModeTriggerRelease), LLSTRING(WeaponEventModeTriggerReleaseTooltip)], // Stop holding trigger [LLSTRING(WeaponEventModeTriggerPress), LLSTRING(WeaponEventModeTriggerPressTooltip)] // Click trigger again - ], 0], + ], 1], 2 ] call CBA_settings_fnc_init; From f695182693cb927926f0dbc134308498fbf05cd8 Mon Sep 17 00:00:00 2001 From: jonpas Date: Thu, 4 Apr 2019 18:11:31 +0200 Subject: [PATCH 4/8] Fix and GVAR weapon event options --- addons/events/XEH_postInit.sqf | 12 ++++++------ addons/events/fnc_weaponEvents.sqf | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/addons/events/XEH_postInit.sqf b/addons/events/XEH_postInit.sqf index 3142e5fc3..915d76eaf 100644 --- a/addons/events/XEH_postInit.sqf +++ b/addons/events/XEH_postInit.sqf @@ -70,19 +70,19 @@ if (isServer) then { // trigger pressed // using display EH due to better reliance compared to inputAction ["MouseButtonDown", { - params ["", "_key"]; + params ["", "_button"]; // TODO Support non-LMB (?) - if (_key == 0) { - CBA_triggerPressed = true; + if (_button == 0) { + GVAR(triggerPressed) = true; }; }] call CBA_fnc_addDisplayHandler; ["MouseButtonUp", { - params ["", "_key"]; + params ["", "_button"]; // TODO Support non-LMB (?) - if (_key == 0) { - CBA_triggerPressed = false; + if (_button == 0) { + GVAR(triggerPressed) = false; }; }] call CBA_fnc_addDisplayHandler; diff --git a/addons/events/fnc_weaponEvents.sqf b/addons/events/fnc_weaponEvents.sqf index 1a0516d26..d7f5adce3 100644 --- a/addons/events/fnc_weaponEvents.sqf +++ b/addons/events/fnc_weaponEvents.sqf @@ -77,14 +77,14 @@ if (!_isEmpty || _onEmpty) then { _optic = _weapon; }; - private _trigger = CBA_triggerPressed; + private _triggerReleased = false; [{ params [ "_unit", "_weapon", "_muzzle", "_optic", "_handAction", "_sound", "_soundSource", "_expectedMagazineCount", "_time", "_delay", - "_trigger" + "_triggerReleased" ]; // exit if unit switched weapon @@ -96,13 +96,18 @@ if (!_isEmpty || _onEmpty) then { // mode 0: while in gunner view, keep waiting // mode 1: while holding trigger, keep waiting // mode 2: while holding trigger and not pressing it, keep waiting - private _wait = (GVAR(weaponEventMode) == 0 && cameraView == "GUNNER" && _optic != "") || - {GVAR(weaponEventMode) == 1 && CBA_triggerPressed} || - {GVAR(weaponEventMode) == 2 && (_trigger || !CBA_triggerPressed)}; + private _wait = call ([{ + cameraView == "GUNNER" && _optic != "" + }, { + GVAR(triggerPressed) + }, { + !_triggerReleased || !GVAR(triggerPressed) + }] select GVAR(weaponEventMode)); if (_wait) exitWith { - if (GVAR(weaponEventMode) == 2) then { - _this set [9, CBA_triggerPressed]; + // Detect trigger release + if (GVAR(weaponEventMode) == 2 && !GVAR(triggerPressed) then { + _this set [9, true]; }; _this set [8, CBA_missionTime]; @@ -126,6 +131,6 @@ if (!_isEmpty || _onEmpty) then { _unit, _weapon, _muzzle, _optic, _handAction, _sound, call _fnc_soundSource, _expectedMagazineCount, CBA_missionTime, _delay, - _trigger + _triggerReleased ]] call CBA_fnc_waitUntilAndExecute; }; From d1ccc198252e24f802aeed3ee2751d842232fa1d Mon Sep 17 00:00:00 2001 From: jonpas Date: Thu, 4 Apr 2019 19:05:33 +0200 Subject: [PATCH 5/8] Fix weapon event options --- addons/events/XEH_postInit.sqf | 4 ++-- addons/events/XEH_preInit.sqf | 7 ++++++- addons/events/fnc_weaponEvents.sqf | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/events/XEH_postInit.sqf b/addons/events/XEH_postInit.sqf index 915d76eaf..1bdb5193a 100644 --- a/addons/events/XEH_postInit.sqf +++ b/addons/events/XEH_postInit.sqf @@ -73,7 +73,7 @@ if (isServer) then { params ["", "_button"]; // TODO Support non-LMB (?) - if (_button == 0) { + if (_button == 0) then { GVAR(triggerPressed) = true; }; }] call CBA_fnc_addDisplayHandler; @@ -82,7 +82,7 @@ if (isServer) then { params ["", "_button"]; // TODO Support non-LMB (?) - if (_button == 0) { + if (_button == 0) then { GVAR(triggerPressed) = false; }; }] call CBA_fnc_addDisplayHandler; diff --git a/addons/events/XEH_preInit.sqf b/addons/events/XEH_preInit.sqf index 74fe1c2f3..5dc2aa13f 100644 --- a/addons/events/XEH_preInit.sqf +++ b/addons/events/XEH_preInit.sqf @@ -25,7 +25,12 @@ if (isServer) then { }; #include "backwards_comp.sqf" -#include "initSettings.sqf" + +["CBA_settingsInitialized", { + // Events required by settings + // make sure we load events settings after + #include "initSettings.sqf" +}] call CBA_fnc_addEventHandler; ADDON = true; diff --git a/addons/events/fnc_weaponEvents.sqf b/addons/events/fnc_weaponEvents.sqf index d7f5adce3..2c21b7200 100644 --- a/addons/events/fnc_weaponEvents.sqf +++ b/addons/events/fnc_weaponEvents.sqf @@ -106,8 +106,8 @@ if (!_isEmpty || _onEmpty) then { if (_wait) exitWith { // Detect trigger release - if (GVAR(weaponEventMode) == 2 && !GVAR(triggerPressed) then { - _this set [9, true]; + if (GVAR(weaponEventMode) == 2 && !GVAR(triggerPressed)) then { + _this set [10, true]; }; _this set [8, CBA_missionTime]; From a366fc1b0327eb43da4c090ee0dc46ded391e360 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 5 Apr 2019 16:26:21 +0200 Subject: [PATCH 6/8] Use cba_settings_fnc_init directly instead of from unprepared cache --- addons/events/XEH_preInit.sqf | 7 +------ addons/events/initSettings.sqf | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/addons/events/XEH_preInit.sqf b/addons/events/XEH_preInit.sqf index 5dc2aa13f..74fe1c2f3 100644 --- a/addons/events/XEH_preInit.sqf +++ b/addons/events/XEH_preInit.sqf @@ -25,12 +25,7 @@ if (isServer) then { }; #include "backwards_comp.sqf" - -["CBA_settingsInitialized", { - // Events required by settings - // make sure we load events settings after - #include "initSettings.sqf" -}] call CBA_fnc_addEventHandler; +#include "initSettings.sqf" ADDON = true; diff --git a/addons/events/initSettings.sqf b/addons/events/initSettings.sqf index 1ec52d6a1..dd2097188 100644 --- a/addons/events/initSettings.sqf +++ b/addons/events/initSettings.sqf @@ -9,4 +9,4 @@ [LLSTRING(WeaponEventModeTriggerPress), LLSTRING(WeaponEventModeTriggerPressTooltip)] // Click trigger again ], 1], 2 -] call CBA_settings_fnc_init; +] call (uiNamespace getVariable "cba_settings_fnc_init"); From cd8a9c75027dbe5d260dd68b89867a40fa8075af Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 7 Apr 2019 09:01:23 +0200 Subject: [PATCH 7/8] Update addons/events/initSettings.sqf --- addons/events/initSettings.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/events/initSettings.sqf b/addons/events/initSettings.sqf index dd2097188..66ae4fd6f 100644 --- a/addons/events/initSettings.sqf +++ b/addons/events/initSettings.sqf @@ -9,4 +9,4 @@ [LLSTRING(WeaponEventModeTriggerPress), LLSTRING(WeaponEventModeTriggerPressTooltip)] // Click trigger again ], 1], 2 -] call (uiNamespace getVariable "cba_settings_fnc_init"); +] call CBA_fnc_addSetting; From 5a3ce4ab7a9537fb22f7e04fc78267c91d0758bf Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 7 Apr 2019 15:44:58 +0200 Subject: [PATCH 8/8] German translations and UI text changes --- addons/events/fnc_weaponEvents.sqf | 4 ++-- addons/events/initSettings.sqf | 12 +++++------ addons/events/stringtable.xml | 33 +++++++++++++++++++----------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/addons/events/fnc_weaponEvents.sqf b/addons/events/fnc_weaponEvents.sqf index 2c21b7200..e6dc73b1b 100644 --- a/addons/events/fnc_weaponEvents.sqf +++ b/addons/events/fnc_weaponEvents.sqf @@ -102,11 +102,11 @@ if (!_isEmpty || _onEmpty) then { GVAR(triggerPressed) }, { !_triggerReleased || !GVAR(triggerPressed) - }] select GVAR(weaponEventMode)); + }] select GVAR(repetitionMode)); if (_wait) exitWith { // Detect trigger release - if (GVAR(weaponEventMode) == 2 && !GVAR(triggerPressed)) then { + if (GVAR(repetitionMode) == 2 && !GVAR(triggerPressed)) then { _this set [10, true]; }; diff --git a/addons/events/initSettings.sqf b/addons/events/initSettings.sqf index 66ae4fd6f..0f8c6e118 100644 --- a/addons/events/initSettings.sqf +++ b/addons/events/initSettings.sqf @@ -1,12 +1,12 @@ [ - QGVAR(weaponEventMode), + QGVAR(repetitionMode), "LIST", - [LLSTRING(WeaponEventMode), LLSTRING(WeaponEventModeTooltip)], - LLSTRING(Category), + [LLSTRING(RepetitionMode), LLSTRING(RepetitionModeTooltip)], + LLSTRING(WeaponsCategory), [[0, 1, 2], [ - [LLSTRING(WeaponEventModeOptic), LLSTRING(WeaponEventModeOpticTooltip)], // Exit optic view - [LLSTRING(WeaponEventModeTriggerRelease), LLSTRING(WeaponEventModeTriggerReleaseTooltip)], // Stop holding trigger - [LLSTRING(WeaponEventModeTriggerPress), LLSTRING(WeaponEventModeTriggerPressTooltip)] // Click trigger again + [LLSTRING(RepetitionModeOptic), LLSTRING(RepetitionModeOpticTooltip)], // Exit optic view + [LLSTRING(RepetitionModeTriggerRelease), LLSTRING(RepetitionModeTriggerReleaseTooltip)], // Stop holding trigger + [LLSTRING(RepetitionModeTriggerPress), LLSTRING(RepetitionModeTriggerPressTooltip)] // Click trigger again ], 1], 2 ] call CBA_fnc_addSetting; diff --git a/addons/events/stringtable.xml b/addons/events/stringtable.xml index 9559dab8d..5865563c6 100644 --- a/addons/events/stringtable.xml +++ b/addons/events/stringtable.xml @@ -12,32 +12,41 @@ Community Base Addons - Zdarzenia Community Base Addons - Durumlar - - CBA Events + + CBA Weapons + CBA Waffen - - Weapon Event Mode + + Weapon Repetition Mode + Repetierwaffe laden - - Mode of bolting or pumping weapons supporting Weapon Animations Framework. + + Mode of bolting or pumping weapons. + Art eine Waffe zu repetieren. - + Leave Optics View + Optikansicht verlassen - + Bolt or rack weapon by leaving optics view. + Waffe beim Verlassen der Optikansicht repetieren. - + Release Trigger + Abzug losslassen - + Bolt or rack weapon by releasing trigger (hold trigger to prevent immediate action). + Waffe beim Loslassen des Abzugs repetieren (Abzug halten, um Repetieren zu verzögern). - + Press Trigger + Abzug betätigen - + Bolt or rack weapon by pressing the trigger again. + Waffe beim erneuten Betätigen des Abzugs repetieren.