Guest User

Wormhole TP with ImageSearch

a guest
Jun 11th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.77 KB | None | 0 0
  1. ;notAres' Sarkoth DH Gold Script 1.3a - 6/9/2012 - Holy shit look how beautiful this code is. Utilized ExitLoop to perfect the efficiency when dead/logging out/in need of repair
  2. ;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkarth-dh-gold-script-autoit-script-1920x1080.html
  3. ;Please notice I changed some variable names around and added a variable for teleport time. $waittime is now appropriately named $loadtime.
  4. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  5. ;Required build: http://us.battle.net/d3/en/calculator/demon-hunter#aRYXVT!aTW!YcaZbY
  6. ;Required movement speed: 25% (10% boots + 15% passive 'Hot Pursuit')
  7. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  8. ;Official supported resolution: 1920x1080
  9. ;;;;;
  10. ;Features:
  11. ;Loot scanning. Will only pick up rare/legendary/set pieces [IMPROVED]
  12. ;Randomized aiming coordinates (but still static path)
  13. ;Randomized pickup timers for variation in runs
  14. ;Automatic repair on yellow status icon
  15. ;Automatic resolution adjustment (16:9 only) [BUGGY - need someone to tweak coords]
  16. ;Death check
  17. ;Open window check (in rare case it gets stuck in menu)
  18. ;;;;;
  19. ;Original:
  20. ;[Goldfarming] AFK 150k-200k Gold Per Hour by mackus101 @ ownedcore
  21.  
  22. #include <ImageSearch.au3>
  23. Global $Paused
  24. HotKeySet("=","Leave") ;script started by pressing =
  25. HotKeySet("-", "Pause") ;script paused by pressing -
  26. HotKeySet("x", "Stop") ;script stopped by pressing x
  27.  
  28. $walktime = 3000 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  29. $loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  30. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  31. $yellow = 0xFFF000 ; yellow color code (repair icon)
  32. $red = 0xD90000 ; red color code (repair icon)
  33.  
  34. ;ImageSearch Looting Variables
  35. $ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
  36. $directory = "C:\pics\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
  37. $t1 = 17
  38.  
  39. Global $pick[$t1], $size = WinGetClientSize("[TITLE:Diablo III; CLASS:D3 Main Window Class]"), $go = True, $Leave = False, $Dead = False, $Logout = False, $Window = False, $i = 0, $currentArrayItem = 0, $gX = 0, $gY = 0
  40. If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
  41. $pick[0] = "uare.png|40"
  42. $pick[1] = "tome.png|40"
  43. $pick[2] = "legendaryA.png|20"
  44. $pick[3] = "legendaryE.png|20"
  45. $pick[4] = "legendaryI.png|10"
  46. $pick[5] = "legendaryO.png|20"
  47. $pick[6] = "legendaryU.png|20"
  48. $pick[7] = "setA.png|30"
  49. $pick[8] = "setE.png|30"
  50. $pick[9] = "setU.png|30"
  51. $pick[10] = "setO.png|30"
  52. $pick[11] = "setI.png|30"
  53. $pick[12] = "rareA.png|20" ; comment/delete these and adjust $totalItems to disable rare looting
  54. $pick[13] = "rareE.png|20"
  55. $pick[14] = "rareI.png|20"
  56. $pick[15] = "rareO.png|20"
  57. $pick[16] = "rareU.png|20" ; end comment
  58.  
  59. $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)
  60. $LootGems = False ; Change this to true if you want to pick up gems (messy, can fill up bag with whites/blues)
  61. $Amethyst = 0xAC7FFF
  62. $Ruby = 0xB01D2D
  63. $Emerald = 0x58EE33
  64. $Topaz = 0xFFFF59
  65.  
  66. $go = True
  67. $Leave = False
  68. $Dead = False
  69. $Logout = False
  70. $Window = False
  71. $default_resolutionX = 1920
  72. $default_resolutionY = 1080
  73. $x_ratio = @Desktopwidth / $default_resolutionX
  74. $y_ratio = @Desktopheight / $default_resolutionY
  75. $i = 0
  76.  
  77. Call("RestartRun")
  78.  
  79. Func RestartRun()
  80. While $go
  81. if($Leave) Then
  82. $i = 0
  83. Sleep(1000) ;had to add this since the icon doesn't show up RIGHT away in game
  84. Call("CheckDead")
  85. Call("CheckRepair")
  86. If $Window Then
  87. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  88. Sleep($loadtime)
  89. $Window = False
  90. ExitLoop
  91. ElseIf $Dead or $Logout Then
  92. ExitLoop
  93. EndIf
  94. MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  95. Send("4")
  96. Sleep(140)
  97. Send("4")
  98. Sleep(140)
  99. Send("4")
  100. Sleep(140)
  101. Send("4")
  102. Sleep(80)
  103. Send("4")
  104. Sleep(80)
  105. Send("4")
  106. Sleep(80)
  107. Send("4")
  108. Sleep(80)
  109. Send("4")
  110. Sleep(80)
  111. Send("2")
  112. Send("1")
  113. Send("3")
  114. Sleep(300)
  115. MouseMove(Round(290*$x_ratio),Round(270*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  116. Sleep(700)
  117. Call("CheckDead")
  118. If $Window Then
  119. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  120. Sleep($loadtime)
  121. $Window = False
  122. ExitLoop
  123. ElseIf $Dead or $Logout Then
  124. ExitLoop
  125. EndIf
  126. $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
  127. If Not @error Then
  128. MouseClick("left",Round(290*$x_ratio),Round(270*$y_ratio)) ;Entrance to cellar
  129. Sleep(400)
  130. Send("2")
  131. Sleep($walktime)
  132. MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  133. Sleep(2500)
  134. MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  135. Sleep(10)
  136. Send("{SHIFTDOWN}")
  137. MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  138. MouseDown("right") ;attack middle
  139. Sleep(16000)
  140. MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  141. Sleep(10)
  142. Send("{SHIFTUP}")
  143. Sleep(400)
  144. MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  145. Sleep(2100)
  146. MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
  147. Sleep(1100)
  148. MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
  149. Sleep(1100)
  150. MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
  151. Call("CheckLoot")
  152. Send("t")
  153. Sleep($tptime)
  154. Call("CheckDead")
  155. If Not $Logout And Not $Dead And Not $Window Then
  156. Sleep(300)
  157. Send("{ESCAPE}") ;menu
  158. Sleep(200)
  159. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  160. Sleep($loadtime)
  161. Call("CheckDead")
  162. If Not $Logout Then
  163. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  164. Sleep($loadtime)
  165. EndIf
  166. Else
  167. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  168. Sleep($loadtime)
  169. $Window = False ; reset the flag so it doesn't think a window is always up
  170. EndIf
  171. Else
  172. Sleep(50)
  173. Send("t")
  174. Sleep($tptime)
  175. Call("CheckDead")
  176. If Not $Logout And Not $Dead And Not $Window Then
  177. Sleep(300)
  178. Send("{ESCAPE}") ;menu
  179. Sleep(200)
  180. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  181. Sleep($loadtime)
  182. Call("CheckDead")
  183. If Not $Logout Then
  184. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  185. Sleep($loadtime)
  186. EndIf
  187. Else
  188. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  189. Sleep($loadtime)
  190. $Window = False ; reset the flag so it doesn't think a window is always up
  191. EndIf
  192. EndIf
  193. EndIf
  194. WEnd
  195. Call("RestartRun")
  196. EndFunc
  197.  
  198. Func CheckDead()
  199. Call("CheckWindow")
  200. $YouHaveDied = PixelSearch(Round(620*$x_ratio), Round(325*$y_ratio), Round(625*$x_ratio), Round(330*$y_ratio), 0xFFFFFF) ; checks for white text "YOU HAVE DIED"
  201. If Not @error Then
  202. If Not $Window Then
  203. $Dead = True
  204. Sleep(100)
  205. Send("{Escape}")
  206. Sleep(10)
  207. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  208. Sleep(11000)
  209. Sleep($loadtime)
  210. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  211. Sleep($loadtime)
  212. Else
  213. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  214. Sleep($loadtime)
  215. $Dead = False
  216. EndIf
  217. Else
  218. $Dead = False
  219. EndIf
  220. $LogoutTimerCancel = PixelSearch(Round(900*$x_ratio), Round(240*$y_ratio), Round(1010*$x_ratio), Round(290*$y_ratio), 0x993827) ; checks for cancel button on logout timer
  221. If Not @error Then
  222. Sleep(11000)
  223. Sleep($loadtime)
  224. If Not $Window Then
  225. $Dead = True
  226. $Logout = True
  227. Sleep($loadtime)
  228. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  229. Sleep($loadtime)
  230. Else
  231. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  232. Sleep($loadtime)
  233. $Logout = False
  234. EndIf
  235. Else
  236. $Logout = False
  237. EndIf
  238. EndFunc
  239.  
  240. Func CheckWindow()
  241. $CloseButton = PixelSearch(Round(1570*$x_ratio), Round(110*$y_ratio), Round(1590*$x_ratio), Round(120*$y_ratio), 0x8C2300) ; checks for the red color of the "X" on an open window
  242. If Not @error Then
  243. Sleep(200)
  244. Send("{SPACE}") ;close any open windows
  245. $Window = True
  246. Else
  247. $Window = False
  248. EndIf
  249. EndFunc
  250.  
  251. Func CheckRepair()
  252. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  253. If Not @error Then
  254. Call("DoRepair")
  255. EndIf
  256. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  257. If Not @error Then
  258. Call("DoRepair")
  259. EndIf
  260. EndFunc
  261.  
  262. Func DoRepair()
  263. Sleep(100)
  264. Send("t")
  265. Sleep($tptime)
  266. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  267. Sleep(1500)
  268. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  269. Sleep(1500)
  270. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  271. Sleep(1200)
  272. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  273. Sleep(400)
  274. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  275. Sleep(200)
  276. Call("CheckDead")
  277. If Not $Dead and Not $Logout Then
  278. Send("{ESCAPE}") ;closes repair tab
  279. Sleep(100)
  280. Send("{ESCAPE}") ;menu
  281. Sleep(10)
  282. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  283. Sleep($loadtime)
  284. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  285. Sleep($loadtime)
  286. EndIf
  287. EndFunc
  288.  
  289. Func CheckLoot()
  290. Sleep(Random(500,2000))
  291. If Not $ImgLoot Then
  292. $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  293. If Not @error Then
  294. MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
  295. Sleep(Random(1000,1200))
  296. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  297. $i+= 1
  298. If $i <= 6 Then
  299. Call("CheckLoot")
  300. EndIf
  301. EndIf
  302. $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  303. If Not @error Then
  304. MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
  305. Sleep(Random(1000,1200))
  306. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  307. $i+= 1
  308. If $i <= 6 Then
  309. Call("CheckLoot")
  310. EndIf
  311. EndIf
  312. If $LootRares Then
  313. $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  314. If Not @error Then
  315. MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
  316. Sleep(Random(1000,1200))
  317. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  318. $i+= 1
  319. If $i <= 6 Then
  320. Call("CheckLoot")
  321. EndIf
  322. EndIf
  323. EndIf
  324. Else
  325. Call("pickItems")
  326. EndIf
  327. EndFunc
  328.  
  329. Func pickItems()
  330. $currentArrayItem = 0
  331. For $gI = 0 to ($t1 - 1)
  332. $array = StringSplit($pick[$gI],"|")
  333. $file = $array[1]
  334. $accuracy = $array[2]
  335. $urlString = $directory & $file
  336. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  337. While $i <= 12 ; max: 13 gems and pieces of gear to loot
  338. If $Target And ($gX > 15) And ($gY > 15) Then
  339. ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
  340. MouseClick("left", $gX, $gY, 1, 0)
  341. Sleep(Random(1200,1400))
  342. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  343. Sleep(5)
  344. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  345. $i+= 1
  346. Else
  347. ExitLoop
  348. EndIf
  349. WEnd
  350. Next
  351. EndFunc
  352.  
  353.  
  354. Func Pause()
  355. $Leave = False
  356. EndFunc
  357.  
  358. Func Stop() ;to allow the script to stop
  359. Exit
  360. EndFunc
  361.  
  362. Func Leave()
  363. $Leave = True
  364. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment