Damage calculation - rounding?

chopinsc

Greenhorn
While testing out damage calculations on a Floor 96 slime infestation (where the red slimes have 0 Defence) my numbers didn't entirely match the expected ranges of ((base+rings%)+food)*Fighter*Brute, only falling within rounding distance. The closest results I've been able to get are by taking the ceiling of the final result after rounding at each step, i.e.
Code:
ceiling(round(round((base+rings%)+food)*1.1)*1.25)
This then matches the maximum values without any errors, though it still gives me lower-than-recorded minimum rolls on more than one of the tested configurations, two of which are 2 points off. Is the actual rounding behaviour known to be responsible for these discrepancies (examples below), or is there a source of damage increase (or defence reduction) that I might be missing?

For example, with no rounding anywhere in the calculation:

(all of these include Fighter and Brute)
- base Galaxy Sword, no rings, no food | expected range 75.9 - 101.2 | recorded range 76 - 102
- +0 Infinity Blade, no rings, Magic Rock Candy | expected range 120.175 - 145.475 | recorded range 121 - 147
- +0 Infinity Blade, two Iridium Bands, Magic Rock Candy | expected range 140.415 - 170.775 | recorded range 143 - 172
 

FilthyGorilla

Local Legend
While testing out damage calculations on a Floor 96 slime infestation (where the red slimes have 0 Defence) my numbers didn't entirely match the expected ranges of ((base+rings%)+food)*Fighter*Brute, only falling within rounding distance. The closest results I've been able to get are by taking the ceiling of the final result after rounding at each step, i.e.
Code:
ceiling(round(round((base+rings%)+food)*1.1)*1.25)
This then matches the maximum values without any errors, though it still gives me lower-than-recorded minimum rolls on more than one of the tested configurations, two of which are 2 points off. Is the actual rounding behaviour known to be responsible for these discrepancies (examples below), or is there a source of damage increase (or defence reduction) that I might be missing?

For example, with no rounding anywhere in the calculation:

(all of these include Fighter and Brute)
- base Galaxy Sword, no rings, no food | expected range 75.9 - 101.2 | recorded range 76 - 102
- +0 Infinity Blade, no rings, Magic Rock Candy | expected range 120.175 - 145.475 | recorded range 121 - 147
- +0 Infinity Blade, two Iridium Bands, Magic Rock Candy | expected range 140.415 - 170.775 | recorded range 143 - 172
Are you basing the recorded values from a mod that actually looks at monster health or simply from the values shown on screen.

The game internally tracks incremental values for energy and health (for character), but displays full values rounded up. For example, this is why the 0.1 proficiency for tools actually does something each level (leading to 1.9 energy used per watering can use at level 1 farming for example), but still shows full integers for energy if you hover over the energy bar. I'm pretty sure this doesn't apply to monsters as damage is rounded prior to dealing it but it's still ok as a preface.


The values being a digit or two off is a tad odd, I would have to assume something to do with your calculations/the game is rounding/ceiling a value prior to inputting it for the next calculation and you missed it, or something else I'm forgetting

Just for example though, a damage calc for infinity blade (with fighter/brute+MRC) would be:
Minimum - 80 + (MRC 5 attack = 15 damage) = 95x1.1 = 104.5 -> ceiling to 105 x 1.15 = 120.75 -> ceiling to 121
Maximum - 100 + 15 = 115x1.1=126.5 ->ceiling to 127x1.15 = 146.05 -> ceiling to 147
That results in a damage expectation of 121-147, which matches with what you observed for that case (and will for the others).

This shows that it was just a matter of error on your calculations, though I cannot blame you for not knowing specifics for this equation in particular.
Furthermore, there is no way to 'expect' a decimal value as the game will always ceiling the value at each stage (including the last as I showed).
 

chopinsc

Greenhorn
Are you basing the recorded values from a mod that actually looks at monster health or simply from the values shown on screen.

The game internally tracks incremental values for energy and health (for character), but displays full values rounded up. For example, this is why the 0.1 proficiency for tools actually does something each level (leading to 1.9 energy used per watering can use at level 1 farming for example), but still shows full integers for energy if you hover over the energy bar. I'm pretty sure this doesn't apply to monsters as damage is rounded prior to dealing it but it's still ok as a preface.


The values being a digit or two off is a tad odd, I would have to assume something to do with your calculations/the game is rounding/ceiling a value prior to inputting it for the next calculation and you missed it, or something else I'm forgetting

Just for example though, a damage calc for infinity blade (with fighter/brute+MRC) would be:
Minimum - 80 + (MRC 5 attack = 15 damage) = 95x1.1 = 104.5 -> ceiling to 105 x 1.15 = 120.75 -> ceiling to 121
Maximum - 100 + 15 = 115x1.1=126.5 ->ceiling to 127x1.15 = 146.05 -> ceiling to 147
That results in a damage expectation of 121-147, which matches with what you observed for that case (and will for the others).

This shows that it was just a matter of error on your calculations, though I cannot blame you for not knowing specifics for this equation in particular.
Furthermore, there is no way to 'expect' a decimal value as the game will always ceiling the value at each stage (including the last as I showed).
Okay, that makes sense, yeah. I figured there would be rounding at certain steps but I wasn't sure on which ones/whether it rounded up/down/closer value; taking ceiling() at each step does check out with what I'd recorded. Thanks for the help!
 

FilthyGorilla

Local Legend
Okay, that makes sense, yeah. I figured there would be rounding at certain steps but I wasn't sure on which ones/whether it rounded up/down/closer value; taking ceiling() at each step does check out with what I'd recorded. Thanks for the help!
Yeah the rounding can be a bit random in this game, sometimes it's just truncated and other times stuff is ceilinged like in the damage calcs, and no problem, glad I was able to help
 
Top