]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/common.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / common.qc
index f69faa03a324de3e93d3136610a2835d9bbc781e..4f4da4e0d7339b58e2e8a4d4affd3ee81079dd7a 100644 (file)
 
 void W_GiveWeapon(entity e, int wep)
 {
-       if (!wep) return;
+       if (!wep) { return; }
 
        e.weapons |= WepSet_FromWeapon(Weapons_from(wep));
 
        if (IS_PLAYER(e)) {
-           Send_Notification(NOTIF_ONE, e, MSG_MULTI, ITEM_WEAPON_GOT, wep);
-    }
+               Send_Notification(NOTIF_ONE, e, MSG_MULTI, ITEM_WEAPON_GOT, wep);
+       }
 }
 
 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
+       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)
+       if ((player.items & ITEM_Strength.m_itemid)
                && ((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);
-                       store.prevstrengthsound = time;
-               }
-               store.prevstrengthsoundattempt = time;
+               || (time > store.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold))) {
+               sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM);
+               store.prevstrengthsound = time;
+       }
+       store.prevstrengthsoundattempt = time;
 }
 
 float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception)
@@ -43,37 +42,32 @@ float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype,
        float is_from_owner = (inflictor == projowner);
        float is_from_exception = (exception != -1);
 
-       //dprint(strcat("W_CheckProjectileDamage: from_contents ", ftos(is_from_contents), " : from_owner ", ftos(is_from_owner), " : exception ", strcat(ftos(is_from_exception), " (", ftos(exception), "). \n")));
+       // dprint(strcat("W_CheckProjectileDamage: from_contents ", ftos(is_from_contents), " : from_owner ", ftos(is_from_owner), " : exception ", strcat(ftos(is_from_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(is_from_exception)
-                       return (exception); // if exception is detected, allow it to override
-               else
-                       return false; // otherwise, no other damage is allowed
-       }
-       else if(autocvar_g_projectiles_damage == 0)
-       {
-               if(is_from_exception)
-                       return (exception); // if exception is detected, allow it to override
-               else if(!is_from_contents)
-                       return false; // otherwise, only allow damage from contents
-       }
-       else if(autocvar_g_projectiles_damage == 1)
-       {
-               if(is_from_exception)
-                       return (exception); // if exception is detected, allow it to override
-               else if(!(is_from_contents || is_from_owner))
-                       return false; // otherwise, only allow self damage and damage from contents
-       }
-       else if(autocvar_g_projectiles_damage == 2) // allow any damage, but override for exceptions
-       {
-               if(is_from_exception)
-                       return (exception); // if exception is detected, allow it to override
+       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 (is_from_exception) {
+                       return exception; // if exception is detected, allow it to override
+               } else {
+                       return false;     // otherwise, no other damage is allowed
+               }
+       } else if (autocvar_g_projectiles_damage == 0) {
+               if (is_from_exception) {
+                       return exception; // if exception is detected, allow it to override
+               } else if (!is_from_contents) {
+                       return false;     // otherwise, only allow damage from contents
+               }
+       } else if (autocvar_g_projectiles_damage == 1) {
+               if (is_from_exception) {
+                       return exception; // if exception is detected, allow it to override
+               } else if (!(is_from_contents || is_from_owner)) {
+                       return false;     // otherwise, only allow self damage and damage from contents
+               }
+       } else if (autocvar_g_projectiles_damage == 2) { // allow any damage, but override for exceptions
+               if (is_from_exception) {
+                       return exception; // if exception is detected, allow it to override
+               }
        }
 
        return true; // if none of these return, then allow damage anyway.
@@ -86,8 +80,7 @@ void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this)
 
        MUTATOR_CALLHOOK(PrepareExplosionByDamage, this, attacker);
 
-       if(IS_CLIENT(attacker) && !autocvar_g_projectiles_keep_owner)
-       {
+       if (IS_CLIENT(attacker) && !autocvar_g_projectiles_keep_owner) {
                this.owner = attacker;
                this.realowner = attacker;
        }