From 669092329d80c1cfca53226cd2f6c86ed0a7ffdf Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Fri, 21 Jan 2011 17:18:29 +0200 Subject: [PATCH] Properly do the ammo checks, and tweak the sniper rifle code (still not fixed though) --- qcsrc/server/cl_weaponsystem.qc | 4 ++-- qcsrc/server/w_shotgun.qc | 2 +- qcsrc/server/w_sniperrifle.qc | 25 ++----------------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 94613feb8..a92c642c7 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -1623,9 +1623,9 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread) // weapon reload code // ---------------------------------------------------------------- -float W_ReloadCheck(float ammo_amount, float ammo_use_primary, float ammo_use_secondary) +float W_ReloadCheck(float ammo_amount) { - if(ammo_amount < min(ammo_use_primary, ammo_use_secondary)) // when we get here, ammo_counter must be 0 or -1 + if(!ammo_amount) // when we get here, ammo_counter must be 0 or -1 { print("cannot reload... not enough ammo\n"); self.ammo_counter = -1; // reload later diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index 83087c323..643c3158a 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -40,7 +40,7 @@ void W_Shotgun_Reload() float t; - if(!W_ReloadCheck(self.shotgun_load, autocvar_g_balance_shotgun_primary_ammo, 0)) + if(!W_ReloadCheck(self.ammo_shells)) return; sound (self, CHAN_WEAPON2, "weapons/campingrifle_reload.wav", VOL_BASE, ATTN_NORM); diff --git a/qcsrc/server/w_sniperrifle.qc b/qcsrc/server/w_sniperrifle.qc index 56018ac2a..5bd5d5fc6 100644 --- a/qcsrc/server/w_sniperrifle.qc +++ b/qcsrc/server/w_sniperrifle.qc @@ -44,7 +44,7 @@ void W_SniperRifle_Reload() float t; - if(!W_ReloadCheck(self.sniperrifle_load, autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo)) + if(!W_ReloadCheck(self.ammo_nails)) return; sound (self, CHAN_WEAPON2, "weapons/campingrifle_reload.wav", VOL_BASE, ATTN_NORM); @@ -58,20 +58,6 @@ void W_SniperRifle_Reload() self.ammo_counter = -1; } -float W_SniperRifle_CheckMaxBullets(float checkammo) -{ - float maxbulls; - maxbulls = autocvar_g_balance_sniperrifle_reload_ammo; - if(!maxbulls) - maxbulls = 8; // match HUD - if(checkammo) - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - maxbulls = min(maxbulls, floor(self.ammo_nails / min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo))); - if(self.ammo_counter > maxbulls) - self.ammo_counter = maxbulls; - return (self.ammo_counter == maxbulls); -} - void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant) { if not(self.items & IT_UNLIMITED_WEAPON_AMMO) @@ -183,7 +169,6 @@ void W_SniperRifle_BulletHail(float mode, void(void) AttackFunc, float fr, float .float bot_secondary_sniperriflemooth; float w_sniperrifle(float req) { - float full; if (req == WR_AIM) { self.BUTTON_ATCK=FALSE; @@ -209,7 +194,6 @@ float w_sniperrifle(float req) } else if (req == WR_THINK) { - W_SniperRifle_SetAmmoCounter(); if(autocvar_g_balance_sniperrifle_reload_ammo && self.ammo_counter <= 0) // forced reload W_SniperRifle_Reload(); else @@ -266,11 +250,7 @@ float w_sniperrifle(float req) else if (req == WR_SETUP) { weapon_setup(WEP_SNIPERRIFLE); - - full = W_SniperRifle_CheckMaxBullets(TRUE); - if(autocvar_g_balance_sniperrifle_auto_reload_on_switch) - if(!full) - self.ammo_counter = -1; + W_SniperRifle_SetAmmoCounter(); } else if (req == WR_CHECKAMMO1) { @@ -294,7 +274,6 @@ float w_sniperrifle(float req) { self.sniperrifle_accumulator = time - autocvar_g_balance_sniperrifle_bursttime; self.ammo_counter = autocvar_g_balance_sniperrifle_reload_ammo; - W_SniperRifle_CheckMaxBullets(FALSE); } return TRUE; }; -- 2.39.2