diff --git a/README.md b/README.md
index 90f58990d..a2bb550ee 100644
--- a/README.md
+++ b/README.md
@@ -122,6 +122,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_ammo_respawn_time | 20 | 0.0 | - | The respawn time for ammunition. |
| mp_vote_flags | km | 0 | - | Vote systems enabled in server.
`0` voting disabled
`k` votekick enabled via `vote` command
`m` votemap enabled via `votemap` command |
| mp_votemap_min_time | 180 | 0.0 | - | Minimum seconds that must elapse on map before `votemap` command can be used. |
+| mp_stamina_restore_rate | 0 | 0.0 | - | Framerate (FPS), that used as reference when restoring stamina (fuser2) after jump. |
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index 789435938..ed78a62fd 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -188,6 +188,8 @@ cvar_t ammo_respawn_time = { "mp_ammo_respawn_time", "20", FCVAR_SERVER, 2
cvar_t vote_flags = { "mp_vote_flags", "km", 0, 0.0f, nullptr };
cvar_t votemap_min_time = { "mp_votemap_min_time", "180", 0, 180.0f, nullptr };
+cvar_t stamina_restore_rate = { "mp_stamina_restore_rate", "0", 0, 0.f, nullptr };
+
void GameDLL_Version_f()
{
if (Q_stricmp(CMD_ARGV(1), "version") != 0)
@@ -460,6 +462,8 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&vote_flags);
CVAR_REGISTER(&votemap_min_time);
+ CVAR_REGISTER(&stamina_restore_rate);
+
// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index 09da5305a..611c0223f 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -208,6 +208,7 @@ extern cvar_t weapon_respawn_time;
extern cvar_t ammo_respawn_time;
extern cvar_t vote_flags;
extern cvar_t votemap_min_time;
+extern cvar_t stamina_restore_rate;
#endif
diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp
index fa106c09b..2bb30c66a 100644
--- a/regamedll/pm_shared/pm_shared.cpp
+++ b/regamedll/pm_shared/pm_shared.cpp
@@ -887,6 +887,18 @@ void PM_WalkMove()
{
real_t flRatio = (100 - pmove->fuser2 * 0.001 * 19) * 0.01;
+#ifdef REGAMEDLL_ADD
+ // change stamina restoration speed by fps reference
+ if (stamina_restore_rate.value > 0.0f)
+ {
+ real_t flReferenceFrametime = 1.0f / stamina_restore_rate.value;
+
+ float flFrametimeRatio = pmove->frametime / flReferenceFrametime;
+
+ flRatio = pow(flRatio, flFrametimeRatio);
+ }
+#endif
+
pmove->velocity[0] *= flRatio;
pmove->velocity[1] *= flRatio;
}
@@ -2607,6 +2619,7 @@ void EXT_FUNC __API_HOOK(PM_Jump)()
{
// NOTE: don't do it in .f (float)
real_t flRatio = (100.0 - pmove->fuser2 * 0.001 * 19.0) * 0.01;
+
pmove->velocity[2] *= flRatio;
}