AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CSGO] Change player collision hull (https://forums.alliedmods.net/showthread.php?t=305748)

hmmmmm 03-03-2018 05:17

[CSGO] Change player collision hull
 
Made this for a movement gametype and I thought might be helpful to some others.
Basic idea is that collision hull values are stored in a global variable named g_CSViewVectors (these values are a bit different in CS:GO), so all we have to do is change those values.

To get the address of g_CSViewVectors on Windows, we need to offset 1 byte from CCSGameRules::GetViewVectors function, which has a virtual offset of 30 (120 bytes) from CCSGameRules vtable. I combined this with gamedata I had previously for g_pGameRules from a different project.

So gamedata file ends up looking like this:
Code:

"Games"
{
        "csgo"
        {
                "Addresses"
                {
                        "g_CSViewVectors"
                        {
                                "windows"
                                {
                                        "signature" "g_pGameRules"
                                        "read" "2" // g_pGameRules
                                        "read" "0" // CCSGameRules object
                                        "read" "0" // CCSGameRules vtable
                                        "read" "120" // CCSGameRules::GetViewVectors()
                                        "read" "1" // g_CSViewVectors
                                }
                                "linux"
                                {
                                        "signature" "g_pGameRules"
                                        "read" "2"
                                        "read" "0"
                                        "read" "0"
                                        "read" "124"
                                        "read" "2"
                                }
                        }
                }
               
                "Signatures"
                {
                        "g_pGameRules"
                        {
                                "library"        "server"
                                "windows"        "\x8B\x2A\x2A\x2A\x2A\x2A\x8B\x2A\x8B\x2A\x2A\x2A\x2A\x2A\xFF\x2A\x84\x2A\x75\x2A\x8B\x2A\x2A\x2A\x2A\x2A\x85"
                                "linux"        "\x8B\x2A\x2A\x2A\x2A\x2A\x89\x2A\x2A\x85\x2A\x74\x2A\xA1"
                        }
                }
        }
}

Here's a plugin that changes some of those values so that they match these:
PHP Code:

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

float g_fNewHullValues[] = 
{
      
0.0,   0.0,  64.0,
    
    -
16.0, -16.0,   0.0,
     
16.0,  16.0,  72.0,
    
    -
16.0, -16.0,  0.0,
     
16.0,  16.0,  36.0,
      
0.0,   0.0,  28.0,
    
    -
10.0, -10.0, -10.0,
     
10.0 10.0,  10.0,

      
0.0,   0.0,  14.0
};

float g_fOldHullValues[sizeofg_fNewHullValues )];

Address g_CSViewVectors;

public 
Plugin myinfo 
{
    
name "Change Hull",
    
author "SlidyBat",
    
description "Changes player hulls",
    
version "1.0",
    
url ""
}

// was gonna do OnPluginStart, but not sure if GameRules has been initialized then
public void OnMapStart()
{
    
Handle hGameConf LoadGameConfigFile("changehull.games");
    if(
hGameConf == INVALID_HANDLE)
    {
        
SetFailState"Can't find changehull.games.txt gamedata." );
    }
    
    
g_CSViewVectors GameConfGetAddresshGameConf"g_CSViewVectors" );
    if( 
g_CSViewVectors == Address_Null )
    {
        
SetFailState"Couldn't get address of g_CSViewVectors" );
    }
    
    for( 
int i 0sizeofg_fNewHullValues ); i++ )
    {
        
g_fOldHullValues[i] = view_as<float>( LoadFromAddressg_CSViewVectors view_as<Address>( i*), NumberType_Int32 ) );
        
StoreToAddressg_CSViewVectors view_as<Address>( i*), view_as<int>( g_fNewHullValues[i] ), NumberType_Int32 );
    }
    
    
delete hGameConf;
}

public 
void OnPluginEnd()
{
    
// restore the original hull values, if we patched them.
    
if( g_CSViewVectors != Address_Null )
    {
        for( 
int i 0sizeofg_fOldHullValues ); i++ )
        {
            
StoreToAddress(g_CSViewVectors view_as<Address>( i*), view_as<int>( g_fOldHullValues[i] ), NumberType_Int32 );
        }
    }


You could also possibly set these collision hulls separately by player if you set the values on PreThink, but I haven't tested this out myself.

One of the obvious issues is prediction, since this value is also hardcoded in the client. This is especially obvious when you change height of hull and you hit something above you, due to the client prediction it spases out a bit. Other than that I've found that when there isn't any lag it works alright (although a little snappy in some cases).

SHUFEN.jp 03-07-2018 13:28

Re: [CSGO] Change player collision hull
 
Great job!
We can simulate collision hull like as CS:S

blaacky 03-08-2018 16:31

Re: [CSGO] Change player collision hull
 
I tested it on my CS:GO Linux server and it just caused it to crash

hmmmmm 03-08-2018 17:10

Re: [CSGO] Change player collision hull
 
Yea the gamedata for linux is wrong, someone hooked me up with a test server recently though so I'll try to fix it up later.

hmmmmm 03-08-2018 20:17

Re: [CSGO] Change player collision hull
 
Fixed linux gamedata

_GamerX 05-15-2019 17:53

Re: [CSGO] Change player collision hull
 
can update gamedata for linux?

404UNF 05-16-2019 02:21

Re: [CSGO] Change player collision hull
 
Yeah, update gamedata for linux please-and-thanks.

Peace-Maker 05-19-2019 15:31

Re: [CSGO] Change player collision hull
 
Here's an updated linux signature. Untested.
Code:

\x2A\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x85\xC0\x74\x2A\x8B


All times are GMT -4. The time now is 13:33.

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