Commit 466ca310 authored by TimePath's avatar TimePath

Improve reliability by using total damage

parent 312154cf
......@@ -423,7 +423,11 @@ float unaccounted_damage = 0;
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)
......
......@@ -2204,27 +2204,13 @@ void EndFrame()
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment