Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Created by Wyatt 6/8/16 under Creative Commons Attribution-ShareAlike 3.0 United States
- // This code detects every keypress that happens ingame to allow for custom functions. Functions may be defined for execution near the bottom.
- //Do we need to detect any DIK codes? If so, do it here
- // You can get more action keys from https://community.bistudio.com/wiki/inputAction/actions
- DIK_getover = actionkeys "GetOver"; //Keep in mind that actionkeys produces an array when using this variable.
- // Main keydown check
- keydown_fnc = {
- //This block is ran for every key pressed while in game. Dont do much (or any) evaluation here.
- //If you already have code for detecting keypresses I reccomend you MOVE lines 15 to 21 there and DELETE lines 62 to 64.
- switch (_this) do {
- {
- case _x: {
- [] spawn ANIM_jump;
- };
- case 35: {
- [] spawn holster;
- };
- } 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.
- };
- };
- // Jumping
- // 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.
- ANIM_jump = {
- if ((speed player > 8) && (vehicle player == player) && (isTouchingGround player) && (getfatigue player < 0.80) && (player getvariable["ANIM_jump_ready",true])) then {
- //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.
- player setvariable ["ANIM_jump_ready",false];//This prevents "Big air". Without it, its possible to repeat the acceleration upwards while mid jump.
- [player,""] remoteexec ['switchMove'];//Stop the regular climbover animation.
- //The below calculates the players target jump height, direction and velocity. These numbers attempt to simulate slight realisim.
- _height = 5; //"5-" is the starting upwards acceleration. Keep between 4-7. Higher numbers means more altitude.
- //"*4.25" is the weight penalty curve. Keep between 0-15. Higher numbers means more penalty for having weight.
- _speed = 0.5; //This is the added forward velocity during the jump.
- //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.
- //Math!
- player setVelocity [(velocity player select 0)+(sin direction player*_speed),(velocity player select 1)+(cos direction player*_speed),(velocity player select 2)+_height];
- //for X and Y we are taking the original velocity of the player and propeling them the direction they face with _speed.
- //for Z we are just taking their original velocity (in case of hill, etc) and adding the load adjusted jump _height above.
- [player,"AovrPercMrunSrasWrflDf"] remoteexec ['switchMove']; //The only jump animation is with a primary weapon. :(
- player setFatigue (getfatigue player + 0.2); //Here we cause fatigue.
- waitUntil {!isTouchingGround player};
- sleep 0.1;
- player setvariable ["ANIM_jump_ready",true]; //Re-enable the jump.
- };
- //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.
- if !((isTouchingGround player) && (player getvariable["ANIM_jump_ready",true])) then {
- waitUntil {(animationState player == "AovrPercMstpSrasWrflDf")};
- player switchMove "";
- };
- };
- holster = {
- player action ["SwitchWeapon", player, player, 100];
- player switchcamera cameraView;
- };
- //Start the EH to trigger keydown_fnc
- waituntil {!isnull (finddisplay 46)};
- (findDisplay 46) displayAddEventHandler ["KeyDown","_this select 1 call keydown_fnc;false;"];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement