Added new cvar mp_infinite_ammo also implemented API things for this.

Moved behavior cvar mp_refill_bpammo_weapons 3 into mp_infinite_ammo 2 as it was implemented in the official.
CM3/CXM1014 implemented override func PlayEmptySound.
This commit is contained in:
s1lent 2019-08-13 18:57:19 +07:00
parent fcb597613b
commit 2568d9a2fa
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
11 changed files with 104 additions and 30 deletions

View File

@ -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.<br/>`0` disabled<br/>`1` drop one the grenade<br/>`2` drop an everyone grenades | | mp_nadedrops | 0 | 0 | 2 | Drop a grenade after player death.<br/>`0` disabled<br/>`1` drop one the grenade<br/>`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_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.<br/>`0` disabled<br/>`1` enabled | | mp_auto_reload_weapons | 0 | 0 | 1 | Automatically reload each weapon on player spawn.<br/>`0` disabled<br/>`1` enabled |
| mp_refill_bpammo_weapons | 0 | 0 | 3 | Refill amount of backpack ammo up to the max.<br/>`0` disabled<br/>`1` refill backpack ammo on player spawn<br/>`2` refill backpack ammo on player spawn and on the purchase of the item<br/>`3` refill backpack ammo on each weapon reload | | mp_refill_bpammo_weapons | 0 | 0 | 2 | Refill amount of backpack ammo up to the max.<br/>`0` disabled<br/>`1` refill backpack ammo on player spawn<br/>`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.<br/>`0` disabled<br/>`1` weapon clip infinite<br/>`2` weapon bpammo infinite (This means for reloading) |
| mp_auto_join_team | 0 | 0 | 1 | Automatically joins the team.<br/>`0` disabled<br/>`1` enable (Use in conjunction with the cvar humans_join_team any/CT/T) | | mp_auto_join_team | 0 | 0 | 1 | Automatically joins the team.<br/>`0` disabled<br/>`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_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. | | 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. |

9
dist/game.cfg vendored
View File

@ -89,11 +89,18 @@ mp_auto_reload_weapons "0"
// 0 - disabled (default behaviour) // 0 - disabled (default behaviour)
// 1 - refill backpack ammo on player spawn // 1 - refill backpack ammo on player spawn
// 2 - refill backpack ammo on player spawn and on the purchase of the item // 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" // Default value: "0"
mp_refill_bpammo_weapons 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 // Automatically joins the team
// 0 - disabled // 0 - disabled
// 1 - enabled (Use in conjunction with the cvar humans_join_team any/SPEC/CT/T) // 1 - enabled (Use in conjunction with the cvar humans_join_team any/SPEC/CT/T)

View File

@ -516,3 +516,15 @@ EXT_FUNC bool CCSPlayer::CheckActivityInGame()
return (fabs(deltaYaw) >= 0.1f && fabs(deltaPitch) >= 0.1f); 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;
}

View File

@ -735,6 +735,10 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
*pApersand = ' '; *pApersand = ' ';
} }
#ifdef REGAMEDLL_API
pPlayer->CSPlayer()->Reset();
#endif
UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", (sName[0] != '\0') ? sName : "<unconnected>"); UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", (sName[0] != '\0') ? sName : "<unconnected>");
} }

View File

@ -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 timeleft = { "mp_timeleft", "0", FCVAR_SERVER | FCVAR_UNLOGGED, 0.0f, nullptr };
cvar_t friendlyfire = { "mp_friendlyfire", "0", FCVAR_SERVER, 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 allowmonsters = { "mp_allowmonsters", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t roundtime = { "mp_roundtime", "5", 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 }; 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(&displaysoundlist);
CVAR_REGISTER(&timelimit); CVAR_REGISTER(&timelimit);
CVAR_REGISTER(&friendlyfire); CVAR_REGISTER(&friendlyfire);
#ifdef BUILD_LATEST
CVAR_REGISTER(&infiniteAmmo);
#endif
CVAR_REGISTER(&flashlight); CVAR_REGISTER(&flashlight);
CVAR_REGISTER(&decalfrequency); CVAR_REGISTER(&decalfrequency);

View File

@ -58,6 +58,7 @@ extern cvar_t fadetoblack;
extern cvar_t fragsleft; extern cvar_t fragsleft;
extern cvar_t timeleft; extern cvar_t timeleft;
extern cvar_t friendlyfire; extern cvar_t friendlyfire;
extern cvar_t infiniteAmmo;
extern cvar_t allowmonsters; extern cvar_t allowmonsters;
extern cvar_t roundtime; extern cvar_t roundtime;
extern cvar_t buytime; extern cvar_t buytime;

View File

@ -824,6 +824,35 @@ bool CBasePlayerWeapon::HasSecondaryAttack()
return true; return true;
} }
void CBasePlayerWeapon::HandleInfiniteAmmo()
{
int nInfiniteAmmo = 0;
#ifdef REGAMEDLL_API
nInfiniteAmmo = m_pPlayer->CSPlayer()->m_iWeaponInfiniteAmmo;
#endif
if (!nInfiniteAmmo)
nInfiniteAmmo = static_cast<int>(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() void CBasePlayerWeapon::ItemPostFrame()
{ {
int usableButtons = m_pPlayer->pev->button; int usableButtons = m_pPlayer->pev->button;
@ -888,16 +917,7 @@ void CBasePlayerWeapon::ItemPostFrame()
// Add them to the clip // Add them to the clip
m_iClip += j; 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; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;
#endif
m_pPlayer->TabulateAmmo(); m_pPlayer->TabulateAmmo();
m_fInReload = FALSE; m_fInReload = FALSE;
@ -1006,10 +1026,18 @@ void CBasePlayerWeapon::ItemPostFrame()
} }
} }
#ifdef BUILD_LATEST
HandleInfiniteAmmo();
#endif
WeaponIdle(); WeaponIdle();
return; return;
} }
#ifdef BUILD_LATEST
HandleInfiniteAmmo();
#endif
// catch all // catch all
if (ShouldWeaponIdle()) if (ShouldWeaponIdle())
{ {

View File

@ -393,6 +393,7 @@ public:
void SetPlayerShieldAnim(); void SetPlayerShieldAnim();
void ResetPlayerShieldAnim(); void ResetPlayerShieldAnim();
bool ShieldSecondaryFire(int iUpAnim, int iDownAnim); bool ShieldSecondaryFire(int iUpAnim, int iDownAnim);
void HandleInfiniteAmmo();
void InstantReload(bool bCanRefillBPAmmo = false); void InstantReload(bool bCanRefillBPAmmo = false);
#ifdef REGAMEDLL_API #ifdef REGAMEDLL_API
@ -1251,6 +1252,7 @@ public:
virtual BOOL Deploy(); virtual BOOL Deploy();
virtual float GetMaxSpeed() { return M3_MAX_SPEED; } virtual float GetMaxSpeed() { return M3_MAX_SPEED; }
virtual int iItemSlot() { return PRIMARY_WEAPON_SLOT; } virtual int iItemSlot() { return PRIMARY_WEAPON_SLOT; }
virtual BOOL PlayEmptySound();
virtual void PrimaryAttack(); virtual void PrimaryAttack();
virtual void Reload(); virtual void Reload();
virtual void WeaponIdle(); virtual void WeaponIdle();
@ -1656,6 +1658,7 @@ public:
virtual BOOL Deploy(); virtual BOOL Deploy();
virtual float GetMaxSpeed() { return XM1014_MAX_SPEED; } virtual float GetMaxSpeed() { return XM1014_MAX_SPEED; }
virtual int iItemSlot() { return PRIMARY_WEAPON_SLOT; } virtual int iItemSlot() { return PRIMARY_WEAPON_SLOT; }
virtual BOOL PlayEmptySound();
virtual void PrimaryAttack(); virtual void PrimaryAttack();
virtual void Reload(); virtual void Reload();
virtual void WeaponIdle(); virtual void WeaponIdle();

View File

@ -60,6 +60,13 @@ BOOL CM3::Deploy()
return DefaultDeploy("models/v_m3.mdl", "models/p_m3.mdl", M3_DRAW, "shotgun", UseDecrement() != FALSE); 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() void CM3::PrimaryAttack()
{ {
Vector vecAiming, vecSrc, vecDir; Vector vecAiming, vecSrc, vecDir;
@ -204,15 +211,8 @@ void CM3::Reload()
#endif #endif
{ {
m_iClip++; m_iClip++;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
#ifdef REGAMEDLL_ADD m_pPlayer->ammo_buckshot--;
if (refill_bpammo_weapons.value < 3.0f)
#endif
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->ammo_buckshot--;
}
m_fInSpecialReload = 1; m_fInSpecialReload = 1;
} }
} }

View File

@ -58,6 +58,13 @@ BOOL CXM1014::Deploy()
return DefaultDeploy("models/v_xm1014.mdl", "models/p_xm1014.mdl", XM1014_DRAW, "m249", UseDecrement() != FALSE); 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() void CXM1014::PrimaryAttack()
{ {
Vector vecAiming, vecSrc, vecDir; Vector vecAiming, vecSrc, vecDir;
@ -207,15 +214,8 @@ void CXM1014::Reload()
#endif #endif
{ {
m_iClip++; m_iClip++;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
#ifdef REGAMEDLL_ADD m_pPlayer->ammo_buckshot--;
if (refill_bpammo_weapons.value < 3.0f)
#endif
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->ammo_buckshot--;
}
m_fInSpecialReload = 1; m_fInSpecialReload = 1;
} }
} }

View File

@ -31,9 +31,19 @@
#include <API/CSPlayerItem.h> #include <API/CSPlayerItem.h>
#include <API/CSPlayerWeapon.h> #include <API/CSPlayerWeapon.h>
enum WeaponInfiniteAmmoMode
{
WPNMODE_INFINITE_CLIP = 1,
WPNMODE_INFINITE_BPAMMO
};
class CCSPlayer: public CCSMonster { class CCSPlayer: public CCSMonster {
public: 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'; m_szModel[0] = '\0';
} }
@ -84,6 +94,7 @@ public:
virtual void RemoveSpawnProtection(); virtual void RemoveSpawnProtection();
virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);
void Reset();
CBasePlayer *BasePlayer() const; CBasePlayer *BasePlayer() const;
public: public:
@ -103,6 +114,7 @@ public:
float m_flRespawnPending; float m_flRespawnPending;
float m_flSpawnProtectionEndTime; float m_flSpawnProtectionEndTime;
Vector m_vecOldvAngle; Vector m_vecOldvAngle;
int m_iWeaponInfiniteAmmo;
}; };
// Inlines // Inlines