Implemented cvar mp_infinite_grenades.

Reworked cvar mp_infinite_ammo, not include grenades
This commit is contained in:
s1lent 2019-08-26 05:45:27 +07:00
parent a7f20dc2e8
commit 69e5c854e2
9 changed files with 37 additions and 1 deletions

View File

@ -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.<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 | 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_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_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_infinite_grenades | 0 | 0 | 1 | Enable infinite grenades.<br/>`0` disabled<br/>`1` grenades infinite |
| 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. |

7
dist/game.cfg vendored
View File

@ -101,6 +101,13 @@ mp_refill_bpammo_weapons 0
// Default value: "0" // Default value: "0"
mp_infinite_ammo 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 // 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

@ -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 friendlyfire = { "mp_friendlyfire", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t infiniteAmmo = { "mp_infinite_ammo", "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 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 };
@ -189,6 +190,7 @@ void EXT_FUNC GameDLLInit()
#ifdef BUILD_LATEST #ifdef BUILD_LATEST
CVAR_REGISTER(&infiniteAmmo); CVAR_REGISTER(&infiniteAmmo);
CVAR_REGISTER(&infiniteGrenades);
#endif #endif
CVAR_REGISTER(&flashlight); CVAR_REGISTER(&flashlight);

View File

@ -59,6 +59,7 @@ 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 infiniteAmmo;
extern cvar_t infiniteGrenades;
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

@ -6281,7 +6281,9 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse)
#ifdef REGAMEDLL_API #ifdef REGAMEDLL_API
CSPlayer()->m_iWeaponInfiniteAmmo = WPNMODE_INFINITE_BPAMMO; CSPlayer()->m_iWeaponInfiniteAmmo = WPNMODE_INFINITE_BPAMMO;
CSPlayer()->m_iWeaponInfiniteIds = WEAPON_ALLWEAPONS;
#endif #endif
GiveNamedItemEx("item_longjump"); GiveNamedItemEx("item_longjump");
GiveNamedItemEx("item_thighpack"); GiveNamedItemEx("item_thighpack");
GiveNamedItemEx("item_kevlar"); GiveNamedItemEx("item_kevlar");

View File

@ -839,7 +839,12 @@ void CBasePlayerWeapon::HandleInfiniteAmmo()
{ {
m_iClip = iMaxClip(); 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()) if (pszAmmo1())
{ {

View File

@ -439,6 +439,22 @@ bool IsSecondaryWeapon(int id)
return false; 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) WeaponInfoStruct *GetWeaponInfo(int weaponID)
{ {
for (auto& info : g_weaponInfo) { for (auto& info : g_weaponInfo) {

View File

@ -449,6 +449,7 @@ WeaponClassType AliasToWeaponClass(const char *alias);
WeaponClassType WeaponIDToWeaponClass(int id); WeaponClassType WeaponIDToWeaponClass(int id);
bool IsPrimaryWeapon(int id); bool IsPrimaryWeapon(int id);
bool IsSecondaryWeapon(int id); bool IsSecondaryWeapon(int id);
bool IsGrenadeWeapon(int id);
bool CanBuyWeaponByMaptype(int playerTeam, WeaponIdType weaponID, bool useAssasinationRestrictions); bool CanBuyWeaponByMaptype(int playerTeam, WeaponIdType weaponID, bool useAssasinationRestrictions);
void WeaponInfoReset(); void WeaponInfoReset();

View File

@ -115,6 +115,7 @@ public:
float m_flSpawnProtectionEndTime; float m_flSpawnProtectionEndTime;
Vector m_vecOldvAngle; Vector m_vecOldvAngle;
int m_iWeaponInfiniteAmmo; int m_iWeaponInfiniteAmmo;
int m_iWeaponInfiniteIds;
}; };
// Inlines // Inlines