Advertisement
aeroson

160133-Realistic-Jumping-Script

Aug 11th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. if (isNull player) exitwith {} ;
  2.  
  3. fn_jump_Animation =
  4. {
  5. private ["_unit", "_anim", "_weap"];
  6. _unit = _this select 0;
  7. _anim = _this select 1;
  8. _weap = primaryWeapon _unit;//remember weapon
  9.  
  10. _unit switchMove _anim;// PLAY ANIMATION JUMP
  11. if(currentWeapon _unit != _weap) then {
  12. sleep 0.6;
  13. _unit selectWeapon _weap;
  14. _unit switchMove "";
  15. };
  16. };
  17.  
  18. jump_keyDown={
  19. private ["_r", "_key_delay", "_max_height"] ;
  20. _actionKey = 46;
  21. _key_delay = 0.3;// MAX TIME BETWEEN KEY PRESSES
  22. _max_height = 4.3;// SET MAX JUMP HEIGHT
  23. // player setvariable ["key",false];// ENABLE THIS LINE FOR SINGLE KEYPRESS BY REMOVING // AT THE START OF THE LINE
  24. _r = false;
  25.  
  26. // HINT STR (_this select 1);// show key number
  27.  
  28. // VARIOUS CHECKS
  29. if (player getvariable["key", true] && (_this select 1) == _actionKey) exitwith {
  30. player setvariable["key", false];
  31. [_key_delay] spawn {
  32. sleep (_this select 0);
  33. player setvariable["key", true];
  34. };
  35. _r
  36. };
  37.  
  38. _speed = speed player;
  39. if ((_this select 1) == _actionKey && _speed>8) then {
  40.  
  41. if (
  42. player == vehicle player &&
  43. player getvariable ["jump", true] &&
  44. isTouchingGround player
  45. ) then {
  46.  
  47. player setvariable["key", true];// RESTE DOUBLE KEY TAP
  48. player setvariable["jump", false];// DISABLE JUMP
  49.  
  50. _height = 6-((load player)*10);// REDUCE HEIGHT BASED ON WEIGHT
  51. //hint str _height;
  52.  
  53. // MAKE JUMP IN RIGHT DIRECTION
  54. _vel = velocity player;
  55. _dir = direction player;
  56.  
  57. If (_height > _max_height) then { // MAXIMUM HEIGHT OF JUMP
  58. _height = _max_height
  59. };
  60.  
  61. player setVelocity [
  62. (_vel select 0)+(sin _dir*_speed),
  63. (_vel select 1)+(cos _dir*_speed),
  64. (_vel select 2)+_height
  65. ];
  66.  
  67. [[player, "AovrPercMrunSrasWrflDf"], "fn_Animation", true, false] spawn BIS_fnc_MP; //BROADCAST ANIMATION
  68. player spawn { // RE-ENABLE JUMP
  69. sleep 2;
  70. _this setvariable ["jump", true]
  71. };
  72.  
  73. };
  74.  
  75. _r=true;
  76.  
  77. };
  78.  
  79. _r;
  80.  
  81. } ;
  82.  
  83. waituntil {!(isNull (findDisplay 46))};
  84. (findDisplay 46) displayAddEventHandler ["keydown", "_this call jump_keyDown"];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement