Skip to content

Commit

Permalink
Add variable for framerate (FPS), that used as reference when restori…
Browse files Browse the repository at this point in the history
…ng stamina (fuser2) after jump.
  • Loading branch information
Garey Akhmetshin committed Aug 27, 2024
1 parent dc16b12 commit 9998f68
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>`0` voting disabled<br/>`k` votekick enabled via `vote` command<br/>`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. |

</details>

Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");

Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,15 @@ void PM_WalkMove()
{
real_t flRatio = (100 - pmove->fuser2 * 0.001 * 19) * 0.01;

// 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);
}
pmove->velocity[0] *= flRatio;
pmove->velocity[1] *= flRatio;
}
Expand Down Expand Up @@ -2607,6 +2616,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;
}

Expand Down

0 comments on commit 9998f68

Please sign in to comment.