Skip to content

Commit

Permalink
New CVar: mp_give_c4_frags (#776)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru>
  • Loading branch information
JulioBarker and wopox1337 authored Oct 8, 2022
1 parent 98b387b commit 83151aa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| 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 |
| mp_plant_c4_anywhere | 0 | 0 | 1 | When set, players can plant anywhere, not only in bombsites.<br/>`0` disabled <br/>`1` enabled |
| mp_give_c4_frags | 3 | - | - | How many bonuses (frags) will get the player who defused or exploded the bomb. |
</details>

## How to install zBot for CS 1.6?
Expand Down
6 changes: 6 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,9 @@ sv_enablebunnyhopping 0
//
// Default value: "0"
mp_plant_c4_anywhere 0
// How many bonuses (frags) will get the player who defused or exploded the bomb.
// 3 - (default behaviour)
//
// Default value: "3"
mp_give_c4_frags 3
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ 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 };
cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr };
cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr };

void GameDLL_Version_f()
{
Expand Down Expand Up @@ -403,6 +404,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&sv_autobunnyhopping);
CVAR_REGISTER(&sv_enablebunnyhopping);
CVAR_REGISTER(&plant_c4_anywhere);
CVAR_REGISTER(&give_c4_frags);

// 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 @@ -188,6 +188,7 @@ extern cvar_t allchat;
extern cvar_t sv_autobunnyhopping;
extern cvar_t sv_enablebunnyhopping;
extern cvar_t plant_c4_anywhere;
extern cvar_t give_c4_frags;

#endif

Expand Down
12 changes: 10 additions & 2 deletions regamedll/dlls/ggrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,12 @@ void CGrenade::__API_HOOK(DefuseBombEnd)(CBasePlayer *pPlayer, bool bDefused)
CSGameRules()->m_bBombDefused = true;
CSGameRules()->CheckWinConditions();

// give the defuser credit for defusing the bomb
m_pBombDefuser->pev->frags += 3.0f;
#ifdef REGAMEDLL_ADD
m_pBombDefuser->pev->frags += (int)give_c4_frags.value;
#else
// give the defuser credit for defusing the bomb
m_pBombDefuser->pev->frags += 3.0f;
#endif

MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup);
MESSAGE_END();
Expand Down Expand Up @@ -1435,7 +1439,11 @@ void CGrenade::C4Think()
CBasePlayer *pBombOwner = CBasePlayer::Instance(pev->owner);
if (pBombOwner)
{
#ifdef REGAMEDLL_ADD
pBombOwner->pev->frags += give_c4_frags.value;
#else
pBombOwner->pev->frags += 3.0f;
#endif
}

MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup);
Expand Down

0 comments on commit 83151aa

Please sign in to comment.