@@ -258,6 +258,8 @@ ConVar tf_halloween_giant_health_scale( "tf_halloween_giant_health_scale", "10",
258258ConVar tf_grapplinghook_los_force_detach_time( "tf_grapplinghook_los_force_detach_time", "1", FCVAR_CHEAT );
259259ConVar tf_powerup_max_charge_time( "tf_powerup_max_charge_time", "30", FCVAR_CHEAT );
260260
261+ ConVar tf_unlag_teammates( "tf_unlag_teammates", "1", FCVAR_NOTIFY, "Controls lag compensation for teammates. 0: Disable, 1: Enable, 2: Melee weapons only" );
262+
261263extern ConVar tf_powerup_mode;
262264extern ConVar tf_mvm_buybacks_method;
263265extern ConVar tf_mvm_buybacks_per_wave;
@@ -19230,22 +19232,42 @@ bool CTFPlayer::WantsLagCompensationOnEntity( const CBasePlayer *pPlayer, const
1923019232 }
1923119233 }
1923219234
19233- if ( pPlayer->GetTeamNumber() == GetTeamNumber() && bIsMedic == false )
19234- return false;
19235-
19235+ // check if teammates should be lag compensated
19236+ int iUnlagTeammates = 0;
19237+ if ( pPlayer->GetTeamNumber() == GetTeamNumber() )
19238+ {
19239+ iUnlagTeammates = tf_unlag_teammates.GetInt();
19240+
19241+ if ( iUnlagTeammates == 0 && bIsMedic == false )
19242+ return false;
19243+ }
19244+
1923619245 // If this entity hasn't been transmitted to us and acked, then don't bother lag compensating it.
1923719246 if ( pEntityTransmitBits && !pEntityTransmitBits->Get( pPlayer->entindex() ) )
1923819247 return false;
1923919248
1924019249 const Vector &vMyOrigin = GetAbsOrigin();
1924119250 const Vector &vHisOrigin = pPlayer->GetAbsOrigin();
19251+
19252+ float fDistance = vHisOrigin.DistTo( vMyOrigin );
19253+
19254+ // teammates are only lag compensated for melee attacks for tf_unlag_teammates 2
19255+ if ( iUnlagTeammates == 2 )
19256+ {
19257+ if ( fDistance > 512 )
19258+ return false;
19259+
19260+ CTFWeaponBaseMelee *pWeapon = dynamic_cast <CTFWeaponBaseMelee*>( GetActiveWeapon() );
19261+ if ( !pWeapon )
19262+ return false;
19263+ }
1924219264
1924319265 // get max distance player could have moved within max lag compensation time,
1924419266 // multiply by 1.5 to to avoid "dead zones" (sqrt(2) would be the exact value)
1924519267 float maxDistance = 1.5 * pPlayer->MaxSpeed() * sv_maxunlag.GetFloat();
1924619268
1924719269 // If the player is within this distance, lag compensate them in case they're running past us.
19248- if ( vHisOrigin.DistTo( vMyOrigin ) < maxDistance )
19270+ if ( fDistance < maxDistance )
1924919271 return true;
1925019272
1925119273 // If their origin is not within a 45 degree cone in front of us, no need to lag compensate.
0 commit comments