AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Count length of jump ? (https://forums.alliedmods.net/showthread.php?t=88649)

4JOKE 03-27-2009 18:47

Count length of jump ?
 
It's possible to count length of jump which player just jumped ? If yes, how ? Thnx.

Dr.G 03-27-2009 18:48

Re: Count length of jump ?
 
check this http://forums.alliedmods.net/showthread.php?t=87906

4JOKE 03-27-2009 18:54

Re: Count length of jump ?
 
wow thanks, fast reply :D
Ok, I will try to understand that code, hope it's not too much complicated...

SchlumPF* 03-27-2009 19:23

Re: Count length of jump ?
 
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;



Dores 03-28-2009 15:19

Re: Count length of jump ?
 
Wow, the only calculation I understand here is the distance one, and nothing more. :shock:

Note: this is not a request for explanation.

IneedHelp 03-28-2009 15:26

Re: Count length of jump ?
 
Can anybody explain me SchlumPF's code?

Exolent[jNr] 03-28-2009 17:07

Re: Count length of jump ?
 
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.


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

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