Skip to content

Commit 9848daf

Browse files
committed
Allow setting ammo_per_fire to 0 for weapon templates
1 parent 12c6fc2 commit 9848daf

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

dlls/weapons_shared.cpp

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -953,44 +953,47 @@ void CConfigurableWeapon::PerformWeaponFire(bool altMode)
953953
const int ammoPerFire = fire.ammoPerFire.Get(altMode);
954954
const bool useSecondaryAmmo = fire.useSecondaryAmmo.Get(altMode);
955955

956-
if (useSecondaryAmmo)
956+
if (ammoPerFire > 0)
957957
{
958-
if (m_iSecondaryAmmoType > 0)
958+
if (useSecondaryAmmo)
959959
{
960-
if (m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] < ammoPerFire)
960+
if (m_iSecondaryAmmoType > 0)
961961
{
962-
PlayEmptySound(altMode);
963-
return;
962+
if (m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] < ammoPerFire)
963+
{
964+
PlayEmptySound(altMode);
965+
return;
966+
}
967+
m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] -= ammoPerFire;
968+
m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] = Q_max(0, m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()]);
964969
}
965-
m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] -= ammoPerFire;
966-
m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] = Q_max(0, m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()]);
967970
}
968-
}
969-
else
970-
{
971-
if (UsesAmmo())
971+
else
972972
{
973-
if (!HasAmmoToFire(ammoPerFire))
973+
if (UsesAmmo())
974974
{
975-
if (UsesClip() && params.reloadAutostart)
975+
if (!HasAmmoToFire(ammoPerFire))
976976
{
977-
Reload();
978-
if (!HasAmmoToFire(ammoPerFire))
979-
PlayEmptySound(altMode);
980-
}
981-
else
982-
{
983-
if (m_fFireOnEmpty)
977+
if (UsesClip() && params.reloadAutostart)
978+
{
979+
Reload();
980+
if (!HasAmmoToFire(ammoPerFire))
981+
PlayEmptySound(altMode);
982+
}
983+
else
984984
{
985-
PlayEmptySound(altMode);
986-
m_flNextPrimaryAttack = GetNextAttackDelay(fire.delayAfterEmpty.Get(altMode));
985+
if (m_fFireOnEmpty)
986+
{
987+
PlayEmptySound(altMode);
988+
m_flNextPrimaryAttack = GetNextAttackDelay(fire.delayAfterEmpty.Get(altMode));
989+
}
987990
}
991+
return;
988992
}
989-
return;
993+
SpendAmmo(ammoPerFire);
994+
UpdateRechargeTime(altMode);
995+
OnSpendAmmo();
990996
}
991-
SpendAmmo(ammoPerFire);
992-
UpdateRechargeTime(altMode);
993-
OnSpendAmmo();
994997
}
995998
}
996999

@@ -1217,12 +1220,15 @@ void CConfigurableWeapon::PerformWeaponFire(bool altMode)
12171220
m_flNextSecondaryAttack = Q_max(m_flNextPrimaryAttack, m_flNextSecondaryAttack);
12181221
}
12191222

1220-
if (useSecondaryAmmo)
1221-
CheckOutOfSecondaryAmmo();
1222-
else
1223+
if (ammoPerFire > 0)
12231224
{
1224-
if (!CanRechargeAmmo())
1225-
CheckOutOfAmmo();
1225+
if (useSecondaryAmmo)
1226+
CheckOutOfSecondaryAmmo();
1227+
else
1228+
{
1229+
if (!CanRechargeAmmo())
1230+
CheckOutOfAmmo();
1231+
}
12261232
}
12271233

12281234
const float pumpTime = fire.pumpDelay.Get(altMode);

game_shared/schema_weapons.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ const char* const json_schemas::weapons = R"(
341341
},
342342
"ammo_per_fire": {
343343
"type": "integer",
344-
"minimum": 1
344+
"minimum": 0
345345
},
346346
"allow_underwater": {
347347
"type": "boolean"

0 commit comments

Comments
 (0)