]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_damage.qc
Accuracy stats: also count damage dealt by projectiles hitting the enemy after the...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_damage.qc
index 6b968bc80028ed888c54d5864476de6e7fab4843..6be1c7deaabdce0f0f441f4ffcad2ce0d218bbe4 100644 (file)
@@ -33,7 +33,7 @@ void UpdateFrags(entity player, int f)
 void GiveFrags (entity attacker, entity targ, float f, int deathtype)
 {
        // TODO route through PlayerScores instead
-       if(gameover) return;
+       if(game_stopped) return;
 
        if(f < 0)
        {
@@ -294,7 +294,6 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
 
        // Set final information for the death
        targ.death_origin = targ.origin;
-       if(targ != attacker) { targ.killer_origin = attacker.origin; }
        string deathlocation = (autocvar_notification_server_allows_location ? NearestLocation(targ.death_origin) : "");
 
        #ifdef NOTIFICATIONS_DEBUG
@@ -376,6 +375,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
                        attacker.taunt_soundtime = time + 1;
                        attacker.killcount = attacker.killcount + 1;
 
+                       attacker.killsound += 1;
+
                        #define SPREE_ITEM(counta,countb,center,normal,gentle) \
                                case counta: \
                                { \
@@ -529,7 +530,7 @@ void Ice_Think(entity this)
        this.nextthink = time;
 }
 
-void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypoint)
+void Freeze (entity targ, float revivespeed, float frozen_type, float show_waypoint)
 {
        if(!IS_PLAYER(targ) && !IS_MONSTER(targ)) // only specified entities can be freezed
                return;
@@ -542,10 +543,11 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
        STAT(FROZEN, targ) = frozen_type;
        targ.revive_progress = ((frozen_type == 3) ? 1 : 0);
        targ.health = ((frozen_type == 3) ? targ_maxhealth : 1);
-       targ.revive_speed = freeze_time;
+       targ.revive_speed = revivespeed;
        if(targ.bot_attack)
                IL_REMOVE(g_bot_targets, targ);
        targ.bot_attack = false;
+       targ.freeze_time = time;
 
        entity ice = new(ice);
        ice.owner = targ;
@@ -617,30 +619,14 @@ void Unfreeze (entity targ)
 
 void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
-       float mirrordamage;
-       float mirrorforce;
        float complainteamdamage = 0;
-       entity attacker_save;
-       mirrordamage = 0;
-       mirrorforce = 0;
+       float mirrordamage = 0;
+       float mirrorforce = 0;
 
-       if (gameover || targ.killcount == FRAGS_SPECTATOR)
+       if (game_stopped || targ.killcount == FRAGS_SPECTATOR)
                return;
 
-    damage_targ = targ;
-    damage_inflictor = inflictor;
-    damage_attacker = attacker;
-       attacker_save = attacker;
-
-       if(IS_PLAYER(targ))
-       {
-               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-           {
-               .entity weaponentity = weaponentities[slot];
-               if(targ.(weaponentity).hook && targ.(weaponentity).hook.aiment == attacker)
-                       RemoveHook(targ.(weaponentity).hook);
-           }
-       }
+       entity attacker_save = attacker;
 
        // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
        if(DEATH_ISWEAPON(deathtype, WEP_HOOK) || DEATH_ISWEAPON(deathtype, WEP_TUBA))
@@ -739,11 +725,21 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                }
 
                // should this be changed at all? If so, in what way?
-               MUTATOR_CALLHOOK(PlayerDamage_Calculate, inflictor, attacker, targ, deathtype, damage, mirrordamage, force);
+               MUTATOR_CALLHOOK(Damage_Calculate, inflictor, attacker, targ, deathtype, damage, mirrordamage, force);
                damage = M_ARGV(4, float);
                mirrordamage = M_ARGV(5, float);
                force = M_ARGV(6, vector);
 
+               if(IS_PLAYER(targ) && damage > 0 && attacker)
+               {
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                   {
+                       .entity weaponentity = weaponentities[slot];
+                       if(targ.(weaponentity).hook && targ.(weaponentity).hook.aiment == attacker)
+                               RemoveHook(targ.(weaponentity).hook);
+                   }
+               }
+
                if(STAT(FROZEN, targ))
                if(deathtype != DEATH_HURTTRIGGER.m_id && deathtype != DEATH_TEAMCHANGE.m_id && deathtype != DEATH_AUTOTEAMCHANGE.m_id)
                {
@@ -1030,7 +1026,7 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                                                        LOG_INFOF("THROUGHFLOOR: D=%f F=%f max(dD)=1/%f max(dF)=1/%f", finaldmg, vlen(force), mininv_d, mininv_f);
 
 
-                                               total = 0.25 * pow(max(mininv_f, mininv_d), 2);
+                                               total = 0.25 * (max(mininv_f, mininv_d) ** 2);
 
                                                if(autocvar_g_throughfloor_debug)
                                                        LOG_INFOF(" steps=%f", total);