From b9cccc691bdabbf9cb573be8ee5e39c9a4f70c4a Mon Sep 17 00:00:00 2001
From: Alejo <53284952+aleeperezz16@users.noreply.github.com>
Date: Wed, 20 Oct 2021 13:18:30 -0300
Subject: [PATCH] New CVars: `sv_autobunnyhopping` and `sv_enablebunnyhopping`
(#686)
* Add bunnyhopping
* Add missing cvar register. Added cvars to readme and cfg
* API added
* Changed define
---
README.md | 2 ++
dist/game.cfg | 14 +++++++++++++
regamedll/dlls/API/CSPlayer.cpp | 2 ++
regamedll/dlls/game.cpp | 4 ++++
regamedll/dlls/game.h | 2 ++
regamedll/pm_shared/pm_shared.cpp | 24 +++++++++++++++++++++--
regamedll/public/regamedll/API/CSPlayer.h | 6 +++++-
7 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 4df82a681..410672d32 100644
--- a/README.md
+++ b/README.md
@@ -100,6 +100,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_fadetoblack | 0 | 0 | 2 | Observer's screen will fade to black on kill event or permanent.
`0` No fade.
`1` Fade to black and won't be able to watch anybody.
`2` fade to black only on kill moment. |
| mp_falldamage | 1 | 0 | 1 | Damage from falling.
`0` disabled
`1` enabled |
| sv_allchat | 1 | 0 | 1 | Players can receive all other players text chat, team restrictions apply
`0` disabled
`1` enabled |
+| sv_autobunnyhopping | 0 | 0 | 1 | Players automatically re-jump while holding jump button.
`0` disabled
`1` enabled |
+| sv_enablebunnyhopping | 0 | 0 | 1 | Allow player speed to exceed maximum running speed.
`0` disabled
`1` enabled |
## How to install zBot for CS 1.6?
diff --git a/dist/game.cfg b/dist/game.cfg
index 175f8d803..326201471 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -462,3 +462,17 @@ mp_free_armor 0
//
// Default value: "0"
sv_allchat 0
+
+// Players automatically re-jump while holding jump button.
+// 0 - disabled (default behaviour)
+// 1 - enabled
+//
+// Default value: "0"
+sv_autobunnyhopping 0
+
+// Allow player speed to exceed maximum running speed
+// 0 - disabled (default behaviour)
+// 1 - enabled
+//
+// Default value: "0"
+sv_enablebunnyhopping 0
diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp
index e2d69608d..6b11725fe 100644
--- a/regamedll/dlls/API/CSPlayer.cpp
+++ b/regamedll/dlls/API/CSPlayer.cpp
@@ -539,6 +539,8 @@ void CCSPlayer::Reset()
m_iWeaponInfiniteIds = 0;
m_bCanShootOverride = false;
m_bGameForcingRespawn = false;
+ m_bAutoBunnyHopping = false;
+ m_bMegaBunnyJumping = false;
}
void CCSPlayer::OnSpawn()
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index dbe9b9ae7..de055fd75 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -159,6 +159,8 @@ cvar_t t_default_weapons_secondary = { "mp_t_default_weapons_secondary", "
cvar_t t_default_weapons_primary = { "mp_t_default_weapons_primary", "", 0, 0.0f, nullptr };
cvar_t free_armor = { "mp_free_armor", "0", 0, 0.0f, nullptr };
cvar_t allchat = { "sv_allchat", "0", 0, 0.0f, nullptr };
+cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f, nullptr };
+cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr };
void GameDLL_Version_f()
{
@@ -387,6 +389,8 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&t_default_weapons_primary);
CVAR_REGISTER(&free_armor);
CVAR_REGISTER(&allchat);
+ CVAR_REGISTER(&sv_autobunnyhopping);
+ CVAR_REGISTER(&sv_enablebunnyhopping);
// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index cc04e1c68..2f362c050 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -185,6 +185,8 @@ extern cvar_t t_default_weapons_secondary;
extern cvar_t t_default_weapons_primary;
extern cvar_t free_armor;
extern cvar_t allchat;
+extern cvar_t sv_autobunnyhopping;
+extern cvar_t sv_enablebunnyhopping;
#endif
diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp
index b50fde669..75d4a4909 100644
--- a/regamedll/pm_shared/pm_shared.cpp
+++ b/regamedll/pm_shared/pm_shared.cpp
@@ -2418,8 +2418,19 @@ void PM_Jump()
return;
}
+#ifdef REGAMEDLL_API
+ const CCSPlayer* player = UTIL_PlayerByIndex(pmove->player_index + 1)->CSPlayer();
+#endif
+
// don't pogo stick
- if (pmove->oldbuttons & IN_JUMP)
+ if (pmove->oldbuttons & IN_JUMP
+#ifdef REGAMEDLL_ADD
+ && sv_autobunnyhopping.value <= 0.0
+#ifdef REGAMEDLL_API
+ && !player->m_bAutoBunnyHopping
+#endif
+#endif
+ )
{
return;
}
@@ -2434,7 +2445,16 @@ void PM_Jump()
// In the air now.
pmove->onground = -1;
- PM_PreventMegaBunnyJumping();
+#ifdef REGAMEDLL_ADD
+ if (sv_enablebunnyhopping.value <= 0.0
+#ifdef REGAMEDLL_API
+ && !player->m_bMegaBunnyJumping
+#endif
+ )
+#endif
+ {
+ PM_PreventMegaBunnyJumping();
+ }
real_t fvel = Length(pmove->velocity);
float fvol = 1.0f;
diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h
index 5020585a6..4bee3ce02 100644
--- a/regamedll/public/regamedll/API/CSPlayer.h
+++ b/regamedll/public/regamedll/API/CSPlayer.h
@@ -46,7 +46,9 @@ class CCSPlayer: public CCSMonster {
m_iWeaponInfiniteAmmo(0),
m_iWeaponInfiniteIds(0),
m_bCanShootOverride(false),
- m_bGameForcingRespawn(false)
+ m_bGameForcingRespawn(false),
+ m_bAutoBunnyHopping(false),
+ m_bMegaBunnyJumping(false)
{
m_szModel[0] = '\0';
}
@@ -125,6 +127,8 @@ class CCSPlayer: public CCSMonster {
int m_iWeaponInfiniteIds;
bool m_bCanShootOverride;
bool m_bGameForcingRespawn;
+ bool m_bAutoBunnyHopping;
+ bool m_bMegaBunnyJumping;
};
// Inlines