friquentin

Untitled

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