diff --git a/docs/cvars.md b/docs/cvars.md
index 46f98ba8..59291ac0 100644
--- a/docs/cvars.md
+++ b/docs/cvars.md
@@ -261,7 +261,7 @@
|sar_hud_ghost_spec|0|Show the name of the ghost you're currently spectating.|
|sar_hud_grounded|0|Draws the state of player being on ground.|
|sar_hud_groundframes|0|Draws the number of ground frames since last landing. Setting it to 2 preserves the value.|
-|sar_hud_groundspeed|0|Draw the speed of the player upon leaving the ground.|
+|sar_hud_groundspeed|0|Draw the speed of the player upon leaving the ground.
0 = Default,
1 = Groundspeed,
2 = Groundspeed (Gain)|
|sar_hud_hide_text|cmd|sar_hud_hide_text \ - hides the nth text value in the HUD|
|sar_hud_inspection|0|Draws entity inspection data.|
|sar_hud_jump|0|Draws current jump distance.|
diff --git a/src/Features/Hud/Hud.cpp b/src/Features/Hud/Hud.cpp
index 442e71f8..aed48db7 100644
--- a/src/Features/Hud/Hud.cpp
+++ b/src/Features/Hud/Hud.cpp
@@ -761,10 +761,15 @@ HUD_ELEMENT_MODE2(velang, "0", 0, 2,
ctx->DrawElement("velang: -");
}
}
-HUD_ELEMENT2(groundspeed, "0", "Draw the speed of the player upon leaving the ground.\n", HudType_InGame | HudType_Paused | HudType_LoadingScreen) {
+HUD_ELEMENT_MODE2(groundspeed, "0", 0, 2, "Draw the speed of the player upon leaving the ground.\n"
+ "0 = Default\n"
+ "1 = Groundspeed\n"
+ "2 = Groundspeed (Gain)\n",
+ HudType_InGame | HudType_Paused | HudType_LoadingScreen) {
static float speeds[2];
static float drawSpeeds[2];
static bool groundeds[2];
+ static float lastSpeeds[2] = {0};
auto player = client->GetPlayer(ctx->slot + 1);
if (!player) {
@@ -779,10 +784,15 @@ HUD_ELEMENT2(groundspeed, "0", "Draw the speed of the player upon leaving the gr
speeds[ctx->slot] = client->GetLocalVelocity(player).Length();
} else if (groundeds[ctx->slot]) {
groundeds[ctx->slot] = false;
+ lastSpeeds[ctx->slot] = drawSpeeds[ctx->slot];
drawSpeeds[ctx->slot] = speeds[ctx->slot];
}
-
- ctx->DrawElement("groundspeed: %.*f", getPrecision(true), drawSpeeds[ctx->slot]);
+ if (mode == 2) {
+ ctx->DrawElement("groundspeed: %.*f (%.*f)", getPrecision(true), drawSpeeds[ctx->slot], getPrecision(true), drawSpeeds[ctx->slot] - lastSpeeds[ctx->slot]);
+ } else {
+ ctx->DrawElement("groundspeed: %.*f", getPrecision(true), drawSpeeds[ctx->slot]);
+ }
+
}
QAngle g_bluePortalAngles[2];
QAngle g_orangePortalAngles[2];