]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_shotgun.qc
Move weapon load floats in defs.qh, rather than in each weapon file. Necessary to...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_shotgun.qc
index 54043a9b430d8b92130fb58ed496b184821f25ab..50ad77bde336ae3636f19b4109c5325aa0668915 100644 (file)
@@ -3,8 +3,6 @@ REGISTER_WEAPON(SHOTGUN, w_shotgun, IT_SHELLS, 2, WEP_FLAG_NORMAL | WEP_TYPE_HIT
 #else
 #ifdef SVQC
 
-.float shotgun_load;
-
 void W_Shotgun_SetAmmoCounter()
 {
        // set clip_load to the weapon we have switched to, if the gun uses reloading
@@ -41,7 +39,7 @@ void W_Shotgun_Reload()
        if(!autocvar_g_balance_shotgun_reload_ammo)
                return;
 
-       if(!W_ReloadCheck(self.ammo_shells))
+       if(!W_ReloadCheck(self.ammo_shells, autocvar_g_balance_shotgun_primary_ammo))
                return;
 
        float t;
@@ -69,9 +67,6 @@ void W_Shotgun_Attack (void)
        float   bulletconstant;
        local entity flash;
 
-       if(autocvar_g_balance_shotgun_reload_ammo && self.clip_load <= 0)
-               return; // reloading, so we are done
-
        ammoamount = autocvar_g_balance_shotgun_primary_ammo;
        bullets = autocvar_g_balance_shotgun_primary_bullets;
        d = autocvar_g_balance_shotgun_primary_damage;
@@ -80,6 +75,18 @@ void W_Shotgun_Attack (void)
        bulletspeed = autocvar_g_balance_shotgun_primary_speed;
        bulletconstant = autocvar_g_balance_shotgun_primary_bulletconstant;
 
+       // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
+       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       {
+               if(autocvar_g_balance_shotgun_reload_ammo)
+               {
+                       self.clip_load -= ammoamount;
+                       self.shotgun_load = self.clip_load;
+               }
+               else
+                       self.ammo_shells -= ammoamount;
+       }
+
        W_SetupShot (self, autocvar_g_antilag_bullets && bulletspeed >= autocvar_g_antilag_bullets, 5, "weapons/shotgun_fire.wav", CHAN_WEAPON, d * bullets);
        for (sc = 0;sc < bullets;sc = sc + 1)
                fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_SHOTGUN, 0, 1, bulletconstant);
@@ -99,18 +106,6 @@ void W_Shotgun_Attack (void)
        flash.nextthink = time + 0.06;
        flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
        W_AttachToShotorg(flash, '5 0 0');
-
-       // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-       {
-               if(autocvar_g_balance_shotgun_reload_ammo)
-               {
-                       self.clip_load -= ammoamount;
-                       self.shotgun_load = self.clip_load;
-               }
-               else
-                       self.ammo_shells -= ammoamount;
-       }
 }
 
 void shotgun_meleethink (void)
@@ -176,7 +171,7 @@ float w_shotgun(float req)
                        self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
        else if (req == WR_THINK)
        {
-               if(autocvar_g_balance_shotgun_reload_ammo && self.clip_load <= 0) // forced reload
+               if(autocvar_g_balance_shotgun_reload_ammo && self.clip_load < autocvar_g_balance_shotgun_primary_ammo) // forced reload
                        W_Shotgun_Reload();
                else
                {