Guest User

Untitled

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