Advertisement
Guest User

MarketPlace

a guest
Feb 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.81 KB | None | 0 0
  1. Func Marketplace()
  2.     Local Const $PurpleBags = "res/marketplace_purplebags.bmp"
  3.     Local $RegistrationCountOffset[4] = [70, -9, 110, 5]
  4.     Local $RefreshOffset[2] = [-440, 480]
  5.     Local $x, $y, $IS
  6.     Local $Diff[4]
  7.     Local $timer
  8.  
  9.     $ResOffset = DetectFullscreenToWindowedOffset()
  10.     $IS = _ImageSearchArea($PurpleBags, 1, $ResOffset[0], $ResOffset[1], $ResOffset[2], $ResOffset[3], $x, $y, 0, 0)
  11.     If $IS = False Then
  12.         SetGUIStatus("No PurpleBags found. Stopping.")
  13.         $Marketplace = False
  14.     EndIf
  15.  
  16.     Local $count = 0, $breakout = 0
  17.     While $Marketplace
  18.         SetGUIStatus("Waiting for Registration Count change")
  19.         $number = FastFindBidBuy($x, $y)
  20.         If $number >= 0 Then BuyItem($x, $y, $number)
  21.  
  22.         $Diff[$count] = PixelChecksum($x + $RegistrationCountOffset[0], $y + $RegistrationCountOffset[1], $x + $RegistrationCountOffset[2], $y + $RegistrationCountOffset[3])
  23.         For $i = 0 To UBound($Diff) - 1
  24.             If $Diff[0] <> $Diff[$i] Then
  25.                 If TimerDiff($timer) > 1000 Then
  26.                     SetGUIStatus("Refresh (Registration Count change)")
  27.                     MouseClick("left", $x + $RefreshOffset[0], $y + $RefreshOffset[1], 1, 0)
  28.                     $timer = TimerInit()
  29.                     Sleep(50)
  30.                     ExitLoop
  31.                 Else
  32.                     $breakout += 1
  33.                     If $breakout > 10 Then
  34.                         $IS = _ImageSearchArea($PurpleBags, 1, $x - 10, $y - 10, $x + 10, $y + 10, $x, $y, 0, 0)
  35.                         If $IS = False Then
  36.                             SetGUIStatus("No PurpleBags found. Stopping.")
  37.                             $Marketplace = False
  38.                         Else
  39.                             $breakout = 0
  40.                         EndIf
  41.                     EndIf
  42.                 EndIf
  43.             EndIf
  44.         Next
  45.         If TimerDiff($timer) > 30000 Then
  46.             SetGUIStatus("Refresh (30s no change detected)")
  47.             MouseClick("left", $x + $RefreshOffset[0], $y + $RefreshOffset[1], 1, 0)
  48.             $timer = TimerInit()
  49.             Sleep(50)
  50.         EndIf
  51.         Sleep(50)
  52.         $count += 1
  53.         If $count = 4 Then $count = 0
  54.     WEnd
  55. EndFunc   ;==>Marketplace
  56.  
  57. Func FastFindBidBuy($x, $y)
  58.     Local $Valid[2] = [0x979292, 0xB8B8B8]
  59.     Local $SSN = 1, $FF
  60.     Local $BidR[3] = [21, 12, 21]
  61.     Local $Buy[3] = [3, 12, 21]
  62.     Local $Bid[3] = [4, 12, 21]
  63.     Local $BuyOffset[3] = [78, 54, 62] ; x, y, height 7
  64.     Local $ButtonRegion[4] = [$x + $BuyOffset[0] - 15, $y + $BuyOffset[1] - 15, $x + $BuyOffset[0] + 15, $y + $BuyOffset[1] + 15]
  65.     Local $count
  66.  
  67.     FFSnapShot($ButtonRegion[0], $ButtonRegion[1], $ButtonRegion[2], $ButtonRegion[3] + $BuyOffset[2] * 6, $SSN)
  68.  
  69.     For $i = 0 To 6
  70.         $count = 0
  71.         For $yBid = $Bid[1] To $Bid[2]
  72.             $FF = FFGetPixel($ButtonRegion[0] + $Bid[0], $ButtonRegion[1] + $yBid + $BuyOffset[2] * $i, $SSN)
  73.             If $FF = $Valid[0] Or $FF = $Valid[1] Then
  74.                 $count += 1
  75.             EndIf
  76.         Next
  77.         If $count > 9 Then
  78.             SetGUIStatus("Bid " & $i)
  79.             MouseClick("left", $x + $BuyOffset[0], $y + $BuyOffset[1] + $i * $BuyOffset[2], 2, 0)
  80.             CoSe("{SPACE}")
  81.         EndIf
  82.     Next
  83.  
  84.  
  85.     For $i = 0 To 6
  86.         $count = 0
  87.         For $yBuy = $Buy[1] To $Buy[2]
  88.             $FF = FFGetPixel($ButtonRegion[0] + $Buy[0], $ButtonRegion[1] + $yBuy + $BuyOffset[2] * $i, $SSN)
  89.             If $FF = $Valid[0] Or $FF = $Valid[1] Then
  90.                 $count += 1
  91.             EndIf
  92.         Next
  93.         If $count > 9 Then
  94.             SetGUIStatus("Buy " & $i)
  95.             Return ($i)
  96.         EndIf
  97.         $count = 0
  98.         For $yBidR = $BidR[1] To $BidR[2]
  99.             $FF = FFGetPixel($ButtonRegion[0] + $BidR[0], $ButtonRegion[1] + $yBidR + $BuyOffset[2] * $i, $SSN)
  100.             If $FF = $Valid[0] Or $FF = $Valid[1] Then
  101.                 $count += 1
  102.             EndIf
  103.         Next
  104.         If $count > 9 Then
  105.             SetGUIStatus("BidR " & $i)
  106.             Return ($i)
  107.         EndIf
  108.     Next
  109.     Return -1
  110. EndFunc   ;==>FastFindBidBuy
  111.  
  112.  
  113. Func BuyItem($x, $y, $number)
  114.     Local $MaxOffset[2] = [-111, 297]
  115.     Local $BuyOffset[3] = [78, 54, 62] ; x, y, height
  116.  
  117.     MouseClick("left", $x + $BuyOffset[0], $y + $BuyOffset[1] + $number * $BuyOffset[2], 2, 0) ; buy
  118.     MouseClick("left", $x + $MaxOffset[0] - 30, $y + $MaxOffset[1], 1, 0) ; amount
  119.     CoSe("f") ; max
  120.     CoSe("r") ; confirm
  121.     CoSe("{SPACE}") ; yes
  122.     $buycount = $buycount + 1
  123.     SetCountStatus($buycount)
  124.  EndFunc   ;==>BuyItem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement