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

[CSGO] Change player collision hull


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 03-03-2018 , 05:17   [CSGO] Change player collision hull
Reply With Quote #1

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).

Last edited by hmmmmm; 03-09-2018 at 02:11. Reason: Fix linux gamedata
hmmmmm is offline
SHUFEN
Senior Member
Join Date: Jun 2014
Location: Japan, Tokyo
Old 03-07-2018 , 13:28   Re: [CSGO] Change player collision hull
Reply With Quote #2

Great job!
We can simulate collision hull like as CS:S
SHUFEN is offline
Send a message via Skype™ to SHUFEN
blaacky
Senior Member
Join Date: Oct 2012
Old 03-08-2018 , 16:31   Re: [CSGO] Change player collision hull
Reply With Quote #3

I tested it on my CS:GO Linux server and it just caused it to crash
__________________
blaacky is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 03-08-2018 , 17:10   Re: [CSGO] Change player collision hull
Reply With Quote #4

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 is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 03-08-2018 , 20:17   Re: [CSGO] Change player collision hull
Reply With Quote #5

Fixed linux gamedata
hmmmmm is offline
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 05-15-2019 , 17:53   Re: [CSGO] Change player collision hull
Reply With Quote #6

can update gamedata for linux?
__________________
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
404UserNotFound
BANNED
Join Date: Dec 2011
Old 05-16-2019 , 02:21   Re: [CSGO] Change player collision hull
Reply With Quote #7

Yeah, update gamedata for linux please-and-thanks.
404UserNotFound is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-19-2019 , 15:31   Re: [CSGO] Change player collision hull
Reply With Quote #8

Here's an updated linux signature. Untested.
Code:
\x2A\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x85\xC0\x74\x2A\x8B
__________________
Peace-Maker is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 08-30-2020 , 11:51   Re: [CSGO] Change player collision hull
Reply With Quote #9

edit: nvm, i just had it setup wrong..

Last edited by safetymoose; 08-30-2020 at 13:52.
safetymoose is offline
FroGeX
Senior Member
Join Date: Aug 2020
Old 08-30-2020 , 11:59   Re: [CSGO] Change player collision hull
Reply With Quote #10

Cool plugin, but how to get hull values from models? e.g. i want change player to chicken so i need hull value from chicken model.
FroGeX is offline
Reply


Thread Tools
Display Modes

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 18:30.


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