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 reload mutex as canInteractWith condition #4062

Merged
merged 5 commits into from
Jul 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ GVAR(OldIsCamera) = false;
//////////////////////////////////////////////////

["isNotDead", {
params ["_unit", "_target"];
params ["_unit"];
alive _unit
}] call FUNC(addCanInteractWithCondition);

Expand All @@ -400,6 +400,48 @@ GVAR(OldIsCamera) = false;

["isNotInZeus", {isNull curatorCamera}] call FUNC(addCanInteractWithCondition);

//////////////////////////////////////////////////
// Set up reload mutex
//////////////////////////////////////////////////

GVAR(isReloading) = false;

["isNotReloading", {!GVAR(isReloading)}] call FUNC(addCanInteractWithCondition);

["keyDown", {
if ((_this select 1) in actionKeys "ReloadMagazine" && {alive ACE_player}) then {
private _weapon = currentWeapon ACE_player;

if (_weapon != "") then {
private _gesture = getText (configfile >> "CfgWeapons" >> _weapon >> "reloadAction");
private _isLauncher = _weapon isKindOf ["Launcher", configFile >> "CfgWeapons"];
private _config = ["CfgGesturesMale", "CfgMovesMaleSdr"] select _isLauncher;
private _duration = getNumber (configfile >> _config >> "States" >> _gesture >> "speed");

if (_duration != 0) then {
_duration = if (_duration < 0) then { abs _duration } else { 1 / _duration };
} else {
_duration = 3;
};

TRACE_2("Reloading, blocking gestures",_weapon,_duration);
GVAR(reloadingETA) = CBA_missionTime + _duration;

if (!GVAR(isReloading)) then {
GVAR(isReloading) = true;

[{
CBA_missionTime > GVAR(reloadingETA)
},{
GVAR(isReloading) = false;
}] call CBA_fnc_waitUntilAndExecute;
};
};
};

false
}] call CBA_fnc_addDisplayHandler;

//////////////////////////////////////////////////
// Set up PlayerJIP eventhandler
//////////////////////////////////////////////////
Expand Down
6 changes: 0 additions & 6 deletions addons/gestures/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,3 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

class Extended_DisplayLoad_EventHandlers {
class RscDisplayMission {
ADDON = QUOTE(_this call COMPILE_FILE(XEH_missionDisplayLoad));
};
};
2 changes: 1 addition & 1 deletion addons/gestures/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ADDON {
displayName = CSTRING(Gestures);
condition = QUOTE((canStand _target) && GVAR(ReloadMutex) && {GVAR(showOnInteractionMenu) == 2});
condition = QUOTE((canStand _target) && {GVAR(showOnInteractionMenu) == 2});
statement = "";
showDisabled = 1;
priority = 3.5;
Expand Down
32 changes: 0 additions & 32 deletions addons/gestures/XEH_missionDisplayLoad.sqf

This file was deleted.

3 changes: 0 additions & 3 deletions addons/gestures/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

if (!hasInterface) exitWith {};

// reload mutex, you can't play signal while reloading
GVAR(ReloadMutex) = true;

// Add keybinds
{
_x params ["_currentName", "_key", ["_vanillaKey", false] ];
Expand Down
2 changes: 1 addition & 1 deletion addons/gestures/functions/fnc_playSignal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

TRACE_1("params",_this);

if (!GVAR(ReloadMutex)) exitWith {false};
if (EGVAR(common,isReloading)) exitWith {false};
if (GVAR(showOnInteractionMenu) == 0) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};

Expand Down