Merge pull request #4062 from acemod/disable-interaction-menu-while-reloading

Add reload mutex as canInteractWith condition
This commit is contained in:
commy2 2016-07-09 21:03:55 +02:00 committed by GitHub
commit d249132864
6 changed files with 45 additions and 44 deletions

View File

@ -381,7 +381,7 @@ GVAR(OldIsCamera) = false;
//////////////////////////////////////////////////
["isNotDead", {
params ["_unit", "_target"];
params ["_unit"];
alive _unit
}] call FUNC(addCanInteractWithCondition);
@ -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
//////////////////////////////////////////////////

View File

@ -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));
};
};

View File

@ -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;

View File

@ -1,32 +0,0 @@
#include "script_component.hpp"
disableSerialization;
params ["_display"];
_display displayAddEventHandler ["KeyDown", {
if ((_this select 1) in actionKeys "ReloadMagazine") then {
if (isNull ACE_player || {!alive ACE_player}) exitWith {false};
private _weapon = currentWeapon ACE_player;
if (_weapon != "") then {
GVAR(ReloadMutex) = false;
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(ReloadMutex) = true;}, [], _duration] call CBA_fnc_waitAndExecute;
};
};
false
}];

View File

@ -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] ];

View File

@ -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};