Advertisement
GkevinOD

GetGold Function

Dec 20th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 9.92 KB | None | 0 0
  1. ;*Coded by GkevinOD
  2.  
  3. $HWnD = WinGetHandle (WinGetTitle ("BlueStacks App Player"))
  4. $BlueStacks_XY = WinGetPos($HWnD, "")
  5.  
  6. Global $x = $BlueStacks_XY [0] + 53 ;May need to be edited to the first pixel in the upper-left corner of the first GOLD digit
  7. Global $y = $BlueStacks_XY [1] + 94 ;May need to be edited to the first pixel in the upper-left corner of the first GOLD digit
  8.  
  9. Global $Gold
  10.  
  11. $Gold &= getDigitGold($x, $y)
  12. $Gold &= getDigitGold($x, $y)
  13. $Gold &= getDigitGold($x, $y)
  14. $x += 6 ;The space that seperate the gold into two sections, usually 5 or 6 pixels long. Ex: "123 321"
  15. $Gold &= getDigitGold($x, $y)
  16. $Gold &= getDigitGold($x, $y)
  17. $Gold &= getDigitGold($x, $y)
  18.  
  19. MsgBox(0, "Gold Search", "Gold: " & $Gold)
  20.  
  21. ;************************************************************************
  22. ; This codes are only for Gold because it detects the pattern of the colors to get the digits and GOLD has slightly different color from ELIXIR
  23. ; Has very high accuracy, occasionally the Y coordination may be 1 pixel off.
  24. ;
  25. ; *Must have 860x720 Resolution!
  26. ;
  27. ; Instructions:
  28. ; 1) Find a match
  29. ; 2) Run the script
  30. ; 3) MsgBox should appear with the gold
  31. ;
  32. ; May take a couple of seconds for message box to appear due to multiple uses on PixelSearch.
  33. ; If you are able to improve the code to make it faster, please share in the forums.
  34. ;************************************************************************
  35.  
  36. Func boolPixelSearch($pixel1, $pixel2, $pixel3)
  37.    If IsArray(PixelSearch($pixel1[0], $pixel1[1], $pixel1[0], $pixel1[1], $pixel1[2], 10)) = True And IsArray(PixelSearch($pixel2[0], $pixel2[1], $pixel2[0], $pixel2[1], $pixel2[2], 10)) = True And IsArray(PixelSearch($pixel3[0], $pixel3[1], $pixel3[0], $pixel3[1], $pixel3[2], 10)) = True  Then
  38.       Return True ;Checks if each PixelSearch is an array indicating that it has been found in that location.
  39.    Else
  40.       Return False
  41.    EndIf
  42. EndFunc
  43.  
  44. Func getDigitGold(ByRef $x, $y)
  45.    Local $width = 0
  46.  
  47.    ;Search for digit 0
  48.    $width = 13
  49.    Local $pixel1[3] = [$x+6, $y+4, 0x989579], $pixel2[3] = [$x+7, $y+7, 0x39382E], $pixel3[3] = [$x+10, $y+13, 0x272720] ;Uses one pixel and color to check a 3 pixel pattern found in certain locations
  50.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  51.       $x += $width ;Adds to x coordinate to get the next digit
  52.       Return 0
  53.    Else
  54.       $x -= 1 ;Solves the problem when the spaces between the middle goes from 6 to 5 pixels
  55.       Local $pixel1[3] = [$x+6, $y+4, 0x989579], $pixel2[3] = [$x+7, $y+7, 0x39382E], $pixel3[3] = [$x+10, $y+13, 0x272720]
  56.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  57.          $x += $width ;Changes x coordinate for the next digit.
  58.          Return 0
  59.       Else
  60.          $x += 2 ;Solves the problem when there is 1 pixel space between a set of numbers
  61.          Local $pixel1[3] = [$x+6, $y+4, 0x989579], $pixel2[3] = [$x+7, $y+7, 0x39382E], $pixel3[3] = [$x+10, $y+13, 0x272720]
  62.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  63.             $x += $width
  64.             Return 0
  65.          Else
  66.             $x -= 1
  67.          EndIf
  68.       EndIf
  69.    EndIf
  70.  
  71.    ;Search for digit 1
  72.    $width = 6
  73.    Local $pixel1[3] = [$x+1, $y+1, 0x969478], $pixel2[3] = [$x+1, $y+12, 0x313027], $pixel3[3] = [$x+4, $y+12, 0xD8D4AC]
  74.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  75.       $x += $width
  76.       Return 1
  77.    Else
  78.       $x -= 1
  79.       Local $pixel1[3] = [$x+1, $y+1, 0x969478], $pixel2[3] = [$x+1, $y+12, 0x313027], $pixel3[3] = [$x+4, $y+12, 0xD8D4AC]
  80.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  81.          $x += $width
  82.          Return 1
  83.       Else
  84.          $x += 2
  85.          Local $pixel1[3] = [$x+1, $y+1, 0x969478], $pixel2[3] = [$x+1, $y+12, 0x313027], $pixel3[3] = [$x+4, $y+12, 0xD8D4AC]
  86.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  87.             $x += $width
  88.             Return 1
  89.          Else
  90.             $x -= 1
  91.          EndIf
  92.       EndIf
  93.    EndIf
  94.  
  95.    ;Search for digit 2
  96.    $width = 10
  97.    Local $pixel1[3] = [$x+1, $y+7, 0xA09D80], $pixel2[3] = [$x+3, $y+6, 0xD8D4AC], $pixel3[3] = [$x+4, $y+5, 0x77755F]
  98.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  99.       $x += $width
  100.       Return 2
  101.    Else
  102.       $x -= 1
  103.       Local $pixel1[3] = [$x+1, $y+7, 0xA09D80], $pixel2[3] = [$x+3, $y+6, 0xD8D4AC], $pixel3[3] = [$x+4, $y+5, 0x77755F]
  104.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  105.          $x += $width
  106.          Return 2
  107.       Else
  108.          $x += 2
  109.          Local $pixel1[3] = [$x+1, $y+7, 0xA09D80], $pixel2[3] = [$x+3, $y+6, 0xD8D4AC], $pixel3[3] = [$x+4, $y+5, 0x77755F]
  110.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  111.             $x += $width
  112.             Return 2
  113.          Else
  114.             $x -= 1
  115.          EndIf
  116.       EndIf
  117.    EndIf
  118.  
  119.    ;Search for digit 3
  120.    $width = 10
  121.    Local $pixel1[3] = [$x+8, $y+6, 0x1A1A15], $pixel2[3] = [$x+4, $y+8, 0x070706], $pixel3[3] = [$x+8, $y+1, 0x575646]
  122.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  123.       $x += $width
  124.       Return 3
  125.    Else
  126.       $x -= 1
  127.       Local $pixel1[3] = [$x+8, $y+6, 0x1A1A15], $pixel2[3] = [$x+4, $y+8, 0x070706], $pixel3[3] = [$x+8, $y+1, 0x575646]
  128.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  129.          $x += $width
  130.          Return 3
  131.       Else
  132.          $x += 2
  133.          Local $pixel1[3] = [$x+8, $y+6, 0x1A1A15], $pixel2[3] = [$x+4, $y+8, 0x070706], $pixel3[3] = [$x+8, $y+1, 0x575646]
  134.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  135.             $x += $width
  136.             Return 3
  137.          Else
  138.                $x -= 1
  139.          EndIf
  140.       EndIf
  141.    EndIf
  142.  
  143.    ;Search for digit 4
  144.    $width = 12
  145.    Local $pixel1[3] = [$x+2, $y+3, 0x282720], $pixel2[3] = [$x+3, $y+1, 0x080806], $pixel3[3] = [$x+1, $y+5, 0x403F33]
  146.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  147.       $x += $width
  148.       Return 4
  149.    Else
  150.       $x -= 1
  151.       Local $pixel1[3] = [$x+2, $y+3, 0x282720], $pixel2[3] = [$x+3, $y+1, 0x080806], $pixel3[3] = [$x+1, $y+5, 0x403F33]
  152.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  153.          $x += $width
  154.          Return 4
  155.       Else
  156.          $x += 2
  157.          Local $pixel1[3] = [$x+2, $y+3, 0x282720], $pixel2[3] = [$x+3, $y+1, 0x080806], $pixel3[3] = [$x+1, $y+5, 0x403F33]
  158.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  159.             $x += $width
  160.             Return 4
  161.          Else
  162.             $x -= 1
  163.          EndIf
  164.       EndIf
  165.    EndIf
  166.  
  167.    ;Search for digit 5
  168.    $width = 10
  169.    Local $pixel1[3] = [$x+5, $y+4, 0x060605], $pixel2[3] = [$x+4, $y+9, 0x040403], $pixel3[3] = [$x+7, $y+12, 0x5F5D4C]
  170.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  171.       $x += $width
  172.       Return 5
  173.    Else
  174.       $x -= 1
  175.       Local $pixel1[3] = [$x+5, $y+4, 0x060605], $pixel2[3] = [$x+4, $y+9, 0x040403], $pixel3[3] = [$x+7, $y+12, 0x5F5D4C]
  176.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  177.          $x += $width
  178.          Return 5
  179.       Else
  180.          $x += 2
  181.          Local $pixel1[3] = [$x+5, $y+4, 0x060605], $pixel2[3] = [$x+4, $y+9, 0x040403], $pixel3[3] = [$x+7, $y+12, 0x5F5D4C]
  182.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  183.             $x += $width
  184.             Return 5
  185.          Else
  186.             $x -= 1
  187.          EndIf
  188.       EndIf
  189.    EndIf
  190.  
  191.    ;Search for digit 6
  192.    $width = 11
  193.    Local $pixel1[3] = [$x+5, $y+4, 0x070605], $pixel2[3] = [$x+5, $y+9, 0x040403], $pixel3[3] = [$x+8, $y+5, 0x181713]
  194.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  195.       $x += $width
  196.       Return 6
  197.    Else
  198.       $x -= 1
  199.       Local $pixel1[3] = [$x+5, $y+4, 0x070605], $pixel2[3] = [$x+5, $y+9, 0x040403], $pixel3[3] = [$x+8, $y+5, 0x181713]
  200.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  201.          $x += $width
  202.          Return 6
  203.       Else
  204.          $x += 2
  205.          Local $pixel1[3] = [$x+5, $y+4, 0x070605], $pixel2[3] = [$x+5, $y+9, 0x040403], $pixel3[3] = [$x+8, $y+5, 0x181713]
  206.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  207.             $x += $width
  208.             Return 6
  209.          Else
  210.             $x -= 1
  211.          EndIf
  212.       EndIf
  213.    EndIf
  214.  
  215.    ;Search for digit 7
  216.    $width = 10
  217.    Local $pixel1[3] = [$x+5, $y+11, 0x5E5C4B], $pixel2[3] = [$x+6, $y+9, 0x5D5C4B], $pixel3[3] = [$x+7, $y+7, 0x5D5C4B]
  218.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  219.       $x += $width
  220.       Return 7
  221.    Else
  222.       $x -= 1
  223.       Local $pixel1[3] = [$x+5, $y+11, 0x5E5C4B], $pixel2[3] = [$x+6, $y+9, 0x5D5C4B], $pixel3[3] = [$x+7, $y+7, 0x5D5C4B]
  224.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  225.          $x += $width
  226.          Return 7
  227.       Else
  228.          $x += 2
  229.          Local $pixel1[3] = [$x+5, $y+11, 0x5E5C4B], $pixel2[3] = [$x+6, $y+9, 0x5D5C4B], $pixel3[3] = [$x+7, $y+7, 0x5D5C4B]
  230.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  231.             $x += $width
  232.             Return 7
  233.          Else
  234.             $x -= 1
  235.          EndIf
  236.       EndIf
  237.    EndIf
  238.  
  239.    ;Search for digit 8
  240.    $width = 12
  241.    Local $pixel1[3] = [$x+5, $y+3, 0x27261F], $pixel2[3] = [$x+5, $y+10, 0x302F26], $pixel3[3] = [$x+1, $y+6, 0x26261F]
  242.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  243.       $x += $width
  244.       Return 8
  245.    Else
  246.       $x -= 1
  247.       Local $pixel1[3] = [$x+5, $y+3, 0x27261F], $pixel2[3] = [$x+5, $y+10, 0x302F26], $pixel3[3] = [$x+1, $y+6, 0x26261F]
  248.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  249.          $x += $width
  250.          Return 8
  251.       Else
  252.          $x += 2
  253.          Local $pixel1[3] = [$x+5, $y+3, 0x27261F], $pixel2[3] = [$x+5, $y+10, 0x302F26], $pixel3[3] = [$x+1, $y+6, 0x26261F]
  254.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  255.             $x += $width
  256.             Return 8
  257.          Else
  258.             $x -= 1
  259.          EndIf
  260.       EndIf
  261.    EndIf
  262.  
  263.    ;Search for digit 9
  264.    $width = 11
  265.    Local $pixel1[3] = [$x+5, $y+5, 0x302F26], $pixel2[3] = [$x+5, $y+9, 0x050504], $pixel3[3] = [$x+8, $y+12, 0x272720]
  266.    If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  267.       $x += $width
  268.       Return 9
  269.    Else
  270.       $x -= 1
  271.       Local $pixel1[3] = [$x+5, $y+5, 0x302F26], $pixel2[3] = [$x+5, $y+9, 0x050504], $pixel3[3] = [$x+8, $y+12, 0x272720]
  272.       If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  273.          $x += $width
  274.          Return 9
  275.       Else
  276.          $x += 2
  277.          Local $pixel1[3] = [$x+5, $y+5, 0x302F26], $pixel2[3] = [$x+5, $y+9, 0x050504], $pixel3[3] = [$x+8, $y+12, 0x272720]
  278.          If boolPixelSearch($pixel1, $pixel2, $pixel3) = True Then
  279.             $x += $width
  280.             Return 9
  281.          Else
  282.             $x -= 1
  283.          EndIf
  284.       EndIf
  285.    EndIf
  286.  
  287.    Return "" ;Returns nothing to when there are no matches, usually when the number is below 100k
  288. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement