]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/damage.qc
Merge branch 'terencehill/scoreboard_ui' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / damage.qc
index 95e1488fe5a6e86cb8a7f56fb57db8a571d02b7b..3cbc07c57d3dddb989bd6b954ad58df86e6186f0 100644 (file)
@@ -17,6 +17,7 @@
 #include <common/physics/movetypes/movetypes.qh>
 #include <common/physics/player.qh>
 #include <common/playerstats.qh>
+#include <common/resources/sv_resources.qh>
 #include <common/state.qh>
 #include <common/teams.qh>
 #include <common/util.qh>
@@ -31,7 +32,6 @@
 #include <server/items/items.qh>
 #include <server/main.qh>
 #include <server/mutators/_mod.qh>
-#include <server/resources.qh>
 #include <server/scores.qh>
 #include <server/spawnpoints.qh>
 #include <server/teamplay.qh>
@@ -95,10 +95,6 @@ string AppendItemcodes(string s, entity player)
                if(w != 0 || slot == 0)
                        s = strcat(s, ftos(w));
        }
-       if(StatusEffects_active(STATUSEFFECT_Strength, player))
-               s = strcat(s, "S");
-       if(StatusEffects_active(STATUSEFFECT_Shield, player))
-               s = strcat(s, "I");
        if(PHYS_INPUT_BUTTON_CHAT(player))
                s = strcat(s, "T");
        // TODO: include these codes as a flag on the item itself
@@ -613,9 +609,12 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
                // These are ALWAYS lethal
                // No damage modification here
                // Instead, prepare the victim for his death...
-               SetResourceExplicit(targ, RES_ARMOR, 0);
-               targ.spawnshieldtime = 0;
-               SetResourceExplicit(targ, RES_HEALTH, 0.9); // this is < 1
+               if(deathtype == DEATH_TEAMCHANGE.m_id || deathtype == DEATH_AUTOTEAMCHANGE.m_id)
+               {
+                       SetResourceExplicit(targ, RES_ARMOR, 0);
+                       SetResourceExplicit(targ, RES_HEALTH, 0.9); // this is < 1
+               }
+               StatusEffects_remove(STATUSEFFECT_SpawnShield, targ, STATUSEFFECT_REMOVE_CLEAR);
                targ.flags -= targ.flags & FL_GODMODE;
                damage = 100000;
        }
@@ -629,7 +628,10 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
                if(deathtype != DEATH_TELEFRAG.m_id)
                if(IS_PLAYER(attacker))
                {
-                       if(IS_PLAYER(targ) && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
+                       // avoid dealing damage or force to other independent players
+                       // and avoid dealing damage or force to things owned by other independent players
+                       if((IS_PLAYER(targ) && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ))) ||
+                               (targ.realowner && IS_INDEPENDENT_PLAYER(targ.realowner) && attacker != targ.realowner))
                        {
                                damage = 0;
                                force = '0 0 0';
@@ -764,34 +766,6 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
                        }
                }
 
-               if(!MUTATOR_IS_ENABLED(mutator_instagib))
-               {
-                       // apply strength multiplier
-                       if (attacker.items & ITEM_Strength.m_itemid)
-                       {
-                               if(targ == attacker)
-                               {
-                                       damage = damage * autocvar_g_balance_powerup_strength_selfdamage;
-                                       force = force * autocvar_g_balance_powerup_strength_selfforce;
-                               }
-                               else
-                               {
-                                       damage = damage * autocvar_g_balance_powerup_strength_damage;
-                                       force = force * autocvar_g_balance_powerup_strength_force;
-                               }
-                       }
-
-                       // apply invincibility multiplier
-                       if (targ.items & ITEM_Shield.m_itemid)
-                       {
-                               damage = damage * autocvar_g_balance_powerup_invincible_takedamage;
-                               if (targ != attacker)
-                               {
-                                       force = force * autocvar_g_balance_powerup_invincible_takeforce;
-                               }
-                       }
-               }
-
                if (targ == attacker)
                        damage = damage * autocvar_g_balance_selfdamagepercent; // Partial damage if the attacker hits himself
 
@@ -819,7 +793,7 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
                                                        if(PHYS_INPUT_BUTTON_CHAT(victim))
                                                                attacker.typehitsound += 1;
                                                        else
-                                                               attacker.damage_dealt += damage;
+                                                               attacker.hitsound_damage_dealt += damage;
                                                }
 
                                                impressive_hits += 1;
@@ -853,7 +827,7 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
        // apply push
        if (targ.damageforcescale)
        if (force)
-       if (!IS_PLAYER(targ) || time >= targ.spawnshieldtime || targ == attacker)
+       if (!IS_PLAYER(targ) || !StatusEffects_active(STATUSEFFECT_SpawnShield, targ) || targ == attacker)
        {
                vector farce = damage_explosion_calcpush(targ.damageforcescale * force, targ.velocity, autocvar_g_balance_damagepush_speedfactor);
                if(targ.move_movetype == MOVETYPE_PHYSICS)
@@ -910,6 +884,8 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                return 0;
        }
 
+       if (rad < 0) rad = 0;
+
        RadiusDamage_running = 1;
 
        tfloordmg = autocvar_g_throughfloor_damage;
@@ -941,27 +917,25 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                if (((cantbe != targ) && !mustbe) || (mustbe == targ))
                if (targ.takedamage)
                {
-                       vector nearest;
-                       vector diff;
-                       float power;
-
-                       // LordHavoc: measure distance to nearest point on target (not origin)
-                       // (this guarentees 100% damage on a touch impact)
-                       nearest = targ.WarpZone_findradius_nearest;
-                       diff = targ.WarpZone_findradius_dist;
+                       // measure distance from nearest point on target (not origin)
+                       // to nearest point on inflictor (not origin)
+                       vector nearest = targ.WarpZone_findradius_nearest;
+                       vector inflictornearest = NearestPointOnBoundingBox(
+                               inflictororigin - (inflictor.maxs - inflictor.mins) * 0.5,
+                               inflictororigin + (inflictor.maxs - inflictor.mins) * 0.5,
+                               nearest);
+                       vector diff = inflictornearest - nearest;
+
                        // round up a little on the damage to ensure full damage on impacts
                        // and turn the distance into a fraction of the radius
-                       power = 1 - ((vlen (diff) - bound(MIN_DAMAGEEXTRARADIUS, targ.damageextraradius, MAX_DAMAGEEXTRARADIUS)) / rad);
-                       //bprint(" ");
-                       //bprint(ftos(power));
-                       //if (targ == attacker)
-                       //      print(ftos(power), "\n");
-                       if (power > 0)
+                       float dist = max(0, vlen(diff) - bound(MIN_DAMAGEEXTRARADIUS, targ.damageextraradius, MAX_DAMAGEEXTRARADIUS));
+                       if (dist <= rad)
                        {
-                               float finaldmg;
-                               if (power > 1)
-                                       power = 1;
-                               finaldmg = coredamage * power + edgedamage * (1 - power);
+                               float power = 1;
+                               if (rad > 0)
+                                       power -= (dist / rad);
+                               // at this point power can't be < 0 or > 1
+                               float finaldmg = coredamage * power + edgedamage * (1 - power);
                                if (finaldmg > 0)
                                {
                                        float a;
@@ -1226,12 +1200,12 @@ void Fire_ApplyDamage(entity e)
        t = min(frametime, fireendtime - time);
        d = e.fire_damagepersec * t;
 
-       hi = e.fire_owner.damage_dealt;
+       hi = e.fire_owner.hitsound_damage_dealt;
        ty = e.fire_owner.typehitsound;
        Damage(e, e, e.fire_owner, d, e.fire_deathtype, DMG_NOWEP, e.origin, '0 0 0');
        if(e.fire_hitsound && e.fire_owner)
        {
-               e.fire_owner.damage_dealt = hi;
+               e.fire_owner.hitsound_damage_dealt = hi;
                e.fire_owner.typehitsound = ty;
        }
        e.fire_hitsound = true;