Skip to content

Commit

Permalink
Rough draft for lean speed/angle toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
nullsystem committed Jul 7, 2024
1 parent 87c0230 commit 382fd31
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions mp/src/game/shared/neo/neo_predicted_viewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ void CNEOPredictedViewModel::DrawRenderToTextureDebugInfo(IClientRenderable* pRe
#endif

ConVar neo_lean_debug_draw_hull("neo_lean_debug_draw_hull", "0", FCVAR_CHEAT | FCVAR_REPLICATED);
ConVar neo_lean_speed("neo_lean_speed", "0.333", FCVAR_REPLICATED | FCVAR_CHEAT, "Lean speed scale", true, 0.0, false, 1000.0);
// Original Neotokyo with the latest leftlean fix uses 7 for leftlean and 15 for rightlean yaw slide.
ConVar neo_lean_yaw_peek_left_amount("neo_lean_yaw_peek_left_amount", "7.0", FCVAR_REPLICATED | FCVAR_CHEAT, "How far sideways will a full left lean view reach.", true, 0.001f, false, 0);
ConVar neo_lean_speed("neo_lean_speed", "0.2", FCVAR_REPLICATED | FCVAR_CHEAT, "Lean speed scale", true, 0.0, false, 1000.0);
ConVar neo_lean_yaw_peek_left_amount("neo_lean_yaw_peek_left_amount", "15.0", FCVAR_REPLICATED | FCVAR_CHEAT, "How far sideways will a full left lean view reach.", true, 0.001f, false, 0);
ConVar neo_lean_yaw_peek_right_amount("neo_lean_yaw_peek_right_amount", "15.0", FCVAR_REPLICATED | FCVAR_CHEAT, "How far sideways will a full right lean view reach.", true, 0.001f, false, 0);
ConVar neo_lean_angle_percentage("neo_lean_angle_percentage", "0.75", FCVAR_REPLICATED | FCVAR_CHEAT, "for adjusting the actual angle of lean to a percentage of lean.", true, 0.0, true, 1.0);
ConVar neo_lean_tp_exaggerate_scale("neo_lean_tp_exaggerate_scale", "2", FCVAR_REPLICATED | FCVAR_CHEAT, "How much more to scale leaning motion in 3rd person animation vs 1st person viewmodel.", true, 0.0, false, 0);
Expand Down Expand Up @@ -299,14 +298,14 @@ float CNEOPredictedViewModel::lean(CNEO_Player *player){


if (dY != 0){
const float leanStep = 0.25f;
static constexpr float LEAN_SNAP = 0.25f;

// Almost done leaning; snap to zero to avoid back-and-forth "wiggle"
if (fabs(dY) - leanStep < 0) {
if (fabs(dY) - LEAN_SNAP < 0) {
Ycurrent = Yfinal;
}
else {
Ycurrent = Lerp(leanStep * neo_lean_speed.GetFloat(), Ycurrent, Yfinal);
Ycurrent = Lerp(neo_lean_speed.GetFloat(), Ycurrent, Yfinal);
}
}

Expand Down Expand Up @@ -349,15 +348,7 @@ float CNEOPredictedViewModel::lean(CNEO_Player *player){
SetNextThink(gpGlobals->curtime);
#endif

if (leanAngle >= 0)
{
return leanAngle * neo_lean_tp_exaggerate_scale.GetFloat();
}
else
{
const float leftleanOverleanRatio = (neo_lean_yaw_peek_right_amount.GetFloat() / neo_lean_yaw_peek_left_amount.GetFloat());
return leanAngle * neo_lean_tp_exaggerate_scale.GetFloat() * leftleanOverleanRatio;
}
return leanAngle * neo_lean_tp_exaggerate_scale.GetFloat();
}

void CNEOPredictedViewModel::CalcViewModelView(CBasePlayer *pOwner,
Expand Down

2 comments on commit 382fd31

@AdamTadeusz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nullsystem Should we open a PR for this?

@nullsystem
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdamTadeusz I've made it a PR. I've basically forgotten about this commit for a long while, but the change is more like a perception that it seems like OG:NT, but the speed + angle aren't really. But then again the lean mechanic is different.

Please sign in to comment.