Guest User

Wizard Sarkoth with Logs

a guest
Jun 13th, 2012
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.02 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. Global $Paused
  23. HotKeySet("=","Leave") ;script started by pressing =
  24. HotKeySet("-", "Pause") ;script paused by pressing -
  25. HotKeySet("x", "Stop") ;script stopped by pressing x
  26.  
  27. $startHour = @HOUR
  28. $startMin = @MIN
  29. $runsPerHour = 0
  30.  
  31. $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
  32. $loadtime = 4000 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  33. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  34. $yellow = 0xFFF000 ; yellow color code (repair icon)
  35. $red = 0xD90000 ; red color code (repair icon)
  36. $blueInventory = 0x161D35
  37. $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)
  38. $LootBlues = True
  39. $LootGems = False ; Change this to true if you want to pick up gems (messy, can fill up bag with whites/blues)
  40.  
  41. $MaxBluesBeforeSell = 10
  42. $Amethyst = 0xAC7FFF
  43. $Ruby = 0xB01D2D
  44. $Emerald = 0x58EE33
  45. $Topaz = 0xFFFF59
  46.  
  47. $go = True
  48. $Leave = False
  49. $Dead = False
  50. $Logout = False
  51. $Window = False
  52. $default_resolutionX = 1920
  53. $default_resolutionY = 1080
  54. $x_ratio = @Desktopwidth / $default_resolutionX
  55. $y_ratio = @Desktopheight / $default_resolutionY
  56. $i = 0
  57. $runsSinceLastSell = 0
  58.  
  59. $statsFile = FileOpen("runStats.txt", 0)
  60. if $statsFile = -1 Then
  61. $runCount = 0
  62. $repairCount = 0
  63. $bluesPickedUpCount = 0
  64. $deathCount = 0
  65. $overallBlueCount = 0
  66. $cellarClosedCount = 0
  67. $overallRareCount = 0
  68. Else
  69. $runCount = FileReadLine($statsFile)
  70. $repairCount = FileReadLine($statsFile)
  71. $bluesPickedUpCount = FileReadLine($statsFile)
  72. $deathCount = FileReadLine($statsFile)
  73. $overallBlueCount = FileReadLine($statsFile)
  74. $cellarClosedCount = FileReadLine($statsFile)
  75. $overallRareCount = FileReadLine($statsFile)
  76. EndIf
  77.  
  78. FileClose($statsFile)
  79.  
  80. Call("RestartRun")
  81.  
  82. Func RestartRun()
  83. While $go
  84. if($Leave) Then
  85. $i = 0
  86. Sleep(1000) ;had to add this since the icon doesn't show up RIGHT away in game
  87. CalculateRPH()
  88. Call("CheckDead")
  89. Call("CheckRepair")
  90. if $bluesPickedUpCount >= $MaxBluesBeforeSell and $LootBlues Then
  91. Call("DoSellBlues")
  92. EndIf
  93. If $Window Then
  94. MouseClick("left", Round(230*$x_ratio),Round(416*$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. MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  102. Send("{4 down}")
  103. Sleep(2500)
  104. Send("{4 up}")
  105. Sleep(80)
  106. Send("1")
  107. Send("3")
  108. Sleep(500)
  109. MouseMove(Round(255*$x_ratio),Round(290*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  110. Sleep(300)
  111. Call("CheckDead")
  112. If $Window Then
  113. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  114. Sleep($loadtime)
  115. $Window = False
  116. ExitLoop
  117. ElseIf $Dead or $Logout Then
  118. ExitLoop
  119. EndIf
  120. $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,5); ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
  121. If Not @error Then
  122. MouseClick("left",Round(255*$x_ratio),Round(290*$y_ratio)) ;Entrance to cellar
  123. Sleep(400)
  124. Sleep($walktime)
  125. MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  126. Sleep(2500)
  127. MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  128. Sleep(10)
  129. Send("{SHIFTDOWN}")
  130. MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  131. MouseDown("right") ;attack middle
  132. Sleep(12000)
  133. MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  134. Sleep(10)
  135. Send("{SHIFTUP}")
  136. Sleep(400)
  137. MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  138. sleep(2000)
  139. Call("CheckLoot")
  140. Send("t")
  141. $runCount += 1
  142. Sleep($tptime)
  143. Call("CheckDead")
  144. If Not $Logout And Not $Dead And Not $Window Then
  145. Sleep(300)
  146. Send("{ESCAPE}") ;menu
  147. Sleep(200)
  148. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  149. Sleep($loadtime)
  150. Call("CheckDead")
  151. If Not $Logout Then
  152. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  153. Sleep($loadtime)
  154. EndIf
  155. Else
  156. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  157. Sleep($loadtime)
  158. $Window = False ; reset the flag so it doesn't think a window is always up
  159. EndIf
  160. Else
  161. $cellarClosedCount += 1
  162. Send("2")
  163. Sleep(700)
  164. Send("t")
  165. Sleep($tptime)
  166. Call("CheckDead")
  167. If Not $Logout And Not $Dead And Not $Window Then
  168. Sleep(300)
  169. Send("{ESCAPE}") ;menu
  170. Sleep(200)
  171. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  172. Sleep($loadtime)
  173. Call("CheckDead")
  174. If Not $Logout Then
  175. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  176. Sleep($loadtime)
  177. EndIf
  178. Else
  179. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  180. Sleep($loadtime)
  181. $Window = False ; reset the flag so it doesn't think a window is always up
  182. EndIf
  183. EndIf
  184. EndIf
  185. WEnd
  186. Call("RestartRun")
  187. EndFunc
  188.  
  189. Func CheckDead()
  190. Call("CheckWindow")
  191. ToolTip("Successful Runs: " & $runCount & @CR & "Closed Cellar Runs: " & $cellarClosedCount & @CR &"Deaths: " & $deathCount & " Repairs: " & $repairCount & @CR & "Blues: " & $overallBlueCount & " Rares: " & $overallRareCount & @CR & "(BETA)Runs per hour: " &$runsPerHour,0,0,"Tadgh's Bot stats v0.1",1)
  192. $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"
  193. If Not @error Then
  194. If Not $Window Then
  195. $Dead = True
  196. $deathCount += 1
  197. Sleep(100)
  198. Send("{Escape}")
  199. Sleep(10)
  200. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  201. Sleep(11000)
  202. Sleep($loadtime)
  203. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  204. Sleep($loadtime)
  205. Else
  206. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  207. Sleep($loadtime)
  208. $Dead = False
  209. EndIf
  210. Else
  211. $Dead = False
  212. EndIf
  213. $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
  214. If Not @error Then
  215. Sleep(11000)
  216. Sleep($loadtime)
  217. If Not $Window Then
  218. $Dead = True
  219. $Logout = True
  220. Sleep($loadtime)
  221. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  222. Sleep($loadtime)
  223. Else
  224. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  225. Sleep($loadtime)
  226. $Logout = False
  227. EndIf
  228. Else
  229. $Logout = False
  230. EndIf
  231. EndFunc
  232.  
  233. Func CheckWindow()
  234. $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
  235. If Not @error Then
  236. Sleep(200)
  237. Send("{SPACE}") ;close any open windows
  238. $Window = True
  239. Else
  240. $Window = False
  241. EndIf
  242. EndFunc
  243.  
  244. Func CheckRepair()
  245. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  246. If Not @error Then
  247. Call("DoRepair")
  248. $repairCount += 1
  249. EndIf
  250. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  251. If Not @error Then
  252. Call("DoRepair")
  253. $repairCount +=1
  254. EndIf
  255. EndFunc
  256.  
  257.  
  258. Func DoSellBlues()
  259. Sleep(100)
  260. Send("t")
  261. Sleep($tptime)
  262. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  263. Sleep(1500)
  264. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  265. Sleep(1500)
  266. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  267. Sleep(1200)
  268. ;Send("i")
  269. For $xInv = 1417 To 1894 Step 48
  270. For $yInv = 588 To 825 Step 48
  271. $bluePixel = PixelSearch(Round($xInv * $x_ratio),Round($yInv*$y_ratio),Round(($xInv + 48)*$x_ratio),Round($yInv +48*$y_ratio), $blueInventory,15)
  272. If @error Then
  273. sleep(100)
  274. Else
  275. MouseClick("right", $bluePixel[0], $bluePixel[1])
  276. sleep(100)
  277. EndIf
  278. Next
  279. Next
  280. $bluesPickedUpCount = 0
  281. Call("CheckDead")
  282. If Not $Dead and Not $Logout Then
  283. Send("{ESCAPE}") ;closes repair tab
  284. Sleep(100)
  285. Send("{ESCAPE}") ;menu
  286. Sleep(10)
  287. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  288. Sleep($loadtime)
  289. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  290. Sleep($loadtime)
  291. EndIf
  292. EndFunc
  293.  
  294. Func DoRepair()
  295. Sleep(100)
  296. Send("t")
  297. Sleep($tptime)
  298. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  299. Sleep(1500)
  300. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  301. Sleep(1500)
  302. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  303. Sleep(1200)
  304. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  305. Sleep(400)
  306. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  307. Sleep(200)
  308.  
  309. Call("CheckDead")
  310. If Not $Dead and Not $Logout Then
  311. Send("{ESCAPE}") ;closes repair tab
  312. Sleep(100)
  313. Send("{ESCAPE}") ;menu
  314. Sleep(10)
  315. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  316. Sleep($loadtime)
  317. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  318. Sleep($loadtime)
  319. EndIf
  320. EndFunc
  321.  
  322. Func CheckLoot()
  323. Sleep(Random(500,2000))
  324. $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  325. If Not @error Then
  326. MouseClick ('left', $SetLoot[0], $SetLoot[1])
  327. Sleep(Random(800,1200))
  328. $i+= 1
  329. If $i <= 6 Then
  330. Call("CheckLoot")
  331. EndIf
  332.  
  333. EndIf
  334.  
  335. If $LootBlues Then
  336. $BlueLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x5555CD, 2) ; blue loot (darker for compatibility)
  337. If Not @error Then
  338. MouseClick ('left', $BlueLoot[0], $BlueLoot[1])
  339. Sleep(Random(700,900))
  340. $i+= 1
  341. $bluesPickedUpCount +=1
  342. $overallBlueCount += 1
  343. If $i <= 6 Then
  344. Call("CheckLoot")
  345. EndIf
  346. EndIf
  347. EndIf
  348.  
  349. If $LootRares Then
  350. $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  351. If Not @error Then
  352. MouseClick ('left', $RareLoot[0], $RareLoot[1])
  353. Sleep(Random(700,900))
  354. $i+= 1
  355. $overallRareCount += 1
  356. If $i <= 6 Then
  357. Call("CheckLoot")
  358. EndIf
  359. EndIf
  360. EndIf
  361.  
  362. $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  363. If Not @error Then
  364. MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1])
  365. Sleep(Random(800,1200))
  366. $i+= 1
  367. If $i <= 6 Then
  368. Call("CheckLoot")
  369. EndIf
  370. EndIf
  371.  
  372.  
  373. If $LootGems Then
  374. $AmethystDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Amethyst,8)
  375. If Not @error Then
  376. MouseClick("left", $AmethystDrop[0], $AmethystDrop[1])
  377. Sleep(Random(900,1400))
  378. $i+= 1
  379. If $i <= 10 Then
  380. Call("CheckLoot")
  381. EndIf
  382. EndIf
  383. $RubyDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Ruby,6)
  384. If Not @error Then
  385. MouseClick("left", $RubyDrop[0], $RubyDrop[1])
  386. Sleep(Random(900,1400))
  387. $i+= 1
  388. If $i <= 10 Then
  389. Call("CheckLoot")
  390. EndIf
  391. EndIf
  392. $EmeraldDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Emerald,11)
  393. If Not @error Then
  394. MouseClick("left", $EmeraldDrop[0], $EmeraldDrop[1])
  395. Sleep(Random(900,1400))
  396. $i+= 1
  397. If $i <= 10 Then
  398. Call("CheckLoot")
  399. EndIf
  400. EndIf
  401. $TopazDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Topaz,2)
  402. If Not 1 = 1 Then ; change to 'If Not @error Then' if you want to search for topazes
  403. MouseClick("left", $TopazDrop[0], $TopazDrop[1])
  404. Sleep(Random(900,1400))
  405. $i+= 1
  406. If $i <= 10 Then
  407. Call("CheckLoot")
  408. EndIf
  409. EndIf
  410. EndIf
  411. EndFunc
  412.  
  413. Func Pause()
  414. $Leave = False
  415. EndFunc
  416.  
  417. Func Stop() ;to allow the script to stop
  418. $outFile = FileOpen("runStats.txt", 10)
  419. FileWriteLine($outFile, $runCount)
  420. FileWriteLine($outFile, $repairCount)
  421. FileWriteLine($outFile, $bluesPickedUpCount)
  422. FileWriteLine($outFile, $deathCount)
  423. FileWriteLine($outFile, $overallBlueCount)
  424. FileWriteLine($outFile, $cellarClosedCount)
  425. FileWriteLine($outFile, $overallRareCount)
  426. ;FileWriteLine($outFile, $timeElapsed)
  427. FileClose($outFile)
  428. Exit
  429. EndFunc
  430.  
  431. Func CalculateRPH()
  432. $currHour = @HOUR
  433. $currMin = @MIN
  434.  
  435. if ($currHour - $startHour) == 0 Then
  436. $timeElapsed = $currMin - $startMin
  437. ElseIf $currHour - $startHour <> 0
  438. $timeElapsed = (($currHour - $startHour)*60) - ($startMin - $currMin)
  439. EndIf
  440.  
  441. $timeInHours = Round($timeElapsed / 60, 2)
  442. $runsPerHour = Round(($cellarClosedCount + $runCount) / $timeInHours)
  443.  
  444. EndFunc
  445.  
  446. Func Leave()
  447. $Leave = True
  448. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment