]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_shotgun.qc
Move load persistence floats back to their weapon files. That should be the last...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_shotgun.qc
index c3ed59164f2c76b1801a53a920c2352cd4f49fb5..7d515ddeea28c0857dadc25b817386fc4bd62a55 100644 (file)
@@ -3,6 +3,9 @@ REGISTER_WEAPON(SHOTGUN, w_shotgun, IT_SHELLS, 2, WEP_FLAG_NORMAL | WEP_TYPE_HIT
 #else
 #ifdef SVQC
 
+// weapon load persistence, for weapons that support reloading
+.float shotgun_load;
+
 void W_Shotgun_SetAmmoCounter()
 {
        // set clip_load to the weapon we have switched to, if the gun uses reloading
@@ -164,6 +167,7 @@ void spawnfunc_weapon_shotgun(); // defined in t_items.qc
 
 float w_shotgun(float req)
 {
+       float ammo_amount;
        if (req == WR_AIM)
                if(vlen(self.origin-self.enemy.origin) <= autocvar_g_balance_shotgun_secondary_melee_range)
                        self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
@@ -213,27 +217,23 @@ 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;
+               ammo_amount = self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo;
+               ammo_amount += (autocvar_g_balance_shotgun_reload_ammo && self.shotgun_load >= autocvar_g_balance_shotgun_primary_ammo);
+               return ammo_amount;
        }
        else if (req == WR_CHECKAMMO2)
        {
+               // melee attack is always available
                return TRUE;
        }
-       else if (req == WR_RELOAD)
+       else if (req == WR_RESETPLAYER)
        {
-               W_Shotgun_Reload();
+               // all weapons must be fully loaded when we spawn
+               self.shotgun_load = autocvar_g_balance_shotgun_reload_ammo;
        }
-       else if (req == WR_SWITCHABLE)
+       else if (req == WR_RELOAD)
        {
-               // checks if this weapon can be switched to, when reloading is enabled
-               // returns true if there's either enough load in the weapon to use it,
-               // or we have enough ammo to reload the weapon to a usable point
-               float ammo_amount;
-               ammo_amount = autocvar_g_balance_shotgun_primary_ammo;
-               return (autocvar_g_balance_shotgun_reload_ammo && self.shotgun_load >= ammo_amount) || self.ammo_shells >= ammo_amount;
+               W_Shotgun_Reload();
        }
        return TRUE;
 };