AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved How is PVS ( Potentially view set ) calculated for an origin ? (https://forums.alliedmods.net/showthread.php?t=338218)

Natsheh 06-18-2022 13:10

How is PVS ( Potentially view set ) calculated for an origin ?
 
I am trying to check if an origin can be in a player's potenially view set so far i've made this, but its buggy, because it create entities.

PHP Code:

// Is Origin in player's potentially view set?
bool:IsOriginInPlayerPVS(const id, const Float:fOrigin[3])
{
    static 
iEntnextFloat:fEntOrigin[3];

    
iEnt create_entity("info_target");

    if( 
iEnt )
    {
        
engfunc(EngFunc_SetOriginiEntfOrigin);

        
next engfunc(EngFunc_EntitiesInPVSid);

        while( 
next )
        {
            
pev(nextpev_originfEntOrigin);

            if( 
xs_vec_equal(fOriginfEntOrigin) )
            {
                
set_pev(iEntpev_flagsFL_KILLME);
                
dllfunc(DLLFunc_ThinkiEnt);

                return 
true;
            }

            
next pev(nextpev_chain);
        }

        
set_pev(iEntpev_flagsFL_KILLME);
        
dllfunc(DLLFunc_ThinkiEnt);

        return 
false;
    }

    return 
false;


Edit: Looking through Xash3D engine i found out this native Mod_GetPVSForPoint but i couldn't locate its function.

Shadows Adi 06-18-2022 14:27

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
Check this out: https://github.com/dreamstalker/rehl....cpp#L763-L804

Natsheh 06-18-2022 17:41

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
Alright i set up a new function to find if the origin is in player PVS but now i am having problems with getting signatures :)

PHP Code:

// Is Origin in player's potentially view set?
bool:IsOriginInPlayerPVS(const id, const Float:fMessageOrigin[3])
{
    static 
Float:fvPlayerOrigin[3], leafnummaskbitNumber;

    
leafnum OrpheuCallSV_PointLeafnumfMessageOrigin );
    
mask OrpheuCallCM_LeafPVSleafnum );

    if( !
mask )
    {
        return 
true;
    }

    
pev(idpev_originfvPlayerOrigin);
    
bitNumber OrpheuCallSV_PointLeafnumfvPlayerOrigin );

    if( ((
mask |= ((bitNumber 1) >> 3)) & (<< ((bitNumber 1) & 7))) )
    {
        return 
true;
    }

    return 
false;



Shadows Adi 06-18-2022 17:54

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
HLDS / reHLDS? Version?

Natsheh 06-18-2022 19:31

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
I found a simpler way to do it using SV_ValidClientMulticast.

PHP Code:

// Is Origin in player's potentially view set?
bool:IsOriginInPlayerPVS(const idFloat:fMessageOrigin[3])
{
    static 
leafnum;
    
leafnum OrpheuCallSV_PointLeafnumfMessageOrigin );

    return 
boolOrpheuCallSV_ValidClientMulticastidleafnumMSG_PVS );


all i need are the signatures :( ReHLDS latest version REHLDS_v311-776

iceeedr 06-18-2022 23:57

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
Quote:

Originally Posted by Natsheh (Post 2781913)
I found a simpler way to do it using SV_ValidClientMulticast.

PHP Code:

// Is Origin in player's potentially view set?
bool:IsOriginInPlayerPVS(const idFloat:fMessageOrigin[3])
{
    static 
leafnum;
    
leafnum OrpheuCallSV_PointLeafnumfMessageOrigin );

    return 
boolOrpheuCallSV_ValidClientMulticastidleafnumMSG_PVS );


all i need are the signatures :( ReHLDS latest version REHLDS_v311-776

Dumb question, you've tried it, I haven't tested it so I can't confirm.

PHP Code:

bool:IsOriginInPlayerPVS(const idFloat:fMessageOrigin[3])
{
        static 
leafnum;
        
leafnum SV_PointLeafnum(fMessageOrigin)

        return 
boolSV_ValidClientMulticastidleafnumMSG_PVS );



Shadows Adi 06-19-2022 06:26

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
Here are the signatures for
SV_ValidClientMulticast ( the linux signature could not work, because I found just a reference from this function, not it's offset ):
PHP Code:

{
    
"name" "SV_ValidClientMulticast",
    
"library" "engine",
    
"arguments" :
    [
        {
            
"type" "int"
        
},
        {
            
"type" "int"
        
},
        {
            
"type" "int"
        
}
    ],
    
"return" :
    {
        
"type" "bool"
    
},
    
"identifiers" :
    [
        {
            
"os"    "windows",
            
"mod"   "cstrike",
            
"value" : [0x550x8B"*"0x510x560x33"*"0x570x8B0xF9]
        },
        {
            
"os"    "linux",
            
"mod"   "cstrike",
            
"value" : [0x4D0x55"*"0x540x490x430x410x530x54"*"0x200x450x20x72"*"0x720x200x250x640x21]
        }
    ]


and

SV_PointLeafnum:
PHP Code:

{
    
"name" "SV_PointLeafnum",
    
"library" "engine",
    
"arguments" :
    [
        {
            
"type" "float"
        
}
    ],
    
"return" :
    {
        
"type" "int"
    
},
    
"identifiers" :
    [
        {
            
"os"    "windows",
            
"mod"   "cstrike",
            
"value" : [0x510x8B0x150xB0"*""*"0x040xE8]
        },
        {
            
"os"    "linux",
            
"mod"   "cstrike",
            
"value" 0x6A6B4
        
}
    ]


Tested on windows and linux ( but with the problem mentioned above for 'SV_ValidClientMulticast' )

Natsheh 06-19-2022 11:16

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
Anyway to get the address of SV_ValidClientMulticast ? i already found a ref tho but i don't know how to use it to find the actual function.

Can anyone disassemble the engine using linux OS. ?

Natsheh 06-21-2022 17:22

Re: How is PVS ( Potentially view set ) calculated for an origin ?
 
Solved: Using the first method in post #1 but creating the entity once and never removing it also moving it around for players prediction.


All times are GMT -4. The time now is 01:39.

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