Raised This Month: $ Target: $400
 0% 

G-strafe/Double-duck in CS:GO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mehis
Senior Member
Join Date: Mar 2013
Location: basement
Old 06-17-2015 , 09:30   Re: G-strafe/Double-duck in CS:GO
Reply With Quote #1

Sorry, I was probably using sm_rcon instead of sm_cvar ;)

Here's what I did:

PHP Code:
#include <sourcemod>
#include <sdktools>

#define DOUBLEDUCK_HEIGHT 32.0 // Has to be more or equal to 20 units.

public Action OnPlayerRunCmdint clientint &buttons )
{
    if ( !
IsPlayerAliveclient ) ) return Plugin_Continue;
    
    static 
int fFlags;
    
fFlags GetEntityFlagsclient );
    
    if ( 
fFlags FL_ONGROUND )
    {
        static 
bool bAllowDoubleDuck[MAXPLAYERS];
        
        if ( 
fFlags FL_DUCKING )
        {
            
// We're fully crouched, no doubleducking.
            
bAllowDoubleDuck[client] = false;
            return 
Plugin_Continue;
        }
        
        if ( 
buttons IN_DUCK )
        {
            
// Next time when we're not holding duck we can do a doubleduck.
            
bAllowDoubleDuck[client] = true;
            return 
Plugin_Continue;
        }
        
        
        
// Is transitioning?
        // m_bDucking doesn't actually tell us whether we're uncrouching or crouching. That is why we're using bAllowDoubleDuck.
        
if ( GetEntPropclientProp_Data"m_bDucking" ) && bAllowDoubleDuck[client] )
        {
            
float vecPos[3];
            
GetClientAbsOriginclientvecPos );
            
vecPos[2] += DOUBLEDUCK_HEIGHT
            
            if ( 
IsValidPlayerPosclientvecPos ) )
            {
                
TeleportEntityclientvecPosNULL_VECTORNULL_VECTOR );
            }
        }

    }
    
    return 
Plugin_Continue;
}

public 
bool IsValidPlayerPosint clientfloat vecPos[3] )
{
    static const 
float vecMins[] = { -16.0, -16.00.0 };
    static const 
float vecMaxs[] = { 16.016.072.0 };
    
    
TR_TraceHullFiltervecPosvecPosvecMinsvecMaxsMASK_SOLIDTraceFilter_IgnorePlayerclient );
    
    return ( !
TR_DidHitnull ) );
}

public 
bool TraceFilter_IgnorePlayerint entint maskany ignore_me )
{
    return ( 
ent != ignore_me );


Last edited by Mehis; 06-17-2015 at 09:37.
Mehis is offline
Beaverboys
Member
Join Date: Aug 2012
Old 06-17-2015 , 09:42   Re: G-strafe/Double-duck in CS:GO
Reply With Quote #2

Quote:
Originally Posted by Mehis View Post
Sorry, I was probably using sm_rcon instead of sm_cvar ;)

Here's what I did:

PHP Code:
#include <sourcemod>
#include <sdktools>

#define DOUBLEDUCK_HEIGHT 32.0 // Has to be more or equal to 20 units.

public Action OnPlayerRunCmdint clientint &buttons )
{
    if ( !
IsPlayerAliveclient ) ) return Plugin_Continue;
    
    static 
int fFlags;
    
fFlags GetEntityFlagsclient );
    
    if ( 
fFlags FL_ONGROUND )
    {
        static 
bool bAllowDoubleDuck[MAXPLAYERS];
        
        if ( 
fFlags FL_DUCKING )
        {
            
// We're fully crouched, no doubleducking.
            
bAllowDoubleDuck[client] = false;
            return 
Plugin_Continue;
        }
        
        if ( 
buttons IN_DUCK )
        {
            
// Next time when we're not holding duck we can do a doubleduck.
            
bAllowDoubleDuck[client] = true;
            return 
Plugin_Continue;
        }
        
        
        
// Is transitioning?
        // m_bDucking doesn't actually tell us whether we're uncrouching or crouching. That is why we're using bAllowDoubleDuck.
        
if ( GetEntPropclientProp_Data"m_bDucking" ) && bAllowDoubleDuck[client] )
        {
            
float vecPos[3];
            
GetClientAbsOriginclientvecPos );
            
vecPos[2] += DOUBLEDUCK_HEIGHT
            
            if ( 
IsValidPlayerPosclientvecPos ) )
            {
                
TeleportEntityclientvecPosNULL_VECTORNULL_VECTOR );
            }
        }

    }
    
    return 
Plugin_Continue;
}

public 
bool IsValidPlayerPosint clientfloat vecPos[3] )
{
    static const 
float vecMins[] = { -16.0, -16.00.0 };
    static const 
float vecMaxs[] = { 16.016.072.0 };
    
    
TR_TraceHullFiltervecPosvecPosvecMinsvecMaxsMASK_SOLIDTraceFilter_IgnorePlayerclient );
    
    return ( !
TR_DidHitnull ) );
}

public 
bool TraceFilter_IgnorePlayerint entint maskany ignore_me )
{
    return ( 
ent != ignore_me );

Thanks, this is extremely helpful, however I don't really understand the purpose of the two bool functions at the end. Also, why does the doubleduck height have to be >= 20? Why can't it be 18 to match CS 1.6?
Beaverboys 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 20:25.


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