]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weapons.qc
Merge branch 'tzork/gm_nexball' of git://de.git.xonotic.org/xonotic/xonotic-data...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weapons.qc
index edf5b1f5e5c697d07087509075ef53edc2af5bd0..dc827c9a21d019d833d97c2722d76fed77306b9a 100644 (file)
@@ -170,7 +170,7 @@ float W_WeaponBit(float wpn)
 
 float W_AmmoItemCode(float wpn)
 {
-       return (get_weaponinfo(wpn)).items;
+       return (get_weaponinfo(wpn)).items & IT_AMMO;
 }
 
 void thrown_wep_think()
@@ -198,7 +198,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        wep.colormap = own.colormap;
 
        wa = W_AmmoItemCode(wpn);
-       if(wa == IT_SUPERWEAPON || wa == 0)
+       if(wa == 0)
        {
                oldself = self;
                self = wep;
@@ -220,7 +220,25 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                self = oldself;
                if(startitem_failed)
                        return string_null;
-               if(doreduce)
+               if(doreduce && g_weapon_stay == 2)
+               {
+                       for(i = 0, j = 1; i < 24; ++i, j *= 2)
+                       {
+                               if(wa & j)
+                               {
+                                       ammofield = Item_CounterField(j);
+                                       wep.ammofield = 0;
+
+                                       // if our weapon is loaded, give its load back to the player
+                                       if(self.(weapon_load[self.weapon]) > 0)
+                                       {
+                                               own.ammofield += self.(weapon_load[self.weapon]);
+                                               self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
+                                       }
+                               }
+                       }
+               }
+               else if(doreduce)
                {
                        for(i = 0, j = 1; i < 24; ++i, j *= 2)
                        {
@@ -245,6 +263,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                wep.glowmod = own.weaponentity_glowmod;
                wep.think = thrown_wep_think;
                wep.nextthink = time + 0.5;
+               wep.pickup_anyway = TRUE; // these are ALWAYS pickable
                return s;
        }
 }
@@ -263,20 +282,18 @@ float W_IsWeaponThrowable(float w)
                return 0;
        if (g_cts)
                return 0;
-       if (g_nexball && w == WEP_GRENADE_LAUNCHER)
-               return 0;
 
        wb = W_WeaponBit(w);
        if(!wb)
                return 0;
+       if(wb & WEPBIT_SUPERWEAPONS) // can't throw a superweapon, they don't work
+               return 0;
        wa = W_AmmoItemCode(w);
        if(start_weapons & wb)
        {
-               if(wa == IT_SUPERWEAPON && start_items & IT_UNLIMITED_SUPERWEAPONS)
-                       return 0;
-               if(wa != IT_SUPERWEAPON && start_items & IT_UNLIMITED_WEAPON_AMMO)
-                       return 0;
                // start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
+               if(start_items & IT_UNLIMITED_WEAPON_AMMO)
+                       return 0;
                if(wa == 0)
                        return 0;
        }
@@ -297,8 +314,6 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
                return;
        if(!autocvar_g_weapon_throwable)
                return;
-       if(autocvar_g_weapon_stay == 1)
-               return;
        if(self.weaponentity.state != WS_READY)
                return;
        if(!W_IsWeaponThrowable(w))