Raised This Month: $ Target: $400
 0% 

PM_Jump


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
yuri69
New Member
Join Date: Sep 2011
Old 08-22-2012 , 13:35   PM_Jump
Reply With Quote #1

Found this ConnorMcLeod's Jump implementation via Orpheu
http://pastebin.com/74rsrfgg#

Tweaked it and added some bits like an imitation of the PM_FixupGravityVelocity() which I had found at the forum.

My question is, is this really equal to the actual 1.6 PM_Jump()? Cause according to my testing the 300+ u/sec jump speed punishment doesn't really work like in the 1.6.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#include <hlsdk_const>
#include <orpheu_stocks>
#include <xs>

new const VERSION[] = "0.0.3"
new const NAME[] = "yuri" // original by ConnorMcLeod
new OrpheuFunction:OfCheckVelocity;
new 
OrpheuStruct:ppmove;
    
public 
plugin_init()
{
    
register_plugin("Jump_CS-SDK"VERSIONNAME)
    
    
OrpheuRegisterHook(OrpheuGetDLLFunction("pfnPM_Move","PM_Move"), "OnPM_Move")
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"), "OnPM_Jump")
    
OfCheckVelocity OrpheuGetFunction("PM_CheckVelocity")  
}

public 
OrpheuHookReturn:OnPM_Move(OrpheuStruct:pmoveserver)
{
    
ppmove pmove;
}

           
public 
OrpheuHookReturn:OnPM_Jump()
{
    
// check if rly just jumping
    
if(        OrpheuGetStructMember(ppmove"dead")
        ||      
OrpheuGetStructMember(ppmove"waterjumptime")
        ||      
OrpheuGetStructMember(ppmove"waterlevel")
        ||      
OrpheuGetStructMember(ppmove"onground") == -1
        
||      (OrpheuGetStructMember(ppmove"oldbuttons") & IN_JUMP) )
    {
        return 
OrpheuIgnored
    
}

    
OrpheuSetStructMember(ppmove"onground", -1)

    new 
Float:fVecVelocity[3]

    
OrpheuGetStructMember(ppmove"velocity"fVecVelocity)

    
// max unpunished speed = 300 u/sec
    
new Float:maxscaledspeed 1.2 Float:OrpheuGetStructMember(ppmove"maxspeed")

    
// div 0 check
    
if ( maxscaledspeed 0.0 )
    {
        new 
Float:spd vector_length(fVecVelocity)
        
        
// too fast - punish
        
if ( spd maxscaledspeed )
        {
            
client_print(0print_chat"clamping %f"spd)
        
            
// apply the punishment
            
new Float:fraction = ( maxscaledspeed spd ) * 0.8//( 0.99 + random_float( 0.0020, 0.0045 ) );
            
xs_vec_mul_scalar(fVecVelocityfractionfVecVelocity)
        }
    }

    
    new 
Float:flGravity Float:OrpheuGetStructMember(ppmove"gravity")

    if( !
flGravity )
    {
        
flGravity 1.0
    
}

            
    
// base Z jump vel
    
fVecVelocity[2] = floatsqroot800 45.0 );
            
    
// determinate how much do we punish for too early jump
    
if( Float:OrpheuGetStructMember(ppmove"fuser2") > 0.0 )
    {
        
fVecVelocity[2] *= ( 100.0 Float:OrpheuGetStructMember(ppmove"fuser2") * 0.001 19.0 ) * 0.01;
    }

    static 
Float:fFrameTimeFloat:fPlayerGravity

    
// get member
    
global_get(glb_frametimefFrameTime)
    
    
//pev(id, pev_gravity, fPlayerGravity)
    //hack
    
fPlayerGravity 1.0
    
    
// apply gravity fix
    
fVecVelocity[2] -= fPlayerGravity fFrameTime 0.5 flGravity
    
    
// run the check of max vel
    
OrpheuCall(OfCheckVelocity)
    
    
// set the vel
    
OrpheuSetStructMember(ppmove"velocity"fVecVelocity)

    
// reset the timer
    
OrpheuSetStructMember(ppmove"fuser2"1315.7894)
            
    
// set buttons
    
OrpheuSetStructMember(ppmove"oldbuttons"OrpheuGetStructMember(ppmove"oldbuttons") | IN_JUMP)

    return 
OrpheuSupercede

yuri69 is offline
 



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 05:52.


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