From d8faea0966e80450814de7a10d63b55cd2e87416 Mon Sep 17 00:00:00 2001
From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com>
Date: Fri, 28 Mar 2025 03:28:15 +0500
Subject: [PATCH] Add new CVar mp_jump_height (#1022)
---
README.md | 1 +
dist/game.cfg | 5 +++++
regamedll/dlls/game.cpp | 2 ++
regamedll/dlls/game.h | 1 +
regamedll/dlls/player.cpp | 4 ++--
regamedll/pm_shared/pm_shared.cpp | 7 ++++++-
6 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 639b335f..7611beb1 100644
--- a/README.md
+++ b/README.md
@@ -124,6 +124,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_jump_height | 45 | 0.0 | - | Player jump height. |
| bot_excellent_morale | 0 | 0 | 1 | Bots always have great morale regardless of defeat or victory. |
| mp_randomspawn | 0 | 0 | 1 | Random player spawns
`0` disabled
`1` enabled
`NOTE`: Navigation `maps/.nav` file required |
diff --git a/dist/game.cfg b/dist/game.cfg
index c84fde86..95c7b32a 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -628,6 +628,11 @@ mp_vote_flags "km"
// Default value: "180"
mp_votemap_min_time "180"
+// Player jump height
+//
+// Default value: "45"
+mp_jump_height "45"
+
// Bots always have great morale regardless of defeat or victory.
// 0 - disabled (default behaviour)
// 1 - enabled
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index baaed369..37b264fb 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -172,6 +172,7 @@ cvar_t deathmsg_flags = { "mp_deathmsg_flags", "abc", 0, 0.0f
cvar_t assist_damage_threshold = { "mp_assist_damage_threshold", "40", 0, 40.0f, nullptr };
cvar_t freezetime_duck = { "mp_freezetime_duck", "1", 0, 1.0f, nullptr };
cvar_t freezetime_jump = { "mp_freezetime_jump", "1", 0, 1.0f, nullptr };
+cvar_t jump_height = { "mp_jump_height", "45", FCVAR_SERVER, 45.0f, nullptr };
cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };
@@ -453,6 +454,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&freezetime_duck);
CVAR_REGISTER(&freezetime_jump);
+ CVAR_REGISTER(&jump_height);
CVAR_REGISTER(&defuser_allocation);
CVAR_REGISTER(&location_area_info);
CVAR_REGISTER(&chat_loc_fallback);
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index e7dba1f2..f016c0f3 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -201,6 +201,7 @@ extern cvar_t deathmsg_flags;
extern cvar_t assist_damage_threshold;
extern cvar_t freezetime_duck;
extern cvar_t freezetime_jump;
+extern cvar_t jump_height;
extern cvar_t defuser_allocation;
extern cvar_t location_area_info;
extern cvar_t chat_loc_fallback;
diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp
index b32928c3..d510b6ce 100644
--- a/regamedll/dlls/player.cpp
+++ b/regamedll/dlls/player.cpp
@@ -1487,7 +1487,7 @@ void CBasePlayer::PackDeadPlayerItems()
{
DropShield();
#ifdef REGAMEDLL_ADD
- if(iPackGun != GR_PLR_DROP_GUN_ALL)
+ if (iPackGun != GR_PLR_DROP_GUN_ALL)
#endif
{
bSkipPrimSec = true;
@@ -2219,7 +2219,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
{
CBasePlayer *pAttacker = CBasePlayer::Instance(pevAttacker);
- if(pAttacker /*safety*/ && !pAttacker->IsBot() && pAttacker->m_iTeam != m_iTeam)
+ if (pAttacker /*safety*/ && !pAttacker->IsBot() && pAttacker->m_iTeam != m_iTeam)
{
if (pAttacker->HasShield())
killerHasShield = true;
diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp
index e9efb376..2de5f5fd 100644
--- a/regamedll/pm_shared/pm_shared.cpp
+++ b/regamedll/pm_shared/pm_shared.cpp
@@ -2429,13 +2429,18 @@ inline real_t PM_JumpHeight(bool longjump)
#ifdef REGAMEDLL_API
if (longjump)
{
- if(pmoveplayer->m_flLongJumpHeight > 0.0)
+ if (pmoveplayer->m_flLongJumpHeight > 0.0)
return pmoveplayer->m_flLongJumpHeight;
}
else if (pmoveplayer->m_flJumpHeight > 0.0)
return pmoveplayer->m_flJumpHeight;
#endif
+
+#ifdef REGAMEDLL_ADD
+ return Q_sqrt(2.0 * 800.0f * (longjump ? 56.0f : Q_max(jump_height.value, 0.0f)));
+#else
return Q_sqrt(2.0 * 800.0f * (longjump ? 56.0f : 45.0f));
+#endif
}
LINK_HOOK_VOID_CHAIN2(PM_Jump)