Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. //Created by Wyatt 6/8/16 under Creative Commons Attribution-ShareAlike 3.0 United States
  2. // This code detects every keypress that happens ingame to allow for custom functions. Functions may be defined for execution near the bottom.
  3.  
  4.  
  5. //Do we need to detect any DIK codes? If so, do it here
  6. // You can get more action keys from https://community.bistudio.com/wiki/inputAction/actions
  7.  
  8. DIK_getover = actionkeys "GetOver"; //Keep in mind that actionkeys produces an array when using this variable.
  9.  
  10.  
  11. // Main keydown check
  12. keydown_fnc = {
  13. //This block is ran for every key pressed while in game. Dont do much (or any) evaluation here.
  14. //If you already have code for detecting keypresses I reccomend you MOVE lines 15 to 21 there and DELETE lines 62 to 64.
  15. switch (_this) do {
  16. {
  17. case _x: {
  18. [] spawn ANIM_jump;
  19. };
  20. case 35: {
  21. [] spawn holster;
  22. };
  23. } foreach DIK_getover; //Handle incoming actionkey DIK codes via foreach, instead of select 0 because some clients may have more than one button for it.
  24. };
  25. };
  26.  
  27.  
  28. // Jumping
  29. // This function can be placed with the rest of your functions, however I ask you keep the header (lines 1 and 2) with this code.
  30. ANIM_jump = {
  31. if ((speed player > 8) && (vehicle player == player) && (isTouchingGround player) && (getfatigue player < 0.80) && (player getvariable["ANIM_jump_ready",true])) then {
  32. //The above IF statement checks the players speed, makes sure the player is not in a vehicle, has not been too fatigued, and is not mid jump.
  33.  
  34. player setvariable ["ANIM_jump_ready",false];//This prevents "Big air". Without it, its possible to repeat the acceleration upwards while mid jump.
  35. [player,""] remoteexec ['switchMove'];//Stop the regular climbover animation.
  36.  
  37. //The below calculates the players target jump height, direction and velocity. These numbers attempt to simulate slight realisim.
  38. _height = 5; //"5-" is the starting upwards acceleration. Keep between 4-7. Higher numbers means more altitude.
  39. //"*4.25" is the weight penalty curve. Keep between 0-15. Higher numbers means more penalty for having weight.
  40. _speed = 0.5; //This is the added forward velocity during the jump.
  41. //0 will cause the person jumping to rely on their forward momentum. Adding to it "pushes" them forward during the jump. Numbers past 5 cause injury.
  42.  
  43. //Math!
  44. player setVelocity [(velocity player select 0)+(sin direction player*_speed),(velocity player select 1)+(cos direction player*_speed),(velocity player select 2)+_height];
  45. //for X and Y we are taking the original velocity of the player and propeling them the direction they face with _speed.
  46. //for Z we are just taking their original velocity (in case of hill, etc) and adding the load adjusted jump _height above.
  47.  
  48. [player,"AovrPercMrunSrasWrflDf"] remoteexec ['switchMove']; //The only jump animation is with a primary weapon. :(
  49. player setFatigue (getfatigue player + 0.2); //Here we cause fatigue.
  50.  
  51. waitUntil {!isTouchingGround player};
  52. sleep 0.1;
  53.  
  54. player setvariable ["ANIM_jump_ready",true]; //Re-enable the jump.
  55. };
  56.  
  57. //This bottom block is to avoid issues with pushing the button while mid air. Without it, a repeat push will cause the slow climb over when youve landed.
  58. if !((isTouchingGround player) && (player getvariable["ANIM_jump_ready",true])) then {
  59. waitUntil {(animationState player == "AovrPercMstpSrasWrflDf")};
  60. player switchMove "";
  61. };
  62. };
  63.  
  64. holster = {
  65. player action ["SwitchWeapon", player, player, 100];
  66. player switchcamera cameraView;
  67. };
  68. //Start the EH to trigger keydown_fnc
  69. waituntil {!isnull (finddisplay 46)};
  70. (findDisplay 46) displayAddEventHandler ["KeyDown","_this select 1 call keydown_fnc;false;"];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement