]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/common.qc
Merged master
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / common.qc
index 6d163755067def2224a973db9bc311f1dcb60770..fb57d92774d01657e5c4e98228a7175f8efe6252 100644 (file)
@@ -5,6 +5,7 @@
 #include <common/net_linked.qh>
 #include <common/deathtypes/all.qh>
 #include <common/notifications/all.qh>
+#include <common/state.qh>
 #include <common/util.qh>
 #include <common/weapons/_all.qh>
 #include <common/items/_mod.qh>
@@ -20,16 +21,18 @@ void W_GiveWeapon(entity e, int wep)
     }
 }
 
-void W_PlayStrengthSound(entity player) // void W_PlayStrengthSound
+void W_PlayStrengthSound(entity player)
 {
+       entity store = IS_PLAYER(player) ? PS(player) : player; // because non-player entities can fire, but can they have items? TODO
+
        if((player.items & ITEM_Strength.m_itemid)
-               && ((time > player.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam
-               || (time > player.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)))
+               && ((time > store.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam
+               || (time > store.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)))
                {
                        sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM);
-                       player.prevstrengthsound = time;
+                       store.prevstrengthsound = time;
                }
-               player.prevstrengthsoundattempt = time;
+               store.prevstrengthsoundattempt = time;
 }
 
 float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception)