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(host, pev_origin, origin[0]);
xs_vec_copy(ghost_data[host][frame_origin], origin[1]);
new spec = pev(host, pev_iuser2);
if(spec && spec != ent)
{
ghost_data[host] = ghost_data[spec];
}
set_es(es_handle, ES_Velocity, ghost_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_handle, ghost_data[host][frame_buttons], onground);
set_es(es_handle, ES_Angles, ghost_data[host][frame_angles]);
set_es(es_handle, ES_Origin, ghost_data[host][frame_origin]);
set_es(es_handle, ES_Solid, SOLID_NOT);
// fix ugly sequence
set_es(es_handle, ES_Sequence , 75);
set_es(es_handle, ES_RenderMode, kRenderTransAdd);
set_es(es_handle, ES_RenderFx, kRenderFxSolidFast, 0);
//set_es(es_handle, ES_RenderFx, kRenderFxSolidSlow, 0);
set_es(es_handle, ES_RenderAmt, floatround(get_distance_f(origin[0], origin[1]) * 255.0 / 360.0, floatround_floor));
//return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED;
}
FM_CheckVisibility
PHP Code:
public checkVisibility(id,pset){
forward_return(FMV_CELL, 1);
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 i = 0; i < 33; i++){
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(entityOrigin, playerOrigin);
if(distance < 2000.0){
forward_return(FMV_CELL, 1);
return FMRES_SUPERCEDE;
}
}
}
}
return FMRES_IGNORED;
}