PHP script to Decode style
reason for this release is cause i wanna see if any of u find faults in it
PHP Code:
function decode_style($r) {
//get gender
$gender_array = array('Male', 'Female', 'Male 2','Female 2','Male 3', 'Female 3');
$style['Gender'] = $gender_array[round($r / hexdec(4000000))];
//GET AURA
$style['Aura'] = round(($r % hexdec(4000000)) / hexdec(200000));
// hair
$style['Hair'] = round(($r % hexdec(4000000) % hexdec(200000) ) / hexdec(20000));
//hair color
$style['Hair_Color'] = round((($r % hexdec(4000000)) % hexdec(20000)) / hexdec(2000));
// get face
$style['Face'] = round(((($r % hexdec(4000000)) % hexdec(20000)) % hexdec(2000)) / hexdec(100));
// get rank
$style['Class_Rank'] = round((((($r % hexdec(4000000)) % hexdec(20000)) % hexdec(2000)) % hexdec(100)) / 8 );
// get class
$class_array = array(4=>'Force Archer',5=>'Force Shielder',6=>'Force Blader',
9=>'Warrior',10=>'Blader',11=>'Wizard',12=>'Force Archer',13=>'Force Shielder',14=>'Force Blader');
$style['Class'] = (((($r % hexdec(4000000)) % hexdec(20000)) % hexdec(2000)) % hexdec(100)) - (($style['Class_Rank'] -1) * 8) ;
$style['Class_Name'] = $class_array[$style['Class']] ;
return $style;
}
how to use decode_style(STYLE);
returns an array
something like this
PHP Code:
[Gender] => Male
[Hair] => 4
[Hair_Color] => 6
[Face] => 3
[Class_Rank] => 1
[Class] => 9
[Class_Name] => Warrior
see it in action here: http://cabal.mmowebs.com/hero-48-Kronpass.html
Re: PHP script to Decode style
Quote:
Originally Posted by
john_d
reason for this release is cause i wanna see if any of u find faults in it
haha, kk testing..
Re: PHP script to Decode style
Re: PHP script to Decode style
updated:
added aura edit:
u can also reverse it to create new style codes.
warning: not all faces will work since most clients do not have some faces/hairs/colors... so better experiment 1st.
http://johnd.sytes.net/cabal/style.php
Re: PHP script to Decode style
download??? nice style *.*
Re: PHP script to Decode style
Can you please explain what's going on in English, so i can apply this to other programming languages.
Thanks (I don't understand PHP very well Q_Q)
Re: PHP script to Decode style
It's just a set of mathematical formulas to extract specific values from the class. Just take each line one at a time and pull it apart. $r is the class.
$style['Gender'] = $gender_array[round($r / hexdec(4000000))];
hexdec(4000000) = 3D0900
http://uk.php.net/manual/en/function.hexdec.php
So $r divided by 3D0900 (and then rounded) = your gender.
You can look up the other operators like modulus here.
http://uk.php.net/manual/en/language...arithmetic.php
You can tell no-one understands it as there are so few comments on what is one of the best posts here ;)
Re: PHP script to Decode style
Quote:
Originally Posted by
chumpywumpy
It's just a set of mathematical formulas to extract specific values from the class. Just take each line one at a time and pull it apart. $r is the class.
$style['Gender'] = $gender_array[round($r / hexdec(4000000))];
hexdec(4000000) = 3D0900
http://uk.php.net/manual/en/function.hexdec.php
So $r divided by 3D0900 (and then rounded) = your gender.
You can look up the other operators like modulus here.
http://uk.php.net/manual/en/language...arithmetic.php
You can tell no-one understands it as there are so few comments on what is one of the best posts here ;)
Thanks ALOT (again) LOL, ill try this right now :), only problem now T_T how do i get the remainder from windows calculator lol
Re: PHP script to Decode style
Quote:
Originally Posted by
02goswej
Thanks ALOT (again) LOL, ill try this right now :), only problem now T_T how do i get the remainder from windows calculator lol
easy as pie
NUMBER1 DIVIDE NUMBER2 =
[I]NUMBER3[/I].DECIMALS ...
SUBTRACT THE [I]NUMBER3[/I] AND MULTIPLE BY NUMBER2
Sample:
23 / 8 = 2.875
2.875 - 2 = 0.875
0.875 * 8 = 7
Re: PHP script to Decode style
Quote:
Originally Posted by
john_d
easy as pie
NUMBER1 DIVIDE NUMBER2 =
[I]NUMBER3[/I].DECIMALS ...
SUBTRACT THE [I]NUMBER3[/I] AND MULTIPLE BY NUMBER2
Sample:
23 / 8 = 2.875
2.875 - 2 = 0.875
0.875 * 8 = 7
okay so, can you give me an example of working out the whole of a style, because i want to make sure it's correct, so what would this give you? Just the first two or three (Like sex, aura) would be enough to make me understand really, sorry lol >_<
Style example: 213934124
As you can see it goes 100% wrong when i do it, although i did it all as decimals as you can only get whole numbers when using Hexadecimal numbers
Code:
213934124 / 4000000 => 53.483531 - 53 => .483531 * 4000000 => % 1934124 'Gender
1934124 / 200000 => 09.67062 - 09 => .67062 * 200000 => % 134124 'Aura
134124 / 20000 => 06.7062 - 06 => .7062 * 20000 => % 14124 'Hair
14124 / 2000 => 07.062 - 07 => .062 * 2000 => % 124 'Hair Color
124 / 100 => 01.24 - 01 => .24 * 100 => % 24 'Face
24 / 8 => 03.00 - 03 => .00 * 8 => % 0 'Rank
Re: PHP script to Decode style
u totally ignored the fact that it the whole numbers there are HEX not decimals. i only put 4000000 cause i was too lazy to type up their decimal values
gender :
PHP Code:
$style['Gender'] = $gender_array[round($r / hexdec(4000000))];
213934124 / 67108864 = 3.187866866588592529296875 = 3
- gender gets only the whole number ( ROUND IT )
- 3 would be female 2. ( array starts with 0 )
aura:
PHP Code:
$style['Aura'] = round(($r % hexdec(4000000)) / hexdec(200000));
213934124 / 67108864 = 3.187866866588592529296875 - 3 = * 67108864 =
12607532 / 2097152 = 6.0117397308349609375
= 6
same goes for the rest. it is just a repeat process just adding new values.
notes:
% mean find remainder
/ means divide
round means to get the whole number
() means calculate priority. inner-most comes first ie. (3nd cal((1st / cal) * 2nd cal ))
anyway here is the output of 213934124
[Gender] => Female 2
[Aura] => 6
[Hair] => 0
[Hair_Color] => 3
[Face] => 0
[Class_Rank] => 6
[Class] => 4
[Class_Name] => Force Archer
Re: PHP script to Decode style
Quote:
Originally Posted by
john_d
u totally ignored the fact that it the whole numbers there are HEX not decimals. i only put 4000000 cause i was too lazy to type up their decimal values
gender :
PHP Code:
$style['Gender'] = $gender_array[round($r / hexdec(4000000))];
213934124 / 67108864 = 3.187866866588592529296875 = 3
- gender gets only the whole number ( ROUND IT )
- 3 would be female 2. ( array starts with 0 )
aura:
PHP Code:
$style['Aura'] = round(($r % hexdec(4000000)) / hexdec(200000));
213934124 / 67108864 = 3.187866866588592529296875 - 3 = * 67108864 =
12607532 / 2097152 = 6.0117397308349609375
= 6
same goes for the rest. it is just a repeat process just adding new values.
notes:
% mean find remainder
/ means divide
round means to get the whole number
() means calculate priority. inner-most comes first ie. (3nd cal((1st / cal) * 2nd cal ))
anyway here is the output of 213934124
[Gender] => Female 2
[Aura] => 6
[Hair] => 0
[Hair_Color] => 3
[Face] => 0
[Class_Rank] => 6
[Class] => 4
[Class_Name] => Force Archer
Thanks ALOT i understand now :)
But im hitting a snag in my program, and i don't understand why O_o
Code:
Style = DataReader.GetValue(12)
Gender = Style / 67108864
Aura = (((Gender - CInt(Gender)) * 67108864) / 2097152)
Hair = (((Aura - CInt(Aura)) * 67108864) / 131072)
Color = (((Hair - CInt(Hair)) * 67108864) / 8192)
Face = (((Color - CInt(Color)) * 67108864) / 256)
Rank = (((Face - CInt(Face)) * 67108864) / 8)
txtRank.Text = CInt(Rank)
when it gets to my variable color, it ALWAYS ends up as a whole number. meaning everything else (face and rank) become just 0.
I notice you don't carry the aura down to the hair color, could this be the problem?
Can you spot a problem? :S
Re: PHP script to Decode style
Thanks jhon_d for this code. Very good.
02goswej seams you are trying to translate to vb or asp. If this is the case I have made a simple translation to asp:
<%
Function hexdec (sStyle)
hexdec=clng("&h" & sStyle)
End Function
%>
<%
Function decode_style (sStyle)
DIM gender_array(5)
'gender_array=Array(Male,Female,Male 2,Female 2,Male 3,Female 3)
gender_array (0) = "Male"
gender_array (1) = "Female"
gender_array (2) = "Male 2"
gender_array (3) = "Female 2"
gender_array (4) = "Male 3"
gender_array (5) = "Female 3"
'GET Gender
Gender= gender_array(round(sStyle / hexdec(4000000)))
'GET Aura
Aura = round((sStyle mod hexdec(4000000)) / hexdec(200000))
' hair
Hair = round((sStyle mod hexdec(4000000) mod hexdec(200000) ) / hexdec(20000))
'hair color
Hair_Color = round(((sStyle mod hexdec(4000000)) mod hexdec(20000)) / hexdec(2000))
' get face
Face = round((((sStyle mod hexdec(4000000)) mod hexdec(20000)) mod hexdec(2000)) / hexdec(100))
' get rank
Class_Rank = round(((((sStyle mod hexdec(4000000)) mod hexdec(20000)) mod hexdec(2000)) mod hexdec(100)) / 8 )
' get class
DIM class_array(14)
class_array (4) = "Force Archer"
class_array (5) = "Force Shielder"
class_array (6) = "Force Blader"
class_array (9) = "Warrior"
class_array (10) = "Blader"
class_array (11) = "Wizard"
class_array (12) = "Force Archer"
class_array (13) = "Force Shielder"
class_array (14) = "Force Blader"
sClass = (((( sStyle mod hexdec(4000000)) mod hexdec(20000)) mod hexdec(2000)) mod hexdec(100)) - ((Class_Rank -1) * 8)
Class_Name = class_array(sClass)
decode_style= "[Gender] => " & Gender & "<BR>" & "[Hair] => " & Hair & "<BR>" & "[Hair_Color] => " & Hair_Color & "<BR>" & "[Face] => " & Face & "<BR>" & "[Class_Rank] => " & Class_Rank & "<BR>" & "[Class] => " & sClass & "<BR>" & "[Class_Name] => " & Class_Name
End Function
%>
So you can test using:
<% response.write ( decode_style(12984740)) %>
and result is:
[Gender] => Male
[Hair] => 3
[Hair_Color] => 1
[Face] => 2
[Class_Rank] => 20
[Class] => 12
[Class_Name] => Force Archer
==============================
Or you can use sql analyzer to show rank 18 class:
use [SERVER01] -- or use [GAMEDB]
SELECT Name,Style from dbo.cabal_character_table WHERE
round(((((([Style] % (67108864)) % (131072)) % (8192)) % (256)) / 8 ),1)= 18
and even update class 18 to 20 :) :
update dbo.cabal_character_table
set [Style]=[Style]+16 where round(((((([Style] % (67108864)) % (131072)) % (8192)) % (256)) / 8 ),1)= 18
Re: PHP script to Decode style
Re: PHP script to Decode style
Thanks for the help, just checked today but I fixed it a long time ago, adding more to it now, how would I rebuild the style after I have edited things like the rank/Hair etc