• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Negative damage, are you using 2 byte ints?

So in pretty much every game I play as Sharpshooter, the after action report says I did negative damage with the Winchester. I always use it for all 10 waves, so at about 50 shots per wave, 100 damage per shot, over 10 waves, I would expect 50,000 damage. If you're using 2 byte ints to track total damage, they would wrap over into negative after 32,768 damage. Did I guess the root cause correctly? If so I wouldn't mind a mint condition rail gun skin as a reward :p
 
There are no short/halfword integers on the script side (only Int and Byte) and we don't use them in native either (usually). No skin for you.

Well I am both happy and sad to hear that. As a fellow software engineer I would have to give whoever thought that was a good idea a talking to :p I hope the negative damage reports are at least under investigation?
 
Upvote 0
They'll only become negative if they are signed, but I don't think that's the problem.

The damage delt to zeds is negative, since it lowers zeds hp and then when they want to display that damage first that comes to your mind is positive damage, but the number is actually negative that's turned into positive, they didn't make it positive so it shows as negative. This is just a guess tho and either it's too easy to fix so they don't bother (also it's unimportant) or it's not because of this.
 
Upvote 0
Well I am both happy and sad to hear that. As a fellow software engineer I would have to give whoever thought that was a good idea a talking to :p I hope the negative damage reports are at least under investigation?

Yeah, sure :)

Edit: If you want to have a look at the code, download the KF2 SDK. It comes with the entire Unreal script source.
 
Upvote 0
EphemeralMatchStats class, function InternalRecordWeaponDamage (string 440):

Code:
Damage = ((TargetPawn.Health > 0) ? Damage : TargetPawn.Health + Damage);

If you hurt ZED and it still alive it writes DamageDealt correctly, but if you overkill it, the things getting messed up.

TargetPawn.Health can easily went down below 0 far far away because:

1. If you headshot it, there happening additional damage calculation involving Extra Head Damage value that being taken through whole TakeDamage function once again.
2. If you headshot it with shotgun, it takes 7 pellets on account even when only one hits. This decreases HP of ZED's corpse even further below 0.

For example off-perk impact with RPG-7 (150 + 750) against Clot (100 HP, ~ -750 when overkilled) only shows around 50 points of DamageDealt

-850 + 900 = 50, the numbers are approximative.

You can try to fix it by calculating DamageDealt value as a difference between ZED's Max health and current health. No need to take "overkill" damage on account. Logically you can't do more damage to ZED than it has health:

Code:
Damage = ((TargetPawn.Health > 0) ? Damage : (TargetPawn.MaxHealth - TargetPawn.Health));
 
Last edited:
Upvote 0
EphemeralMatchStats class, function InternalRecordWeaponDamage (string 440):

Code:
Damage = ((TargetPawn.Health > 0) ? Damage : TargetPawn.Health + Damage);

If you hurt ZED and it still alive it writes DamageDealt correctly, but if you overkill it, the things getting messed up.

TargetPawn.Health can easily went down below 0 far far away because:

1. If you headshot it, there happening additional damage calculation involving Extra Head Damage value that being taken through whole TakeDamage function once again.
2. If you headshot it with shotgun, it takes 7 pellets on account even when only one hits. This decreases HP of ZED's corpse even further below 0.

For example off-perk impact with RPG-7 (150 + 750) against Clot (100 HP, ~ -750 when overkilled) only shows around 50 points of DamageDealt

-850 + 900 = 50, the numbers are approximative.

You can try to fix it by calculating DamageDealt value as a difference between ZED's Max health and current health. No need to take "overkill" damage on account. Logically you can't do more damage to ZED then it has health:

Code:
Damage = ((TargetPawn.Health > 0) ? Damage : (TargetPawn.MaxHealth - TargetPawn.Health));

Hmm, why are we trying to avoid counting overkill? If I shoot my rail gun at a clot's head I would want it to count 750 damage rather than 25.
 
Upvote 0
seems like the primary problem here is dealing with positive and negative values.
games almost never need to deal with these. unnecessary.

'everybody else' treats Damage and Health as positive values, and subtracts Damage from Health.
adding negative Damage to Health is unnecessarily complicated and unreliable, honestly. adds a middle man without the necessity for it.

and then for Healing, positive values still tend to be used, but handled in a different manner.
Hmm, why are we trying to avoid counting overkill? If I shoot my rail gun at a clot's head I would want it to count 750 damage rather than 25.

but you didn't deal 750 Damage.
 
Upvote 0
taiiat;n2157634 said:
but you didn't deal 750 Damage.
hmm, I would say that I did, and I REALLY REALLY showed that clot. Sure I could have taken it down with 25 damage to the head, but I fired a much more powerful weapon didn't I? The weapon deals 750 damage, even if I don't have to deal that much to kill the clot. In fact, I would love to see the clot explode into tiny little pieces from the overkill. (does it? I don't know, I haven't actually been shooting clots with the railgun)
 
Upvote 0