Raised This Month: $32 Target: $400
 8% 

fakemeta forward FM_CheckVisibility


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mrshark45
Member
Join Date: Jan 2016
Old 12-15-2019 , 13:54   fakemeta forward FM_CheckVisibility
Reply With Quote #1

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 is offline
mrshark45
Member
Join Date: Jan 2016
Old 12-19-2019 , 13:46   Re: fakemeta forward FM_CheckVisibility
Reply With Quote #2

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 is offline
mrshark45
Member
Join Date: Jan 2016
Old 12-19-2019 , 13:48   Re: fakemeta forward FM_CheckVisibility
Reply With Quote #3

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.

Last edited by mrshark45; 12-19-2019 at 14:15.
mrshark45 is offline
mrshark45
Member
Join Date: Jan 2016
Old 12-19-2019 , 16:46   Re: fakemeta forward FM_CheckVisibility
Reply With Quote #4

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

Last edited by mrshark45; 12-19-2019 at 16:47.
mrshark45 is offline
mrshark45
Member
Join Date: Jan 2016
Old 01-18-2020 , 14:54   Re: fakemeta forward FM_CheckVisibility
Reply With Quote #5

someone?
mrshark45 is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 01-21-2020 , 17:29   Re: fakemeta forward FM_CheckVisibility
Reply With Quote #6

https://forums.alliedmods.net/showth...20#post2673120
https://pastebin.com/8vHufWEX
check it out.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply



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 16:46.


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