Guest User

Untitled

a guest
Jun 10th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.57 KB | None | 0 0
  1. #cs ----------------------------------------------------------------------------
  2.  
  3. AutoIt Version: 3.3.8.1
  4. Author: myName
  5.  
  6. Script Function:
  7. Template AutoIt script.
  8.  
  9. #ce ----------------------------------------------------------------------------
  10.  
  11. ; Script Start - Add your code below here
  12. ;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
  13. ;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkarth-dh-gold-script-autoit-script-1920x1080.html
  14. ;Please notice I changed some variable names around and added a variable for teleport time. $waittime is now appropriately named $loadtime.
  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% (10% boots + 15% passive 'Hot Pursuit')
  18. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  19. ;Official supported resolution: 1920x1080
  20. ;;;;;
  21. ;Features:
  22. ;Loot scanning. Will only pick up rare/legendary/set pieces [IMPROVED]
  23. ;Randomized aiming coordinates (but still static path)
  24. ;Randomized pickup timers for variation in runs
  25. ;Automatic repair on yellow status icon
  26. ;Automatic resolution adjustment (16:9 only) [BUGGY - need someone to tweak coords]
  27. ;Death check
  28. ;Open window check (in rare case it gets stuck in menu)
  29. ;;;;;
  30. ;Original:
  31. ;[Goldfarming] AFK 150k-200k Gold Per Hour by mackus101 @ ownedcore
  32.  
  33. #include <ImageSearch.au3>
  34.  
  35. Global $Paused
  36. HotKeySet("=","Leave") ;script started by pressing =
  37. HotKeySet("-", "Pause") ;script paused by pressing -
  38. HotKeySet("x", "Stop") ;script stopped by pressing x
  39. HotKeySet("c", "pickItems") ;for devs: triggers Func (gem)
  40.  
  41. $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
  42. $loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  43. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  44. $yellow = 0xFFF000 ; yellow color code (repair icon)
  45. $red = 0xD90000 ; red color code (repair icon)
  46.  
  47. $pickItems = True ; Change this to true if you want to pick up gems (messy, can fill up bag with whites/blues)
  48. $Amethyst = 0xAC7FFF
  49. $Ruby = 0xB01D2D
  50. $Emerald = 0x58EE33
  51. $Topaz = 0xFFFF59
  52.  
  53. $go = True
  54. $Leave = False
  55. $Dead = False
  56. $Logout = False
  57. $Window = False
  58. $default_resolutionX = 1920
  59. $default_resolutionY = 1080
  60. $x_ratio = @Desktopwidth / $default_resolutionX
  61. $y_ratio = @Desktopheight / $default_resolutionY
  62. $i = 0
  63.  
  64. ;imgSearch vars
  65. $totalItems = 2
  66. $currentArrayItem = 0
  67. $gX = 0
  68. $gY = 0
  69.  
  70. Global $pick[$totalItems]
  71. $pick[0] = "square.png"
  72. $pick[1] = "tome.png"
  73.  
  74. Call("RestartRun")
  75.  
  76. Func RestartRun()
  77. While $go
  78. if($Leave) Then
  79. $i = 0
  80. Sleep(800) ;had to add this since the icon doesn't show up RIGHT away in game
  81. Call("CheckDead")
  82. Call("CheckRepair")
  83. If $Window Then
  84. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  85. Sleep($loadtime)
  86. $Window = False
  87. ExitLoop
  88. ElseIf $Dead or $Logout Then
  89. ExitLoop
  90. EndIf
  91. MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
  92. Sleep(900)
  93. Send("2")
  94. Sleep(250)
  95. MouseClick("middle", 1, Round(370*$y_ratio)) ;waits ~1 second then [waypoint 2]
  96. Sleep(1500)
  97. MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard [waypoint 3]
  98. Sleep(40)
  99. Send("2")
  100. Sleep(20)
  101. Send("3")
  102. Sleep(600)
  103. Send("1")
  104. Sleep(300)
  105. MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  106. Sleep(790)
  107. Call("CheckDead")
  108. If $Window Then
  109. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  110. Sleep($loadtime)
  111. $Window = False
  112. ExitLoop
  113. ElseIf $Dead or $Logout Then
  114. ExitLoop
  115. EndIf
  116. $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)
  117. If Not @error Then
  118. MouseClick("left",Round(300*$x_ratio),Round(100*$y_ratio)) ;Entrance to cellar
  119. Sleep(300)
  120. Send("2")
  121. Sleep($walktime)
  122. MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  123. Sleep(2500)
  124. MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  125. Sleep(10)
  126. Send("{SHIFTDOWN}")
  127. MouseDown("right") ;attack middle
  128. Sleep(1200)
  129. Send("4")
  130. Sleep(3000)
  131. MouseUp("right")
  132. MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  133. MouseMove(Round(240*$x_ratio),Round(75*$y_ratio),1) ;attack left
  134. Sleep(40)
  135. MouseDown("right")
  136. Sleep(2800)
  137. MouseUp("right")
  138. MouseMove(Round(590*$x_ratio),Round(50*$y_ratio),1) ;attack right
  139. MouseDown("right")
  140. Sleep(1800)
  141. MouseUp("right")
  142. MouseDown("left")
  143. MouseMove(Round(Random(240,260)*$x_ratio),Round(75*$y_ratio),1) ;attack left
  144. Sleep(1200)
  145. MouseMove(Round(Random(560,600)*$x_ratio),Round(50*$y_ratio),1) ;attack right
  146. Sleep(1200)
  147. MouseUP("left")
  148. Sleep(10)
  149. MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  150. Sleep(10)
  151. Send("{SHIFTUP}")
  152. Sleep(400)
  153. MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  154. Sleep(2100)
  155. MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
  156. Sleep(1100)
  157. MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
  158. Sleep(1100)
  159. Send("4")
  160. MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
  161. Call("CheckLoot")
  162. Send("t")
  163. Sleep($tptime)
  164. Call("CheckDead")
  165. If Not $Logout And Not $Dead And Not $Window Then
  166. Sleep(300)
  167. Send("{ESCAPE}") ;menu
  168. Sleep(200)
  169. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  170. Sleep($loadtime)
  171. Call("CheckDead")
  172. If Not $Logout Then
  173. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  174. Sleep($loadtime)
  175. EndIf
  176. Else
  177. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  178. Sleep($loadtime)
  179. $Window = False ; reset the flag so it doesn't think a window is always up
  180. EndIf
  181. Else
  182. Sleep(10)
  183. MouseClick("middle",Round(1100*$x_ratio),Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  184. Sleep(200)
  185. Send("1")
  186. Sleep(620)
  187. Send("2")
  188. Sleep(40)
  189. Send("t")
  190. Sleep($tptime)
  191. Call("CheckDead")
  192. If Not $Logout And Not $Dead And Not $Window Then
  193. Sleep(300)
  194. Send("{ESCAPE}") ;menu
  195. Sleep(200)
  196. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  197. Sleep($loadtime)
  198. Call("CheckDead")
  199. If Not $Logout Then
  200. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  201. Sleep($loadtime)
  202. EndIf
  203. Else
  204. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  205. Sleep($loadtime)
  206. $Window = False ; reset the flag so it doesn't think a window is always up
  207. EndIf
  208. EndIf
  209. EndIf
  210. WEnd
  211. Call("RestartRun")
  212. EndFunc
  213.  
  214. Func CheckDead()
  215. Call("CheckWindow")
  216. $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"
  217. If Not @error Then
  218. If Not $Window Then
  219. $Dead = True
  220. Sleep(100)
  221. Send("{Escape}")
  222. Sleep(10)
  223. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  224. Sleep(11000)
  225. Sleep($loadtime)
  226. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  227. Sleep($loadtime)
  228. Else
  229. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  230. Sleep($loadtime)
  231. $Dead = False
  232. EndIf
  233. Else
  234. $Dead = False
  235. EndIf
  236. $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
  237. If Not @error Then
  238. Sleep(11000)
  239. Sleep($loadtime)
  240. If Not $Window Then
  241. $Dead = True
  242. $Logout = True
  243. Sleep($loadtime)
  244. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  245. Sleep($loadtime)
  246. Else
  247. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  248. Sleep($loadtime)
  249. $Logout = False
  250. EndIf
  251. Else
  252. $Logout = False
  253. EndIf
  254. EndFunc
  255.  
  256. Func CheckWindow()
  257. $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
  258. If Not @error Then
  259. Sleep(200)
  260. Send("{SPACE}") ;close any open windows
  261. $Window = True
  262. Else
  263. $Window = False
  264. EndIf
  265. EndFunc
  266.  
  267. Func CheckRepair()
  268. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  269. If Not @error Then
  270. Call("DoRepair")
  271. EndIf
  272. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  273. If Not @error Then
  274. Call("DoRepair")
  275. EndIf
  276. EndFunc
  277.  
  278. Func DoRepair()
  279. Sleep(100)
  280. Send("t")
  281. Sleep($tptime)
  282. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  283. Sleep(1500)
  284. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  285. Sleep(1500)
  286. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  287. Sleep(1200)
  288. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  289. Sleep(400)
  290. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  291. Sleep(200)
  292. Call("CheckDead")
  293. If Not $Dead and Not $Logout Then
  294. Send("{ESCAPE}") ;closes repair tab
  295. Sleep(100)
  296. Send("{ESCAPE}") ;menu
  297. Sleep(10)
  298. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  299. Sleep($loadtime)
  300. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  301. Sleep($loadtime)
  302. EndIf
  303. EndFunc
  304.  
  305. Func CheckLoot()
  306. Sleep(Random(500,2000))
  307. If $pickItems Then
  308. pickItems()
  309. EndIf
  310. EndFunc
  311.  
  312. Func Pause()
  313. $Leave = False
  314. EndFunc
  315.  
  316. Func Stop() ;to allow the script to stop
  317. Exit
  318. EndFunc
  319.  
  320. Func Leave()
  321. $Leave = True
  322. EndFunc
  323.  
  324. Func pickItems()
  325. $currentArrayItem = 0
  326. for $i = 0 to ($totalItems - 1)
  327. $urlString = "C:\Users\army\Desktop\D3img\" & $pick[$i]
  328. $Search = _ImageSearchArea($urlString,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,100)
  329. while $search = 1
  330. if $search = 1 then
  331. MouseMove($gX, $gY, 3)
  332. Sleep(100)
  333. MouseClick("left",$gX,$gY,1,1)
  334. sleep(1200)
  335. $Search = _ImageSearchArea($urlString,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,100)
  336. Else
  337. EndIf
  338. wend
  339. next
  340. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment