Advertisement
friquentin

Untitled

Jan 2nd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.65 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 {157} 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.  
  34. //Hotfix for Interaction key not being able to be bound on some operation systems.
  35. if (!(count (actionKeys "User10") isEqualTo 0) && {(inputAction "User10" > 0)}) exitWith {
  36. //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
  37. if (!life_action_inUse) then {
  38. [] spawn {
  39. private "_handle";
  40. _handle = [] spawn life_fnc_actionKeyHandler;
  41. waitUntil {scriptDone _handle};
  42. life_action_inUse = false;
  43. };
  44. };
  45. true;
  46. };
  47.  
  48. if (life_container_active) then {
  49. switch (_code) do {
  50. //space key
  51. case 57: {
  52. [] spawn life_fnc_placestorage;
  53. };
  54. };
  55. true;
  56. };
  57.  
  58. switch (_code) do {
  59. // -- Disable commander/tactical view
  60. if (LIFE_SETTINGS(getNumber,"disableCommanderView") isEqualTo 1) then {
  61. private _CommandMode = actionKeys "tacticalView";
  62.  
  63. if (_code in _CommandMode) then {
  64. hint localize "STR_NOTF_CommanderView";
  65. _handled = true;
  66. };
  67. };
  68.  
  69. //Map Key
  70. case _mapKey: {
  71. execVM "core\functions\fn_actualiseMap.sqf";
  72. switch (playerSide) do {
  73. case west: {if (!visibleMap) then {[] spawn life_fnc_copMarkers;}};
  74. case independent: {if (!visibleMap) then {[] spawn life_fnc_medicMarkers;}};
  75. case civilian: {if (!visibleMap) then {[] spawn life_fnc_civMarkers;}};
  76. case east: {if(!visibleMap) then {[] spawn life_fnc_adacMarkers;}};
  77. };
  78. };
  79.  
  80. case 46 : {
  81. _currentPos = getPosATL life_barrier_activeObj;
  82. detach life_barrier_activeObj;
  83. life_barrier_activeObj setPos[(getPos life_barrier_activeObj select 0), (getPos life_barrier_activeObj select 1), 0];
  84. life_barrier_activeObj enableSimulationGlobal true;
  85. life_bar_placey pushBack life_barrier_activeObj;
  86. life_barrier_active = false;
  87. life_barrier_activeObj = ObjNull;
  88. hint "Vous avez placé l'objet !";
  89. };
  90.  
  91. // C = Ouverture des portes automatique
  92. case 46: {
  93. if (!_shift && !_alt && !_ctrlKey && (playerSide == west) && (vehicle player != player)) then {
  94. [] call life_fnc_copOpener;
  95. };
  96. };
  97.  
  98. //Holster / recall weapon. (Shift + H)
  99. case 35: {
  100. if (_shift && !_ctrlKey && !(currentWeapon player isEqualTo "")) then {
  101. life_curWep_h = currentWeapon player;
  102. player action ["SwitchWeapon", player, player, 100];
  103. player switchCamera cameraView;
  104. };
  105.  
  106. if (!_shift && _ctrlKey && !isNil "life_curWep_h" && {!(life_curWep_h isEqualTo "")}) then {
  107. if (life_curWep_h in [primaryWeapon player,secondaryWeapon player,handgunWeapon player]) then {
  108. player selectWeapon life_curWep_h;
  109. };
  110. };
  111. };
  112.  
  113. //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
  114. case _interactionKey: {
  115. if (!life_action_inUse) then {
  116. [] spawn {
  117. private "_handle";
  118. _handle = [] spawn life_fnc_actionKeyHandler;
  119. waitUntil {scriptDone _handle};
  120. life_action_inUse = false;
  121. };
  122. };
  123. };
  124.  
  125. //Restraining (Shift + R)
  126. case 19: {
  127. if (_shift) then {_handled = true;};
  128. 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 {
  129. };
  130. };
  131.  
  132. //Knock out, this is experimental and yeah... (Shift + G)
  133. case 34: {
  134. if (_shift) then {_handled = true;};
  135. if (_shift && playerSide isEqualTo civilian && !isNull cursorObject && cursorObject isKindOf "Man" && isPlayer cursorObject && alive cursorObject && cursorObject distance player < 4 && speed cursorObject < 1) then {
  136. 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 {
  137. [cursorObject] spawn life_fnc_knockoutAction;
  138. };
  139. };
  140. };
  141.  
  142. //T Key (Trunk)
  143. case 20: {
  144. if (!_alt && !_ctrlKey && !dialog && {!life_action_inUse}) then {
  145. if (!(isNull objectParent player) && alive vehicle player) then {
  146. if ((vehicle player) in life_vehicles) then {
  147. [vehicle player] spawn life_fnc_openInventory;
  148. };
  149. } else {
  150. private "_list";
  151. _list = ((ASLtoATL (getPosASL player)) nearEntities [["Box_IND_Grenades_F","B_supplyCrate_F","Land_Sink_F","Land_Workbench_01_F","Land_BarrelEmpty_grey_F","Land_BarrelEmpty_F","Land_WaterTank_F","Land_TripodScreen_01_large_F"], 2.5]) select 0;
  152. if (!(isNil "_list")) then {
  153. _house = nearestObject [(ASLtoATL (getPosASL _list)), "House"];
  154. if (_house getVariable ["locked", false]) then {
  155. hint localize "STR_House_ContainerDeny";
  156. } else {
  157. [_list] spawn life_fnc_openInventory;
  158. };
  159. } else {
  160. _list = ["landVehicle","Air","Ship"];
  161. if (KINDOF_ARRAY(cursorObject,_list) && {player distance cursorObject < 7} && {isNull objectParent player} && {alive cursorObject} && {!life_action_inUse}) then {
  162. if (cursorObject in life_vehicles || {locked cursorObject isEqualTo 0}) then {
  163. [cursorObject] spawn life_fnc_openInventory;
  164. };
  165. };
  166. };
  167. };
  168. };
  169. };
  170.  
  171. case 38: //Shift-L = Gyrophare / L= Radar
  172. {
  173. _veh = vehicle player;
  174. if (_shift && !_alt && !_ctrlKey) then
  175. {
  176. if(playerSide in [west,independent] && _veh != player && ((driver _veh) == player)) then
  177. {
  178. if(!isNil {_veh getVariable "lights"}) then
  179. {
  180. if(playerSide == west) then
  181. {
  182. [_veh] call life_fnc_sirenLights;
  183. } else {
  184. [_veh] call life_fnc_medicSirenLights;
  185. };
  186. };
  187. };
  188. _handled = true;
  189. };
  190. if (!_alt && !_ctrlKey && playerSide == west) then { [] call life_fnc_radar; };
  191. };
  192.  
  193. //Y Iphone X
  194. case 21: {
  195. if (!_alt && !_ctrlKey && !dialog && !(player getVariable ["restrained",false]) && {!life_action_inUse}) then {
  196. if ("Mattaust_Phone" in assignedItems player) then {
  197. [1] spawn the_programmer_iphone_fnc_phone_init;
  198. } else {
  199. hint "Vous n'avez pas de telephone dans votre poche";
  200. };
  201. };
  202. };
  203.  
  204. //F Key
  205. case 33: {
  206. if (playerSide in [west,independent] && {vehicle player != player} && {!life_siren_active} && {((driver vehicle player) == player)}) then {
  207. [] spawn {
  208. life_siren_active = true;
  209. sleep 4.7;
  210. life_siren_active = false;
  211. };
  212.  
  213. _veh = vehicle player;
  214. if (isNil {_veh getVariable "siren"}) then {_veh setVariable ["siren",false,true];};
  215. if ((_veh getVariable "siren")) then {
  216. titleText [localize "STR_MISC_SirensOFF","PLAIN"];
  217. _veh setVariable ["siren",false,true];
  218. if !(isNil {(_veh getVariable "sirenJIP")}) then {
  219. private _jip = _veh getVariable "sirenJIP";
  220. _veh setVariable ["sirenJIP",nil,true];
  221. remoteExec ["",_jip]; //remove from JIP queue
  222. };
  223. } else {
  224. titleText [localize "STR_MISC_SirensON","PLAIN"];
  225. _veh setVariable ["siren",true,true];
  226. private "_jip";
  227. if (playerSide isEqualTo west) then {
  228. _jip = [_veh] remoteExec ["life_fnc_copSiren",RCLIENT,true];
  229. } else {
  230. _jip = [_veh] remoteExec ["life_fnc_medicSiren",RCLIENT,true];
  231. };
  232. _veh setVariable ["sirenJIP",_jip,true];
  233. };
  234. };
  235. };
  236.  
  237. //Ninja(Shift + Num 1)
  238. case 79:
  239. {
  240. if(_shift) then {_handled = true;};
  241. if ((_shift) && (vehicle player == player)) then
  242. {
  243. cutText [format["Moi j'aime le riz cantonné !!!"], "PLAIN DOWN"];
  244. player playMove "AmovPercMstpSnonWnonDnon_exerciseKata";
  245. };
  246. };
  247.  
  248. //Kneebend Lent(Shift + Num 2)
  249. case 80:
  250. {
  251. if(_shift) then {_handled = true;};
  252. if ((_shift) && (vehicle player == player)) then
  253. {
  254. cutText [format["Tranquille ma guelle~"], "PLAIN DOWN"];
  255. player playMove "AmovPercMstpSnonWnonDnon_exercisekneeBendA";
  256. };
  257. };
  258.  
  259. //Movement rapide(Shift + Num 3)
  260. case 81:
  261. {
  262. if(_shift) then {_handled = true;};
  263. if ((_shift) && (vehicle player == player)) then
  264. {
  265. cutText [format["Allez on bouge !!!!"], "PLAIN DOWN"];
  266. player playMove "AmovPercMstpSnonWnonDnon_exercisekneeBendB";
  267. };
  268. };
  269.  
  270. //Pompe(Shift + Num 4)
  271. case 75:
  272. {
  273. if(_shift) then {_handled = true;};
  274. if ((_shift) && (vehicle player == player)) then
  275. {
  276. cutText [format["POMPES!!!!!!"], "PLAIN DOWN"];
  277. player playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
  278. };
  279. };
  280.  
  281. //U Key
  282. case 22: {
  283. if (!_alt && !_ctrlKey) then {
  284. if (isNull objectParent player) then {
  285. _veh = cursorObject;
  286. } else {
  287. _veh = vehicle player;
  288. };
  289.  
  290. if (_veh isKindOf "House_F" && {playerSide isEqualTo civilian}) then {
  291. if (_veh in life_vehicles && {player distance _veh < 20}) then {
  292. _door = [_veh] call life_fnc_nearestDoor;
  293. if (_door isEqualTo 0) exitWith {hint localize "STR_House_Door_NotNear"};
  294. _locked = _veh getVariable [format ["bis_disabled_Door_%1",_door],0];
  295.  
  296. if (_locked isEqualTo 0) then {
  297. _veh setVariable [format ["bis_disabled_Door_%1",_door],1,true];
  298. _veh animateSource [format ["Door_%1_source", _door], 0];
  299. systemChat localize "STR_House_Door_Lock";
  300. } else {
  301. _veh setVariable [format ["bis_disabled_Door_%1",_door],0,true];
  302. _veh animateSource [format ["Door_%1_source", _door], 1];
  303. systemChat localize "STR_House_Door_Unlock";
  304. };
  305. };
  306. } else {
  307. _locked = locked _veh;
  308. if (_veh in life_vehicles && {player distance _veh < 20}) then {
  309. if (_locked isEqualTo 2) then {
  310. #include "..\..\The-Programmer\Contravention\scripts\unlockVehCheck.sqf"
  311. if (local _veh) then {
  312. _veh lock 0;
  313.  
  314. // BI
  315. _veh animateDoor ["door_back_R",1];
  316. _veh animateDoor ["door_back_L",1];
  317. _veh animateDoor ['door_R',1];
  318. _veh animateDoor ['door_L',1];
  319. _veh animateDoor ['Door_L_source',1];
  320. _veh animateDoor ['Door_rear',1];
  321. _veh animateDoor ['Door_rear_source',1];
  322. _veh animateDoor ['Door_1_source',1];
  323. _veh animateDoor ['Door_2_source',1];
  324. _veh animateDoor ['Door_3_source',1];
  325. _veh animateDoor ['Door_LM',1];
  326. _veh animateDoor ['Door_RM',1];
  327. _veh animateDoor ['Door_LF',1];
  328. _veh animateDoor ['Door_RF',1];
  329. _veh animateDoor ['Door_LB',1];
  330. _veh animateDoor ['Door_RB',1];
  331. _veh animateDoor ['DoorL_Front_Open',1];
  332. _veh animateDoor ['DoorR_Front_Open',1];
  333. _veh animateDoor ['DoorL_Back_Open',1];
  334. _veh animateDoor ['DoorR_Back_Open ',1];
  335. } else {
  336. [_veh,0] remoteExecCall ["life_fnc_lockVehicle",_veh];
  337.  
  338. _veh animateDoor ["door_back_R",1];
  339. _veh animateDoor ["door_back_L",1];
  340. _veh animateDoor ['door_R',1];
  341. _veh animateDoor ['door_L',1];
  342. _veh animateDoor ['Door_L_source',1];
  343. _veh animateDoor ['Door_rear',1];
  344. _veh animateDoor ['Door_rear_source',1];
  345. _veh animateDoor ['Door_1_source',1];
  346. _veh animateDoor ['Door_2_source',1];
  347. _veh animateDoor ['Door_3_source',1];
  348. _veh animateDoor ['Door_LM',1];
  349. _veh animateDoor ['Door_RM',1];
  350. _veh animateDoor ['Door_LF',1];
  351. _veh animateDoor ['Door_RF',1];
  352. _veh animateDoor ['Door_LB',1];
  353. _veh animateDoor ['Door_RB',1];
  354. _veh animateDoor ['DoorL_Front_Open',1];
  355. _veh animateDoor ['DoorR_Front_Open',1];
  356. _veh animateDoor ['DoorL_Back_Open',1];
  357. _veh animateDoor ['DoorR_Back_Open ',1];
  358. };
  359. systemChat localize "STR_MISC_VehUnlock";
  360. [_veh,"carUnlock"] remoteExec ["life_fnc_say3D",RANY];
  361. } else {
  362. if (local _veh) then {
  363. _veh lock 2;
  364.  
  365. _veh animateDoor ["door_back_R",0];
  366. _veh animateDoor ["door_back_L",0];
  367. _veh animateDoor ['door_R',0];
  368. _veh animateDoor ['door_L',0];
  369. _veh animateDoor ['Door_L_source',0];
  370. _veh animateDoor ['Door_rear',0];
  371. _veh animateDoor ['Door_rear_source',0];
  372. _veh animateDoor ['Door_1_source',0];
  373. _veh animateDoor ['Door_2_source',0];
  374. _veh animateDoor ['Door_3_source',0];
  375. _veh animateDoor ['Door_LM',0];
  376. _veh animateDoor ['Door_RM',0];
  377. _veh animateDoor ['Door_LF',0];
  378. _veh animateDoor ['Door_RF',0];
  379. _veh animateDoor ['Door_LB',0];
  380. _veh animateDoor ['Door_RB',0];
  381. _veh animateDoor ['DoorL_Front_Open',0];
  382. _veh animateDoor ['DoorR_Front_Open',0];
  383. _veh animateDoor ['DoorL_Back_Open',0];
  384. _veh animateDoor ['DoorR_Back_Open ',0];
  385. } else {
  386. [_veh,2] remoteExecCall ["life_fnc_lockVehicle",_veh];
  387.  
  388. _veh animateDoor ["door_back_R",0];
  389. _veh animateDoor ["door_back_L",0];
  390. _veh animateDoor ['door_R',0];
  391. _veh animateDoor ['door_L',0];
  392. _veh animateDoor ['Door_L_source',0];
  393. _veh animateDoor ['Door_rear',0];
  394. _veh animateDoor ['Door_rear_source',0];
  395. _veh animateDoor ['Door_1_source',0];
  396. _veh animateDoor ['Door_2_source',0];
  397. _veh animateDoor ['Door_3_source',0];
  398. _veh animateDoor ['Door_LM',0];
  399. _veh animateDoor ['Door_RM',0];
  400. _veh animateDoor ['Door_LF',0];
  401. _veh animateDoor ['Door_RF',0];
  402. _veh animateDoor ['Door_LB',0];
  403. _veh animateDoor ['Door_RB',0];
  404. _veh animateDoor ['DoorL_Front_Open',0];
  405. _veh animateDoor ['DoorR_Front_Open',0];
  406. _veh animateDoor ['DoorL_Back_Open',0];
  407. _veh animateDoor ['DoorR_Back_Open ',0];
  408. };
  409. systemChat localize "STR_MISC_VehLock";
  410. [_veh,"carLock"] remoteExec ["life_fnc_say3D",RANY];
  411. };
  412. };
  413. };
  414. };
  415. };
  416. };
  417.  
  418. _handled;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement