diff --git a/README.md b/README.md
index 12842096..e7dd5305 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@ therefore for this enter `-beta` option at the command line HLDS.
| mp_auto_reload_weapons | 0 | 0 | 1 | Automatically reload each weapon on player spawn.
`0` disabled
`1` enabled |
| mp_refill_bpammo_weapons | 0 | 0 | 2 | Refill amount of backpack ammo up to the max.
`0` disabled
`1` refill backpack ammo on player spawn
`2` refill backpack ammo on player spawn and on the purchase of the item |
| mp_infinite_ammo | 0 | 0 | 2 | Sets the mode infinite ammo for weapons.
`0` disabled
`1` weapon clip infinite
`2` weapon bpammo infinite (This means for reloading) |
+| mp_infinite_grenades | 0 | 0 | 1 | Enable infinite grenades.
`0` disabled
`1` grenades infinite |
| mp_auto_join_team | 0 | 0 | 1 | Automatically joins the team.
`0` disabled
`1` enable (Use in conjunction with the cvar humans_join_team any/CT/T) |
| mp_max_teamkills | 3 | 0 | - | Maximum number of allowed teamkills before autokick. Used when enabled mp_autokick. |
| mp_fragsleft | - | - | - | Is the number of frags left, if you have set mp_fraglimit. You just type mp_fragsleft in server console, and it tells you the number of frags left depending of mp_fraglimit. |
diff --git a/dist/game.cfg b/dist/game.cfg
index f3a08b20..8014805c 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -101,6 +101,13 @@ mp_refill_bpammo_weapons 0
// Default value: "0"
mp_infinite_ammo 0
+// Enable infinite grenades
+// 0 - disabled (default behaviour)
+// 1 - grenades infinite
+//
+// Default value: "0"
+mp_infinite_grenades 0
+
// Automatically joins the team
// 0 - disabled
// 1 - enabled (Use in conjunction with the cvar humans_join_team any/SPEC/CT/T)
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index 1ffbd8ff..e959c772 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -21,6 +21,7 @@ cvar_t timeleft = { "mp_timeleft", "0", FCVAR_SERVER | FCVAR_UNLOGG
cvar_t friendlyfire = { "mp_friendlyfire", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t infiniteAmmo = { "mp_infinite_ammo", "0", FCVAR_SERVER, 0.0f, nullptr };
+cvar_t infiniteGrenades = { "mp_infinite_grenades", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t allowmonsters = { "mp_allowmonsters", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t roundtime = { "mp_roundtime", "5", FCVAR_SERVER, 0.0f, nullptr };
cvar_t buytime = { "mp_buytime", "1.5", FCVAR_SERVER, 0.0f, nullptr };
@@ -189,6 +190,7 @@ void EXT_FUNC GameDLLInit()
#ifdef BUILD_LATEST
CVAR_REGISTER(&infiniteAmmo);
+ CVAR_REGISTER(&infiniteGrenades);
#endif
CVAR_REGISTER(&flashlight);
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index 54015bfa..f4ac3727 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -59,6 +59,7 @@ extern cvar_t fragsleft;
extern cvar_t timeleft;
extern cvar_t friendlyfire;
extern cvar_t infiniteAmmo;
+extern cvar_t infiniteGrenades;
extern cvar_t allowmonsters;
extern cvar_t roundtime;
extern cvar_t buytime;
diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp
index 7f522316..2e01be1f 100644
--- a/regamedll/dlls/player.cpp
+++ b/regamedll/dlls/player.cpp
@@ -6281,7 +6281,9 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse)
#ifdef REGAMEDLL_API
CSPlayer()->m_iWeaponInfiniteAmmo = WPNMODE_INFINITE_BPAMMO;
+ CSPlayer()->m_iWeaponInfiniteIds = WEAPON_ALLWEAPONS;
#endif
+
GiveNamedItemEx("item_longjump");
GiveNamedItemEx("item_thighpack");
GiveNamedItemEx("item_kevlar");
diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp
index 799e39c7..86491a46 100644
--- a/regamedll/dlls/weapons.cpp
+++ b/regamedll/dlls/weapons.cpp
@@ -839,7 +839,12 @@ void CBasePlayerWeapon::HandleInfiniteAmmo()
{
m_iClip = iMaxClip();
}
- else if (nInfiniteAmmo == WPNMODE_INFINITE_BPAMMO)
+ else if ((nInfiniteAmmo == WPNMODE_INFINITE_BPAMMO &&
+#ifdef REGAMEDLL_API
+ ((m_pPlayer->CSPlayer()->m_iWeaponInfiniteIds & (1 << m_iId)) || (m_pPlayer->CSPlayer()->m_iWeaponInfiniteIds <= 0 && !IsGrenadeWeapon(m_iId)))
+#endif
+ )
+ || (IsGrenadeWeapon(m_iId) && infiniteGrenades.value == 1.0f))
{
if (pszAmmo1())
{
diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp
index e59d46fb..f677ee29 100644
--- a/regamedll/dlls/weapontype.cpp
+++ b/regamedll/dlls/weapontype.cpp
@@ -439,6 +439,22 @@ bool IsSecondaryWeapon(int id)
return false;
}
+// Return true if given weapon ID is a grenade
+bool IsGrenadeWeapon(int id)
+{
+ switch (id)
+ {
+ case WEAPON_HEGRENADE:
+ case WEAPON_FLASHBANG:
+ case WEAPON_SMOKEGRENADE:
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
WeaponInfoStruct *GetWeaponInfo(int weaponID)
{
for (auto& info : g_weaponInfo) {
diff --git a/regamedll/dlls/weapontype.h b/regamedll/dlls/weapontype.h
index 311faf4a..390ca22a 100644
--- a/regamedll/dlls/weapontype.h
+++ b/regamedll/dlls/weapontype.h
@@ -449,6 +449,7 @@ WeaponClassType AliasToWeaponClass(const char *alias);
WeaponClassType WeaponIDToWeaponClass(int id);
bool IsPrimaryWeapon(int id);
bool IsSecondaryWeapon(int id);
+bool IsGrenadeWeapon(int id);
bool CanBuyWeaponByMaptype(int playerTeam, WeaponIdType weaponID, bool useAssasinationRestrictions);
void WeaponInfoReset();
diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h
index d78e124d..73092176 100644
--- a/regamedll/public/regamedll/API/CSPlayer.h
+++ b/regamedll/public/regamedll/API/CSPlayer.h
@@ -115,6 +115,7 @@ public:
float m_flSpawnProtectionEndTime;
Vector m_vecOldvAngle;
int m_iWeaponInfiniteAmmo;
+ int m_iWeaponInfiniteIds;
};
// Inlines