]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
Merge remote branch 'refs/remotes/origin/fruitiex/racefixes'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index 925d53fa7e3cc218cfeba460f432969db25d7a47..4537573c5d57b28c6ed7757a4aea131bcd78d109 100644 (file)
@@ -130,6 +130,8 @@ vector w_shotend;
 // this function calculates w_shotorg and w_shotdir based on the weapon model
 // offset, trueaim and antilag, and won't put w_shotorg inside a wall.
 // make sure you call makevectors first (FIXME?)
+.float prevstrengthsound;
+.float prevstrengthsoundattempt;
 void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, string snd, float maxdamage, float range)
 {
        float nudge = 1; // added to traceline target and subtracted from result
@@ -245,9 +247,18 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
                sound (ent, CHAN_WEAPON, snd, VOL_BASE, ATTN_NORM);
        }
 
-       if (ent.items & IT_STRENGTH)
-       if (!g_minstagib)
-               sound (ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
+       if(ent.items & IT_STRENGTH)
+       if(!g_minstagib)
+       if(
+               (time > ent.prevstrengthsound + cvar("sv_strengthsound_antispam_time"))
+               ||
+               (time > ent.prevstrengthsoundattempt + cvar("sv_strengthsound_antispam_refire_threshold"))
+       ) // prevent insane sound spam
+       {
+               sound(ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
+               ent.prevstrengthsound = time;
+       }
+       ent.prevstrengthsoundattempt = time;
 
        // nudge w_shotend so a trace to w_shotend hits
        w_shotend = w_shotend + normalize(w_shotend - w_shotorg) * nudge;
@@ -981,6 +992,13 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                self = cl;
                                f = weapon_action(wpn, WR_CHECKAMMO1);
                                f = f + weapon_action(wpn, WR_CHECKAMMO2);
+
+                               // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
+                               local entity mine;
+                               if(wpn == WEP_MINE_LAYER)
+                               for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
+                                       f = 1;
+
                                self = oldself;
                        }
                        if (!f)
@@ -1093,6 +1111,15 @@ float weapon_prepareattack_checkammo(float secondary)
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
        if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary))
        {
+               // always keep the Mine Layer if we placed mines, so that we can detonate them
+               local entity mine;
+               if(self.weapon == WEP_MINE_LAYER)
+               for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
+                       return FALSE;
+
+               if(self.weapon == self.switchweapon) // only play once BEFORE starting to switch weapons
+                       sound (self, CHAN_AUTO, "weapons/dryfire.wav", VOL_BASE, ATTN_NORM);
+
                W_SwitchToOtherWeapon(self);
                return FALSE;
        }