void UpdateDamage()
{
// accumulate damage with each stat update
- float unaccounted_damage_new = getstati(STAT_DAMAGE_DEALT_TOTAL);
+ static float damage_total_prev = 0;
+ float damage_total = getstati(STAT_DAMAGE_DEALT_TOTAL);
+ float unaccounted_damage_new = COMPARE_INCREASING(damage_total, damage_total_prev);
+ damage_total_prev = damage_total;
+
static float damage_dealt_time_prev = 0;
float damage_dealt_time = getstatf(STAT_HIT_TIME);
if (damage_dealt_time != damage_dealt_time_prev)
float altime;
FOR_EACH_REALCLIENT(self)
{
- self.damage_dealt_total = 0;
-
- if(IS_SPEC(self))
- {
- if(self.enemy.typehitsound)
- self.typehit_time = time;
- else if(self.enemy.damage_dealt)
- {
- self.hit_time = time;
- self.damage_dealt_total = ceil(self.enemy.damage_dealt);
- }
- }
- else
+ entity e = IS_SPEC(self) ? self.enemy : self;
+ if(e.typehitsound)
+ self.typehit_time = time;
+ else if(e.damage_dealt)
{
- if(self.typehitsound)
- self.typehit_time = time;
- else if(self.damage_dealt)
- {
- self.hit_time = time;
- self.damage_dealt_total = ceil(self.damage_dealt);
- }
+ self.hit_time = time;
+ self.damage_dealt_total += ceil(e.damage_dealt);
}
}
altime = time + frametime * (1 + autocvar_g_antilag_nudge);