Skip to content

Commit

Permalink
fix: allow tf_viewmodels_offset_override (with limits)
Browse files Browse the repository at this point in the history
allow players to customize their viewmodel offset like in CSGO

ref: ValveSoftware/Source-1-Games#2484
  • Loading branch information
mastercoms committed Apr 19, 2023
1 parent e25089a commit bc2cc88
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/game/shared/tf/tf_viewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ ConVar cl_gunlowerspeed( "cl_gunlowerspeed", "2", FCVAR_CLIENTDLL | FCVAR_CHEAT

ConVar tf_use_min_viewmodels( "tf_use_min_viewmodels", "0", FCVAR_ARCHIVE, "Use minimized viewmodels." );

ConVar tf_viewmodels_offset_override( "tf_viewmodels_offset_override", "", FCVAR_CHEAT, "If set, this will override the position of all viewmodels. Usage 'x y z'" );
ConVar tf_viewmodels_offset_override( "tf_viewmodels_offset_override", "", 0, "If set, this will override the position of all viewmodels. Usage 'x y z'" );
#endif

void CTFViewModel::CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition, const QAngle& eyeAngles )
Expand Down Expand Up @@ -185,6 +185,13 @@ void CTFViewModel::CalcViewModelView( CBasePlayer *owner, const Vector& eyePosit
if ( bOverride )
{
UTIL_StringToVector( viewmodelOffset.Base(), pszVMOffsetOverride );
static ConVarRef sv_cheats("sv_cheats");
if (!sv_cheats.GetBool())
{
viewmodelOffset.x = clamp(viewmodelOffset.x, -2.0f, 2.5f);
viewmodelOffset.y = clamp(viewmodelOffset.y, -2.0f, 2.0f);
viewmodelOffset.z = clamp(viewmodelOffset.z, -2.0f, 2.0f);
}
}
else
{
Expand Down

0 comments on commit bc2cc88

Please sign in to comment.