PM_Jump
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", VERSION, NAME)
OrpheuRegisterHook(OrpheuGetDLLFunction("pfnPM_Move","PM_Move"), "OnPM_Move")
OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"), "OnPM_Jump")
OfCheckVelocity = OrpheuGetFunction("PM_CheckVelocity")
}
public OrpheuHookReturn:OnPM_Move(OrpheuStruct:pmove, server)
{
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(0, print_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(fVecVelocity, fraction, fVecVelocity)
}
}
new Float:flGravity = Float:OrpheuGetStructMember(ppmove, "gravity")
if( !flGravity )
{
flGravity = 1.0
}
// base Z jump vel
fVecVelocity[2] = floatsqroot( 2 * 800 * 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:fFrameTime, Float:fPlayerGravity
// get member
global_get(glb_frametime, fFrameTime)
//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
}
|