]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Properly consider ammo we still had in the weapon before reloading
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 02:30:24 +0000 (04:30 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 02:30:24 +0000 (04:30 +0200)
qcsrc/server/defs.qh
qcsrc/server/w_shotgun.qc
qcsrc/server/w_sniperrifle.qc

index e835738a099c73a318e206a97c6181eb449889c5..a6374e46d8ee3e85f3f5f7c09a9aadc2ee86c87a 100644 (file)
@@ -613,6 +613,7 @@ float client_cefc_accumulatortime;
 #endif
 
 .float ammo_counter;
+.float old_ammo_counter;
 .float wish_reload;
 
 #define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_CORPSE; (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE
index 67c5da3f63653983e05d46bea22b4ea89f55a2b4..a99786ae3ca1e7390bd4e68cc85c7e90dbefdee9 100644 (file)
@@ -19,7 +19,7 @@ void W_Shotgun_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_shotgun_reload_ammo && self.ammo_shells) // make sure we don't add more than the amount of ammo we have
        {
                self.ammo_counter += 1;
@@ -50,6 +50,7 @@ void W_Shotgun_Reload()
 
        weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_sniperrifle_reloadtime, W_Shotgun_ReloadedAndReady);
 
+       self.old_ammo_counter = self.ammo_counter;
        self.ammo_counter = -1;
 }
 
index 22ff36ce5489b0b4be48eb78b347467b1d44acaa..c4d273c82900b996e10b59228c682deab9de1850 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;
 }