]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_common.qc
Remove whitespace in W_CheckPRojectileDamage function
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_common.qc
index 3816594a97fda0a1ab824941f9947ecc3e6ee72a..81cf68ef227822a09c116c9bec99bdf33b9ec976 100644 (file)
@@ -117,7 +117,7 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
 
                        if(!pseudoprojectile)
                                pseudoprojectile = spawn(); // we need this so the sound uses the "entchannel4" volume
-                       soundtoat(MSG_ONE, pseudoprojectile, beampos, CHAN_PROJECTILE, snd, VOL_BASE * f, ATTN_NONE);
+                       soundtoat(MSG_ONE, pseudoprojectile, beampos, CH_SHOTS, snd, VOL_BASE * f, ATTN_NONE);
                }
 
                if(pseudoprojectile)
@@ -541,6 +541,39 @@ void fireBullet (vector start, vector dir, float spread, float damage, float for
        trace_endpos = end;
 }
 
+float W_CheckProjectileDamage(entity inflictor, entity projowner, float deathtype, float exception)
+{
+       float is_from_contents = (deathtype == DEATH_SLIME || deathtype == DEATH_LAVA);
+       float is_from_owner = (inflictor == projowner);
+       
+       print(strcat("from_contents ", ftos(is_from_contents), " : from_owner ", ftos(is_from_owner), " : exception ", ftos(exception), ". \n"));
+       
+       if(autocvar_g_projectiles_damage <= -2)
+       {
+               return FALSE; // no damage to projectiles at all, not even with the exceptions
+       }
+       else if(autocvar_g_projectiles_damage == -1)
+       {
+               if not(exception)
+                       return FALSE; // no damage other than exceptions (electro combo, hagar join explode, minelayer mines)
+       }
+       else if(autocvar_g_projectiles_damage == 0)
+       {
+               if not(is_from_contents || exception)
+                       return FALSE; // only damage from contents or exceptions is allowed
+       }       
+       else if(autocvar_g_projectiles_damage == 1)
+       {
+               if not(is_from_contents || is_from_owner || exception)
+                       return FALSE; // only self damage or damage from contents or exceptions is allowed 
+       }
+       
+       // -2 or lower disables all damage including exceptions
+       // 2 or higher automatically allows all damage normally 
+
+       return TRUE; // continue with the damage as planned
+}
+
 void W_PrepareExplosionByDamage(entity attacker, void() explode)
 {
        self.takedamage = DAMAGE_NO;