]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
Merge remote branch 'origin/terencehill/powerups_respawntime_fix'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index 4acb8da891fa4fa4158b5ef01b7026a176cced5e..4f496e56ebb7f102ea22f58ea14d53944e49544a 100644 (file)
@@ -185,8 +185,6 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
                vecs = ent.weaponentity.movedir;
        else
                vecs = '0 0 0';
-       if(debug_shotorg != '0 0 0')
-               vecs = debug_shotorg;
 
        dv = v_right * -vecs_y + v_up * vecs_z;
        w_shotorg = ent.origin + ent.view_ofs + dv;
@@ -609,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)
@@ -681,6 +675,8 @@ void CL_ExteriorWeaponentity_Think()
 
        self.glowmod = self.owner.weaponentity_glowmod;
        self.colormap = self.owner.colormap;
+
+       CSQCMODEL_AUTOUPDATE();
 }
 
 // spawning weaponentity for client
@@ -708,6 +704,13 @@ void CL_SpawnWeaponentity()
        self.exteriorweaponentity.angles = '0 0 0';
        self.exteriorweaponentity.think = CL_ExteriorWeaponentity_Think;
        self.exteriorweaponentity.nextthink = time;
+
+       {
+               entity oldself = self;
+               self = self.exteriorweaponentity;
+               CSQCMODEL_AUTOINIT();
+               self = oldself;
+       }
 }
 
 void Send_WeaponComplain (entity e, float wpn, string wpnname, float type)
@@ -850,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;
@@ -871,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)
@@ -889,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;
@@ -906,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
@@ -1487,7 +1512,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
 
        // now begin the reloading process
 
-       sound (self, CH_WEAPON_B, self.reload_sound, VOL_BASE, ATTN_NORM);
+       sound (self, CH_WEAPON_SINGLE, self.reload_sound, VOL_BASE, ATTN_NORM);
 
        // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,
        // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,