Guest User

Testing ImageSearch

a guest
Jun 10th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. #include <ImageSearch.au3>
  2.  
  3. #include <GUIConstantsEx.au3>
  4. #include <Debug.au3>
  5. $sTitle = "My Debug Report"
  6. _DebugSetup($sTitle)
  7. ;~ _DebugOut("Search for item:" & $gI)
  8.  
  9.  
  10. Global $Paused
  11. HotKeySet(",", "Start") ;script started by pressing -
  12. HotKeySet(".", "Pause") ;script paused by pressing =
  13. HotKeySet("x", "Stop") ;script stopped by pressing x
  14.  
  15. Func Start()
  16. $Pause = False
  17. EndFunc ;==>Start
  18.  
  19. Func Pause()
  20. $Pause = True
  21. EndFunc ;==>Pause
  22.  
  23. Func Stop() ;to allow the script to stop
  24. Exit
  25. EndFunc ;==>Stop
  26.  
  27.  
  28. ;ImageSearch Looting Variables
  29. $directory = "D:\Tmp\Diablo\Png\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
  30. $totalItems = 20 ; This needs to match the number of pngs you are loading
  31.  
  32. Global $General[2]
  33. $General[0] = "uare.png" ; Matches "Square" require tolerance >70
  34. $General[1] = "tome.png" ; Matches "Tome" require tolerance >100
  35.  
  36. Global $Legendary[6]
  37. $Legendary[0] = "legendaryA.png" ; Matches "Legenday" require tolerance >70 <100
  38. $Legendary[1] = "legendaryE.png" ;
  39. $Legendary[2] = "legendaryI.png" ;
  40. $Legendary[3] = "legendaryO.png" ;
  41. $Legendary[4] = "legendaryU.png" ;
  42. $Legendary[5] = "legendaryY.png" ;
  43.  
  44. Global $Set[6]
  45. $Set[0] = "setA.png" ; Matches "Set" require tolerance >70
  46. $Set[1] = "setE.png" ;
  47. $Set[2] = "setI.png" ;
  48. $Set[3] = "setO.png" ;
  49. $Set[4] = "setU.png" ;
  50. $Set[5] = "setY.png" ;
  51.  
  52. Global $Rare[6]
  53. $Rare[0] = "rareA.png.png" ; Matches "Rare" require tolerance >70 >>
  54. $Rare[1] = "rareE.png.png" ;
  55. $Rare[2] = "rareI.png.png" ;
  56. $Rare[3] = "rareO.png.png" ;
  57. $Rare[4] = "rareU.png.png" ;
  58. $Rare[5] = "rareY.png.png" ;
  59.  
  60. ;Timers
  61. $walktime = 4500 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  62. $loadtime = 5000 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  63. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  64.  
  65. ;Settings
  66. $Timer = False ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
  67. $LootRares = True ; Change this to false if you don't want the bot to pick up rares (good for legendary/set only, recommend setting LootGems to False)
  68. $LootGems = False ; Change this to true if you want to pick up gems (messy, can fill up bag with whites/blues)
  69.  
  70. ;Repairs colors
  71. $yellow = 0xFFF000 ; yellow color code (repair icon)
  72. $red = 0xD90000 ; red color code (repair icon)
  73.  
  74. $Continue = True
  75. $Pause = True
  76. $Dead = False
  77. $Logout = False
  78. $Window = False
  79. $NeedRepair = False
  80. $default_resolutionX = 1920
  81. $default_resolutionY = 1080
  82. $x_ratio = @DesktopWidth / $default_resolutionX ; Change @Desktopwidth to a static number if you are running different resolutions ingame and on desktop
  83. $y_ratio = @DesktopHeight / $default_resolutionY ; Change @Desktopwidth to a static number if you are running different resolutions ingame and on desktop
  84. $i = 0
  85. $x = 0
  86. $currentArrayItem = 0
  87. $gX = 0
  88. $gY = 0
  89.  
  90. Call("RestartRun")
  91.  
  92. Func RestartRun()
  93. While $Continue
  94. If Not ($Pause) Then
  95. Call("pickItems")
  96. Sleep(10000)
  97. EndIf
  98. WEnd
  99. Call("RestartRun")
  100. EndFunc ;==>RestartRun
  101.  
  102.  
  103. Func pickItems()
  104. Sleep(6000)
  105. ;~ Loot Legenday
  106. For $gI = 0 To (5)
  107. $urlString = $directory & $Legendary[$gI]
  108. $Target = _ImageSearch($urlString, 1, $gX, $gY, 75)
  109. _DebugOut("Link:" & $urlString)
  110. While $i <= 5
  111. If $Target Then
  112. _DebugOut(" ===================================" )
  113. _DebugOut("ItemFound:" & $Target)
  114. _DebugOut("x=" & $gX)
  115. _DebugOut("y=" & $gY)
  116. MouseClick("left", $gX, $gY)
  117. Sleep(Random(1000, 1200))
  118. MouseMove(0, 100) ;Reset cursor position, it doesn't need to hover
  119. $Target = _ImageSearch($urlString, 1, $gX, $gY, 75)
  120. Sleep(5000)
  121. $i += 1
  122. Else
  123. ExitLoop
  124. EndIf
  125. WEnd
  126. Next
  127.  
  128. ;~ Loot Set
  129. For $gI = 0 To (5)
  130. $urlString = $directory & $Set[$gI]
  131. $Target = _ImageSearch($urlString, 1, $gX, $gY, 75)
  132. _DebugOut("Link:" & $urlString)
  133. While $i <= 5
  134. If $Target Then
  135. _DebugOut(" ===================================" )
  136. _DebugOut("ItemFound:" & $Target)
  137. _DebugOut("x=" & $gX)
  138. _DebugOut("y=" & $gY)
  139. MouseClick("left", $gX, $gY)
  140. Sleep(Random(1000, 1200))
  141. MouseMove(0, 100) ;Reset cursor position, it doesn't need to hover
  142. $Target = _ImageSearch($urlString, 1, $gX, $gY, 75)
  143. Sleep(5000)
  144. $i += 1
  145. Else
  146. ExitLoop
  147. EndIf
  148. WEnd
  149. Next
  150.  
  151. ;~ Loot Rare
  152. For $gI = 0 To (5)
  153. $urlString = $directory & $Rare[$gI]
  154. $Target = _ImageSearch($urlString, 1, $gX, $gY, 115)
  155. _DebugOut("Link:" & $urlString)
  156. While $i <= 5
  157. If $Target Then
  158. _DebugOut(" ===================================" )
  159. _DebugOut("ItemFound:" & $Target)
  160. _DebugOut("x=" & $gX)
  161. _DebugOut("y=" & $gY)
  162. MouseClick("left", $gX, $gY)
  163. Sleep(Random(1000, 1200))
  164. MouseMove(0, 100) ;Reset cursor position, it doesn't need to hover
  165. $Target = _ImageSearch($urlString, 1, $gX, $gY, 115)
  166. Sleep(5000)
  167. $i += 1
  168. Else
  169. ExitLoop
  170. EndIf
  171. WEnd
  172. Next
  173.  
  174. ;~ Loot general
  175. For $gI = 0 To (1)
  176. $urlString = $directory & $General[$gI]
  177. $Target = _ImageSearch($urlString, 1, $gX, $gY, 115)
  178. _DebugOut("Link:" & $urlString)
  179. While $i <= 10
  180. If $Target Then
  181. _DebugOut(" ===================================" )
  182. _DebugOut("ItemFound:" & $Target)
  183. _DebugOut("x=" & $gX)
  184. _DebugOut("y=" & $gY)
  185. MouseClick("left", $gX, $gY)
  186. Sleep(Random(1000, 1200))
  187. MouseMove(0, 100) ;Reset cursor position, it doesn't need to hover
  188. $Target = _ImageSearch($urlString, 1, $gX, $gY, 115)
  189. Sleep(5000)
  190. $i += 1
  191. Else
  192. ExitLoop
  193. EndIf
  194. WEnd
  195. Next
  196. EndFunc ;==>pickItems
Advertisement
Add Comment
Please, Sign In to add comment