diff --git a/README.md b/README.md index db1305b01..c7a21372e 100644 --- a/README.md +++ b/README.md @@ -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.
`0` disabled
`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.
`0` disabled
`1` enabled | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 6bb2b7b03..d522eb224 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -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" diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 672c6a62f..e9b12367d 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -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 }; @@ -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); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index bcdfd0196..ec1994b4b 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -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 diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 6202012eb..5999fc0ed 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -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 + ) { ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped"); return nullptr; diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index bd22989e3..fdca09b53 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -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; } @@ -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; } @@ -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; }