Wasteland 2 (integer) damage mechanics and cascade rounding down from hell WIP

Check here to discuss Wasteland 2 gameplay topics. Please avoid spoilers in thread titles.

Moderator: Ranger Team Alpha

Post Reply
peddroelm
Initiate
Posts: 8
Joined: February 6th, 2015, 4:21 am

Wasteland 2 (integer) damage mechanics and cascade rounding down from hell WIP

Post by peddroelm » January 19th, 2017, 1:48 am

Wasteland 2 damage mechanics are somewhat "peculiar" compared to other modern games. It uses a lot of Integer math (source of multistage rounding down errors) instead of float. ( modern games use float math internally and only rounded for display purposes not messing with the game math - the rounded displayed values lie a little, but I consider it a much less necessary evil )

Even if the variable for current HP is of float type in memory (unity) the game uses a lot of integer math. Calculated damage values are rounded to integer value (multiple times) BEFORE being subtracted from target HP (source of rounding errors that make reverse engineering the damage mechanics more tedious than usual).

While the the damage losses due to the multiple rounding down stages (probably cut both ways) - they are particularly annoying since even when down to as low as 1 constitution enemies will do full damage.

This means the weapon damage intervals have distinct integer values.

For example:
lvl 14 brawler with 10 STR and 10-12 weapon (brass knuckles) *2.5 crit multiplier at 10 STR.
10*1.2 + 14 = 26 12*1.2 + 14 = 28.4 rounded down to 28 [26,27,28] non-crit damage range.
Weapon listed as 26-28 with 2.5 crit multiplier on char screen will only inflict 26,27 or 28 damage on non-crits and 26*2.5=65 , 27*2.5=67.5 (rounded down) to 67, and 28*2.5=70 on crits. [65,67,70]
Max damage WITHOUT THE DOUBLE ROUNDING ERROR would have been ((12 * 1.2) + 14) * 2.5 = 71. (versus 0 Armor)

Same brawler with 3-5 sap glove *2.4 crit multiplier at 10 STR
3*1.2+14 = 17.6 rounded down to 17 5*1.2+14 = 20 [17,18,19,20] *2.4 40.8 , 43.2, 45.6, 48 => [40,43,45,48] crit damage range after the rounding down.


Adding 5 Armor on test target into the equation. (4 point difference for brass knuckles is *0.4 damage , 5 point difference for sap gloves is *0.2 damage)

brass knuckles (armor pen 1)
[26,27,28] * 0.4 10.4 10.8 11.2 ; after rounding non-crit damage range vs 4 armor [10, 11]
crit damage range vs 4 armor 25 27.5 [25,27]
crit damage interval without rounding ((10 * 1.2) + 14) * 0.4 * 2.5 = 26 ((12 * 1.2) + 14) * 0.4 * 2.5 = 28.4

(sap glove armor pen 0)
[17, 18, 19, 20] * 0.2 3.4 3.6 3.8 4 ; after rounding it gets [3,4] non-crit damage range.
[3 , 4] * 2.4 => 7.2 9.6 after rounding [7,9] crit damage interval.
crit damage interval without rounding (3*1.2+14)*0.2*2.4 = 8.448 ((5 * 1.2) + 14) * 0.2 * 2.4 = 9.6

Vulture's cry with 1-3 red ryder bb gun 0 armor pen vs 1 armor (*0.8) . *5 crit multiplier
non-crit damage range 1*0.8 = 0.8 1.6 2.4 rounded down to [1 2] (all attacks projectiles will do 1 damage minimum ?).
Crit damage range [1 2] * 5 [5 10]

I think the weapons that suffer most from this are the weapons that dilute their damage into multiple projectiles (Heavy Weapons & SMGs) that's one of the main reasons why their low tier models are so sucky on SJ. (damage loss due to rounding downs represents a significant % amount of the total projectile damage ..)

Those were friendly fire tests (*1 difficulty damage modifier). Will update what happens on SJ with *0.5 difficulty modifier ( probably extra rounding down step).
Might even get to testing some damage relevant quirks and perks if I don't lose interest.

A scary thought right now is that each ability that adds a multiplicative bonus adds its own stage of rounding down . Maybe some of the bonuses are summed together, applied as a single multiplier and only rounded down once ?

peddroelm
Initiate
Posts: 8
Joined: February 6th, 2015, 4:21 am

Re: Wasteland 2 (integer) damage mechanics and cascade rounding down from hell WIP

Post by peddroelm » January 23rd, 2017, 4:16 am

combat test (night terror makes a decent punchbag test subject ) Edit: he does not, he soon explodes even if you keep healing him fully after every hit :( . Must be a a separate variable accumulating damage received for the purpose of self detonation ..

difficulty multiplier and down-rounding applies AFTER the armor multiplier and down-rounding.

test. [27,28,29] fist damage range *3 crit multiplier ( 0 armor pen vs 2 armor *7 ; SJ diff *0.5)

[27, 28, 29] * 0.7 => [18 19 20] * [0.5] => [9 10] * 3 => [27 30] recorded test crit damage values
[27, 28, 29] * 0.7 => [18 19 20] * 3=> [54 57 60] * 0.5 => [27 28 30] possibly supported by test results ( perhaps a 28 will roll with more samples)
[27, 28, 29] * 0.5 => [13 14] * [0.7] => [9] * 3 => [27] not supported by test results

Added extra variable to the test head-shot *1.35 . Recorded crit damage values [ 36 39 40].
40 is a very weird value in this case since is not divisible by 3

*0.7 *3 *0.5 ?? 1.35

a) *1.35 0.7 *3 *0.5 [27 28 29] * 1.35 => [36 37 39] * 0.7 = [25 27] WRONG
b) *0.7 *1.35 *3 *0.5 [27 28 29] * 0.7 => [18 19 20] * 1.35 => [24 25 27] *3 => [72 75 81] * 0.5 => [36 37 40] WRONG
c) *0.7 *3 *1.35 *0.5 [27 28 29] * 0.7 => [18 19 20] * 3 => [54 57 60] * 1.35 => [72 76 81] *0.5 =? [36 38 40] WRONG
d) *0.7 *3 *0.5 *1.35 [27 28 29] * 0.7 => [18 19 20] * 3 => [54 57 60] * 0.5 => [27 28 30] * 1.35 => [36 37 40] WRONG

are 2 of the multipliers applied in the same rounding down step ?
[27 28 29] * 0.7 * 1.35 => [25 26 27] * 3 => [75 78 81] * 0.5 => [37 39 40] WRONG



So the steps I have so far:

1. [STR multiplier down-rounding]
2. [armor reduction ]
3. [crit multiplier down-rounding]
4. [difficulty down-rounding]

peddroelm
Initiate
Posts: 8
Joined: February 6th, 2015, 4:21 am

Re: Wasteland 2 (integer) damage mechanics and cascade rounding down from hell WIP

Post by peddroelm » February 2nd, 2017, 12:35 am

Figured out a much easier way to test damage mechanics - edit in the constant damage (no RNG damage roll - much easier to reverse engineer the operations involved ) weapon Handgun_Tier_A_MILLION in a .xml savegame (text file) and go from there. Replace another handgun on char/inventory. Ideally remove the mods in weapon before saving so you don't (try) to end up with incompatible mods in the cheater/tester weapon.

I'm almost at the end of my play-trough (final battle) and might lack the interest to do more tests for this game - but if in the future somebody wants to take this further it should be easy ...

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests