]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a function to check if the player is dual wielding
authorMario <mario@smbclan.net>
Mon, 12 Feb 2018 23:32:46 +0000 (09:32 +1000)
committerMario <mario@smbclan.net>
Mon, 12 Feb 2018 23:32:46 +0000 (09:32 +1000)
qcsrc/server/weapons/common.qc
qcsrc/server/weapons/tracing.qc

index f69faa03a324de3e93d3136610a2835d9bbc781e..9254ad581100394ffcb4d5a64addc675f246d97e 100644 (file)
 #include <common/weapons/_all.qh>
 #include <common/items/_mod.qh>
 
+bool W_DualWielding(entity player)
+{
+       int held_weapons = 0;
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if(player.(weaponentity) && player.(weaponentity).m_switchweapon != WEP_Null)
+                       ++held_weapons;
+       }
+
+       return held_weapons > 1;
+}
+
 void W_GiveWeapon(entity e, int wep)
 {
        if (!wep) return;
index 486ae180a2a0c80c3dea73f34dc0f45b36c45322..da61547942617a29a42bcd1d42f2cade95908265 100644 (file)
@@ -135,14 +135,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
                ent.punchangle_x = recoil * -1;
 
        if (snd != SND_Null) {
-               int held_weapons = 0; // HACK: muffle weapon sounds slightly while dual wielding!
-               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-               {
-                       .entity wep_ent = weaponentities[slot];
-                       if(ent.(wep_ent) && ent.(wep_ent).m_switchweapon != WEP_Null)
-                               ++held_weapons;
-               }
-               sound (ent, chan, snd, ((held_weapons > 1) ? VOL_BASE * 0.7 : VOL_BASE), ATTN_NORM);
+               sound (ent, chan, snd, ((W_DualWielding(ent) > 1) ? VOL_BASE * 0.7 : VOL_BASE), ATTN_NORM);
                W_PlayStrengthSound(ent);
        }