PHP script to Decode style

Results 1 to 22 of 22
  1. #1
    Alpha Member john_d is offline
    MemberRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    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)) / );
        
        
    // 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
    Last edited by john_d; 11-08-08 at 03:39 AM.


  2. #2
    Akaruz - The Legend [hidden] is offline
    MemberRank
    Jun 2006 Join Date
    ClassifiedLocation
    1,120Posts

    Re: PHP script to Decode style

    Quote Originally Posted by john_d View Post
    reason for this release is cause i wanna see if any of u find faults in it

    haha, kk testing..

  3. #3
    Apprentice muochi is offline
    MemberRank
    Mar 2006 Join Date
    14Posts

    Re: PHP script to Decode style

    very good, sir

  4. #4
    Alpha Member john_d is offline
    MemberRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    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

  5. #5
    Apprentice liviorudson is offline
    MemberRank
    Jan 2008 Join Date
    7Posts

    Re: PHP script to Decode style

    download??? nice style *.*

  6. #6
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts

    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)

  7. #7
    The Dinosaur chumpywumpy is offline
    MemberRank
    Jun 2008 Join Date
    /f451/Location
    5,127Posts

    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 ;)

  8. #8
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts

    Re: PHP script to Decode style

    Quote Originally Posted by chumpywumpy View Post
    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

  9. #9
    Alpha Member john_d is offline
    MemberRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    Re: PHP script to Decode style

    Quote Originally Posted by 02goswej View Post
    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

  10. #10
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts

    Re: PHP script to Decode style

    Quote Originally Posted by john_d View Post
    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

  11. #11
    Alpha Member john_d is offline
    MemberRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    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

  12. #12
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts

    Re: PHP script to Decode style

    Quote Originally Posted by john_d View Post
    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
    Last edited by 02goswej; 23-02-09 at 02:31 PM.

  13. #13
    Valued Member limpamesa is offline
    MemberRank
    Nov 2005 Join Date
    BrazilLocation
    148Posts

    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

  14. #14
    Alpha Member john_d is offline
    MemberRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    Re: PHP script to Decode style

    @limpamesa Nice Post

  15. #15
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts

    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

  16. #16
    Alpha Member john_d is offline
    MemberRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    Re: PHP script to Decode style

    just reverse the math

  17. #17
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts

    Re: PHP script to Decode style

    What's reverse of mod O_o

  18. #18
    The Cat in the Hat cypher is offline
    MemberRank
    Oct 2005 Join Date
    IrelandLocation
    5,073Posts

    Re: PHP script to Decode style

    google is your friend when your logic is being exceeded

  19. #19
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts
    All im finding on google with string "Reverse Modulus" is basically....Impossible ;P im retarded when in comes to complex maths :o (And i have been up since 5AM and just woken up now :P)
    here is my VB Code for decoding the style:

    Code:
                Style = DR.GetValue(12)
                Gender = Style / 67108864
                Aura = (Style Mod 67108864) / 2097152
                Hair = ((Style Mod 67108864) Mod 2097152) / 131072
                HColor = ((Style Mod 67108864) Mod 131072) / 8192
                Face = (((Style Mod 67108864) Mod 131072) Mod 8192) / 256
                Rank = ((((Style Mod 67108864) Mod 131072) Mod 8192) Mod 256) / 8
                PlayerClass = ((((Style Mod 67108864) Mod 131072) Mod 8192) Mod 256) - ((Rank - 1) * 8)
    so in reverse would i be somthing like
    Code:
    Style = 2097152 * (Aura / 67108864) or would it be  (Aura Mod 67108864)
    -02goswej

    bump, Help please :S
    Last edited by cypher; 30-03-09 at 09:17 PM. Reason: fixed dbl post.

  20. #20
    Alpha Member john_d is offline
    MemberRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    Re: PHP script to Decode style

    all u have to do

    create the value for each category ( hair, haircolor, face, gender, class, class rank )

    then add them all ^^

  21. #21
    Valued Member 02goswej is offline
    MemberRank
    Jul 2005 Join Date
    UKLocation
    126Posts

    Re: PHP script to Decode style

    So using this code:

    Code:
      Style = DR.GetValue(12)
                Gender = Style / 67108864
                Aura = (Style Mod 67108864) / 2097152
                Hair = ((Style Mod 67108864) Mod 2097152) / 131072
                HColor = ((Style Mod 67108864) Mod 131072) / 8192
                Face = (((Style Mod 67108864) Mod 131072) Mod 8192) / 256
                Rank = ((((Style Mod 67108864) Mod 131072) Mod 8192) Mod 256) / 8
                PlayerClass = ((((Style Mod 67108864) Mod 131072) Mod 8192) Mod 256) - ((Rank - 1) * 8)
    it would be
    Code:
    NewStyle = Gender + Aura + Hair + HColor + Face + Rank + PlayerClass
    Or not O_O, i tried this and it gives me an incorrect number hehe

  22. #22
    Enthusiast MarmotaXD is offline
    MemberRank
    Mar 2013 Join Date
    46Posts

    Re: PHP script to Decode style

    hello could use calculations
    most could not understand how to identify which type
    hair, or auria the character is?



Advertisement