From: Mircea Kitsune Date: Fri, 21 Jan 2011 14:38:10 +0000 (+0200) Subject: Allow using weapons when the player has no more ammo of that type, but the weapon... X-Git-Tag: xonotic-v0.5.0~309^2~7^2~164 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fc05a442e575eb9722e603ff5fdfd71c2d39e3b2;p=xonotic%2Fxonotic-data.pk3dir.git Allow using weapons when the player has no more ammo of that type, but the weapon itself is still loaded --- diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 0e0335b9f..94613feb8 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -1047,6 +1047,13 @@ float weapon_prepareattack_checkammo(float secondary) if not(self.items & IT_UNLIMITED_WEAPON_AMMO) if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary)) { + // don't switch away from reloadable weapons, even if we're out of ammo, since the + // weapon itself might still be loaded. The reload code takes care of the switching + entity e; + e = get_weaponinfo(self.weapon); + if(cvar(strcat("g_balance_", e.netname, "_reload_ammo"))) + return FALSE; + // always keep the Mine Layer if we placed mines, so that we can detonate them local entity mine; if(self.weapon == WEP_MINE_LAYER) diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index 118fbf088..a2cf7bdac 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -221,7 +221,12 @@ float w_shotgun(float req) W_Shotgun_SetAmmoCounter(); } else if (req == WR_CHECKAMMO1) - return self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo; + { + if(autocvar_g_balance_shotgun_reload_ammo) + return self.shotgun_load; + else + return self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo; + } else if (req == WR_CHECKAMMO2) { return TRUE; diff --git a/qcsrc/server/w_sniperrifle.qc b/qcsrc/server/w_sniperrifle.qc index d31796d90..c1b9386f4 100644 --- a/qcsrc/server/w_sniperrifle.qc +++ b/qcsrc/server/w_sniperrifle.qc @@ -273,9 +273,19 @@ float w_sniperrifle(float req) self.ammo_counter = -1; } else if (req == WR_CHECKAMMO1) - return self.ammo_nails >= autocvar_g_balance_sniperrifle_primary_ammo; + { + if(autocvar_g_balance_sniperrifle_reload_ammo) + return self.sniperrifle_load; + else + return self.ammo_nails >= autocvar_g_balance_sniperrifle_primary_ammo; + } else if (req == WR_CHECKAMMO2) - return self.ammo_nails >= autocvar_g_balance_sniperrifle_secondary_ammo; + { + if(autocvar_g_balance_sniperrifle_reload_ammo) + return self.sniperrifle_load; + else + return self.ammo_nails >= autocvar_g_balance_sniperrifle_secondary_ammo; + } else if (req == WR_RELOAD) { W_SniperRifle_Reload();