Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
|
04-10-2016
, 08:33
Re: CL_FlushEntityPacket when >=120 entities' info is sent to player
|
#6
|
Mine are just env_sprite entities with move type changed to MOVETYPE_NOCLIP and some velocity set.
They also got a think registered with engine module's register_think. I've made the "manual" think method because engine's think was only triggering 10 times per second for some reason and I didn't have time to debug it. Still that isn't the reason why the problem is happening since I tried it with engine's think too.
Here's part of the code. Unfortunately, I can't fully post it since it's a private request.
Code:
static iAllocStringEnvSprite;
if (!iAllocStringEnvSprite)
iAllocStringEnvSprite = engfunc(EngFunc_AllocString, "env_sprite");//info_target
new Float:fCvarMolotovRadius = get_pcvar_float(g_pCvarFire_field_radius);
new iID_Ent2;
for (new iID = 0; iID < get_pcvar_num(g_pCvarFire_field_flames); iID++)
{
iID_Ent2 = engfunc(EngFunc_CreateNamedEntity, iAllocStringEnvSprite);
if (!pev_valid(iID_Ent2))
continue;
ftEntSetSprite(iID_Ent2, g_iArrayID_SPMF, random_num(0, g_iArraySize_SPMF))
set_pev(iID_Ent2, pev_animtime, fGameTime)
set_pev(iID_Ent2, pev_framerate, random_float(10.0, 15.0))//random_float(20.0, 25.0)
set_pev(iID_Ent2, pev_spawnflags, SF_SPRITE_STARTON)
set_pev(iID_Ent2, pev_flags, (pev(iID_Ent2, pev_flags) | FL_ALWAYSTHINK))
dllfunc(DLLFunc_Spawn, iID_Ent2)
set_pev(iID_Ent2, pev_classname, g_szClassNameMolotovFlame)
set_pev(iID_Ent2, pev_owner, iID_Ent)
set_pev(iID_Ent2, pev_solid, SOLID_NOT)
set_pev(iID_Ent2, pev_scale, 0.5)//random_float(0.357, 0.577)
set_pev(iID_Ent2, pev_rendermode, kRenderTransAdd)
//set_pev(iID_Ent2, pev_rendercolor, Float:{ 255.0, 255.0, 255.0 })
//set_pev(iID_Ent2, pev_renderfx, kRenderFxNone)
set_pev(iID_Ent2, pev_renderamt, 255.0)
//set_pev(iID_Ent2, pev_sequence, 0)
//set_pev(iID_Ent2, pev_gaitsequence, 0)
//set_pev(iID_Ent2, pev_frame, 0.0)
if (!iID)
{
fVecTemp[0] = 0.0;
fVecTemp[1] = 0.0;
}
else
{
fVecTemp[0] = random_float(-fCvarMolotovRadius, fCvarMolotovRadius); //g_fFireFieldRadiusVisual 0.0, random_num(0, 1) ? fCvarMolotovRadius : -fCvarMolotovRadius
fVecTemp[1] = random_float(-fCvarMolotovRadius, fCvarMolotovRadius);
}
fVecTemp[2] = 45.0; //0.0; //5.0
// save our fire sprite position
set_pev(iID_Ent2, pev_punchangle, fVecTemp)
fVecTemp[0] += fVecOrigin[0];
fVecTemp[1] += fVecOrigin[1];
fVecTemp[2] += fVecOrigin[2];
set_pev(iID_Ent2, pev_fuser4, fVecTemp[2])
set_pev(iID_Ent2, pev_origin, fVecTemp)
//set_pev(iID_Ent2, pev_, )
set_pev(iID_Ent2, pev_movetype, MOVETYPE_NOCLIP)
fVecTemp[0] = 0.0;
fVecTemp[1] = 0.0;
fVecTemp[2] = random_float(40.0, 70.0);
set_pev(iID_Ent2, pev_velocity, fVecTemp)
}
}
Code:
public server_frame()
{
new iID_Ent = g_iMaxPlayers;
while ((iID_Ent = engfunc(EngFunc_FindEntityByString, iID_Ent, "classname", g_szClassNameMolotovFlame)) != 0)
fwEgThinkMolotovFlame(iID_Ent)
}
public fwEgThinkMolotovFlame(const iID_Ent)
{
/* static Float:fGameTime, Float:fGameTimeLast, iThinkCount, iID;
fGameTime = get_gametime();
//Make sure we count the thinks on a single entity
if (iID == iID_Ent)
{
if (fGameTime - fGameTimeLast <= 1.0)
{
iThinkCount++;
}
else
{
ftD7Log(_, _, "[fwEgThinkMolotovFlame] iID_Ent: %d. Thinks per second: %d.", iID_Ent, iThinkCount)
iThinkCount = 0;
fGameTimeLast = fGameTime;
}
}
else if (fGameTime - fGameTimeLast > 1.0)
{
iID = iID_Ent;
iThinkCount = 0;
fGameTimeLast = fGameTime;
}
*/
static Float:fVecTemp[3];
pev(iID_Ent, pev_punchangle, fVecTemp)
new Float:fCvarMolotovRadius = get_pcvar_float(g_pCvarFire_field_radius),
Float:fCvarMolotovRadiusZ = (fCvarMolotovRadius - fVecTemp[2]);// * 0.3;
static Float:fVecOrigin[3];
pev(iID_Ent, pev_origin, fVecOrigin)
new Float:fStartPositionZ;
pev(iID_Ent, pev_fuser4, fStartPositionZ)
new Float:fEntDistanceTraveled = fVecOrigin[2] - fStartPositionZ;
//ftD7Log(_, _, "[fwEgThinkMolotovFlame] iID_Ent: %d. fStartPositionZ: %f. fVecOrigin[2]: %f. fCvarMolotovRadiusZ: %f. Percentage: %f. iID_Ent render amount: %f.",
//iID_Ent, fStartPositionZ, fVecOrigin[2], fCvarMolotovRadiusZ, fPercentage, 255.0 * fPercentage / 100.0)
//
if (fEntDistanceTraveled > fCvarMolotovRadiusZ)
{
new iID_EntOwner = pev(iID_Ent, pev_owner);
if (iID_EntOwner != iID_Ent)
{
set_pev(iID_Ent, pev_frame, 0.0)
if (!pev_valid(iID_EntOwner) || pev(iID_EntOwner, g_iConstPevNadeType) != g_iConstPevNadeTypeMolotov)
{
//ftD7Log(_, _, "[fwEgThinkMolotovFlame] iID_Ent: %d. iID_EntOwner(%d) is = iID_Ent, invalid or not type molotov.", iID_Ent, iID_EntOwner)
//
//iID_EntOwner = iID_Ent;
//
set_pev(iID_Ent, pev_owner, iID_Ent)
ftEntSetSprite(iID_Ent, g_iArrayID_SPMS, random_num(0, g_iArraySize_SPMS))
set_pev(iID_Ent, pev_scale, 5.0)
set_pev(iID_Ent, pev_rendermode, kRenderTransAlpha)
set_pev(iID_Ent, pev_rendercolor, { 1.0, 1.0, 1.0 })
set_pev(iID_Ent, pev_renderamt, 255.0)
//set_pev(iID_Ent, pev_frame, 0.0)
set_pev(iID_Ent, pev_framerate, 5.0)
/*
// Smoke sprite
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fVecOrigin, 0)
write_byte(TE_SMOKE) // TE id
engfunc(EngFunc_WriteCoord, fVecOrigin[0]) // x
engfunc(EngFunc_WriteCoord, fVecOrigin[1]) // y
engfunc(EngFunc_WriteCoord, fVecOrigin[2]) // z
write_short(ArrayGetCell(g_iArrayID_SPMS_IDs, random_num(0, g_iArraySize_SPMS))) // sprite
write_byte(random_num(7, 10)) // scale
write_byte(random_num(10, 15)) // framerate
message_end()*/
return;
}
//ftD7Log(_, _, "^n[fwEgThinkMolotovFlame] iID_Ent: %d. Reset.", iID_Ent)
//
pev(iID_EntOwner, pev_origin, fVecOrigin)
static Float:fVecTemp2[3], Float:fVecTemp3[3];
if (fVecTemp[0] != 0.0)
{
fVecTemp2[0] = fVecOrigin[0] + random_float(-fCvarMolotovRadius, fCvarMolotovRadius);
fVecTemp2[1] = fVecOrigin[1] + random_float(-fCvarMolotovRadius, fCvarMolotovRadius);
fVecTemp2[2] = fVecOrigin[2];
fVecTemp3[0] = 9000.0;
trace_line(iID_Ent, fVecOrigin, fVecTemp2, fVecTemp3);
if (fVecTemp3[0] != 9000.0)
{
fVecTemp[0] = fVecTemp3[0];
fVecTemp[1] = fVecTemp3[1];
}
else
{
fVecTemp[0] = fVecTemp2[0];
fVecTemp[1] = fVecTemp2[1];
}
}
else
{
fVecTemp[0] = fVecOrigin[0];
fVecTemp[1] = fVecOrigin[1];
}
fStartPositionZ = fVecTemp[2];
fVecTemp[2] = fVecOrigin[2];
fVecTemp2[0] = fVecTemp[0];
fVecTemp2[1] = fVecTemp[1];
fVecTemp2[2] = fVecOrigin[2] - fCvarMolotovRadius;
fVecTemp3[0] = 9000.0;
trace_line(iID_Ent, fVecTemp, fVecTemp2, fVecTemp3);
fVecTemp[2] = fStartPositionZ;
if (fVecTemp3[0] != 9000.0)
fVecTemp[2] += fVecTemp3[2];
else
fVecTemp[2] += fVecTemp2[2];
//fVecTemp[2] += fVecOrigin[2];
//
set_pev(iID_Ent, pev_origin, fVecTemp)
set_pev(iID_Ent, pev_fuser4, fVecTemp[2])
fVecTemp[0] = 0.0;
fVecTemp[1] = 0.0;
fVecTemp[2] = random_float(40.0, 70.0);
set_pev(iID_Ent, pev_velocity, fVecTemp)
}
else
{
if (fEntDistanceTraveled > (fCvarMolotovRadiusZ * 2))
{
//ftD7Log(_, _, "[fwEgThinkMolotovFlame] iID_Ent: %d. iID_EntOwner: %d. Removing flame/smoke entity.", iID_Ent, iID_EntOwner)
//
engfunc(EngFunc_RemoveEntity, iID_Ent)
}
/*else
{
//ftD7Log(_, _, "[fwEgThinkMolotovFlame] iID_Ent: %d. iID_EntOwner(%d) != iID_Ent. Setting new render, sprite, owner and start position.", iID_Ent, iID_EntOwner)
//
ftEntSetSmoke(iID_Ent)
}*/
}
}
else
{
new Float:fPercentage;
fPercentage = fEntDistanceTraveled * 100.0 / fCvarMolotovRadiusZ;
//fPercentage = 50.0 - (50.0 - fPercentage);
fPercentage = 50.0 - fPercentage;
if (fPercentage < 0.0)
fPercentage *= -1;
fPercentage = 50.0 - fPercentage;
fPercentage = fPercentage * 100.0 / 50.0;
if (fPercentage < 0.0)
fPercentage = 0.0;
else if (fPercentage > 100.0)
fPercentage = 100.0;
set_pev(iID_Ent, pev_renderamt, 255.0 * fPercentage / 100.0)
}
}
__________________
|
|