AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   fakemeta forward FM_CheckVisibility (https://forums.alliedmods.net/showthread.php?t=320321)

mrshark45 12-15-2019 13:54

fakemeta forward FM_CheckVisibility
 
Hey, can someone explain to me what FM_CheckVisibility does, returns and what parameters does it have. I'm modifying a plugin that uses that to render entities when you spectate a bot, the bot position is {8192, 8192, 8192} and I set his view velocity, view position and view angles in FM_AddToFullPack and when a player spectates it the entities on the map doesn't render so the guy who made it used FM_CheckVisibility to render all the entities everytime , and it does a lot of lag, fps drop 150-200.
How can I render entities that are around the view position of the bot only for the players spectating it.
FM_AddToFullPack
PHP Code:

public fw_addtofullpack(es_handle,e,ent,host,hostflags,player,pSet)
{
    if(
global_bot == host)
    {        
        return 
FMRES_IGNORED;
    }
    
    if(
player)
    {        
        if(
ArraySize(bot_sources[plr_source[host]][source_array]) > plr_frame_it[host])
        if(
global_bot == ent && sources_num)
        {
            new 
Float:origin[2][3];
            
pev(hostpev_originorigin[0]);
            
xs_vec_copy(ghost_data[host][frame_origin], origin[1]);
            new 
spec pev(hostpev_iuser2);
            if(
spec && spec != ent)
            {
                
ghost_data[host] = ghost_data[spec];
            }    
            
set_es(es_handleES_Velocityghost_data[host][frame_velocity]);
            
ghost_data[host][frame_angles][0] /= -3.0;
            new 
bool:onground ghost_data[host][frame_velocity][2] == 0.0 true false
            animate_legs
(es_handleghost_data[host][frame_buttons], onground);
            
set_es(es_handleES_Anglesghost_data[host][frame_angles]);
            
set_es(es_handleES_Originghost_data[host][frame_origin]);                
            
set_es(es_handleES_SolidSOLID_NOT);
            
// fix ugly sequence
            
set_es(es_handleES_Sequence 75);
            
set_es(es_handleES_RenderModekRenderTransAdd);            
            
set_es(es_handleES_RenderFxkRenderFxSolidFast0);            
            
//set_es(es_handle, ES_RenderFx, kRenderFxSolidSlow, 0);            
            
set_es(es_handleES_RenderAmtfloatround(get_distance_f(origin[0], origin[1]) * 255.0 360.0floatround_floor));
            
//return FMRES_SUPERCEDE;
        
}
    }
    
    return 
FMRES_IGNORED;


FM_CheckVisibility
PHP Code:

public checkVisibility(id,pset){
        
forward_return(FMV_CELL1);    
        return 
FMRES_SUPERCEDE;


and I'm trying to do something like this, but not for all players
PHP Code:

public checkVisibility(id,pset){
    if(
id){
        
//pev(id, pev_origin, entityOrigin);
        
for(new 033i++){
            if(
is_user_connected(i) && cs_get_user_team(i) == CS_TEAM_SPECTATOR){
                
xs_vec_copy(ghost_data[i][frame_origin], playerOrigin);
                
distance floatsqroot(floatpower(entityOrigin[0] - playerOrigin[0], 2.0)+floatpower(entityOrigin[1] - playerOrigin[1], 2.0)+floatpower(entityOrigin[2] - playerOrigin[2], 2.0))
                
distance get_distance_f(entityOriginplayerOrigin);
                if(
distance 2000.0){
                    
forward_return(FMV_CELL1);    
                    return 
FMRES_SUPERCEDE;    
                }
            }
        }
        
    }
    return 
FMRES_IGNORED;



mrshark45 12-19-2019 13:46

Re: fakemeta forward FM_CheckVisibility
 
Ok, I did something, I took the pSet from FM_AddToFullPack and then I tested it in FM_CheckVisibility to check if a player is spectating and to render the entities for him, but it still renders them for all.
FM_AddToFullPack :
PHP Code:

public fw_addtofullpack(es_handle,e,ent,host,hostflags,player,pSet)
{
    
g_cl_pset[host] = pSet;


FM_CheckVisibility
PHP Code:

public checkVisibility(idpset){
    for(new 
0<33;i++){
        if(
is_user_connected(i))
            if(
pset == g_cl_pset[i] && cs_get_user_team(i) == CS_TEAM_SPECTATOR){
                
forward_return(FMV_CELL1);
                return 
FMRES_SUPERCEDE;
            }
    }
    return 
FMRES_IGNORED;



mrshark45 12-19-2019 13:48

Re: fakemeta forward FM_CheckVisibility
 
And it does a lot of lag for players, here are some demos
With CheckVisibility activated:
Click
Without CheckVisibility:
Click
With it's activated , players have lots of lag, not only the spectating ones.

mrshark45 12-19-2019 16:46

Re: fakemeta forward FM_CheckVisibility
 
Ok, I think that I got it , but it still doesn't function at it should be:
FM_AddToFullPack :
PHP Code:

public fw_addtofullpack(es_handle,e,ent,host,hostflags,player,pSet)
{
    
g_cl_pset[host] = pSet;


FM_CheckVisibility
PHP Code:

public checkVisibility(idpset){
    new 
player get_user_id(pset);
    if(!
is_user_connected(player))
        return 
FMRES_IGNORED;
    if(
cs_get_user_team(player) == CS_TEAM_SPECTATOR){
        
forward_return(FMV_CELL1);
        return 
FMRES_SUPERCEDE;
    }

    return 
FMRES_IGNORED;
}


stock get_user_id(pset){
    for(new 
33i++){
        if(
pset == g_cl_pset[i])
            return 
i;
    }

    return 
0;


I want to draw all the entities only for the players that are spectating

mrshark45 01-18-2020 14:54

Re: fakemeta forward FM_CheckVisibility
 
someone?

georgik57 01-21-2020 17:29

Re: fakemeta forward FM_CheckVisibility
 
https://forums.alliedmods.net/showth...20#post2673120
https://pastebin.com/8vHufWEX
check it out.


All times are GMT -4. The time now is 02:43.

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