]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
simplify some hacks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index 2062f446fdb9b6f35ac59a0a3758d5f8be6ab57c..1208766e21a99fca98117786b7391e0cb312d6f4 100644 (file)
@@ -607,10 +607,6 @@ void CL_ExteriorWeaponentity_Think()
                }
                else
                        setattachment(self, self.owner, "bip01 r hand");
-
-               // if that didn't find a tag, hide the exterior weapon model
-               if (!self.tag_index)
-                       self.model = "";
        }
        self.effects = self.owner.effects;
        if(sv_pitch_min == sv_pitch_max)
@@ -857,7 +853,7 @@ void weapon_setup(float windex)
        entity e;
        e = get_weaponinfo(windex);
        self.items &~= IT_AMMO;
-       self.items = self.items | e.items;
+       self.items = self.items | (e.items & IT_AMMO);
 
        // the two weapon entities will notice this has changed and update their models
        self.weapon = windex;
@@ -878,7 +874,17 @@ void W_SwitchToOtherWeapon(entity pl)
        if(ww)
                W_SwitchWeapon_Force(pl, ww);
 }
+
+string PrimaryOrSecondary(float secondary)
+{
+       if(secondary)
+               return "secondary";
+       else
+               return "primary";
+}
+
 .float prevdryfire;
+.float prevwarntime;
 float weapon_prepareattack_checkammo(float secondary)
 {
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
@@ -896,7 +902,19 @@ float weapon_prepareattack_checkammo(float secondary)
                        self.prevdryfire = time;
                }
 
-               W_SwitchToOtherWeapon(self);
+               if(weapon_action(self.weapon, WR_CHECKAMMO2 - secondary)) // check if the other firing mode has enough ammo
+               {
+                       if(time - self.prevwarntime > 1)
+                       {
+                               sprint(self, strcat("^2", W_Name(self.weapon), " ", PrimaryOrSecondary(secondary), "^7 is unable to fire, but its ^2", PrimaryOrSecondary(1 - secondary), "^7 can.\n"));
+                       }
+                       self.prevwarntime = time;
+               }
+               else // this weapon is totally unable to fire, switch to another one
+               {
+                       W_SwitchToOtherWeapon(self);
+               }
+               
                return FALSE;
        }
        return TRUE;
@@ -913,7 +931,7 @@ float weapon_prepareattack_check(float secondary, float attacktime)
                return FALSE;
        }
 
-       if (timeoutStatus == 2) //don't allow the player to shoot while game is paused
+       if (timeout_status == TIMEOUT_ACTIVE) //don't allow the player to shoot while game is paused
                return FALSE;
 
        // do not even think about shooting if switching