Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "..\..\script_macros.hpp"
- /*
- * 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"];
- _ctrl = _this select 0;
- _code = _this select 1;
- _shift = _this select 2;
- _ctrlKey = _this select 3;
- _alt = _this select 4;
- _speed = speed cursorObject;
- _handled = false;
- _interactionKey = if (count (actionKeys "User10") isEqualTo 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") || _code in (actionKeys "SitDown") || _code in (actionKeys "Throw") || _code in (actionKeys "GetIn") || _code in (actionKeys "GetOut") || _code in (actionKeys "Fire") || _code in (actionKeys "ReloadMagazine") || _code in [5,6,7,16,18,21]) && ((player getVariable ["restrained",false]) || (player getVariable ["playerSurrender",false]) || (player getVariable ["ziptied",false]) || life_isknocked || life_istazed)) 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") isEqualTo 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 {
- [] spawn {
- private "_handle";
- _handle = [] spawn life_fnc_actionKeyHandler;
- waitUntil {scriptDone _handle};
- life_action_inUse = false;
- };
- };
- true;
- };
- if (life_container_active) then {
- switch (_code) do {
- //space key
- case 57: {
- [] spawn life_fnc_placestorage;
- };
- };
- true;
- };
- if (life_barrier_active) then {
- switch (_code) do {
- //Backspace key
- case 14: {
- [] spawn life_fnc_placeableCancel;
- _handled = true;
- };
- };
- true;
- };
- switch (_code) do {
- // -- Disable commander/tactical view
- if (LIFE_SETTINGS(getNumber,"disableCommanderView") isEqualTo 1) then {
- private _CommandMode = actionKeys "tacticalView";
- if (_code in _CommandMode) then {
- hint localize "STR_NOTF_CommanderView";
- _handled = true;
- };
- };
- //Space key for Jumping
- case 57: {
- if (!_shift && life_barrier_active) then {
- 0 spawn life_fnc_placeablesPlaceComplete;
- };
- if (isNil "jumpActionTime") then {jumpActionTime = 0;};
- if (_shift && {!(animationState player isEqualTo "AovrPercMrunSrasWrflDf")} && {isTouchingGround player} && {stance player isEqualTo "STAND"} && {speed player > 2} && {!life_is_arrested} && {((velocity player) select 2) < 2.5} && {time - jumpActionTime > 1.5}) then {
- if (life_barrier_active) then { [true] call life_fnc_placeableCancel; };
- jumpActionTime = time; //Update the time.
- [player] remoteExec ["life_fnc_jumpFnc",RANY]; //Global execution
- _handled = true;
- };
- };
- //Surrender (Shift + B)
- case 48: {
- if (_shift) then {
- if (player getVariable ["playerSurrender",false]) then {
- player setVariable ["playerSurrender",false,true];
- } else {
- [] spawn life_fnc_surrender;
- };
- _handled = true;
- };
- if( _alt ) then {
- if( playerSide isEqualTo west && { time - life_cooldown > 1 } ) then {
- life_cooldown = time;
- call life_fnc_seizeObjects;
- };
- _handled = true;
- };
- };
- //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;}};
- case civilian: {if (!visibleMap) then {[] spawn life_fnc_civMarkers;}};
- case east: {if (!visibleMap) then {[] spawn life_fnc_thwMarkers;}};
- };
- };
- case 64: {
- if(!(life_idcard_data isEqualto [])) then {
- if(!isnull cursorTarget) then {
- if(alive cursorTarget) then {
- if(cursorTarget isKindOf "Man") then {
- [life_idcard_data,getplayeruid player,player] remoteExec ["life_fnc_show_idcard",cursorTarget];
- hint localize "STR_capps_cur_error_success";
- } else {
- [life_idcard_data,getplayeruid player,player] spawn life_fnc_show_idcard;
- hint localize "STR_capps_cur_error_no_target";
- };
- } else {
- [life_idcard_data,getplayeruid player,player] spawn life_fnc_show_idcard;
- hint localize "STR_capps_cur_error_not_alive";
- };
- } else {
- [life_idcard_data,getplayeruid player,player] spawn life_fnc_show_idcard;
- hint localize "STR_capps_cur_error_no_target";
- };
- } else {
- hint localize "STR_capps_cur_error_no_idcard";
- };
- };
- case 65: {
- if(!(playerSide isEqualto CIVILIAN)) then {
- if(!(life_idcard_data isEqualto [])) then {
- if(!isnull cursorTarget) then {
- if(alive cursorTarget) then {
- if(cursorTarget isKindOf "Man") then {
- [life_idcard_data,getplayeruid player,player,playerSide,(call life_coplevel) + (call life_mediclevel) + (call life_thwlevel)] remoteExec ["life_fnc_show_idcard",cursorTarget];
- hint localize "STR_capps_cur_error_success_card";
- } else {
- [life_idcard_data,getplayeruid player,player,playerSide,(call life_coplevel) + (call life_mediclevel) + (call life_thwlevel)] spawn life_fnc_show_idcard;
- hint localize "STR_capps_cur_error_no_target";
- };
- } else {
- [life_idcard_data,getplayeruid player,player,playerSide,(call life_coplevel) + (call life_mediclevel) + (call life_thwlevel)] spawn life_fnc_show_idcard;
- hint localize "STR_capps_cur_error_not_alive";
- };
- } else {
- [life_idcard_data,getplayeruid player,player,playerSide,(call life_coplevel) + (call life_mediclevel) + (call life_thwlevel)] spawn life_fnc_show_idcard;
- hint localize "STR_capps_cur_error_no_target";
- };
- } else {
- hint localize "STR_capps_cur_error_no_idcard";
- };
- };
- };
- case 207: {
- switch (player getVariable["Earplugs",0]) do {
- case 0: {hint composeText [ image "icons\sound.paa"," 90% Leiser"]; 1 fadeSound 0.1; player setVariable ["Earplugs", 10];life_fadeSound = true; [] call life_fnc_hudUpdate;};
- case 10: {hint composeText [ image "icons\sound.paa"," 60% Leiser"]; 1 fadeSound 0.4; player setVariable ["Earplugs", 40];life_fadeSound = true; [] call life_fnc_hudUpdate;};
- case 40: {hint composeText [ image "icons\sound.paa"," 30% Leiser"]; 1 fadeSound 0.7; player setVariable ["Earplugs", 70];life_fadeSound = true; [] call life_fnc_hudUpdate;};
- case 70: {hint composeText [ image "icons\sound_new.paa"," Normaler Sound"]; 1 fadeSound 1; player setVariable ["Earplugs", 0]; life_fadeSound = false; [] call life_fnc_hudUpdate;};
- };
- };
- //Holster / recall weapon. (Shift + H)
- case 35: {
- if (_shift && !_ctrlKey && !(currentWeapon player isEqualTo "")) 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 isEqualTo "")}) then {
- if (life_curWep_h in [primaryWeapon player,secondaryWeapon player,handgunWeapon player]) then {
- player selectWeapon life_curWep_h;
- };
- };
- };
- //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
- case _interactionKey: {
- if (!life_action_inUse) then {
- [] spawn {
- private "_handle";
- _handle = [] spawn life_fnc_actionKeyHandler;
- waitUntil {scriptDone _handle};
- life_action_inUse = false;
- };
- };
- };
- //Restraining (Shift + R)
- case 19: {
- if ((_alt) && (vehicle player == player)) then {
- [] call life_fnc_useredgull;
- };
- if (_shift) then {_handled = true;};
- if (_shift && playerSide isEqualTo west && {!isNull cursorObject} && {cursorObject isKindOf "Man"} && {(isPlayer cursorObject)} && {(side cursorObject in [civilian,independent,east])} && {alive cursorObject} && {cursorObject distance player < 3.5} && {!(cursorObject getVariable "Escorting")} && {!(cursorObject getVariable "restrained")} && {speed cursorObject < 1}) then {
- [] call life_fnc_restrainAction;
- } else {
- [] call zipties_fnc_zip_tieAction;
- };
- };
- //O Key
- case 24: {
- if (!_shift && !_alt && !_ctrlKey && !(playerSide isEqualTo civilian) && (vehicle player != player)) then {
- [] call life_fnc_gateOpener;
- };
- _handled = true;
- };
- //Ö-Key
- case 39: {
- if ((isNull(findDisplay 20000)) && (!(playerSide isEqualTo civilian))) then {
- 0 spawn life_fnc_placeablesMenu;
- _handled = true;
- };
- _handled = true;
- };
- //ENTF-Key
- case 211: {
- if ((!(playerSide isEqualTo civilian)) && ((typeOf cursorTarget) in life_definePlaceables)) then {
- deleteVehicle cursorTarget;
- hintSilent "Die Absperrung wurde entfernt";
- };
- };
- //Knock out, this is experimental and yeah... (Shift + G)
- case 34: {
- if (_shift) then {_handled = true;};
- if (_shift && playerSide isEqualTo civilian && !isNull cursorObject && cursorObject isKindOf "Man" && isPlayer cursorObject && alive cursorObject && cursorObject distance player < 4 && speed cursorObject < 1) then {
- if ((animationState cursorObject) != "Incapacitated" && (currentWeapon player == primaryWeapon player || currentWeapon player == handgunWeapon player) && currentWeapon player != "" && !life_knockout && !(player getVariable ["restrained",false]) && !life_istazed && !life_isknocked) then {
- [cursorObject] spawn life_fnc_knockoutAction;
- };
- };
- if!(_shift) then {
- if ((vehicle player getVariable "side") isEqualTo "cop" && !(vehicle player isKindOf "Air")) then {
- if (!isNil {vehicle player getVariable "lights"}) then {
- if ((vehicle player != player) && {!life_warningcop_active} && {((driver vehicle player) == player)}) then {
- [] spawn {
- life_warningcop_active = true;
- sleep 0.2;
- life_warningcop_active = false;
- };
- _veh = vehicle player;
- if (isNil {_veh getVariable "warningcop"}) then {_veh setVariable ["warningcop",false,true];};
- if ((_veh getVariable "warningcop")) then {
- _veh setVariable["warningcop",false,true];
- } else {
- _veh setVariable["warningcop",true,true];
- [_veh,"warningcop"] remoteExec ["life_fnc_say3D",RANY];
- };
- };
- };
- };
- };
- };
- //T Key (Trunk)
- case 20: {
- // Feind Device
- _itsOk = if
- (
- !isNil {cursorObject getVariable "process"} || !isNil {vehicle player getVariable "process"}
- || DeviceProcess_inAction || MedicSystem_inAction
- ) then {false} else {true};
- if (!_alt && !_ctrlKey && !dialog && {!life_action_inUse} && _itsOk) then {
- /* [MdF] Feindflug Crafting Box */
- _nearestCraftBox = nearestObjects[player,["Land_WoodenCrate_01_stack_x5_F"],5];
- if(count _nearestCraftBox > 0) then
- {
- _nearBox = (_nearestCraftBox select 0);
- if(!isNil "_nearBox") then {[_nearBox] spawn life_fnc_openInventory;};
- /* ############################ */
- } else {
- if (!(isNull objectParent player) && alive vehicle player) then {
- if ((vehicle player) in life_vehicles) then {
- [vehicle player] spawn life_fnc_openInventory;
- };
- } else {
- private "_list";
- _list = ((ASLtoATL (getPosASL player)) nearEntities [["Box_IND_Grenades_F","B_supplyCrate_F"], 2.5]) select 0;
- if (!(isNil "_list")) then {
- _house = nearestObject [(ASLtoATL (getPosASL _list)), "House"];
- if (_house getVariable ["locked", false]) then {
- hint localize "STR_House_ContainerDeny";
- } else {
- [_list] spawn life_fnc_openInventory;
- };
- } else {
- _list = ["landVehicle","Air","Ship"];
- if (KINDOF_ARRAY(cursorObject,_list) && {player distance cursorObject < 7} && {isNull objectParent player} && {alive cursorObject} && {!life_action_inUse}) then {
- if (cursorObject in life_vehicles || {locked cursorObject isEqualTo 0}) then {
- [cursorObject] spawn life_fnc_openInventory;
- };
- };
- };
- };
- };
- };
- };
- //EMP Konsole - K
- case 37: {
- if (!_shift && !_alt && !_ctrlKey && (playerSide == west) && ((vehicle player getVariable "side") isEqualTo "cop") && (vehicle player != player) && (typeOf vehicle player) in ["O_Heli_Light_02_unarmed_F","I_Heli_light_03_unarmed_F"]) then {
- [] call life_fnc_openEmpMenu; [_this] call life_fnc_isEmpOperator;
- };
- };
- //L Key?
- case 38: {
- //If cop run checks for turning lights on.
- if (_shift) then {
- if (!isNil {vehicle player getVariable "lights"}) then {
- switch (vehicle player getVariable "side") do {
- case "cop": {[vehicle player] call life_fnc_sirenLights;};
- case "med": {[vehicle player] call life_fnc_medicSirenLights;};
- case "thw": {[vehicle player] call life_fnc_thwSirenLights;};
- };
- _handled = true;
- };
- };
- if (!_alt && !_ctrlKey) then { [] call life_fnc_radar; };
- };
- //Y Player Menu
- case 21: {
- if (!_alt && !_ctrlKey && !dialog && !(player getVariable ["restrained",false]) && !(player getVariable ["ziptied",false]) && {!life_action_inUse || MedicSystem_inAction}) then {
- [] call life_fnc_p_openMenu;
- };
- };
- //F Key
- case 33: {
- if(!_shift) then {
- if ((vehicle player != player) && !(vehicle player isKindOf "Air") && {!life_siren_active} && {((driver vehicle player) == player)}) then {
- if (!isNil {vehicle player getVariable "lights"}) 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];
- switch (_veh getVariable "side") do {
- case "cop": {[_veh] remoteExec ["life_fnc_copSiren",RCLIENT];};
- case "med": {[_veh] remoteExec ["life_fnc_medicSiren",RCLIENT];};
- case "thw": {[_veh] remoteExec ["life_fnc_thwSiren",RCLIENT];};
- };
- };
- };
- };
- };
- };
- //Q Key
- case 16: {
- if(!_shift) then {
- if ((vehicle player getVariable "side") in ["thw","med"] && !(vehicle player isKindOf "Air")) then {
- if (!isNil {vehicle player getVariable "lights"}) then {
- if ((vehicle player != player) && {!life_thwhorn_active} && {((driver vehicle player) == player)}) then {
- [] spawn {
- life_thwhorn_active = true;
- sleep 0.2;
- life_thwhorn_active = false;
- };
- _veh = vehicle player;
- if (isNil {_veh getVariable "thwhorn"}) then {_veh setVariable ["thwhorn",false,true];};
- if ((_veh getVariable "thwhorn")) then {
- _veh setVariable["thwhorn",false,true];
- } else {
- _veh setVariable["thwhorn",true,true];
- [_veh,"thwhorn"] remoteExec ["life_fnc_say3D",RANY];
- };
- };
- };
- };
- if ((vehicle player getVariable "side") isEqualTo "cop" && !(vehicle player isKindOf "Air")) then {
- if (!isNil {vehicle player getVariable "lights"}) then {
- if ((vehicle player != player) && {!life_copstopCar_active} && {((driver vehicle player) == player)}) then {
- [] spawn {
- life_copstopCar_active = true;
- sleep 0.2;
- life_copstopCar_active = false;
- };
- _veh = vehicle player;
- if (isNil {_veh getVariable "copstopCar"}) then {_veh setVariable ["copstopCar",false,true];};
- if ((_veh getVariable "copstopCar")) then {
- _veh setVariable["copstopCar",false,true];
- } else {
- _veh setVariable["copstopCar",true,true];
- [_veh,"copstopCar"] remoteExec ["life_fnc_say3D",RANY];
- };
- };
- };
- };
- };
- };
- //U Key
- case 22: {
- if (!_alt && !_ctrlKey) then {
- if (isNull objectParent player) then {
- _veh = cursorObject;
- } else {
- _veh = vehicle player;
- };
- if (_veh isKindOf "House_F" && {playerSide isEqualTo civilian}) then {
- if (_veh in life_vehicles && {player distance _veh < 20}) then {
- _door = [_veh] call life_fnc_nearestDoor;
- if (_door isEqualTo 0) exitWith {hint localize "STR_House_Door_NotNear"};
- _locked = _veh getVariable [format ["bis_disabled_Door_%1",_door],0];
- if (_locked isEqualTo 0) then {
- _veh setVariable [format ["bis_disabled_Door_%1",_door],1,true];
- _veh animateSource [format ["Door_%1_source", _door], 0];
- systemChat localize "STR_House_Door_Lock";
- } else {
- _veh setVariable [format ["bis_disabled_Door_%1",_door],0,true];
- _veh animateSource [format ["Door_%1_source", _door], 1];
- systemChat localize "STR_House_Door_Unlock";
- };
- };
- } else {
- _locked = locked _veh;
- if (_veh in life_vehicles && {player distance _veh < 20}) then {
- if (_locked isEqualTo 2) then {
- if (local _veh) then {
- _veh lock 0;
- // BI
- _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_L_source',1];
- _veh animateDoor ['Door_rear',1];
- _veh animateDoor ['Door_rear_source',1];
- _veh animateDoor ['Door_1_source',1];
- _veh animateDoor ['Door_2_source',1];
- _veh animateDoor ['Door_3_source',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];
- _veh animateDoor ['DoorL_Front_Open',1];
- _veh animateDoor ['DoorR_Front_Open',1];
- _veh animateDoor ['DoorL_Back_Open',1];
- _veh animateDoor ['DoorR_Back_Open ',1];
- } else {
- [_veh,0] remoteExecCall ["life_fnc_lockVehicle",_veh];
- _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_L_source',1];
- _veh animateDoor ['Door_rear',1];
- _veh animateDoor ['Door_rear_source',1];
- _veh animateDoor ['Door_1_source',1];
- _veh animateDoor ['Door_2_source',1];
- _veh animateDoor ['Door_3_source',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];
- _veh animateDoor ['DoorL_Front_Open',1];
- _veh animateDoor ['DoorR_Front_Open',1];
- _veh animateDoor ['DoorL_Back_Open',1];
- _veh animateDoor ['DoorR_Back_Open ',1];
- };
- //systemChat localize "STR_MISC_VehUnlock";
- hint localize "STR_MISC_VehUnlock";
- [_veh,"unlockCarSound"] remoteExec ["life_fnc_say3D",RANY];
- } 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_L_source',0];
- _veh animateDoor ['Door_rear',0];
- _veh animateDoor ['Door_rear_source',0];
- _veh animateDoor ['Door_1_source',0];
- _veh animateDoor ['Door_2_source',0];
- _veh animateDoor ['Door_3_source',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];
- _veh animateDoor ['DoorL_Front_Open',0];
- _veh animateDoor ['DoorR_Front_Open',0];
- _veh animateDoor ['DoorL_Back_Open',0];
- _veh animateDoor ['DoorR_Back_Open ',0];
- } else {
- [_veh,2] remoteExecCall ["life_fnc_lockVehicle",_veh];
- _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_L_source',0];
- _veh animateDoor ['Door_rear',0];
- _veh animateDoor ['Door_rear_source',0];
- _veh animateDoor ['Door_1_source',0];
- _veh animateDoor ['Door_2_source',0];
- _veh animateDoor ['Door_3_source',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];
- _veh animateDoor ['DoorL_Front_Open',0];
- _veh animateDoor ['DoorR_Front_Open',0];
- _veh animateDoor ['DoorL_Back_Open',0];
- _veh animateDoor ['DoorR_Back_Open ',0];
- };
- //systemChat localize "STR_MISC_VehLock";
- hint localize "STR_MISC_VehLock";
- [_veh,"unlockCarSound"] remoteExec ["life_fnc_say3D",RANY];
- };
- };
- };
- };
- };
- //4 Hi
- case 5: {
- if(vehicle player isEqualTo player) then {
- if(!life_action_inUse) then {
- player playActionNow "gestureHi";
- };
- };
- };
- //5 Hi low
- case 6: {
- if(vehicle player isEqualTo player) then {
- if(!life_action_inUse) then {
- player playActionNow "gestureHiC";
- };
- };
- };
- //6 Finger
- case 7: {
- if(vehicle player isEqualTo player) then {
- if(!life_action_inUse) then {
- player playActionNow "gestureHiB";
- };
- };
- };
- //7 nicken
- case 8: {
- if(vehicle player isEqualTo player) then {
- if(!life_action_inUse) then {
- player playActionNow "gesturenod";
- };
- };
- };
- };
- _handled;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement