]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_sniperrifle.qc
Fix weapons with reloading disabled
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_sniperrifle.qc
index fbee51a97c5cfb4d373705454edba1e3917fb50e..0938cae0a649e6cd32d0ce98c63b32fd857770e0 100644 (file)
@@ -23,7 +23,7 @@ void W_SniperRifle_ReloadedAndReady()
        float t;
 
        // now do the ammo maths
-       self.ammo_counter = 0; // when we get here it's -1
+       self.ammo_counter = self.old_ammo_counter; // restore ammo counter, in case we still had ammo in the weapon while reloading
        while(self.ammo_counter < autocvar_g_balance_sniperrifle_reload_ammo && self.ammo_nails) // make sure we don't add more than the amount of ammo we have
        {
                self.ammo_counter += 1;
@@ -54,6 +54,7 @@ void W_SniperRifle_Reload()
 
        weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_sniperrifle_reloadtime, W_SniperRifle_ReloadedAndReady);
 
+       self.old_ammo_counter = self.ammo_counter;
        self.ammo_counter = -1;
 }
 
@@ -134,8 +135,10 @@ void spawnfunc_weapon_campingrifle (void)
 void W_SniperRifle_BulletHail_Continue()
 {
        float r, sw, af;
-       if(self.ammo_counter <= 0)
+
+       if(autocvar_g_balance_sniperrifle_reload_ammo && self.ammo_counter <= 0)
                return; // reloading, so we are done
+
        sw = self.switchweapon; // make it not detect weapon changes as reason to abort firing
        af = ATTACK_FINISHED(self);
        self.switchweapon = self.weapon;
@@ -207,7 +210,7 @@ float w_sniperrifle(float req)
        else if (req == WR_THINK)
        {
                W_SniperRifle_SetAmmoCounter();
-               if(self.ammo_counter < 0) // forced reload (e.g. because interrupted)
+               if(autocvar_g_balance_sniperrifle_reload_ammo && self.ammo_counter <= 0) // forced reload
             W_SniperRifle_Reload();
                else
                {