Guest User

Untitled

a guest
Jun 11th, 2012
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.91 KB | None | 0 0
  1. ;notAres' Sarkoth DH Gold Script 1.4a - 6/10/2012 - Improved looting with black backgrounds. Experimental support for different resolutions (especially windowed mode). Rehauled ImageSearch looting, contributions from rvbfreak, goofinator, and asuRob
  2. ;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkoth-dh-gold-script-autoit-script-1920x1080.html
  3. ;IF YOU PLAN TO USE IMAGESEARCH FUNCTIONS:
  4. ;Download: http://www.mediafire.com/?vtx9l1woj61h8r6 (1.4a new link)
  5. ;If your Windows installation is x64, use the 64-bit native AutoIt and the x64 directory in the archive
  6. ;Extract and copy AutoIt3 folder to Program Files directory
  7. ;Extract and copy all dlls to C:\Windows\ directory (optionally copy the MSVCR dlls to System32 as well)
  8. ;Extract pics directory anywhere and update the $directory var - INCLUDE TRAILING BACKSLASH: C:\pics\
  9. ;If you are running anything but fullscreen mode, the size of letters will mismatch and not loot anything. Resize or make your own pngs.
  10. ;IF YOU COMPILE THE SCRIPT TO EXE AND YOU USE X64:
  11. ;Run "Compile script to .exe (x64)"
  12. ;Check "Lowest" under the Compression menu option
  13. ;Leave x64 checkbox checked
  14. ;;;;;
  15. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  16. ;Required build: http://us.battle.net/d3/en/calculator/demon-hunter#aRYXVT!aTW!YcaZbY
  17. ;Required movement speed: 25% (at least 10% on gear + 15% passive 'Hot Pursuit')
  18. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  19. ;Official supported resolution: 1920x1080
  20. ;;;;;
  21. ;Original: [Goldfarming] AFK 150k-200k Gold Per Hour by mackus101 @ ownedcore
  22. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  23.  
  24. #include <ImageSearch.au3> ;comment this if you are not using the new looting system
  25. Global $Paused
  26. Opt('MouseCoordMode', 2)
  27. Opt('PixelCoordMode', 2)
  28. HotKeySet("=","Leave") ;script started by pressing =
  29. HotKeySet("-", "Pause") ;script paused by pressing -
  30. HotKeySet("x", "Stop") ;script stopped by pressing x
  31.  
  32. ;ImageSearch Looting Variables
  33. $ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
  34. $directory = "C:\pics\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
  35. $totalItems = 10 ; This needs to match the number of pngs you are loading
  36. Global $pick[$totalItems], $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
  37. If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
  38. $pick[0] = "Ruby.png|40"
  39. $pick[1] = "Topaz.png|40"
  40. $pick[2] = "Amethyst.png|40"
  41. $pick[3] = "Emerald.png|40"
  42. $pick[4] = "Page.png|40"
  43. $pick[5] = "RareA.png|40" ; comment/delete these and adjust $totalItems to disable rare looting
  44. $pick[6] = "RareE.png|40"
  45. $pick[7] = "RareI.png|40"
  46. $pick[8] = "RareO.png|40"
  47. $pick[9] = "RareU.png|40" ; end comment
  48.  
  49. $LootRares = True ; set this to false if you don't want the bot to pick up rares (old looting method only)
  50. $Timer = False ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
  51. $walktime = 2600 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  52. $loadtime = 4200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  53. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  54. $x_ratio = $size[0] / 1920
  55. $y_ratio = $size[1] / 1080
  56. $yellow = 0xFFF000 ; yellow color code (repair icon)
  57. $red = 0xD90000 ; red color code (repair icon)
  58.  
  59. Call("RestartRun")
  60. Func RestartRun()
  61. While $go
  62. if($Leave) Then
  63. $i = 0
  64. Call("CheckExit")
  65. Sleep(850) ;had to add this since the icon doesn't show up RIGHT away in game
  66. Call("CheckDead")
  67. Call("CheckRepair")
  68. If $Window Then
  69. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  70. Sleep($loadtime)
  71. $Window = False
  72. ExitLoop
  73. ElseIf $Dead or $Logout Then
  74. ExitLoop
  75. EndIf
  76. MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
  77. Sleep(900)
  78. Send("2")
  79. Sleep(300)
  80. MouseClick("middle", 1, Round(370*$y_ratio)) ;waits ~1 second then [waypoint 2]
  81. Sleep(1400)
  82. MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard [waypoint 3]
  83. Sleep(40)
  84. Send("2")
  85. Sleep(20)
  86. Send("3")
  87. Sleep(600)
  88. Send("1")
  89. Sleep(300)
  90. MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  91. Sleep(790)
  92. Call("CheckDead")
  93. If $Window Then
  94. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  95. Sleep($loadtime)
  96. $Window = False
  97. ExitLoop
  98. ElseIf $Dead or $Logout Then
  99. ExitLoop
  100. EndIf
  101. $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x600 box from the top left - where it should always be)
  102. If Not @error Then
  103. MouseClick("left",Round(300*$x_ratio),Round(100*$y_ratio)) ;Entrance to cellar
  104. Sleep(300)
  105. Send("2")
  106. Sleep(350) ; second cast in case the cooldown timer isn't quite right (rarely happens)
  107. Send("2")
  108. Sleep($walktime)
  109. MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  110. Sleep(2500)
  111. MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  112. Sleep(10)
  113. Send("{SHIFTDOWN}")
  114. MouseDown("right") ;attack middle
  115. Sleep(1200)
  116. Send("4")
  117. Sleep(3000)
  118. MouseUp("right")
  119. MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  120. MouseMove(Round(240*$x_ratio),Round(75*$y_ratio),1) ;attack left
  121. Sleep(40)
  122. MouseDown("right")
  123. Sleep(2800)
  124. MouseUp("right")
  125. MouseMove(Round(590*$x_ratio),Round(50*$y_ratio),1) ;attack right
  126. MouseDown("right")
  127. Sleep(1800)
  128. MouseUp("right")
  129. MouseDown("left")
  130. MouseMove(Round(Random(240,260)*$x_ratio),Round(75*$y_ratio),1) ;attack left
  131. Sleep(1200)
  132. MouseMove(Round(Random(560,600)*$x_ratio),Round(50*$y_ratio),1) ;attack right
  133. Sleep(1200)
  134. MouseUP("left")
  135. Sleep(10)
  136. MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  137. Sleep(10)
  138. Send("{SHIFTUP}")
  139. Sleep(400)
  140. MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  141. Sleep(2100)
  142. MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
  143. Sleep(1100)
  144. MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
  145. Sleep(1100)
  146. Send("4")
  147. MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
  148. Call("CheckLoot")
  149. Send("t")
  150. Sleep($tptime)
  151. Call("RandomSleep")
  152. Call("CheckDead")
  153. If Not $Logout And Not $Dead And Not $Window Then
  154. Sleep(300)
  155. Send("{ESCAPE}") ;menu
  156. Sleep(200)
  157. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  158. Sleep($loadtime)
  159. Call("CheckDead")
  160. If Not $Logout Then
  161. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  162. Sleep($loadtime)
  163. EndIf
  164. Else
  165. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  166. Sleep($loadtime)
  167. $Window = False ; reset the flag so it doesn't think a window is always up
  168. EndIf
  169. Else
  170. Sleep(10)
  171. MouseClick("middle",Round(1100*$x_ratio),Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  172. Sleep(200)
  173. Send("1")
  174. Sleep(620)
  175. Send("2")
  176. Sleep(40)
  177. Send("t")
  178. Sleep($tptime)
  179. Call("RandomSleep")
  180. Call("CheckDead")
  181. If Not $Logout And Not $Dead And Not $Window Then
  182. Sleep(300)
  183. Send("{ESCAPE}") ;menu
  184. Sleep(200)
  185. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  186. Sleep($loadtime)
  187. Call("CheckDead")
  188. If Not $Logout Then
  189. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  190. Sleep($loadtime)
  191. EndIf
  192. Else
  193. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  194. Sleep($loadtime)
  195. $Window = False ; reset the flag so it doesn't think a window is always up
  196. EndIf
  197. EndIf
  198. EndIf
  199. WEnd
  200. Call("RestartRun")
  201. EndFunc
  202.  
  203. Func CheckDead()
  204. Call("CheckWindow")
  205. $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"
  206. If Not @error Then
  207. If Not $Window Then
  208. $Dead = True
  209. Sleep(100)
  210. Send("{Escape}")
  211. Sleep(10)
  212. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  213. Sleep(11000)
  214. Sleep($loadtime)
  215. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  216. Sleep($loadtime)
  217. Else
  218. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  219. Sleep($loadtime)
  220. $Dead = False
  221. EndIf
  222. Else
  223. $Dead = False
  224. EndIf
  225. $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
  226. If Not @error Then
  227. Sleep(11000)
  228. Sleep($loadtime)
  229. If Not $Window Then
  230. $Dead = True
  231. $Logout = True
  232. Sleep($loadtime)
  233. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  234. Sleep($loadtime)
  235. Else
  236. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  237. Sleep($loadtime)
  238. $Logout = False
  239. EndIf
  240. Else
  241. $Logout = False
  242. EndIf
  243. EndFunc
  244.  
  245. Func CheckWindow()
  246. $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
  247. If Not @error Then
  248. Sleep(200)
  249. Send("{SPACE}") ;close any open windows
  250. $Window = True
  251. Else
  252. $Window = False
  253. EndIf
  254. EndFunc
  255.  
  256. Func CheckExit()
  257. $ExitButton = PixelSearch(Round(1190*$x_ratio), Round(400*$y_ratio), Round(1200*$x_ratio), Round(440*$y_ratio), 0x14100E) ; checks for the grey border of the exit prompt
  258. If Not @error Then
  259. Send("{ESCAPE}")
  260. Sleep(100)
  261. Send("{SPACE}") ;close any open windows
  262. Sleep(200)
  263. MouseMove(1,1) ; reset cursor position before checking for button
  264. $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
  265. If $Resume == "400900" Or $Resume == "380900" Then
  266. Sleep(200)
  267. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  268. Sleep($loadtime)
  269. EndIf
  270. EndIf
  271. EndFunc
  272.  
  273. Func CheckRepair()
  274. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  275. If Not @error Then
  276. Call("DoRepair")
  277. EndIf
  278. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  279. If Not @error Then
  280. Call("DoRepair")
  281. EndIf
  282. EndFunc
  283.  
  284. Func DoRepair()
  285. Sleep(100)
  286. Send("t")
  287. Sleep($tptime)
  288. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  289. Sleep(1500)
  290. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  291. Sleep(1500)
  292. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  293. Sleep(1200)
  294. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  295. Sleep(400)
  296. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  297. Sleep(200)
  298. Call("CheckDead")
  299. If Not $Dead and Not $Logout Then
  300. Send("{ESCAPE}") ;closes repair tab
  301. Sleep(100)
  302. Send("{ESCAPE}") ;menu
  303. Sleep(10)
  304. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  305. Sleep($loadtime)
  306. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  307. Sleep($loadtime)
  308. EndIf
  309. EndFunc
  310.  
  311. Func CheckLoot()
  312. Sleep(Random(500,2000))
  313. If Not $ImgLoot Then
  314. $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  315. If Not @error Then
  316. MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
  317. Sleep(Random(1000,1200))
  318. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  319. $i+= 1
  320. If $i <= 6 Then
  321. Call("CheckLoot")
  322. EndIf
  323. EndIf
  324. $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  325. If Not @error Then
  326. MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
  327. Sleep(Random(1000,1200))
  328. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  329. $i+= 1
  330. If $i <= 6 Then
  331. Call("CheckLoot")
  332. EndIf
  333. EndIf
  334. If $LootRares Then
  335. $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  336. If Not @error Then
  337. MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
  338. Sleep(Random(1000,1200))
  339. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  340. $i+= 1
  341. If $i <= 6 Then
  342. Call("CheckLoot")
  343. EndIf
  344. EndIf
  345. EndIf
  346. Else
  347. Call("pickItems")
  348. EndIf
  349. EndFunc
  350.  
  351. Func pickItems()
  352. $currentArrayItem = 0
  353. For $gI = 0 to ($totalItems - 1)
  354. $array = StringSplit($pick[$gI],"|")
  355. $file = $array[1]
  356. $accuracy = $array[2]
  357. $urlString = $directory & $file
  358. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  359. While $i <= 12 ; max: 13 gems and pieces of gear to loot
  360. If $Target And ($gX > 15) And ($gY > 15) Then
  361. ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
  362. MouseClick("left", $gX, $gY, 1, 0)
  363. Sleep(Random(1200,1400))
  364. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  365. Sleep(5)
  366. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  367. $i+= 1
  368. Else
  369. ExitLoop
  370. EndIf
  371. WEnd
  372. Next
  373. EndFunc
  374.  
  375. Func RandomSleep()
  376. If $Timer And Random(1,20) = 20 Then
  377. Sleep(Random(30000,60000)
  378. EndIf
  379. EndFunc
  380.  
  381. Func Pause()
  382. $Leave = False
  383. EndFunc
  384.  
  385. Func Stop() ;to allow the script to stop
  386. Exit
  387. EndFunc
  388.  
  389. Func Leave()
  390. $Leave = True
  391. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment