]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_damage.qc
fix a stupid typo, add a cvar to autocvars.qh
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_damage.qc
index e5e972bf6fb284420f7776d565a0f28bd591103a..0c07ad5a74de568af22a5fbb73cdf7345a4ba439 100644 (file)
@@ -102,7 +102,7 @@ void UpdateFrags(entity player, float f)
 
 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
 void W_SwitchWeapon_Force(entity e, float w);
-void GiveFrags (entity attacker, entity targ, float f)
+void GiveFrags (entity attacker, entity targ, float f, float deathtype)
 {
        float w;
 
@@ -139,19 +139,36 @@ void GiveFrags (entity attacker, entity targ, float f)
        if(targ != attacker) // not for suicides
        if(g_weaponarena_random)
        {
-               // after a frag, choose another random weapon set
-               if(inWarmupStage)
-                       w = warmup_start_weapons;
-               else
-                       w = start_weapons;
+               // after a frag, exchange the current weapon (or the culprit, if detectable) by a new random weapon
+               float culprit;
+               culprit = DEATH_WEAPONOF(deathtype);
+               if(!culprit || !(attacker.weapons & W_WeaponBit(culprit)))
+                       culprit = attacker.weapon;
 
-               attacker.weapons = randombits(w - (w & W_WeaponBit(attacker.weapon)), g_weaponarena_random, TRUE);
-               if(attacker.weapons < 0)
+               if(g_weaponarena_random_with_laser && culprit == WEPBIT_LASER)
                {
-                       // error from randombits: no weapon available
-                       // this means we can just give ALL weapons
-                       attacker.weapons = w;
+                       // no exchange
                }
+               else
+               {
+                       if(inWarmupStage)
+                               w = warmup_start_weapons;
+                       else
+                               w = start_weapons;
+
+                       // all others (including the culprit): remove
+                       w &~= attacker.weapons;
+
+                       // among the remaining ones, choose one by random
+                       w = randombits(w, 1, FALSE);
+                       if(w)
+                       {
+                               attacker.weapons |= w;
+                               attacker.weapons &~= W_WeaponBit(culprit);
+                       }
+               }
+
+               // after a frag, choose another random weapon set
                if not(attacker.weapons & W_WeaponBit(attacker.weapon))
                        W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker));
        }
@@ -301,7 +318,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                        if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
                        {
                                LogDeath("suicide", deathtype, targ, targ);
-                               GiveFrags(attacker, targ, -1);
+                               GiveFrags(attacker, targ, -1, deathtype);
                        }
 
                        if (targ.killcount > 2)
@@ -325,7 +342,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                else
                                        type = KILL_TEAM_BLUE;
 
-                               GiveFrags(attacker, targ, -1);
+                               GiveFrags(attacker, targ, -1, deathtype);
 
                                Send_CSQC_Centerprint(attacker, s, "", type, MSG_KILL);
 
@@ -379,10 +396,10 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                {
                                        UpdateFrags(attacker, ctf_score_value("score_kill"));
                                        PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
-                                       GiveFrags(attacker, targ, 0); // for logging
+                                       GiveFrags(attacker, targ, 0, deathtype); // for logging
                                }
                                else
-                                       GiveFrags(attacker, targ, 1);
+                                       GiveFrags(attacker, targ, 1, deathtype);
 
                                if (targ.killcount > 2) {
                                        Send_KillNotification(s, ftos(targ.killcount), a, KILL_END_SPREE, MSG_SPREE);
@@ -441,7 +458,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                        if(strstrofs(msg, "%", 0) < 0)
                                msg = strcat("%s ", msg);
 
-                       GiveFrags(targ, targ, -1);
+                       GiveFrags(targ, targ, -1, deathtype);
                        if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
                                AnnounceTo(targ, "botlike");
                        }
@@ -585,7 +602,8 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                                                                targ.dmg_save += v_y;
                                                                targ.dmg_inflictor = inflictor;
                                                                damage = 0;
-                                                               force = '0 0 0';
+                                if(!autocvar_g_friendlyfire_virtual_force)
+                                    force = '0 0 0';
                                                        }
                                                }
                                                else
@@ -1003,33 +1021,47 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e
                                                // laser force adjustments :P
                                                if(DEATH_WEAPONOF(deathtype) == WEP_LASER)
                                                {
-                                                       vector vel;
-
-                                                       float force_zscale;
-                                                       float force_velocitybiasramp;
-                                                       float force_velocitybias;
-
-                                                       force_velocitybiasramp = autocvar_sv_maxspeed;
-                                                       if(deathtype & HITTYPE_SECONDARY)
-                                                       {
-                                                               force_zscale = autocvar_g_balance_laser_secondary_force_zscale;
-                                                               force_velocitybias = autocvar_g_balance_laser_secondary_force_velocitybias;
-                                                       }
-                                                       else
-                                                       {
-                                                               force_zscale = autocvar_g_balance_laser_primary_force_zscale;
-                                                               force_velocitybias = autocvar_g_balance_laser_primary_force_velocitybias;
-                                                       }
-
-                                                       vel = targ.velocity;
-                                                       vel_z = 0;
-                                                       vel = normalize(vel) * bound(0, vlen(vel) / force_velocitybiasramp, 1) * force_velocitybias;
-                                                       force =
-                                                               vlen(force)
-                                                               *
-                                                               normalize(normalize(force) + vel);
-
-                                                       force_z *= force_zscale;
+                            if (targ == attacker)
+                            {
+                                vector vel;
+
+                                float force_zscale;
+                                float force_velocitybiasramp;
+                                float force_velocitybias;
+
+                                force_velocitybiasramp = autocvar_sv_maxspeed;
+                                if(deathtype & HITTYPE_SECONDARY)
+                                {
+                                    force_zscale = autocvar_g_balance_laser_secondary_force_zscale;
+                                    force_velocitybias = autocvar_g_balance_laser_secondary_force_velocitybias;
+                                }
+                                else
+                                {
+                                    force_zscale = autocvar_g_balance_laser_primary_force_zscale;
+                                    force_velocitybias = autocvar_g_balance_laser_primary_force_velocitybias;
+                                }
+
+                                vel = targ.velocity;
+                                vel_z = 0;
+                                vel = normalize(vel) * bound(0, vlen(vel) / force_velocitybiasramp, 1) * force_velocitybias;
+                                force =
+                                    vlen(force)
+                                    *
+                                    normalize(normalize(force) + vel);
+
+                                force_z *= force_zscale;
+                            }
+                            else
+                            {
+                                if(deathtype & HITTYPE_SECONDARY)
+                                {
+                                    force *= autocvar_g_balance_laser_secondary_force_other_scale;
+                                }
+                                else
+                                {
+                                    force *= autocvar_g_balance_laser_primary_force_other_scale;
+                                }
+                            }
                                                }
 
                                                //if (targ == attacker)