diff --git a/README.md b/README.md
index 072b2f58..6d785431 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,8 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
| mp_nadedrops | 0 | 0 | 2 | Drop a grenade after player death.
`0` disabled
`1` drop one the grenade
`2` drop an everyone grenades |
| mp_roundrespawn_time | 20 | 0 | - | Player cannot respawn until next round if more than N seconds has elapsed since the beginning round |
| mp_auto_reload_weapons | 0 | 0 | 1 | Automatically reload each weapon on player spawn.
`0` disabled
`1` enabled |
-| mp_refill_bpammo_weapons | 0 | 0 | 3 | 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
`3` refill backpack ammo on each weapon reload |
+| 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_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 39dd2865..a384ac5f 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -89,11 +89,18 @@ mp_auto_reload_weapons "0"
// 0 - disabled (default behaviour)
// 1 - refill backpack ammo on player spawn
// 2 - refill backpack ammo on player spawn and on the purchase of the item
-// 3 - refill backpack ammo on each weapon reload (NOTE: Useful for mods like DeathMatch, GunGame, ZombieMod etc.)
//
// Default value: "0"
mp_refill_bpammo_weapons 0
+// Sets the mode infinite ammo for weapons
+// 0 - disabled (default behaviour)
+// 1 - weapon clip infinite
+// 2 - weapon bpammo infinite (This means for reloading)
+//
+// Default value: "0"
+mp_infinite_ammo 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/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp
index f021870a..0cd10a9c 100644
--- a/regamedll/dlls/API/CSPlayer.cpp
+++ b/regamedll/dlls/API/CSPlayer.cpp
@@ -516,3 +516,15 @@ EXT_FUNC bool CCSPlayer::CheckActivityInGame()
return (fabs(deltaYaw) >= 0.1f && fabs(deltaPitch) >= 0.1f);
}
+
+void CCSPlayer::Reset()
+{
+ m_szModel[0] = '\0';
+
+ m_bForceShowMenu = false;
+ m_flRespawnPending =
+ m_flSpawnProtectionEndTime = 0.0f;
+
+ m_vecOldvAngle = g_vecZero;
+ m_iWeaponInfiniteAmmo = 0;
+}
diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp
index f42d1656..6b3e42b7 100644
--- a/regamedll/dlls/client.cpp
+++ b/regamedll/dlls/client.cpp
@@ -735,6 +735,10 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
*pApersand = ' ';
}
+#ifdef REGAMEDLL_API
+ pPlayer->CSPlayer()->Reset();
+#endif
+
UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", (sName[0] != '\0') ? sName : "");
}
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index 7481e4f1..c1416ba0 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -20,6 +20,7 @@ cvar_t fragsleft = { "mp_fragsleft", "0", FCVAR_SERVER | FCVAR_UNLOG
cvar_t timeleft = { "mp_timeleft", "0", FCVAR_SERVER | FCVAR_UNLOGGED, 0.0f, nullptr };
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 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 };
@@ -184,6 +185,11 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&displaysoundlist);
CVAR_REGISTER(&timelimit);
CVAR_REGISTER(&friendlyfire);
+
+#ifdef BUILD_LATEST
+ CVAR_REGISTER(&infiniteAmmo);
+#endif
+
CVAR_REGISTER(&flashlight);
CVAR_REGISTER(&decalfrequency);
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index 137a5dce..71e2a133 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -58,6 +58,7 @@ extern cvar_t fadetoblack;
extern cvar_t fragsleft;
extern cvar_t timeleft;
extern cvar_t friendlyfire;
+extern cvar_t infiniteAmmo;
extern cvar_t allowmonsters;
extern cvar_t roundtime;
extern cvar_t buytime;
diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp
index 19722b35..799e39c7 100644
--- a/regamedll/dlls/weapons.cpp
+++ b/regamedll/dlls/weapons.cpp
@@ -824,6 +824,35 @@ bool CBasePlayerWeapon::HasSecondaryAttack()
return true;
}
+void CBasePlayerWeapon::HandleInfiniteAmmo()
+{
+ int nInfiniteAmmo = 0;
+
+#ifdef REGAMEDLL_API
+ nInfiniteAmmo = m_pPlayer->CSPlayer()->m_iWeaponInfiniteAmmo;
+#endif
+
+ if (!nInfiniteAmmo)
+ nInfiniteAmmo = static_cast(infiniteAmmo.value);
+
+ if (nInfiniteAmmo == WPNMODE_INFINITE_CLIP)
+ {
+ m_iClip = iMaxClip();
+ }
+ else if (nInfiniteAmmo == WPNMODE_INFINITE_BPAMMO)
+ {
+ if (pszAmmo1())
+ {
+ m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] = iMaxAmmo1();
+ }
+
+ if (pszAmmo2())
+ {
+ m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] = iMaxAmmo2();
+ }
+ }
+}
+
void CBasePlayerWeapon::ItemPostFrame()
{
int usableButtons = m_pPlayer->pev->button;
@@ -888,16 +917,7 @@ void CBasePlayerWeapon::ItemPostFrame()
// Add them to the clip
m_iClip += j;
-
-#ifdef REGAMEDLL_ADD
- // Do not remove bpammo of the player,
- // if cvar allows to refill bpammo on during reloading the weapons
- if (refill_bpammo_weapons.value < 3.0f) {
- m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;
- }
-#else
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;
-#endif
m_pPlayer->TabulateAmmo();
m_fInReload = FALSE;
@@ -1006,10 +1026,18 @@ void CBasePlayerWeapon::ItemPostFrame()
}
}
+#ifdef BUILD_LATEST
+ HandleInfiniteAmmo();
+#endif
+
WeaponIdle();
return;
}
+#ifdef BUILD_LATEST
+ HandleInfiniteAmmo();
+#endif
+
// catch all
if (ShouldWeaponIdle())
{
diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h
index c3b6d35d..bc39f86c 100644
--- a/regamedll/dlls/weapons.h
+++ b/regamedll/dlls/weapons.h
@@ -393,6 +393,7 @@ public:
void SetPlayerShieldAnim();
void ResetPlayerShieldAnim();
bool ShieldSecondaryFire(int iUpAnim, int iDownAnim);
+ void HandleInfiniteAmmo();
void InstantReload(bool bCanRefillBPAmmo = false);
#ifdef REGAMEDLL_API
@@ -1251,6 +1252,7 @@ public:
virtual BOOL Deploy();
virtual float GetMaxSpeed() { return M3_MAX_SPEED; }
virtual int iItemSlot() { return PRIMARY_WEAPON_SLOT; }
+ virtual BOOL PlayEmptySound();
virtual void PrimaryAttack();
virtual void Reload();
virtual void WeaponIdle();
@@ -1656,6 +1658,7 @@ public:
virtual BOOL Deploy();
virtual float GetMaxSpeed() { return XM1014_MAX_SPEED; }
virtual int iItemSlot() { return PRIMARY_WEAPON_SLOT; }
+ virtual BOOL PlayEmptySound();
virtual void PrimaryAttack();
virtual void Reload();
virtual void WeaponIdle();
diff --git a/regamedll/dlls/wpn_shared/wpn_m3.cpp b/regamedll/dlls/wpn_shared/wpn_m3.cpp
index c97f502b..5ece5aa3 100644
--- a/regamedll/dlls/wpn_shared/wpn_m3.cpp
+++ b/regamedll/dlls/wpn_shared/wpn_m3.cpp
@@ -60,6 +60,13 @@ BOOL CM3::Deploy()
return DefaultDeploy("models/v_m3.mdl", "models/p_m3.mdl", M3_DRAW, "shotgun", UseDecrement() != FALSE);
}
+BOOL CM3::PlayEmptySound()
+{
+ BOOL result = CBasePlayerWeapon::PlayEmptySound();
+ m_iPlayEmptySound = 0;
+ return result;
+}
+
void CM3::PrimaryAttack()
{
Vector vecAiming, vecSrc, vecDir;
@@ -204,15 +211,8 @@ void CM3::Reload()
#endif
{
m_iClip++;
-
-#ifdef REGAMEDLL_ADD
- if (refill_bpammo_weapons.value < 3.0f)
-#endif
- {
- m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
- m_pPlayer->ammo_buckshot--;
- }
-
+ m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
+ m_pPlayer->ammo_buckshot--;
m_fInSpecialReload = 1;
}
}
diff --git a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp
index 8c973eab..e4069208 100644
--- a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp
+++ b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp
@@ -58,6 +58,13 @@ BOOL CXM1014::Deploy()
return DefaultDeploy("models/v_xm1014.mdl", "models/p_xm1014.mdl", XM1014_DRAW, "m249", UseDecrement() != FALSE);
}
+BOOL CXM1014::PlayEmptySound()
+{
+ BOOL result = CBasePlayerWeapon::PlayEmptySound();
+ m_iPlayEmptySound = 0;
+ return result;
+}
+
void CXM1014::PrimaryAttack()
{
Vector vecAiming, vecSrc, vecDir;
@@ -207,15 +214,8 @@ void CXM1014::Reload()
#endif
{
m_iClip++;
-
-#ifdef REGAMEDLL_ADD
- if (refill_bpammo_weapons.value < 3.0f)
-#endif
- {
- m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
- m_pPlayer->ammo_buckshot--;
- }
-
+ m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
+ m_pPlayer->ammo_buckshot--;
m_fInSpecialReload = 1;
}
}
diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h
index cbf6a999..d78e124d 100644
--- a/regamedll/public/regamedll/API/CSPlayer.h
+++ b/regamedll/public/regamedll/API/CSPlayer.h
@@ -31,9 +31,19 @@
#include
#include
+enum WeaponInfiniteAmmoMode
+{
+ WPNMODE_INFINITE_CLIP = 1,
+ WPNMODE_INFINITE_BPAMMO
+};
+
class CCSPlayer: public CCSMonster {
public:
- CCSPlayer() : m_bForceShowMenu(false), m_flRespawnPending(0), m_flSpawnProtectionEndTime(0)
+ CCSPlayer() :
+ m_bForceShowMenu(false),
+ m_flRespawnPending(0),
+ m_flSpawnProtectionEndTime(0),
+ m_iWeaponInfiniteAmmo(0)
{
m_szModel[0] = '\0';
}
@@ -84,6 +94,7 @@ public:
virtual void RemoveSpawnProtection();
virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);
+ void Reset();
CBasePlayer *BasePlayer() const;
public:
@@ -103,6 +114,7 @@ public:
float m_flRespawnPending;
float m_flSpawnProtectionEndTime;
Vector m_vecOldvAngle;
+ int m_iWeaponInfiniteAmmo;
};
// Inlines