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
Stratti