Raised This Month: $ Target: $400
 0% 

Count length of jump ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4JOKE
Member
Join Date: Jan 2008
Old 03-27-2009 , 18:47   Count length of jump ?
Reply With Quote #1

It's possible to count length of jump which player just jumped ? If yes, how ? Thnx.
4JOKE is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 03-27-2009 , 18:48   Re: Count length of jump ?
Reply With Quote #2

check this http://forums.alliedmods.net/showthread.php?t=87906
__________________
Dr.G is offline
4JOKE
Member
Join Date: Jan 2008
Old 03-27-2009 , 18:54   Re: Count length of jump ?
Reply With Quote #3

wow thanks, fast reply
Ok, I will try to understand that code, hope it's not too much complicated...
4JOKE is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 03-27-2009 , 19:23   Re: Count length of jump ?
Reply With Quote #4

the plugin linked above is currently inaccurate, look at these calculations if you want to know how to calculate jumps. they were made by eDark. i translated the code for failed jumps and rewrote the code for nonfailed jumps which was translated into pawn by numb before.

feel free to ask if you have any question concerning the calculations

PHP Code:
// ducking = whether the player is ducking or not
// gravity = pev_gravity * sv_gravity
// jumpoff_origin = position at which the player jumped

// current_origin = position in which the player lands
// frame_origin[0] & frame_velocity[0] = first frame after jumping
// frame_origin[1] & frame_velocity[1] = last frame before landing
Float:calculate_nonfailed_distancebool:duckingFloat:gravityFloat:jumpoff_origin[3], Float:current_origin[3], Float:frame_origin[2][3], Float:frame_velocity[2][3] )
{
    static 
Float:distance1;
    
distance1 floatsqroot( ( jumpoff_origin[0] - current_origin[0] ) * ( jumpoff_origin[0] - current_origin[0] ) + ( jumpoff_origin[1] - current_origin[1] ) * ( jumpoff_origin[1] - current_origin[1] ) );
            
    static 
Float:airtime;
    
airtime = ( -floatsqrootframe_velocity[0][2] * frame_velocity[0][2] + ( 2.0 gravity * ( frame_origin[0][2] - current_origin[2] ) ) ) - frame_velocity[1][2] ) / -gravity;
            
    static 
Float:land_origin[3];
    
land_origin[0] = frame_origin[1][0] < current_origin[0] ? frame_origin[1][0] + airtime floatabsframe_velocity[1][0] ) : frame_origin[1][0] - airtime floatabsframe_velocity[1][0] );
    
land_origin[1] = frame_origin[1][1] < current_origin[1] ? frame_origin[1][1] + airtime floatabsframe_velocity[1][1] ) : frame_origin[1][1] - airtime floatabsframe_velocity[1][1] );
    
land_origin[2] = ducking current_origin[2] + 18.0 current_origin[2];
            
    static 
Float:distance2;
    
distance2 floatsqroot( ( jumpoff_origin[0] - land_origin[0] ) * ( jumpoff_origin[0] - land_origin[0] ) + ( jumpoff_origin[1] - land_origin[1] ) * ( jumpoff_origin[1] - land_origin[1] ) );
    
    return 
floatmindistance1distance2 ) + 32.0;
}

// current_velocity = velocity on landing
// failed_origin & failed_velocity = last frame in which the player could have landed
Float:calculate_failed_distancebool:duckingFloat:gravityFloat:jumpoff_origin[3], Float:current_velocity[3], Float:failed_origin[3], Float:failed_velocity[3] )
{
    if( 
ducking jumpoff_origin[2] -= 18.0;
            
    static 
Float:airtime;
    
airtime = ( -failed_velocity[2] - floatsqrootfailed_velocity[2] * failed_velocity[2] - 2.0 * -gravity * ( failed_origin[2] - jumpoff_origin[2] ) ) ) / -gravity;
    
    static 
Float:distance_xFloat:distance_y;
    
distance_x floatabsfailed_origin[0] - jumpoff_origin[0] ) + floatabscurrent_velocity[0] * airtime );
    
distance_y floatabsfailed_origin[1] - jumpoff_origin[1] ) + floatabscurrent_velocity[1] * airtime );
    
    return 
floatsqrootdistance_x distance_x distance_y distance_y ) + 32.0;

__________________

Last edited by SchlumPF*; 03-27-2009 at 19:26.
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-28-2009 , 15:19   Re: Count length of jump ?
Reply With Quote #5

Wow, the only calculation I understand here is the distance one, and nothing more.

Note: this is not a request for explanation.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
IneedHelp
Veteran Member
Join Date: Mar 2007
Location: Argentina
Old 03-28-2009 , 15:26   Re: Count length of jump ?
Reply With Quote #6

Can anybody explain me SchlumPF's code?
__________________
IneedHelp is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-28-2009 , 17:07   Re: Count length of jump ?
Reply With Quote #7

If you don't understand it, it's because it is higher math calculations.
They are based off of eDark, who is brilliant in mathematics.
If you want to understand it, read up on it on the XJ Website. It will be in their Forums.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode