Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Cvar: mp_drop_grenade_enable #782

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| 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. |
| mp_hostages_rescued_ratio | 1.0 | 0.0 | 1.0 | Ratio of hostages rescued to win the round. |
| mp_drop_grenade_enable | 0 | 0 | 1 | Allow players to drop grenades from their inventory.<br/>`0` disabled <br/>`1` enabled |
</details>

## How to install zBot for CS 1.6?
Expand Down
7 changes: 7 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,10 @@ mp_give_c4_frags "3"
//
// Default value: "1.0"
mp_hostages_rescued_ratio "1.0"

// Allow players to drop grenades from their inventory
// 0 - disabled (default behaviour)
// 1 - enabled
//
// Default value: "0"
mp_drop_grenade_enable "0"
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f
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 };
cvar_t drop_grenade_enable = { "mp_drop_grenade_enable", "0", 0, 0.0f, nullptr };

cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };

Expand Down Expand Up @@ -407,6 +408,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&sv_enablebunnyhopping);
CVAR_REGISTER(&plant_c4_anywhere);
CVAR_REGISTER(&give_c4_frags);
CVAR_REGISTER(&drop_grenade_enable);

CVAR_REGISTER(&hostages_rescued_ratio);

Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ extern cvar_t sv_enablebunnyhopping;
extern cvar_t plant_c4_anywhere;
extern cvar_t give_c4_frags;
extern cvar_t hostages_rescued_ratio;
extern cvar_t drop_grenade_enable;

#endif

Expand Down
6 changes: 5 additions & 1 deletion regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7928,7 +7928,11 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszIte
#endif
if (pWeapon)
{
if (!pWeapon->CanDrop())
if (!pWeapon->CanDrop()
#ifdef REGAMEDLL_ADD
|| (!drop_grenade_enable.value && IsGrenadeWeapon(pWeapon->m_iId)) || (IsGrenadeWeapon(pWeapon->m_iId) && m_rgAmmo[pWeapon->PrimaryAmmoIndex()] <= 0)
#endif
Comment on lines +7931 to +7934
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check how mp_nadedrops works and redo the code to take into account the weaponbox requirements and player checks that are already there.

)
{
ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped");
return nullptr;
Expand Down
27 changes: 24 additions & 3 deletions regamedll/dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,14 @@ class CFlashbang: public CBasePlayerWeapon
virtual void Precache();
virtual int GetItemInfo(ItemInfo *p);
virtual BOOL CanDeploy();
virtual BOOL CanDrop() { return FALSE; }
virtual BOOL CanDrop()
{
#ifdef REGAMEDLL_ADD
return TRUE;
#else
return FALSE;
#endif
}
virtual BOOL Deploy();
virtual void Holster(int skiplocal);
virtual float GetMaxSpeed() { return m_fMaxSpeed; }
Expand Down Expand Up @@ -1120,7 +1127,14 @@ class CHEGrenade: public CBasePlayerWeapon
virtual void Precache();
virtual int GetItemInfo(ItemInfo *p);
virtual BOOL CanDeploy();
virtual BOOL CanDrop() { return FALSE; }
virtual BOOL CanDrop()
{
#ifdef REGAMEDLL_ADD
return TRUE;
#else
return FALSE;
#endif
}
virtual BOOL Deploy();
virtual void Holster(int skiplocal);
virtual float GetMaxSpeed() { return m_fMaxSpeed; }
Expand Down Expand Up @@ -1632,7 +1646,14 @@ class CSmokeGrenade: public CBasePlayerWeapon
virtual void Precache();
virtual int GetItemInfo(ItemInfo *p);
virtual BOOL CanDeploy();
virtual BOOL CanDrop() { return FALSE; }
virtual BOOL CanDrop()
{
#ifdef REGAMEDLL_ADD
return TRUE;
#else
return FALSE;
#endif
}
virtual BOOL Deploy();
virtual void Holster(int skiplocal);
virtual float GetMaxSpeed() { return m_fMaxSpeed; }
Expand Down