Decimal Values Round Incorrectly
Begueiro opened this issue · 1 comments
Describe the bug
I've tested a few save editor tools and all of them (including this one) have this issue: they all round values differently than the game itself.
I happen to have a Superior Kite Shield I found in an NPC shop, which has +15% Enhanced Defense. I added the runes KalOrtTal to it, which brings it to a total of +65 Enhanced Defense. That shield has a defense value of 31.
When editing or creating that same item on a save editor, it ends up with 29 defense points, even though the base defense value is the same: 18.
The way the game seems to make the calculation is by, first, adding the 50% bonus and rounding up. So, 18 + 50%, resulting in 27. After that, it adds the 15% of 27, coming to 31.05.
It doesn't do 15% of 18 (2.7) first, then 50% of 21 (10.5). That would be result in 31.5, which would round up to 32.
It doesn't do 65%, like the tools, either, as the result of that is 29.7 and the tools round it down to 29.
Actually, just creating the base item, within the editor, comes up 1 point short: instead of 21 defense, it rounds the 20.7 result down to 20 points.
Another thing I've noticed is that the game mostly rounds up. For example, a Superior Studded Leather with 15% Enhanced Defense gets 41 defense, instead of 40, as 15% bonus on 35 is 40.25.
My guess, based on these 2 items, is that the game will round up, as long as the tenths place is higher than .0. As in 31.05 will round down to 31, but 31.1 would round up to 32.
Screenshots
The legitimate shield:
Superior Studded Leather getting rounded up:
D2CE new item (it should have 21 defense):
Desktop (please complete the following information):
- Game: Diablo II Resurrected
items that initially spawn with enhanced defense % modifier are set to max defense of the base item + 1. this includes all item rarities.