calculating item % (white stats)

08/08/2012 13:23 pergian#1
hi,

i am bussy with trying to figure out how sro calculates the % stats on an item from the values you get of the packet sro sends.

for example i get these values:

Code:
E0 80 73 00 00 00 00 00
which display on a 2h item 22% phy, 19% att rate, 22% phy rein other are 0%

sro always reads it in reverse so we will get this value:
Code:
00 00 00 00 00 73 80 E0
after a bit of changing the stats around i figured out that

7 = phy
3 8 = att rate
0 E0 = phy rein

and for example phy rein can change like this:
0 E0 = 22%
2 60 = 61%

and also to make it more confusing some values are added up like:
(other item them above - gear part)

Code:
00 00 00 1A 03 80 00
the part: 3 80 = phy def
but when i added mag rein it became: 3 B4 = phy def & mag rein combined

and now i am stuck since i have no idea how to calculate the % out of these values which seems to be different on every white kind

does anyone know how to or maybe i am totally wrong on how to do this?

thx
08/08/2012 13:29 vorosmihaly#2
wtf r u talking about? you cannot split up a byte -.-"
that is seriously one of the stupidest thing I have ever seen. xDDD
08/08/2012 13:40 pergian#3
you can in sro xd, for example i am 100% sure about is
hp/mp in party are in 1 byte

AA which is A = 100% mp, and other A = 100% hp

and yes idk why sro does this but, what i posted above is what came out of it when i changed a stat
08/08/2012 13:43 vorosmihaly#4
Quote:
Originally Posted by pergian View Post
you can in sro xd, for example i am 100% sure about is
hp/mp in party are in 1 byte

AA which is A = 100% mp, and other A = 100% hp

and yes idk why sro does this but, what i posted above is what came out of it when i changed a stat
yeah,you can split a byte,but not in this case. :DD
anyway,if this is the item packet each byte represents one stat,so you don't have to do any crap with the bytes,just leave them as they are and find out which one represents which stat.
08/08/2012 13:49 pergian#5
Quote:
Originally Posted by vorosmihaly View Post
yeah,you can split a byte,but not the way you did it. xDD it's not simply writing the 2 parts of it seperately.
anyway,if this is the item packet each byte represents one stat,so you don't have to do any crap with the bytes,just leave them as they are and find out which one represents which stat.
no not every byte = 1 stat idk why ask joymax :P

like this:
Code:
00 00 00 02 48 C4 3C 23
this is a degree 1 prot hands with 6 stats (above 0%) , but i see only 5 bytes how you explaine this?

and when i change stats i figured out which represents which stat like i said in my first post
08/08/2012 13:50 cyberninjah#6
got any opcode ? so i can trace some packets my self and help you out with info ?
08/08/2012 13:51 vorosmihaly#7
Quote:
Originally Posted by pergian View Post
no not every byte = 1 stat idk why ask joymax :P

like this:
Code:
00 00 00 02 48 C4 3C 23
this is a degree 1 prot hands with 6 stats (above 0%) , but i see only 5 bytes how you explaine this?

and when i change stats i figured out which represents which stat like i said in my first post
well,that sounds weird,but there should be a seperate byte for each stat from what I remember. I'll take a look in my code tomorrow or somewhen if I'll be at home.
08/08/2012 13:52 cyberninjah#8
I think you need to know the max values of the item.

Sro always display the old value and the new value not the lowest value and the highest value.

Maybe the calculation is clientside ?
08/08/2012 13:53 pergian#9
its in any packet which contains an item but for example you can get this out of the inventory which is inside of the playerdata packet 0x3013
08/08/2012 13:54 cyberninjah#10
Quote:
Originally Posted by pergian View Post
its in any packet which contains an item but for example you can get this out of the inventory which is inside of the playerdata packet 0x3013
The max white values are in that packet ?
are you sure about that i cant remember i found that values when i parsed that one.
08/08/2012 13:56 pergian#11
Quote:
Originally Posted by cyberninjah View Post
The max white values are in that packet ?
are you sure about that i cant remember i found that values when i parsed that one.
ah no those values are the actually % but not the max value which i was thinking about too but i couldnt find anything so far in the pk2 about it

and yes i think the calculations is also clientside which i am trying to figure out or is there a easier way to get those calculations of the client?
08/08/2012 14:08 cyberninjah#12
if you know how much % the item has before you start using alchemy you know enough to calculate the new % value
08/08/2012 16:28 Stratti#13
Calculating the uint64 which holds the item white-stats is pretty simple.
First of all you must know that there are 5 bits available for each item stat, so prepare for some bit manipulation.
In this example I'll show you how to calculate 100% stats for accessories, but this will also work with weapons and equip.

5 bits = 32 available numbers (range from 0 to 31)
0 = 0% stat
31 = 100% stat

If you now want to calculate an accessory with 100% stats then you'll need to define two variables (one for phy absorption and one for mag absorption)

Code:
phyAbsorp = 31
magAbsorp = 31
Now you must calculate the uint64 which will be sent to the client.
Foreach white stat you'll have to left shift the previous value of the uint64 by 5 bits and then add the value of the specified white stat to it.

Code:
//"<<" means left shift

stats = 0

stats = stats << 5 //This line is actually unnecessary because 0 << 5 is 0
stats = stats | magAbsorp
stats = stats << 5
stats = stats | phyAbsorp

//The result will be 1023, send this value to the client and you'll have a accessory 
//with 100% white stats, no matter if it is a ring, earring or necklace
Simple C# example:
Code:
byte phyAbsorp = 31; 
byte magAbsorp = 31;

ulong stats = 0;
stats |= magAbsorp;
stats <<= 5;
stats |= phyAbsorp;
Just to make it clear for you, here is the binary view:
Quote:
//Note: I'm not displaying all 64 bits of the uint64, that would be insane.

magAbsorp
phyAbsorp

000000000000000000000000000000000 //stats = 0
000000000000000000000000000011111 //stats = stats | magAbsorp (31)
000000000000000000000001111100000 //stats = stats << 5
000000000000000000000001111111111 //stats = stats | phyAbsorp (31)
That's it! That's how you calculate a 100% accessory, play around with the values from 0 to 31 to see how it affects the % of the selected white stat.
You can do the same for weapons or equip just use more stats.

I hope you understood what I was trying to say because I really suck at explaining :p

Stratti
08/08/2012 16:37 pergian#14
thx alot this is what i need, so far i understand all you said, i will go test now
08/08/2012 17:14 IceAmStiel#15
Lolz thanks Stratti, I could finally convert the Variance values of the database properly xD