Skip to content

Decimal Values Round Incorrectly #12

Description

@Begueiro

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:
Screenshot001

The edited shield:
Screenshot002

Superior Studded Leather getting rounded up:
Screenshot003

D2CE new item (it should have 21 defense):
D2CE

Desktop (please complete the following information):

  • Game: Diablo II Resurrected

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions