Raised This Month: $ Target: $400
 0% 

Count length of jump ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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*
 



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