-
Notifications
You must be signed in to change notification settings - Fork 2.8k
all games: Use cl_interp_npcs for non-player NextBot interpolation #1730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
can you check if it gets lagcomped correctly? set it to 0.5 secs of interp and shoot at a moving target with sv_showlagcompensation set to 1 |
Only players are lag compensated, adding lag comp for them should be another PR |
this^. I'm gonna address that later by pulling lag compensation system changes from Alien Swarm. |
i wasn't aware that skeletons weren't lagcomped (i dont really play halloween stuff much) if they were made to be lagcomped, afaik the game currently wont take cl_interp_npcs into account this is from different source engine game (gmod) but i think the same behaviour will apply: cl_interp 0.5 simplescreenrecorder-2022-05-17_23.00.01.mp4cl_interp 0 simplescreenrecorder-2022-05-17_23.02.52.mp4 |
Fixing this just requires some refactoring in CLagCompensationManager::StartLagCompensation, replace the compute target time logic with something like this: // Get true latency
float flLatency = 0.f;
INetChannelInfo *nci = engine->GetPlayerNetInfo( player->entindex() );
if ( nci )
{
// add network latency
flLatency = nci->GetLatency( FLOW_OUTGOING );
}
auto lambdaCalcTargetTick = [ & ]( int nLerpTicks )
{
// correct is the amout of time we have to correct game time
float correct = flLatency;
// add view interpolation latency see C_BaseEntity::GetInterpolationAmount()
correct += TICKS_TO_TIME( nLerpTicks );
// check bouns [0,sv_maxunlag]
correct = clamp( correct, 0.0f, sv_maxunlag.GetFloat() );
// correct tick send by player
int targettick = cmd->tick_count - nLerpTicks;
// calc difference between tick send by player and our latency based tick
float deltaTime = correct - TICKS_TO_TIME( gpGlobals->tickcount - targettick );
if ( fabs( deltaTime ) > 0.2f )
{
// difference between cmd time and latency is too big > 200ms, use time correction based on latency
// DevMsg("StartLagCompensation: delta too big (%.3f)\n", deltaTime );
targettick = gpGlobals->tickcount - TIME_TO_TICKS( correct );
}
return targettick;
};
float flBaseTargetTime = TICKS_TO_TIME( lambdaCalcTargetTick( TIME_TO_TICKS( player->m_fLerpTime ) ) );
float flNpcTargetTime = TICKS_TO_TIME( lambdaCalcTargetTick( TIME_TO_TICKS( player->m_fNpcLerpTime ) ) );And make it use CBasePlayer needs to be also extended with |
Description
This PR makes NPC NextBots such as tf_zombie and MvM/Halloween bosses respect
cl_interp_npcsvalue for interpolation rather than using basecl_interp. Previously this ConVar would've only affected HL1, HL2 and ASW NPCs.The upside to this change is that it lets you keep lower interp for players while being able to give NPCs a higher value so their animations won't be laggy. Old behavior can be restored by setting
cl_interp_npcslower thancl_interpwhich will make it use the base value again.cl_interp_npcsConVar definition has been also updated to be more inline withcl_interp.Both of the comparison videos below were recorded with
cl_interp_ratio 2;cl_interp 0.03;cl_interp_npcs 0.1.Before:
cl_interp_nb_before.webm
After:
cl_interp_nb_after.webm