/* File: fn_keyHandler.sqf Author: Bryan "Tonic" Boardwine Description: Main key handler for event 'keyDown' */ private ["_handled","_shift","_alt","_code","_ctrl","_alt","_ctrlKey","_veh","_locked","_interactionKey","_mapKey","_interruptionKeys","_nObject"]; _ctrl = _this select 0; _code = _this select 1; _shift = _this select 2; _ctrlKey = _this select 3; _alt = _this select 4; _speed = speed cursorTarget; _handled = false; _interactionKey = if(count (actionKeys "User10") == 0) then {219} else {(actionKeys "User10") select 0}; _mapKey = actionKeys "ShowMap" select 0; //hint str _code; _interruptionKeys = [17,30,31,32]; //A,S,W,D //Vault handling... if((_code in (actionKeys "GetOver") || _code in (actionKeys "salute")) && {(player getVariable ["restrained",false])}) exitWith { true; }; if(life_action_inUse) exitWith { if(!life_interrupted && _code in _interruptionKeys) then {life_interrupted = true;}; _handled; }; //Hotfix for Interaction key not being able to be bound on some operation systems. if(count (actionKeys "User10") != 0 && {(inputAction "User10" > 0)}) exitWith { //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10) if(!life_action_inUse) then { if(!life_action_gather ) then { [] spawn { private["_handle"]; _handle = [] spawn life_fnc_actionKeyHandler; waitUntil {scriptDone _handle}; life_action_inUse = false; }; }; }; true; }; switch (_code) do { //Q Key case 16: { if((!life_action_inUse) && (vehicle player == player) ) then { if(!life_action_gather ) then { { _str = [_x] call life_fnc_varToStr; _val = missionNameSpace getVariable _x; if(_val > 0 ) then { if( _str == "Presslufthammer" || _str == "pressluft" ) then { [] spawn life_fnc_pressluftUse; breakTo "main" }; if( _str == "Spitzhacke" || _str == "pickaxe" ) then { [] spawn life_fnc_pickAxeUse; breakTo "main" }; if( _str == "Axt" || _str == "axt" ) then { [] spawn life_fnc_axtUse; breakTo "main" }; }; } foreach life_inv_items; scopeName "main"; }; }; }; //Map Key case _mapKey: { switch (playerSide) do { case west: {if(!visibleMap) then {[] spawn life_fnc_copMarkers;}}; case independent: {if(!visibleMap) then {[] spawn life_fnc_medicMarkers;}}; if(playerSide == civilian && !visibleMap) then { [] spawn life_fnc_groupMarkers;}; }; }; //Holster / recall weapon. case 35: { if(_shift && !_ctrlKey && currentWeapon player != "") then { life_curWep_h = currentWeapon player; player action ["SwitchWeapon", player, player, 100]; player switchcamera cameraView; }; if(!_shift && _ctrlKey && !isNil "life_curWep_h" && {(life_curWep_h != "")}) then { if(life_curWep_h in [primaryWeapon player,secondaryWeapon player,handgunWeapon player]) then { player selectWeapon life_curWep_h; }; }; if(playerSide == west) then { if(vehicle player != player) then { if(!life_play) then { life_play = true; [[vehicle player,"cop",1],"life_fnc_Sound",nil,true] call life_fnc_MP; life_play = false; }; }; }; }; //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10) case _interactionKey: { if(!life_action_inUse) then { if(!life_action_gather ) then { [] spawn { private["_handle"]; _handle = [] spawn life_fnc_actionKeyHandler; waitUntil {scriptDone _handle}; life_action_inUse = false; }; }; }; }; //Restraining (Shift + R) case 19: { if(_shift) then {_handled = true;}; if(_shift && playerSide == west && !isNull cursorTarget && cursorTarget isKindOf "Man" && (isPlayer cursorTarget) && (side cursorTarget in [civilian,independent]) && alive cursorTarget && cursorTarget distance player < 3.5 && !(cursorTarget getVariable "Escorting") && !(cursorTarget getVariable "restrained") && speed cursorTarget < 1) then { [] call life_fnc_restrainAction; player say3D "handschellen"; }; if(_shift) then {_handled = true;}; if(_shift && playerSide == civilian && !isNull cursorTarget && cursorTarget isKindOf "Man" && isPlayer cursorTarget && alive cursorTarget && cursorTarget distance player < 4 && speed cursorTarget < 1) then { if((animationState cursorTarget) != "Incapacitated" && (currentWeapon player == primaryWeapon player OR currentWeapon player == handgunWeapon player) && currentWeapon player != "" && !life_knockout && !(player getVariable["restrained",false]) && !life_istazed) then { [cursorTarget] spawn life_fnc_knockoutAction; player say3D "niederschlagen"; }; }; }; //surrender... shift + g case 34: { if(_shift) then {_handled = true;}; if (_shift) then { if (vehicle player == player && !(player getVariable ["restrained", false]) && (animationState player) != "Incapacitated" && !life_istazed) then { if (player getVariable ["surrender", false]) then { player setVariable ["surrender", false, true]; } else { [] spawn life_fnc_surrender; }; }; }; if (!_shift && !_alt && !_ctrlKey && (playerSide == west) && (vehicle player != player)) then { [] call life_fnc_copOpener; }; }; //EMP Konsole - K case 37: { if (!_shift && !_alt && !_ctrlKey && (playerSide == west) && (vehicle player != player && (typeOf vehicle player) in ["B_Heli_Light_01_F"])) then { [] call life_fnc_openEmpMenu; [_this] call life_fnc_isEmpOperator; }; }; //T Key (Trunk) case 20: { if(!_alt && !_ctrlKey) then { if(!life_is_processing) then { if(vehicle player != player && alive vehicle player) then { if((vehicle player) in life_vehicles) then { [vehicle player] call life_fnc_openInventory; }; } else { if(( cursorTarget isKindOf "Land_Cargo10_white_F" OR cursorTarget isKindOf "Land_Cargo10_light_green_F" OR cursorTarget isKindOf "Land_Cargo10_blue_F" OR cursorTarget isKindOf "Land_Cargo20_cyan_F" OR cursorTarget isKindOf "Land_Cargo20_light_green_F" OR cursorTarget isKindOf "Land_Cargo20_blue_F" OR cursorTarget isKindOf "Car" OR cursorTarget isKindOf "Air" OR cursorTarget isKindOf "Ship" OR cursorTarget isKindOf "House_F") && player distance cursorTarget < 7 && vehicle player == player && alive cursorTarget) then { if(cursorTarget in life_vehicles OR {!(cursorTarget getVariable ["locked",true])}) then { [cursorTarget] call life_fnc_openInventory; }; }; }; }; }; }; //L Key? case 38: { //If cop run checks for turning lights on. if(_shift && playerSide in [west,independent]) then { if(vehicle player != player && (typeOf vehicle player) in ["I_MRAP_03_hmg_F","I_MRAP_03_F","B_MRAP_01_hmg_F","B_APC_Wheeled_01_cannon_F","C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","C_Hatchback_01_F","B_Heli_Light_01_F","B_Heli_Transport_01_F","B_Heli_Transport_01_camo_F","I_Heli_light_03_F"]) then { if(!isNil {vehicle player getVariable "lights"}) then { if(playerSide == west) then { [vehicle player] call life_fnc_sirenLights; } else { if(playerSide == independent) then { [vehicle player] call life_fnc_medicSiren; }; }; _handled = true; }; }; }; if(!_alt && !_ctrlKey && playerSide == west ) then { [] call life_fnc_radar; }; }; //z Player Menu case 21: { if(!life_action_gather) then { if(!life_action_inUse) then { if(!_alt && !_ctrlKey && !dialog) then { [] call life_fnc_p_openMenu; }; }; }; }; //Shift+O Zipties ( Civilians can restrain ) case 24: { if(_shift) then {_handled = true;}; if(_shift && playerSide == civilian && (animationState cursorTarget) == "Incapacitated" &&!isNull cursorTarget && cursorTarget isKindOf "Man" && (isPlayer cursorTarget) && (side cursorTarget in [civilian,independent,west]) && alive cursorTarget && cursorTarget distance player < 3.5 && !(cursorTarget getVariable "Escorting") && !(cursorTarget getVariable "restrained") && speed cursorTarget < 1) then { if([false,"zipties",1] call life_fnc_handleInv) then { [] call life_fnc_restrainAction; player say3D "handschellen"; } else { hint "Du hast keine Handschellen"; }; }; }; //Shift+P = Faded Sound case 25: { if(_shift) then { [] call life_fnc_fadeSound; _handled = true; }; }; //Takwondo(Traditional Martial arts in korea)(Shift + Num 1) case 79: { if(_shift) then {_handled = true;}; if ((_shift) && (vehicle player == player)) then { cutText [format["Takwondo!!!"], "PLAIN DOWN"]; player playMove "AmovPercMstpSnonWnonDnon_exerciseKata"; }; }; //Kneebend Slow(Shift + Num 2) case 80: { if(_shift) then {_handled = true;}; if ((_shift) && (vehicle player == player)) then { cutText [format["KneeBend Slow baby~"], "PLAIN DOWN"]; player playMove "AmovPercMstpSnonWnonDnon_exercisekneeBendA"; }; }; //Kneebend Fast(Shift + Num 3) case 81: { if(_shift) then {_handled = true;}; if ((_shift) && (vehicle player == player)) then { cutText [format["KneeBend more Hard!!!Move!!Move!!"], "PLAIN DOWN"]; player playMove "AmovPercMstpSnonWnonDnon_exercisekneeBendB"; }; }; //Pushup(Shift + Num 4) case 75: { if(_shift) then {_handled = true;}; if ((_shift) && (vehicle player == player)) then { cutText [format["Pushup!!!!!!"], "PLAIN DOWN"]; player playMove "AmovPercMstpSnonWnonDnon_exercisePushup"; }; }; //F Key case 33: { if(playerSide in [west,independent] && vehicle player != player && !life_siren_active && ((driver vehicle player) == player)) then { [] spawn { life_siren_active = true; sleep 4.7; life_siren_active = false; }; _veh = vehicle player; if(isNil {_veh getVariable "siren"}) then {_veh setVariable["siren",false,true];}; if((_veh getVariable "siren")) then { titleText [localize "STR_MISC_SirensOFF","PLAIN"]; _veh setVariable["siren",false,true]; } else { titleText [localize "STR_MISC_SirensON","PLAIN"]; _veh setVariable["siren",true,true]; if(playerSide == west) then { [[_veh],"life_fnc_copSiren",nil,true] spawn life_fnc_MP; } else { if(playerSide == independent) then { [[_veh],"life_fnc_medicSirenLights",nil,true] spawn life_fnc_MP; }; }; }; }; }; //U Key case 22: { if(!_alt && !_ctrlKey) then { if(vehicle player == player) then { _veh = cursorTarget; } else { _veh = vehicle player; }; if(_veh isKindOf "House_F" && playerSide == civilian) then { _base = [(getPos player) select 0, (getPos player) select 1, 0] nearestObject "Land_Cargo_House_V3_F"; if( (_veh in life_vehicles && player distance _veh < 10 ) OR (_base in life_vehicles && player distance _veh < 20 && (player distance _base) < 60 )) then { _door = [_veh] call life_fnc_nearestDoor; if(_door == 0) exitWith {hint localize "STR_House_Door_NotNear"}; _locked = _veh getVariable [format["bis_disabled_Door_%1",_door],0]; if(_locked == 0) then { _veh setVariable[format["bis_disabled_Door_%1",_door],1,true]; _veh animate [format["door_%1_rot",_door],0]; systemChat localize "STR_House_Door_Lock"; } else { _veh setVariable[format["bis_disabled_Door_%1",_door],0,true]; _veh animate [format["door_%1_rot",_door],1]; systemChat localize "STR_House_Door_Unlock"; }; }; } else { _locked = locked _veh; if(_veh in life_vehicles && player distance _veh < 8) then { if(_locked == 2) then { if(local _veh) then { _veh lock 0; _veh animateDoor ["door_back_R",1]; _veh animateDoor ["door_back_L",1]; _veh animateDoor ['door_R',1]; _veh animateDoor ['door_L',1]; _veh animateDoor ['Door_rear',1]; _veh animateDoor ['Door_LM',1]; _veh animateDoor ['Door_RM',1]; _veh animateDoor ['Door_LF',1]; _veh animateDoor ['Door_RF',1]; _veh animateDoor ['Door_LB',1]; _veh animateDoor ['Door_RB',1]; } else { [[_veh,0],"life_fnc_lockVehicle",_veh,false] spawn life_fnc_MP; _veh animateDoor ["door_back_R",1]; _veh animateDoor ["door_back_L",1]; _veh animateDoor ['door_R',1]; _veh animateDoor ['door_L',1]; _veh animateDoor ['Door_rear',1]; _veh animateDoor ['Door_LM',1]; _veh animateDoor ['Door_RM',1]; _veh animateDoor ['Door_LF',1]; _veh animateDoor ['Door_RF',1]; _veh animateDoor ['Door_LB',1]; _veh animateDoor ['Door_RB',1]; }; systemChat localize "STR_MISC_VehUnlock"; player say3D "unlock"; } else { if(local _veh) then { _veh lock 2; _veh animateDoor ["door_back_R",0]; _veh animateDoor ["door_back_L",0]; _veh animateDoor ['door_R',0]; _veh animateDoor ['door_L',0]; _veh animateDoor ['Door_rear',0]; _veh animateDoor ['Door_LM',0]; _veh animateDoor ['Door_RM',0]; _veh animateDoor ['Door_LF',0]; _veh animateDoor ['Door_RF',0]; _veh animateDoor ['Door_LB',0]; _veh animateDoor ['Door_RB',0]; } else { [[_veh,2],"life_fnc_lockVehicle",_veh,false] spawn life_fnc_MP; _veh animateDoor ["door_back_R",0]; _veh animateDoor ["door_back_L",0]; _veh animateDoor ['door_R',0]; _veh animateDoor ['door_L',0]; _veh animateDoor ['Door_rear',0]; _veh animateDoor ['Door_LM',0]; _veh animateDoor ['Door_RM',0]; _veh animateDoor ['Door_LF',0]; _veh animateDoor ['Door_RF',0]; _veh animateDoor ['Door_LB',0]; _veh animateDoor ['Door_RB',0]; }; systemChat localize "STR_MISC_VehLock"; player say3D "car_lock"; }; }; }; }; }; }; _handled;