Skip to content

Commit

Permalink
New CVars: sv_autobunnyhopping and sv_enablebunnyhopping (#686)
Browse files Browse the repository at this point in the history
* Add bunnyhopping

* Add missing cvar register. Added cvars to readme and cfg

* API added

* Changed define
  • Loading branch information
aleeperezz16 authored Oct 20, 2021
1 parent c6187f3 commit b9cccc6
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/> `0` No fade.<br/>`1` Fade to black and won't be able to watch anybody.<br/>`2` fade to black only on kill moment. |
| mp_falldamage | 1 | 0 | 1 | Damage from falling.<br/>`0` disabled <br/>`1` enabled |
| sv_allchat | 1 | 0 | 1 | Players can receive all other players text chat, team restrictions apply<br/>`0` disabled <br/>`1` enabled |
| sv_autobunnyhopping | 0 | 0 | 1 | Players automatically re-jump while holding jump button.<br/>`0` disabled <br/>`1` enabled |
| sv_enablebunnyhopping | 0 | 0 | 1 | Allow player speed to exceed maximum running speed.<br/>`0` disabled <br/>`1` enabled |
</details>

## How to install zBot for CS 1.6?
Expand Down
14 changes: 14 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 22 additions & 2 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion regamedll/public/regamedll/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down Expand Up @@ -125,6 +127,8 @@ class CCSPlayer: public CCSMonster {
int m_iWeaponInfiniteIds;
bool m_bCanShootOverride;
bool m_bGameForcingRespawn;
bool m_bAutoBunnyHopping;
bool m_bMegaBunnyJumping;
};

// Inlines
Expand Down

0 comments on commit b9cccc6

Please sign in to comment.