From 0f4c03d56310172c92d3a6b2de7c198de966b443 Mon Sep 17 00:00:00 2001 From: AMJ <69196954+ThisAMJ@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:19:22 +1100 Subject: [PATCH] feat: `sar_hud_velang 2` for pitch Fixes #278 --- docs/cvars.md | 2 +- src/Features/Hud/Hud.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/cvars.md b/docs/cvars.md index 55d9c232..0bab6447 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -275,7 +275,7 @@ |sar_hud_timer|0|Draws current value of timer.| |sar_hud_toggle_text|cmd|sar_hud_toggle_text \ - toggles the nth text value in the HUD| |sar_hud_trace|0|Draws info about current trace bbox tick.| -|sar_hud_velang|0|Draw the angle of the player's horizontal velocity vector.| +|sar_hud_velang|0|Draw the angle of the player's horizontal velocity vector.
0 = Default,
1 = yaw,
2 = pitch yaw.| |sar_hud_velocity|0|Draws velocity of the client.
0 = Default,
1 = X, Y, Z
2 = X:Y
3 = X:Y, Z
4 = X:Y:Z
5 = X, Y, X:Y, Z| |sar_hud_velocity_peak|0|Draws last saved velocity peak.| |sar_hud_velocity_precision|2|Precision of velocity HUD numbers.| diff --git a/src/Features/Hud/Hud.cpp b/src/Features/Hud/Hud.cpp index 05ae5979..1d65bc35 100644 --- a/src/Features/Hud/Hud.cpp +++ b/src/Features/Hud/Hud.cpp @@ -709,12 +709,22 @@ HUD_ELEMENT_MODE2(eyeoffset, "0", 0, 2, ctx->DrawElement("eyeoff: -"); } } -HUD_ELEMENT2(velang, "0", "Draw the angle of the player's horizontal velocity vector.\n", HudType_InGame | HudType_Paused | HudType_LoadingScreen) { +HUD_ELEMENT_MODE2(velang, "0", 0, 2, + "Draw the angle of the player's horizontal velocity vector.\n" + "0 = Default,\n" + "1 = yaw,\n" + "2 = pitch yaw.\n", + HudType_InGame | HudType_Paused | HudType_LoadingScreen) { auto player = client->GetPlayer(ctx->slot + 1); if (player) { auto vel = client->GetLocalVelocity(player); - float ang = RAD2DEG(atan2(vel.y, vel.x)); - ctx->DrawElement("velang: %.*f", getPrecision(true), ang); + float pitch = -RAD2DEG(atan2(vel.z, vel.Length2D())); + float yaw = RAD2DEG(atan2(vel.y, vel.x)); + if (mode == 1) { + ctx->DrawElement("velang: %.*f", getPrecision(true), yaw); + } else { + ctx->DrawElement("velang: %.*f %.*f", getPrecision(true), pitch, getPrecision(true), yaw); + } } else { ctx->DrawElement("velang: -"); }