Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trigger options to weapon events / repetition #1107

Merged
merged 9 commits into from
Apr 7, 2019
20 changes: 20 additions & 0 deletions addons/events/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
jonpas marked this conversation as resolved.
Show resolved Hide resolved
CBA_triggerPressed = false;
};
}] call CBA_fnc_addDisplayHandler;
1 change: 1 addition & 0 deletions addons/events/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if (isServer) then {
};

#include "backwards_comp.sqf"
#include "initSettings.sqf"

ADDON = true;

Expand Down
22 changes: 18 additions & 4 deletions addons/events/fnc_weaponEvents.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)};
jonpas marked this conversation as resolved.
Show resolved Hide resolved

if (_wait) exitWith {
if (GVAR(weaponEventMode) == 2) then {
_this set [9, CBA_triggerPressed];
};

_this set [8, CBA_missionTime];
_unit setWeaponReloadingTime [_unit, _muzzle, 1];
false
Expand All @@ -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;
};
12 changes: 12 additions & 0 deletions addons/events/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -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;
27 changes: 27 additions & 0 deletions addons/events/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,32 @@
<Polish>Community Base Addons - Zdarzenia</Polish>
<Turkish>Community Base Addons - Durumlar</Turkish>
</Key>
<Key ID="STR_CBA_Events_Category">
<English>CBA Events</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventMode">
<English>Weapon Event Mode</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventModeTooltip">
<English>Mode of bolting or pumping weapons supporting Weapon Animations Framework.</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventModeOptic">
<English>Leave Optics View</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventModeOpticTooltip">
<English>Bolt or rack weapon by leaving optics view.</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventModeTriggerRelease">
<English>Release Trigger</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventModeTriggerReleaseTooltip">
<English>Bolt or rack weapon by releasing trigger (hold trigger to prevent immediate action).</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventModeTriggerPress">
<English>Press Trigger</English>
</Key>
<Key ID="STR_CBA_Events_WeaponEventModeTriggerPressTooltip">
<English>Bolt or rack weapon by pressing the trigger again.</English>
</Key>
</Package>
</Project>