Raised This Month: $51 Target: $400
 12% 

DoubleJump problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mouro
New Member
Join Date: Sep 2020
Old 09-01-2020 , 14:07   DoubleJump problems
Reply With Quote #1

So I decided to rewrite Paegus' Double Jump plugin, so that it would look like TF2 Scout double jump. I binded positive and negative boosts to WASD, but then I faced a problem: everything was normal, when I jumped looking in a certain direction, but if I turned jumps also changed direction.

I tried to solve this problem on my own but could not find a solution. Can someone please help me with this?

P.S. I just recently started learning modding, so I apologize if this seems like a silly question.
Mouro is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-02-2020 , 06:35   Re: DoubleJump problems
Reply With Quote #2

...I tried mimic code from TF2, AirDash()


This work behind sm_test command.
- There is no jump limits or ground entity check. You can spam.
- I made simple, check which buttons are pressed and send player to that direction.
- Angle is taken from player body, not eyes, like in original code.
- Tested only in CSGO. In other games right and left buttons can be different.

Here is one more snippet
[SNIPPET] Detecting button presses (and releases)


PHP Code:

ConVar sv_maxspeed
;
ConVar sv_cs_player_speed_has_hostage;
ConVar mp_heavyassaultsuit_speed;
//ConVar mp_shield_speed_deployed;
//ConVar mp_shield_speed_holstered;



#include <sdktools>

public void OnPluginStart()
{
    
sv_maxspeed FindConVar("sv_maxspeed");
    if(
sv_maxspeed == nullSetFailState("Game has no ConVar 'sv_maxspeed' ");
    
    
sv_cs_player_speed_has_hostage FindConVar("sv_cs_player_speed_has_hostage");
    
mp_heavyassaultsuit_speed FindConVar("mp_heavyassaultsuit_speed");
    
//mp_shield_speed_deployed = FindConVar("mp_shield_speed_deployed");
    //mp_shield_speed_holstered = FindConVar("mp_shield_speed_holstered");

    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{
    
TFGameMovement_AirDash(client);

    return 
Plugin_Handled;
}




// snip TF2 Scout AirDash()
void TFGameMovement_AirDash(int client)
{

    
float flJumpMod 1.0;
    
    
/*
        to do: code for JumpMod
    */



    // TF2 Scout Air Dash jump up boost velocity
    
float flDashZ 268.3281572999747 flJumpMod;
    

    
// Calculate x, y angle, direction of player body in world, in vectors
    
float m_vecViewAngles[3], vecForward[3], vecRight[3];

    
GetClientAbsAngles(clientm_vecViewAngles);
    
GetAngleVectors(m_vecViewAnglesvecForwardvecRightNULL_VECTOR);

    
// clear z-axis
    
vecForward[2] = 0.0;
    
vecRight[2] = 0.0;


    
// Scale vector length to 1.0 (unit vector )?
    
NormalizeVector(vecForwardvecForward);
    
NormalizeVector(vecRightvecRight);


    
// Set base speed value
    
float m_flMaxSpeed 240.0;

    
GetPlayerMaxSpeed(clientm_flMaxSpeed); // <-- remove this if you don't want edit speed


    // Into this next code, I don't understand how flForwardMove & flSideMove get value in original code.
    // So I made this simple way... check buttons pressed -> set velocity in that direction

    
int buttons GetClientButtons(client);

    
// player pressing both buttons
    
if(buttons IN_FORWARD && buttons IN_BACK)
    {
        
buttons &= ~IN_FORWARD & ~IN_BACK;
    }
    
    
// player pressing both buttons
    
if(buttons IN_MOVERIGHT && buttons IN_MOVELEFT)
    {
        
buttons &= ~IN_MOVERIGHT & ~IN_MOVELEFT;
    }


    
float flForwardMove =     buttons IN_FORWARD    m_flMaxSpeed:(buttons IN_BACK        ? -1.0 m_flMaxSpeed:0.0);
    
float flSideMove =         buttons IN_MOVERIGHT    m_flMaxSpeed:(buttons IN_MOVELEFT    ? -1.0 m_flMaxSpeed:0.0);





    
// "Find the direction, velocity in the x,y plane." - original comment in Valve code
    
float vecWishDirection[3];
    
vecWishDirection[0] = ( vecForward[0] * flForwardMove ) + ( vecRight[0] * flSideMove );
    
vecWishDirection[1] = ( vecForward[1] * flForwardMove ) + ( vecRight[1] * flSideMove );
    
vecWishDirection[2] = flDashZ;

    

    
// update player vecVelocity[]
    
TeleportEntity(clientNULL_VECTORNULL_VECTORvecWishDirection);
}



// Different situations when player max speed is capped
// 
void GetPlayerMaxSpeed(int clientfloat &speed)
{


    
//float speed; = BaseClass::GetPlayerMaxSpeed();

    
if(HasEntProp(clientProp_Send"m_flMaxSpeed"))
    {
        
speed GetEntPropFloat(clientProp_Send"m_flMaxspeed");
        
        if(
speed sv_maxspeed.FloatValue)
        {
            
speed sv_maxspeed.FloatValue;
        }
    }



    if(
HasEntProp(clientProp_Send"m_hCarriedHostage") && GetEntPropEnt(clientProp_Send"m_hCarriedHostage") != -1)
    {
        if(
sv_cs_player_speed_has_hostage != null && speed sv_cs_player_speed_has_hostage.FloatValue)
        {
            
speed sv_cs_player_speed_has_hostage.FloatValue;
        }
    }

    if(
HasEntProp(clientProp_Send"m_bHasHeavyArmor") && GetEntProp(clientProp_Send"m_bHasHeavyArmor"))
    {
        if(
mp_heavyassaultsuit_speed != null && speed mp_heavyassaultsuit_speed.FloatValue)
        {
            
speed mp_heavyassaultsuit_speed.FloatValue;
        }
    }
    
    
// to do: weapon max speed
}


/*

// piece of original code

    speed = MIN( CS_PLAYER_SPEED_RUN, speed );
    
    if ( IsVIP() == true )  // VIP is slow due to the armour he's wearing
    {
        speed = CS_PLAYER_SPEED_VIP;
    }
    else if ( m_hCarriedHostage != NULL )
    {
        speed = CS_PLAYER_SPEED_HAS_HOSTAGE;
    }
    else
    {
        CWeaponCSBase *pWeapon = dynamic_cast<CWeaponCSBase*>( GetActiveWeapon() );

        if ( pWeapon )
        {
            if ( HasShield() && IsShieldDrawn() )
            {
                speed = MIN( CS_PLAYER_SPEED_SHIELD, speed );    
            }
            else
            {
                speed = MIN( pWeapon->GetMaxSpeed(), speed );
            }
        }
    }
}
*/ 
__________________
Do not Private Message @me

Last edited by Bacardi; 09-02-2020 at 08:15. Reason: -1 to -1.0
Bacardi is offline
Mouro
New Member
Join Date: Sep 2020
Old 09-02-2020 , 07:48   Re: DoubleJump problems
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
...I tried mimic code from TF2, AirDash()


This work behind sm_test command.
- There is no jump limits or ground entity check. You can spam.
- I made simple, check which buttons are pressed and send player to that direction.
- Angle is taken from player body, not eyes, like in original code.
- Tested only in CSGO. In other games right and left buttons can be different.

Here is one more snippet
[SNIPPET] Detecting button presses (and releases)


PHP Code:

ConVar sv_maxspeed
;
ConVar sv_cs_player_speed_has_hostage;
ConVar mp_heavyassaultsuit_speed;
//ConVar mp_shield_speed_deployed;
//ConVar mp_shield_speed_holstered;



#include <sdktools>

public void OnPluginStart()
{
    
sv_maxspeed FindConVar("sv_maxspeed");
    if(
sv_maxspeed == nullSetFailState("Game has no ConVar 'sv_maxspeed' ");
    
    
sv_cs_player_speed_has_hostage FindConVar("sv_cs_player_speed_has_hostage");
    
mp_heavyassaultsuit_speed FindConVar("mp_heavyassaultsuit_speed");
    
//mp_shield_speed_deployed = FindConVar("mp_shield_speed_deployed");
    //mp_shield_speed_holstered = FindConVar("mp_shield_speed_holstered");

    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{
    
TFGameMovement_AirDash(client);

    return 
Plugin_Handled;
}




// snip TF2 Scout AirDash()
void TFGameMovement_AirDash(int client)
{

    
float flJumpMod 1.0;
    
    
/*
        to do: code for JumpMod
    */



    // TF2 Scout Air Dash jump up boost velocity
    
float flDashZ 268.3281572999747 flJumpMod;
    

    
// Calculate x, y angle, direction of player body in world, in vectors
    
float m_vecViewAngles[3], vecForward[3], vecRight[3];

    
GetClientAbsAngles(clientm_vecViewAngles);
    
GetAngleVectors(m_vecViewAnglesvecForwardvecRightNULL_VECTOR);

    
// clear z-axis
    
vecForward[2] = 0.0;
    
vecRight[2] = 0.0;


    
// Scale vector length to 1.0 (unit vector )?
    
NormalizeVector(vecForwardvecForward);
    
NormalizeVector(vecRightvecRight);


    
// Set base speed value
    
float m_flMaxSpeed 240.0;

    
GetPlayerMaxSpeed(clientm_flMaxSpeed); // <-- remove this if you don't want edit speed


    // Into this next code, I don't understand how flForwardMove & flSideMove get value in original code.
    // So I made this simple way... check buttons pressed -> set velocity in that direction

    
int buttons GetClientButtons(client);

    
// player pressing both buttons
    
if(buttons IN_FORWARD && buttons IN_BACK)
    {
        
buttons &= ~IN_FORWARD & ~IN_BACK;
    }
    
    
// player pressing both buttons
    
if(buttons IN_MOVERIGHT && buttons IN_MOVELEFT)
    {
        
buttons &= ~IN_MOVERIGHT & ~IN_MOVELEFT;
    }


    
float flForwardMove =     buttons IN_FORWARD    m_flMaxSpeed:(buttons IN_BACK        ? -m_flMaxSpeed:0.0);
    
float flSideMove =         buttons IN_MOVERIGHT    m_flMaxSpeed:(buttons IN_MOVELEFT    ? -m_flMaxSpeed:0.0);





    
// "Find the direction, velocity in the x,y plane." - original comment in Valve code
    
float vecWishDirection[3];
    
vecWishDirection[0] = ( vecForward[0] * flForwardMove ) + ( vecRight[0] * flSideMove );
    
vecWishDirection[1] = ( vecForward[1] * flForwardMove ) + ( vecRight[1] * flSideMove );
    
vecWishDirection[2] = flDashZ;

    

    
// update player vecVelocity[]
    
TeleportEntity(clientNULL_VECTORNULL_VECTORvecWishDirection);
}



// Different situations when player max speed is capped
// 
void GetPlayerMaxSpeed(int clientfloat &speed)
{


    
//float speed; = BaseClass::GetPlayerMaxSpeed();

    
if(HasEntProp(clientProp_Send"m_flMaxSpeed"))
    {
        
speed GetEntPropFloat(clientProp_Send"m_flMaxspeed");
        
        if(
speed sv_maxspeed.FloatValue)
        {
            
speed sv_maxspeed.FloatValue;
        }
    }



    if(
HasEntProp(clientProp_Send"m_hCarriedHostage") && GetEntPropEnt(clientProp_Send"m_hCarriedHostage") != -1)
    {
        if(
sv_cs_player_speed_has_hostage != null && speed sv_cs_player_speed_has_hostage.FloatValue)
        {
            
speed sv_cs_player_speed_has_hostage.FloatValue;
        }
    }

    if(
HasEntProp(clientProp_Send"m_bHasHeavyArmor") && GetEntProp(clientProp_Send"m_bHasHeavyArmor"))
    {
        if(
mp_heavyassaultsuit_speed != null && speed mp_heavyassaultsuit_speed.FloatValue)
        {
            
speed mp_heavyassaultsuit_speed.FloatValue;
        }
    }
    
    
// to do: weapon max speed
}


/*

// piece of original code

    speed = MIN( CS_PLAYER_SPEED_RUN, speed );
    
    if ( IsVIP() == true )  // VIP is slow due to the armour he's wearing
    {
        speed = CS_PLAYER_SPEED_VIP;
    }
    else if ( m_hCarriedHostage != NULL )
    {
        speed = CS_PLAYER_SPEED_HAS_HOSTAGE;
    }
    else
    {
        CWeaponCSBase *pWeapon = dynamic_cast<CWeaponCSBase*>( GetActiveWeapon() );

        if ( pWeapon )
        {
            if ( HasShield() && IsShieldDrawn() )
            {
                speed = MIN( CS_PLAYER_SPEED_SHIELD, speed );    
            }
            else
            {
                speed = MIN( pWeapon->GetMaxSpeed(), speed );
            }
        }
    }
}
*/ 
Thank you very much! It's working properly now.
Mouro 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 16:27.


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