Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.95 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. * File: fn_keyHandler.sqf
  4. * Author: Bryan "Tonic" Boardwine
  5. *
  6. * Description:
  7. * Main key handler for event 'keyDown'.
  8. */
  9. private ["_handled","_shift","_alt","_code","_ctrl","_alt","_ctrlKey","_veh","_locked","_interactionKey","_mapKey","_interruptionKeys"];
  10. _ctrl = _this select 0;
  11. _code = _this select 1;
  12. _shift = _this select 2;
  13. _ctrlKey = _this select 3;
  14. _alt = _this select 4;
  15. _speed = speed cursorObject;
  16. _handled = false;
  17.  
  18. _interactionKey = if (count (actionKeys "User10") isEqualTo 0) then {219} else {(actionKeys "User10") select 0};
  19. _mapKey = (actionKeys "ShowMap" select 0);
  20. //hint str _code;
  21. _interruptionKeys = [17,30,31,32]; //A,S,W,D
  22.  
  23. //Vault handling...
  24. 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 [16,18]) && ((player getVariable ["restrained",false]) || (player getVariable ["playerSurrender",false]) || life_isknocked || life_istazed)) exitWith {
  25. true;
  26. };
  27.  
  28. if (life_action_inUse) exitWith {
  29. if (!life_interrupted && _code in _interruptionKeys) then {life_interrupted = true;};
  30. _handled;
  31. };
  32.  
  33. //Hotfix for Interaction key not being able to be bound on some operation systems.
  34. if (!(count (actionKeys "User10") isEqualTo 0) && {(inputAction "User10" > 0)}) exitWith {
  35. //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
  36. if (!life_action_inUse) then {
  37. [] spawn {
  38. private "_handle";
  39. _handle = [] spawn life_fnc_actionKeyHandler;
  40. waitUntil {scriptDone _handle};
  41. life_action_inUse = false;
  42. };
  43. };
  44. true;
  45. };
  46.  
  47. if (life_container_active) then {
  48. switch (_code) do {
  49. //space key
  50. case 57: {
  51. [] spawn life_fnc_placestorage;
  52. };
  53. };
  54. true;
  55. };
  56.  
  57. if (life_barrier_active) then {
  58. switch (_code) do {
  59. case 57: {
  60. [] spawn life_fnc_placeablesPlaceComplete;
  61. };
  62. };
  63. true;
  64. };
  65.  
  66. if (life_barrier_active) then {
  67. switch (_code) do {
  68. case 57: {
  69. [] spawn life_fnc_placeablesPlaceComplete;
  70. };
  71. };
  72. true;
  73. };
  74.  
  75.  
  76. switch (_code) do {
  77. // -- Disable commander/tactical view
  78. if (LIFE_SETTINGS(getNumber,"disableCommanderView") isEqualTo 1) then {
  79. private _CommandMode = actionKeys "tacticalView";
  80.  
  81. if (_code in _CommandMode) then {
  82. hint localize "STR_NOTF_CommanderView";
  83. _handled = true;
  84. };
  85. };
  86.  
  87. //Space key for Jumping
  88. case 57: {
  89. if (isNil "jumpActionTime") then {jumpActionTime = 0;};
  90. 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 {
  91. jumpActionTime = time; //Update the time.
  92. [player] remoteExec ["life_fnc_jumpFnc",RANY]; //Global execution
  93. _handled = true;
  94. };
  95. };
  96.  
  97. //Surrender (Shift + B)
  98. case 48: {
  99. if (_shift) then {
  100. if (player getVariable ["playerSurrender",false]) then {
  101. player setVariable ["playerSurrender",false,true];
  102. } else {
  103. [] spawn life_fnc_surrender;
  104. };
  105. _handled = true;
  106. };
  107. };
  108.  
  109. //Map Key
  110. case _mapKey: {
  111. switch (playerSide) do {
  112. case west: {if (!visibleMap) then {[] spawn life_fnc_copMarkers;}};
  113. case independent: {if (!visibleMap) then {[] spawn life_fnc_medicMarkers;}};
  114. case civilian: {if (!visibleMap) then {[] spawn life_fnc_civMarkers;}};
  115. };
  116. };
  117.  
  118. //Holster / recall weapon. (Shift + H)
  119. case 35: {
  120. if (_shift && !_ctrlKey && !(currentWeapon player isEqualTo "")) then {
  121. life_curWep_h = currentWeapon player;
  122. player action ["SwitchWeapon", player, player, 100];
  123. player switchCamera cameraView;
  124. };
  125.  
  126. if (!_shift && _ctrlKey && !isNil "life_curWep_h" && {!(life_curWep_h isEqualTo "")}) then {
  127. if (life_curWep_h in [primaryWeapon player,secondaryWeapon player,handgunWeapon player]) then {
  128. player selectWeapon life_curWep_h;
  129. };
  130. };
  131. };
  132.  
  133. //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
  134. case _interactionKey: {
  135. if (!life_action_inUse) then {
  136. [] spawn {
  137. private "_handle";
  138. _handle = [] spawn life_fnc_actionKeyHandler;
  139. waitUntil {scriptDone _handle};
  140. life_action_inUse = false;
  141. };
  142. };
  143. };
  144.  
  145. //Restraining (Shift + R)
  146. case 19: {
  147. if (_shift) then {_handled = true;};
  148. if (_shift && playerSide isEqualTo west && {!isNull cursorObject} && {cursorObject isKindOf "Man"} && {(isPlayer cursorObject)} && {(side cursorObject in [civilian,independent])} && {alive cursorObject} && {cursorObject distance player < 3.5} && {!(cursorObject getVariable "Escorting")} && {!(cursorObject getVariable "restrained")} && {speed cursorObject < 1}) then {
  149. [] call life_fnc_restrainAction;
  150. };
  151. };
  152.  
  153. //T Key (Trunk)
  154. case 20: {
  155. if (!_alt && !_ctrlKey && !dialog && {!life_action_inUse}) then {
  156. if (!(isNull objectParent player) && alive vehicle player) then {
  157. if ((vehicle player) in life_vehicles) then {
  158. [vehicle player] spawn life_fnc_openInventory;
  159. };
  160. } else {
  161. private "_list";
  162. _list = ((ASLtoATL (getPosASL player)) nearEntities [["Box_IND_Grenades_F","B_supplyCrate_F"], 2.5]) select 0;
  163. if (!(isNil "_list")) then {
  164. _house = nearestObject [(ASLtoATL (getPosASL _list)), "House"];
  165. if (_house getVariable ["locked", false]) then {
  166. hint localize "STR_House_ContainerDeny";
  167. } else {
  168. [_list] spawn life_fnc_openInventory;
  169. };
  170. } else {
  171. _list = ["landVehicle","Air","Ship"];
  172. if (KINDOF_ARRAY(cursorObject,_list) && {player distance cursorObject < 7} && {isNull objectParent player} && {alive cursorObject} && {!life_action_inUse}) then {
  173. if (cursorObject in life_vehicles || {locked cursorObject isEqualTo 0}) then {
  174. [cursorObject] spawn life_fnc_openInventory;
  175. };
  176. };
  177. };
  178. };
  179. };
  180. };
  181.  
  182. //O Key?
  183. case 24: {
  184. //If cop run checks for turning lights on.
  185. if (_shift && playerSide in [west,independent]) then {
  186. if (!(isNull objectParent player) && (typeOf vehicle player) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","B_Heli_Light_01_F","B_Heli_Transport_01_F"]) then {
  187. if (!isNil {vehicle player getVariable "lights"}) then {
  188. if (playerSide isEqualTo west) then {
  189. [vehicle player] call life_fnc_sirenLights;
  190. } else {
  191. [vehicle player] call life_fnc_medicSirenLights;
  192. };
  193. _handled = true;
  194. };
  195. };
  196. };
  197.  
  198. if (!_alt && !_ctrlKey) then { [] call life_fnc_radar; };
  199. };
  200.  
  201. //Y Player Menu
  202. case 21: {
  203. if (!_alt && !_ctrlKey && !dialog && !(player getVariable ["restrained",false]) && {!life_action_inUse}) then {
  204. [] call life_fnc_p_openMenu;
  205. };
  206. };
  207.  
  208. //J Key
  209. case 36: {
  210. if (playerSide in [west,independent] && {vehicle player != player} && {!life_siren_active} && {((driver vehicle player) == player)}) then {
  211. [] spawn {
  212. life_siren_active = true;
  213. sleep 4.7;
  214. life_siren_active = false;
  215. };
  216.  
  217. _veh = vehicle player;
  218. if (isNil {_veh getVariable "siren"}) then {_veh setVariable ["siren",false,true];};
  219. if ((_veh getVariable "siren")) then {
  220. titleText [localize "STR_MISC_SirensOFF","PLAIN"];
  221. _veh setVariable ["siren",false,true];
  222. } else {
  223. titleText [localize "STR_MISC_SirensON","PLAIN"];
  224. _veh setVariable ["siren",true,true];
  225. if (playerSide isEqualTo west) then {
  226. [_veh] remoteExec ["life_fnc_copSiren",RCLIENT];
  227. } else {
  228. [_veh] remoteExec ["life_fnc_medicSiren",RCLIENT];
  229. };
  230. };
  231. };
  232. };
  233.  
  234. //F1 Key
  235. case 59:
  236. {
  237. switch (player getVariable["Earplugs",0]) do {
  238. case 0: {hintSilent "Sons réduit de 90%"; 1 fadeSound 0.1; player setVariable ["Earplugs", 10]; };
  239. case 10: {hintSilent "Sons réduit de 60%"; 1 fadeSound 0.4; player setVariable ["Earplugs", 40]; };
  240. case 40: {hintSilent "Sons réduit de 30%"; 1 fadeSound 0.7; player setVariable ["Earplugs", 70]; };
  241. case 70: {hintSilent "Sons à 100%"; 1 fadeSound 1; player setVariable ["Earplugs", 0]; };
  242. };
  243. };
  244.  
  245. //U Key
  246. case 22: {
  247. if (!_alt && !_ctrlKey) then {
  248. if (isNull objectParent player) then {
  249. _veh = cursorObject;
  250. } else {
  251. _veh = vehicle player;
  252. };
  253.  
  254. if (_veh isKindOf "House_F" && {playerSide isEqualTo civilian}) then {
  255. if (_veh in life_vehicles && {player distance _veh < 20}) then {
  256. _door = [_veh] call life_fnc_nearestDoor;
  257. if (_door isEqualTo 0) exitWith {hint localize "STR_House_Door_NotNear"};
  258. _locked = _veh getVariable [format ["bis_disabled_Door_%1",_door],0];
  259.  
  260. if (_locked isEqualTo 0) then {
  261. _veh setVariable [format ["bis_disabled_Door_%1",_door],1,true];
  262. _veh animateSource [format ["Door_%1_source", _door], 0];
  263. systemChat localize "STR_House_Door_Lock";
  264. } else {
  265. _veh setVariable [format ["bis_disabled_Door_%1",_door],0,true];
  266. _veh animateSource [format ["Door_%1_source", _door], 1];
  267. systemChat localize "STR_House_Door_Unlock";
  268. };
  269. };
  270. } else {
  271. _locked = locked _veh;
  272. if (_veh in life_vehicles && {player distance _veh < 20}) then {
  273. if (_locked isEqualTo 2) then {
  274. if (local _veh) then {
  275. _veh lock 0;
  276.  
  277. // BI
  278. _veh animateDoor ["door_back_R",1];
  279. _veh animateDoor ["door_back_L",1];
  280. _veh animateDoor ['door_R',1];
  281. _veh animateDoor ['door_L',1];
  282. _veh animateDoor ['Door_L_source',1];
  283. _veh animateDoor ['Door_rear',1];
  284. _veh animateDoor ['Door_rear_source',1];
  285. _veh animateDoor ['Door_1_source',1];
  286. _veh animateDoor ['Door_2_source',1];
  287. _veh animateDoor ['Door_3_source',1];
  288. _veh animateDoor ['Door_LM',1];
  289. _veh animateDoor ['Door_RM',1];
  290. _veh animateDoor ['Door_LF',1];
  291. _veh animateDoor ['Door_RF',1];
  292. _veh animateDoor ['Door_LB',1];
  293. _veh animateDoor ['Door_RB',1];
  294. _veh animateDoor ['DoorL_Front_Open',1];
  295. _veh animateDoor ['DoorR_Front_Open',1];
  296. _veh animateDoor ['DoorL_Back_Open',1];
  297. _veh animateDoor ['DoorR_Back_Open ',1];
  298. } else {
  299. [_veh,0] remoteExecCall ["life_fnc_lockVehicle",_veh];
  300.  
  301. _veh animateDoor ["door_back_R",1];
  302. _veh animateDoor ["door_back_L",1];
  303. _veh animateDoor ['door_R',1];
  304. _veh animateDoor ['door_L',1];
  305. _veh animateDoor ['Door_L_source',1];
  306. _veh animateDoor ['Door_rear',1];
  307. _veh animateDoor ['Door_rear_source',1];
  308. _veh animateDoor ['Door_1_source',1];
  309. _veh animateDoor ['Door_2_source',1];
  310. _veh animateDoor ['Door_3_source',1];
  311. _veh animateDoor ['Door_LM',1];
  312. _veh animateDoor ['Door_RM',1];
  313. _veh animateDoor ['Door_LF',1];
  314. _veh animateDoor ['Door_RF',1];
  315. _veh animateDoor ['Door_LB',1];
  316. _veh animateDoor ['Door_RB',1];
  317. _veh animateDoor ['DoorL_Front_Open',1];
  318. _veh animateDoor ['DoorR_Front_Open',1];
  319. _veh animateDoor ['DoorL_Back_Open',1];
  320. _veh animateDoor ['DoorR_Back_Open ',1];
  321. };
  322. systemChat localize "STR_MISC_VehUnlock";
  323. [_veh,"unlockCarSound"] remoteExec ["life_fnc_say3D",RANY];
  324. } else {
  325. if (local _veh) then {
  326. _veh lock 2;
  327.  
  328. _veh animateDoor ["door_back_R",0];
  329. _veh animateDoor ["door_back_L",0];
  330. _veh animateDoor ['door_R',0];
  331. _veh animateDoor ['door_L',0];
  332. _veh animateDoor ['Door_L_source',0];
  333. _veh animateDoor ['Door_rear',0];
  334. _veh animateDoor ['Door_rear_source',0];
  335. _veh animateDoor ['Door_1_source',0];
  336. _veh animateDoor ['Door_2_source',0];
  337. _veh animateDoor ['Door_3_source',0];
  338. _veh animateDoor ['Door_LM',0];
  339. _veh animateDoor ['Door_RM',0];
  340. _veh animateDoor ['Door_LF',0];
  341. _veh animateDoor ['Door_RF',0];
  342. _veh animateDoor ['Door_LB',0];
  343. _veh animateDoor ['Door_RB',0];
  344. _veh animateDoor ['DoorL_Front_Open',0];
  345. _veh animateDoor ['DoorR_Front_Open',0];
  346. _veh animateDoor ['DoorL_Back_Open',0];
  347. _veh animateDoor ['DoorR_Back_Open ',0];
  348. } else {
  349. [_veh,2] remoteExecCall ["life_fnc_lockVehicle",_veh];
  350.  
  351. _veh animateDoor ["door_back_R",0];
  352. _veh animateDoor ["door_back_L",0];
  353. _veh animateDoor ['door_R',0];
  354. _veh animateDoor ['door_L',0];
  355. _veh animateDoor ['Door_L_source',0];
  356. _veh animateDoor ['Door_rear',0];
  357. _veh animateDoor ['Door_rear_source',0];
  358. _veh animateDoor ['Door_1_source',0];
  359. _veh animateDoor ['Door_2_source',0];
  360. _veh animateDoor ['Door_3_source',0];
  361. _veh animateDoor ['Door_LM',0];
  362. _veh animateDoor ['Door_RM',0];
  363. _veh animateDoor ['Door_LF',0];
  364. _veh animateDoor ['Door_RF',0];
  365. _veh animateDoor ['Door_LB',0];
  366. _veh animateDoor ['Door_RB',0];
  367. _veh animateDoor ['DoorL_Front_Open',0];
  368. _veh animateDoor ['DoorR_Front_Open',0];
  369. _veh animateDoor ['DoorL_Back_Open',0];
  370. _veh animateDoor ['DoorR_Back_Open ',0];
  371. };
  372. systemChat localize "STR_MISC_VehLock";
  373. [_veh,"lockCarSound"] remoteExec ["life_fnc_say3D",RANY];
  374. };
  375. };
  376. };
  377. };
  378. };
  379. };
  380.  
  381. _handled;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement