Skip to content

Commit e23262b

Browse files
authored
feat: Groundspeed Hud Gain (p2sr#342)
* added ground speed delta, todo: make delta toggleable (potentially change HUD_ELEMENT2 to HUD_ELEMENT_MODE2 * change sar_hud_groundspeed to HUD_ELEMENT_MODE2 * docs: cvars
1 parent 1d5df76 commit e23262b

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

docs/cvars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
|sar_hud_ghost_spec|0|Show the name of the ghost you're currently spectating.|
262262
|sar_hud_grounded|0|Draws the state of player being on ground.|
263263
|sar_hud_groundframes|0|Draws the number of ground frames since last landing. Setting it to 2 preserves the value.|
264-
|sar_hud_groundspeed|0|Draw the speed of the player upon leaving the ground.|
264+
|sar_hud_groundspeed|0|Draw the speed of the player upon leaving the ground.<br>0 = Default,<br>1 = Groundspeed,<br>2 = Groundspeed (Gain)|
265265
|sar_hud_hide_text|cmd|sar_hud_hide_text \<id\|all> - hides the nth text value in the HUD|
266266
|sar_hud_inspection|0|Draws entity inspection data.|
267267
|sar_hud_jump|0|Draws current jump distance.|

src/Features/Hud/Hud.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,15 @@ HUD_ELEMENT_MODE2(velang, "0", 0, 2,
761761
ctx->DrawElement("velang: -");
762762
}
763763
}
764-
HUD_ELEMENT2(groundspeed, "0", "Draw the speed of the player upon leaving the ground.\n", HudType_InGame | HudType_Paused | HudType_LoadingScreen) {
764+
HUD_ELEMENT_MODE2(groundspeed, "0", 0, 2, "Draw the speed of the player upon leaving the ground.\n"
765+
"0 = Default\n"
766+
"1 = Groundspeed\n"
767+
"2 = Groundspeed (Gain)\n",
768+
HudType_InGame | HudType_Paused | HudType_LoadingScreen) {
765769
static float speeds[2];
766770
static float drawSpeeds[2];
767771
static bool groundeds[2];
772+
static float lastSpeeds[2] = {0};
768773

769774
auto player = client->GetPlayer(ctx->slot + 1);
770775
if (!player) {
@@ -779,10 +784,15 @@ HUD_ELEMENT2(groundspeed, "0", "Draw the speed of the player upon leaving the gr
779784
speeds[ctx->slot] = client->GetLocalVelocity(player).Length();
780785
} else if (groundeds[ctx->slot]) {
781786
groundeds[ctx->slot] = false;
787+
lastSpeeds[ctx->slot] = drawSpeeds[ctx->slot];
782788
drawSpeeds[ctx->slot] = speeds[ctx->slot];
783789
}
784-
785-
ctx->DrawElement("groundspeed: %.*f", getPrecision(true), drawSpeeds[ctx->slot]);
790+
if (mode == 2) {
791+
ctx->DrawElement("groundspeed: %.*f (%.*f)", getPrecision(true), drawSpeeds[ctx->slot], getPrecision(true), drawSpeeds[ctx->slot] - lastSpeeds[ctx->slot]);
792+
} else {
793+
ctx->DrawElement("groundspeed: %.*f", getPrecision(true), drawSpeeds[ctx->slot]);
794+
}
795+
786796
}
787797
QAngle g_bluePortalAngles[2];
788798
QAngle g_orangePortalAngles[2];

0 commit comments

Comments
 (0)