Skip to content

Commit

Permalink
feat: sar_hud_velang 2 for pitch
Browse files Browse the repository at this point in the history
Fixes #278
  • Loading branch information
ThisAMJ committed Oct 20, 2024
1 parent c40c550 commit 0f4c03d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/cvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
|sar_hud_timer|0|Draws current value of timer.|
|sar_hud_toggle_text|cmd|sar_hud_toggle_text \<id> - 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.<br>0 = Default,<br>1 = yaw,<br>2 = pitch yaw.|
|sar_hud_velocity|0|Draws velocity of the client.<br>0 = Default,<br>1 = X, Y, Z<br>2 = X:Y<br>3 = X:Y, Z<br>4 = X:Y:Z<br>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.|
Expand Down
16 changes: 13 additions & 3 deletions src/Features/Hud/Hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: -");
}
Expand Down

0 comments on commit 0f4c03d

Please sign in to comment.