Raised This Month: $7 Target: $400
 1% 

[CSGO] Doing stuff with TheNavAreas and navarea_count


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 02-12-2018 , 12:17   [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #1

Gamedata

Code:
"Games"
{
	"csgo"
	{
		"Addresses"
		{
			"navarea_count"
			{
				"windows"
				{
					"signature" "nav_update_lighting" 
					"read" "92"
				}
				"linux"
				{
					"signature" "nav_update_lighting" 
					"read" "18"
				}
			}
		}
		"Signatures"
		{
			"nav_update_lighting"	//nav_update_lighting(CCommand const&) | STR "Computed lighting for %d/%d areas\n"
			{
				"windows"	"\x55\x8B\xEC\x8B\x45\x08\x57\x33\xFF"
				"linux"		"\x55\x89\xE5\x56\x53\x83\xEC\x10\x8B\x45\x08\x83\x38\x02"
			}
		}
	}
}
Plugin
PHP Code:
Address TheNavAreas;
Address navarea_count;

//You want to do this in OnMapStart or else after a map change you will have a bad address
public void OnMapStart()
{
    
Handle hConf LoadGameConfigFile("yourgamedata.txt");
    
    
navarea_count GameConfGetAddress(hConf"navarea_count");
    
PrintToServer("Found \"navarea_count\" @ 0x%X"navarea_count);
    
    
//TheNavAreas is nicely above navarea_count
    
TheNavAreas view_as<Address>(LoadFromAddress(navarea_count view_as<Address>(0x4), NumberType_Int32));
    
PrintToServer("Found \"TheNavAreas\" @ 0x%X"TheNavAreas);
    
    
delete hConf;

Useful things you may do with this
PHP Code:
//Get areas that are bigger than 50 units wide and maybe spawn stuff on them
//Say you were making a hunger games gamemode or a true random spawns deathmatch mode, 
//you could use this to always have a truly random spawn for your player or hunger games loot.
//Yes this is the exact code CS:GO uses to keep the map populated with chickens

void DoStuff()
{
    
int iAreaCount LoadFromAddress(navarea_countNumberType_Int32);

    
int iValidAreaCount 0;
    
    
//Check that this map has any nav areas
    
if ( iAreaCount )
    {
        
//Get a random area 10 times
        
for (int i 0<= 10i++)
        {
            
//Get random area
            
Address RandomArea view_as<Address>(LoadFromAddress(TheNavAreas view_as<Address>(GetRandomInt(0iAreaCount 1)), NumberType_Int32));
            
            
float m_nwCorner[3];
            
m_nwCorner[0] = view_as<float>(LoadFromAddress(RandomArea view_as<Address>(4), NumberType_Int32));
            
m_nwCorner[1] = view_as<float>(LoadFromAddress(RandomArea view_as<Address>(8), NumberType_Int32));
            
m_nwCorner[2] = view_as<float>(LoadFromAddress(RandomArea view_as<Address>(12), NumberType_Int32));
            
            
float m_seCorner[3];
            
m_seCorner[0] = view_as<float>(LoadFromAddress(RandomArea view_as<Address>(16), NumberType_Int32));
            
m_seCorner[1] = view_as<float>(LoadFromAddress(RandomArea view_as<Address>(20), NumberType_Int32));
            
m_seCorner[2] = view_as<float>(LoadFromAddress(RandomArea view_as<Address>(24), NumberType_Int32));
            
            
//Check that the area is bigger than 50 units wide on both sides.
            
if((m_seCorner[0] - m_nwCorner[0]) <= 50.0)
                continue;
            
            if((
m_seCorner[1] - m_nwCorner[1]) <= 50.0)
                continue;
            
            
//Calculate area center position.
            
float vecPos[3];
            
AddVectors(m_nwCornerm_seCornervecPos);
            
ScaleVector(vecPos0.5);
            
            
//Check if any player can see this place
            
if(UTIL_IsVisibleToTeam(vecPos2))
                continue;
            
            if(
UTIL_IsVisibleToTeam(vecPos3))
                continue;
            
            
CreateEntity(vecPos);
            
iValidAreaCount++;
        }
    }
}

stock bool UTIL_IsVisibleToTeam(float vecPos[3], int team)
{
    for (
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;
            
        if(!
IsPlayerAlive(i))
            continue;
            
        if(
GetClientTeam(i) != team)
            continue;
        
        if(!
IsLineOfFireClear(vecPosGetEyePosition(i)))
            continue;
            
        return 
true;
    }
    
    return 
false;
}

stock bool IsLineOfFireClear(float from[3], float to[3])
{
    
Handle trace TR_TraceRayFilterEx(fromtoCONTENTS_SOLID|CONTENTS_MOVEABLE|0x40|CONTENTS_MONSTERRayType_EndPointFilterPlayers);
    
    
float flFraction TR_GetFraction(trace);
    
    
delete trace;
    
    if (
flFraction >= 1.0/* && !trace.allsolid*/
    {
        return !(
flFraction == 0.0);    //allsolid
    
}
    
    return 
false;

WINDOWS Gamedata has been tested and confirmed working
LINUX Gamedata also works according to Rachnus
__________________

Last edited by Pelipoika; 07-31-2018 at 11:34.
Pelipoika is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 02-12-2018 , 13:13   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #2

Nice work!
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-16-2018 , 09:55   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #3

awesome~
__________________
8guawong is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-18-2018 , 13:25   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #4

Code:
L 07/18/2018 - 10:13:57: Info (map "de_dust2") (file "errors_20180718.log")
L 07/18/2018 - 10:13:57: [SM] Exception reported: Invalid address 0x4 is pointing to reserved memory.
L 07/18/2018 - 10:13:57: [SM] Blaming: test.smx
L 07/18/2018 - 10:13:57: [SM] Call stack trace:
L 07/18/2018 - 10:13:57: [SM]   [0] LoadFromAddress
L 07/18/2018 - 10:13:57: [SM]   [1] Line 43, C:\Users\test\sm 1.8\test.sp::OnMapStart
L 07/18/2018 - 10:14:03: Error log file session closed.
whats wrong?
__________________
8guawong is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 07-18-2018 , 14:35   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #5

PHP Code:
navarea_count GameConfGetAddress(hConf"navarea_count"); 
This is returning 0, which is not a valid address. This could be because it failed to read the gamedata or because the gamedata is outdated.
hmmmmm is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 07-18-2018 , 18:53   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #6

Quote:
Originally Posted by hmmmmm View Post
PHP Code:
navarea_count GameConfGetAddress(hConf"navarea_count"); 
This is returning 0, which is not a valid address. This could be because it failed to read the gamedata or because the gamedata is outdated.
Nice OS

EDIT:
Still works fine on Windows 19.07.2018
__________________

Last edited by Pelipoika; 07-19-2018 at 12:21.
Pelipoika is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-23-2018 , 21:25   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #7

Quote:
Originally Posted by Pelipoika View Post
Nice OS

EDIT:
Still works fine on Windows 19.07.2018
still can't get it to work

Code:
Found "navarea_count" @ 0x0
L 07/23/2018 - 18:23:44: [SM] Exception reported: Invalid address 0x4 is pointing to reserved memory.
L 07/23/2018 - 18:23:44: [SM] Blaming: test.smx
L 07/23/2018 - 18:23:44: [SM] Call stack trace:
L 07/23/2018 - 18:23:44: [SM]   [0] LoadFromAddress
L 07/23/2018 - 18:23:44: [SM]   [1] Line 13, C:\Users\test\Dropbox\sm 1.8\test.sp::OnMapStart
[SM] Loaded plugin test.smx successfully.
 
 
 SourceMod Version Information:
    SourceMod Version: 1.9.0.6245
    SourcePawn Engine: 1.9.0.6245, jit-x86 (build 1.9.0.6245)
    SourcePawn API: v1 = 4, v2 = 12
    Compiled on: Jul 13 2018 04:50:03
    Built from: https://github.com/alliedmodders/sourcemod/commit/50b5bb19
    Build ID: 6245:50b5bb19
    http://www.sourcemod.net/
 
 
Metamod:Source version 1.10.7-dev
Built from: https://github.com/alliedmodders/metamod-source/commit/20c72b5
Build ID: 963:20c72b5
Loaded As: Valve Server Plugin
Compiled on: Jul  7 2018
Plugin interface version: 15:14
SourceHook version: 5:5
http://www.metamodsource.net/
PHP Code:
Address TheNavAreas;
Address navarea_count;

//You want to do this in OnMapStart or else after a map change you will have a bad address
public void OnMapStart()
{
    
Handle hConf LoadGameConfigFile("yourgamedata");
    
    
navarea_count GameConfGetAddress(hConf"navarea_count");
    
PrintToServer("Found \"navarea_count\" @ 0x%X"navarea_count);
    
    
//TheNavAreas is nicely above navarea_count
    
TheNavAreas view_as<Address>(LoadFromAddress(navarea_count view_as<Address>(0x4), NumberType_Int32));
    
PrintToServer("Found \"TheNavAreas\" @ 0x%X"TheNavAreas);
    
    
delete hConf;

__________________
8guawong is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 07-23-2018 , 21:50   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #8

Quote:
Originally Posted by 8guawong View Post
still can't get it to work
Sooo... linux?

I've never tested Linux but try "read 17" instead of "read 18"
__________________

Last edited by Pelipoika; 07-23-2018 at 22:01.
Pelipoika is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-23-2018 , 22:10   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #9

Quote:
Originally Posted by Pelipoika View Post
Sooo... linux?

I've never tested Linux but try "read 17" instead of "read 18"
well i'm pretty sure the server is running windows....

162.251.167.84:27019 is the server in question

hostname: [BM] Zombie Riot RPG
version : 1.36.4.2 secure
os : Windows
type : community dedicated
gotv[0]: port 27219, delay 30.0s, rate 32.0
__________________

Last edited by 8guawong; 07-23-2018 at 22:14.
8guawong is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 07-23-2018 , 22:18   Re: [CSGO] Doing stuff with TheNavAreas and navarea_count
Reply With Quote #10

Quote:
Originally Posted by 8guawong View Post
well i'm pretty sure the server is running windows....

162.251.167.84:27019 is the server in question

hostname: [BM] Zombie Riot RPG
version : 1.36.4.2 secure
os : Windows
type : community dedicated
gotv[0]: port 27219, delay 30.0s, rate 32.0
Does that happen instantly when you load the plugin?
Does that happen after a map change?
Does the map have a navmesh?
__________________
Pelipoika 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 22:20.


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