]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix more issues
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 15:53:58 +0000 (17:53 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 15:53:58 +0000 (17:53 +0200)
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/w_shotgun.qc
qcsrc/server/w_sniperrifle.qc

index a92c642c705472cf74a2b05b5fbf8ab6545d212a..84830d4377a68c534ff19cb260d575b3ddbebaba 100644 (file)
@@ -928,6 +928,13 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                f = weapon_action(wpn, WR_CHECKAMMO1);
                                f = f + weapon_action(wpn, WR_CHECKAMMO2);
 
+                               // 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")))
+                                       f = 1;
+
                                // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
                                local entity mine;
                                if(wpn == WEP_MINE_LAYER)
index 643c3158a3b261bebd2f2808765720538374d17d..6202b518b904dfa90dc222767bf324516641c2c4 100644 (file)
@@ -84,7 +84,7 @@ void W_Shotgun_Attack (void)
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
        {
                if(!autocvar_g_balance_shotgun_reload_ammo)
-                       self.ammo_shells = self.ammo_shells - ammoamount;
+                       self.ammo_shells -= ammoamount;
                else
                        self.shotgun_load -= ammoamount;
        }
@@ -222,10 +222,7 @@ float w_shotgun(float req)
        }
        else if (req == WR_CHECKAMMO1)
        {
-               if(autocvar_g_balance_shotgun_reload_ammo)
-                       return self.shotgun_load >= autocvar_g_balance_shotgun_primary_ammo;
-               else
-                       return self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo;
+               return self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo;
        }
        else if (req == WR_CHECKAMMO2)
        {
index 5bd5d5fc6c9a00108184cbe5b5360fa734a0cae7..c17f683449b902aa3184b2f8cabe0c95b08b110e 100644 (file)
@@ -61,12 +61,8 @@ void W_SniperRifle_Reload()
 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)
-       {
-               if(!autocvar_g_balance_sniperrifle_reload_ammo)
-                       self.ammo_nails -= pAmmo;
-               else
-                       self.sniperrifle_load -= pAmmo;
-       }
+       if(!autocvar_g_balance_sniperrifle_reload_ammo)
+               self.ammo_nails -= pAmmo;
 
        if(deathtype & HITTYPE_SECONDARY)
                W_SetupShot (self, autocvar_g_antilag_bullets && pSpeed >= autocvar_g_antilag_bullets, 2, "weapons/campingrifle_fire2.wav", CHAN_WEAPON, autocvar_g_balance_sniperrifle_secondary_damage + autocvar_g_balance_sniperrifle_secondary_headshotaddeddamage);
@@ -89,8 +85,14 @@ void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAdded
 
        if (autocvar_g_casings >= 2)
                SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
-       
-       self.ammo_counter = self.ammo_counter - 1;
+
+       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       {
+               if(!autocvar_g_balance_sniperrifle_reload_ammo)
+                       self.ammo_nails -= 1;
+               else
+                       self.sniperrifle_load -= 1;
+       }
 }
 
 void W_SniperRifle_Attack()
@@ -233,7 +235,7 @@ float w_sniperrifle(float req)
                 if(self.weaponentity.state == WS_READY)
                 {
                     self.wish_reload = 0;
-                    W_SniperRifle_Reload(self.ammo_nails);
+                    W_SniperRifle_Reload();
                 }
             }
         }
@@ -254,17 +256,11 @@ float w_sniperrifle(float req)
        }
        else if (req == WR_CHECKAMMO1)
        {
-               if(autocvar_g_balance_sniperrifle_reload_ammo)
-                       return self.sniperrifle_load >= autocvar_g_balance_sniperrifle_primary_ammo;
-               else
-                       return self.ammo_nails >= autocvar_g_balance_sniperrifle_primary_ammo;
+               return self.ammo_nails >= autocvar_g_balance_sniperrifle_primary_ammo;
        }
        else if (req == WR_CHECKAMMO2)
        {
-               if(autocvar_g_balance_sniperrifle_reload_ammo)
-                       return self.sniperrifle_load >= autocvar_g_balance_sniperrifle_secondary_ammo;
-               else
-                       return self.ammo_nails >= autocvar_g_balance_sniperrifle_secondary_ammo;
+               return self.ammo_nails >= autocvar_g_balance_sniperrifle_secondary_ammo;
        }
        else if (req == WR_RELOAD)
        {