QUOTE (Mattson the 4th @ Jan 31 2009, 06:19 PM)

I'm interested

Let me know if any of this doesn't make sense and I will try to clarify. Also, I apologize if I am providing too much detail, but I would rather err on the side of providing too much information.
Lets start with an item. I modded this sword, just so I could try to analyze the
file.

When we look at the sword in a hex editor we see

I've circle the byte that defines the enchantment with a linked circle to the applicable value.
The enchantment byte is located 13 bytes before the "d" that appears with every enchantment. Some day I will find a better way to define it, but this is still a work in progress.
The listing of enchantment bytes is:
00 Strength
01 Dexterity
02 Vitality
03 Magic
04 Mana
05 Life
06 Stamina
07 Mana Recovery
08 HP Recovery
09 Stamina Recovery
0a Defense
0b Attack
0c Damage Dealt
0d Damage Taken Reduced
oe Knockback
0f Sword Skill
10 Club & Mace Skill
11 Hammer Skill
12 Axe Skill
13 Spear Skill
14 Staff Skill
15 Polearm Skill
16 Bow/Crossbow Skill
17 Critical Strike Skill
18 Spellcasting Skill
19 Dual Wielding Skill
1a Shield Battle Skill
1b Attack Magic Bonus
1c Defense Magic
1d Charm Magic Skill
1e % Strength %
1f % Dexterity %
20 % Vitality
21 % Magic Bonus
22 % Mana Bonus
23 % Life Bonus
24 % Stamina
25 % Movement Speed
26 % Attack Speed Bonus
27 % Defense Bonus
28 % Attack Bonus
29 % Damage Dealt
2a % Damage Taken Reduced
2b % Chance Find Magic Items
2c % Gold Dropped By Enemies
2d % Faster Casting Speed
2e % Life Stolen
2f % Mana Stolen Per Hit
30 % Damage Refl.To Enemy
31 % Chance of Block
32 % Reduced Item Reqs
33 Piercing Resistance
34 Slashing Resistance
35 Crushing Resistance
36 Magic Resistance
37 Fire Resistance
38 Ice Resistance
39 Electrical Resistance
As you can see for each enchantment the "value" is listed three times. I don't yet know why that is, but experience tells me that only the first one is important. If you change the first instance, but not the other two, it will still show up as changed. My speculation is that the other two instances are kept for a history and represent the initial state of the enchantment.
Next is a matter of decoding the values. A listing of the initial values is:
80 3f =1
00 40 =2
40 40 =3
80 40 =4
a0 40 =5
c0 40 =6
e0 40 =7
00 41 =8
10 41 =9
20 41 =10
30 41 =11
40 41 =12
50 51 =13
60 41 =14
70 41 =15
80 41 =16
88 41 =17
90 41 =18
98 41 =19
a0 41 =20
a8 41 =21
b0 41 =22
b8 41 =23
c0 41 =24
c8 41 =25
d0 41 =26
d8 41 =27
e0 41 =28
e8 41 =29
f0 41 =30
f8 41 =31
00 42 =32
...
f4 42 =122
f6 42 =123
f8 42 =124
fa 42 =125
fc 42 =126
fe 42 =127
00 43 =128
Full listing through 128 can be downloaded here. I noticed that the values were increasing in an apparent logarithmic fashion. The first byte was 00 at 2, 8, 32, 128, so it became clear that I was dealing with a log2(x) function. The second byte (3f-43 in the above list) is determined by taking the log2(x) of the number in question, and only using the odd results (1,3,5,7,9,11), half the result, rounded up, is added to 39 (otherwise known as 3f)[EDIT - A slight correction, the result is added to 63, not 39, because 3f is hexadecimal. When 3f is converted to decimal it is 63]. Since the log2(1) is 0, the result is 0+39 or 39. That leaves 1 left over. The 1 is multiplied by 8 and becomes the first digit of the "first byte", or 8. There is nothing left after the decimal point and so there is nothing to put in the second digit of the first byte, so that digit is 0, resulting in 80 3f.
Essentially, each byte beyond the original 3f-43+ is not a single 8 bit byte, but is treated as two 4 bit bytes. This is illustrated with the number 17. Log2(17) is 4.0874628412503400. The 4 is greater than 3 but less than 5, so we add 2 ((3+1)/2) to the 39, resulting in 41, and then subtract 3 from 4.0874628412503400, leaving 1.0874628412503400, multiply that 8 and you get 8.69970273, so the first digit of the first byte becomes 8. We then subtract 8 from the result and get 0.69970273. Now there is a slight change, the remainder is multiplied by 16, resulting in well, actually 11 which is not correct, but is close. The actual number is 8, which becomes the second digit of the first byte resulting in 88 41.
The probable reality is that my calculations are a bit simplified and my formulas need to be refined.
I will attach a spreadsheet that I have been using to test my theories.
fateval.xlsI'm guess that the actual method involves calculating the number of places needed between two numbers. For example there are 6 places between 2 and 7 inclusive. If those numbers are distributed according to a logarithmic scale, you get the proper result. There are two places between 16-17 (18 representing an increase from 8 as the first digit to 9 as the first digit). Since there is only 1 place between 16 and 17 (that being 17), the second digit is assigned an 8 or the midway point between the two. 8 is the midway point because this is all done in base 16.
Bob