- Close interact_menu when the player falls unconscious

- Prevent all types of interactions while unconscious
This commit is contained in:
esteldunedain 2015-04-04 12:20:14 -03:00
parent a5ff34e1d8
commit d090b3328c
3 changed files with 36 additions and 3 deletions

View File

@ -16,8 +16,11 @@
*/
#include "script_component.hpp"
PARAMS_2(_unit,_isUnconc);
EXPLODE_2_PVT(_this,_unit,_isUnconc);
diag_log "handleOnUnconscious";
diag_log _this;
diag_log _unit;
if (!local _unit) exitWith {};
if (_isUnconc) then {

View File

@ -18,11 +18,37 @@ addMissionEventHandler ["Draw3D", DFUNC(render)];
["ACE3", QGVAR(InteractKey), (localize "STR_ACE_Interact_Menu_InteractKey"),
{[0] call FUNC(keyDown)},
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Statement
[0] call FUNC(keyDown)
},
{[0] call FUNC(keyUp)},
[219, [false, false, false]], false] call cba_fnc_addKeybind; //Left Windows Key
["ACE3", QGVAR(SelfInteractKey), (localize "STR_ACE_Interact_Menu_SelfInteractKey"),
{[1] call FUNC(keyDown)},
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Statement
[1] call FUNC(keyDown)
},
{[1] call FUNC(keyUp)},
[219, [false, true, false]], false] call cba_fnc_addKeybind; //Left Windows Key + Ctrl/Strg
// Listens for the falling unconscious event, just in case the menu needs to be closed
["medical_onUnconscious", {
diag_log ["im_onUn 1:",_this];
// If no menu is open just quit
if (GVAR(openedMenuType) < 0) exitWith {};
EXPLODE_2_PVT(_this,_unit,_isUnconscious);
if (_unit != ACE_player || !_isUnconscious) exitWith {};
GVAR(actionSelected) = false;
[] call FUNC(keyUp);
diag_log ["im_onUn 2:",_this];
}] call EFUNC(common,addEventhandler);

View File

@ -240,3 +240,7 @@ if (USE_WOUND_EVENT_SYNC) then {
{((_this select 0) getvariable ["ACE_isDead", false])},
{(((_this select 0) getvariable [QGVAR(airwayStatus), 100]) < 80)}
] call FUNC(addUnconsciousCondition);
// Prevent all types of interaction while unconscious
// @todo: probably remove this when CBA keybind hold key works properly
["isNotUnconscious", {!((_this select 0) getVariable ["ACE_isUnconscious", false])}] call EFUNC(common,addCanInteractWithCondition);