Jump to content

DA:I How to calculate hex code for any wanted stock amount


Snoddas76

Recommended Posts

Hi,

As many of you know, the numbering system used in the EBX-assets for store stock amounts is not standard hexadecimal so if you want to mod your own specific stock amount for items in stores you can't just use a regular HEX conversion of a DEC amount in a hex editor.

 

It is HEX with a twist. Each hex value is a two character value and each of the 4 that make up the 8 total characters representing the amount numerical value has a different base value per hex character. The following applies:
1. Each hex value of two characters does not only have numbers 1 to 9, but then also A-F after 9. This means that hex 10 represents the numberical value 16. Hex 20 is 32, hex 2F is 47 and so on.
2. Each hex character in each hex group has a different base value to be multiplied with the numerical value the hex value represents. They are as follows:
Group 1: 1
Group 2: 256
Group 3: 65 536
Group 4: 16 777 216

For example:
Hex code 12 15 02 02 will give the amount 33.690.898 because of the following:
Hex 12 = 18. 18 times 1 = 18
Hex 15 = 21. 21 times 256 = 5 376
Hex 02 = 2. 2 times 65 536 = 131 072
Hex 02 = 2. 2 times 16 777 216 = 33 554 432

Total sum: 18 + 5376 + 131072 + 33554432 = 33 690 898.

To easily calculate each hex value based on what amount you are after, start with the biggest valued hex group and subtract the total number from each group that fit inside your amount until you have reached 0.

For example. If you want the amount 256 000, first subtract the total number of group 3 values that fit in your desired amount, i.e. how many 65 536 that fit within 256 000. This is calculated easiest by dividing your amount with the group base number and rounding down to the nearest whole number. That number is 3, i.e. 196 608. That means group 3 should be 03.
Then subtract that from 256 000 to see what's left to get a hex number for and repeat with group 2 and then group 1 if needed.
Remaining after group 3 is 59 392 and dividing that value with the group 2 base value of 256 results in exactly 232. So, you need to have the numerical value 232 in hex in group 2. That value is E8. Since there is nothing left, group 1 will be 0.

256 000 = hex 00 E8 03 00

 

Cred to Anhamirak for her great tutorial of making your own mod changes for stores and lootboxes, it helped me when figuring out of how the numbering system works.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...