Advertisement
Guest User

tofuartist's Barbarian Sarkoth Script

a guest
Jun 11th, 2012
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ;IF YOU PLAN TO USE IMAGESEARCH FUNCTIONS:
  3.       ;Download: http://www.mediafire.com/?vtx9l1woj61h8r6 (1.4a new link)
  4.       ;If your Windows installation is x64, use the 64-bit native AutoIt and the x64 directory in the archive
  5.       ;Extract and copy AutoIt3 folder to Program Files directory
  6.       ;Extract and copy all dlls to C:\Windows\ directory (optionally copy the MSVCR dlls to System32 as well)
  7.       ;Extract pics directory anywhere and update the $directory var - INCLUDE TRAILING BACKSLASH: C:\pics\
  8.       ;If you are running anything but fullscreen mode, the size of letters will mismatch and not loot anything. Resize or make your own pngs.
  9. ;IF YOU COMPILE THE SCRIPT TO EXE AND YOU USE X64:
  10.       ;Run "Compile script to .exe (x64)"
  11.       ;Check "Lowest" under the Compression menu option
  12.       ;Leave x64 checkbox checked
  13. ;;;;;
  14. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  15. ;Required build: http://us.battle.net/d3/en/calculator/barbarian#WTXYQg!ZVg!abcZaY
  16. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  17. ;Official supported resolution: 1920x1080
  18. ;;;;;
  19. ;Original: [Goldfarming] AFK 150k-200k Gold Per Hour by mackus101 @ ownedcore
  20. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  21.  
  22. #include <ImageSearch.au3> ;comment this if you are not using the new looting system
  23. Global $Paused
  24. Opt('MouseCoordMode', 2)
  25. Opt('PixelCoordMode', 2)
  26. HotKeySet("=","Leave")  ;script started by pressing =
  27. HotKeySet("-", "Pause") ;script paused by pressing -
  28. HotKeySet("x", "Stop") ;script stopped by pressing x
  29.  
  30. ;ImageSearch Looting Variables
  31. $ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
  32. $directory = "C:\Program Files (x86)\AutoIt3\pics\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
  33. $totalItems = 19; This needs to match the number of pngs you are loading
  34. 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
  35. If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
  36. $pick[0] = "legendaryA.png|40"
  37. $pick[1] = "legendaryE.png|40"
  38. $pick[2] = "legendaryI.png|30"
  39. $pick[3] = "legendaryO.png|40"
  40. $pick[4] = "legendaryU.png|40"
  41. $pick[5] = "setA.png|40"
  42. $pick[6] = "setE.png|40"
  43. $pick[7] = "setU.png|40"
  44. $pick[8] = "setO.png|40"
  45. $pick[9] = "setI.png|40"
  46. $pick[10] = "rareA.png|40"
  47. $pick[11] = "rareE.png|40"
  48. $pick[12] = "rareI.png|30"
  49. $pick[13] = "rareO.png|40"
  50. $pick[14] = "rareU.png|40"
  51. $pick[15] = "ros.png|30"
  52. $pick[16] = "ans.png|30"
  53. $pick[17] = "uare.png|40"
  54. $pick[18] = "tome.png|40"
  55.  
  56. $LootRares = True ; set this to false if you don't want the bot to pick up rares (old looting method only)
  57. $Timer = False ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
  58. $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
  59. $loadtime = 3300 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  60. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  61. $x_ratio = $size[0] / 1920
  62. $y_ratio = $size[1] / 1080
  63. $yellow = 0xFFF000 ; yellow color code (repair icon)
  64. $red = 0xD90000 ; red color code (repair icon)
  65.  
  66. Call("RestartRun")
  67. Func RestartRun()
  68.    While $go
  69.       if($Leave) Then
  70.          $i = 0
  71.          Call("CheckExit")
  72.          Sleep(850) ;had to add this since the icon doesn't show up RIGHT away in game
  73.          Call("CheckDead")
  74.          Call("CheckRepair")
  75.          If $Window Then
  76.             MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  77.             Sleep($loadtime)
  78.             $Window = False
  79.             ExitLoop
  80.          ElseIf $Dead or $Logout Then
  81.             ExitLoop
  82.          EndIf
  83.          MouseClick("middle", Round(587 * $x_ratio),Round(333 * $y_ratio)) ;starts the main run
  84.          Sleep(1090)
  85.          MouseMove(Round(96*$x_ratio),Round(383*$y_ratio),1)
  86.          Sleep(10)
  87.          Send("1")
  88.          Sleep(800)
  89.          MouseClick("middle", Round(56 * $x_ratio),Round(290 * $y_ratio))
  90.          Sleep(2900)
  91.          MouseMove(Round(320*$x_ratio),Round(225*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  92.          Sleep(600)
  93.          Call("CheckDead")
  94.          If $Window Then
  95.             MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  96.             Sleep($loadtime)
  97.             $Window = False
  98.             ExitLoop
  99.          ElseIf $Dead or $Logout Then
  100.             ExitLoop
  101.          EndIf
  102.          $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)
  103.             If Not @error Then
  104.                   MouseClick("left",Round(320*$x_ratio),Round(225*$y_ratio)) ;Entrance to cellar
  105.                   Sleep(1400)
  106.                   Sleep($walktime)
  107.                   MouseClick("middle",Round(80*$x_ratio),Round(830*$y_ratio)) ;moves to doorway leading to rare inside cellar
  108.                   Sleep(2500)
  109.                   MouseMove(Round(350*$x_ratio),Round(60*$y_ratio),1) ;hovers over the rare Sarkoth
  110.                   Sleep(5)
  111.                   Send("1")
  112.                   Sleep(10)
  113.                   MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
  114.                   Sleep(140)
  115.                   MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
  116.                   Sleep(140)
  117.                   MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
  118.                   Sleep(1000)
  119.                   Send("2")
  120.                   Sleep(120)
  121.                   Send("2")
  122.                   Sleep(120)
  123.                   Send("2")
  124.                   Sleep(120)
  125.                   Send("2")
  126.                   Sleep(120)
  127.                   Send("3")
  128.                   Sleep(120)
  129.                   Send("3")
  130.                   Sleep(120)
  131.                   Send("3")
  132.                   Sleep(120)
  133.                   Send("3")
  134.                   Sleep(140)
  135.                   Send("4")
  136.                   Sleep(140)
  137.                   Send("4")
  138.                   Sleep(140)
  139.                   Send("4")
  140.                   Sleep(1700)
  141.                   MouseClick("middle",Round(750*$x_ratio),Round(555*$y_ratio)) ;move to left top corner for gold
  142.                   Sleep(1000)
  143.                   MouseClick("middle",Round(1175*$x_ratio),Round(350*$y_ratio)) ;move to right top corner for gold
  144.                   Sleep(1000)
  145.                   MouseClick("middle",Round(1020*$x_ratio),Round(773*$y_ratio)) ;move to middle before looting
  146.                   Sleep(1000)
  147.                   MouseClick("middle",Round(900*$x_ratio),Round(400*$y_ratio)) ;move to right top corner for gold
  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(40)
  171.                   Send("t")
  172.                   Sleep($tptime)
  173.                   Call("RandomSleep")
  174.                   Call("CheckDead")
  175.                   If Not $Logout And Not $Dead And Not $Window Then
  176.                      Sleep(300)
  177.                      Send("{ESCAPE}") ;menu
  178.                      Sleep(200)
  179.                      MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  180.                      Sleep($loadtime)
  181.                      Call("CheckDead")
  182.                      If Not $Logout Then
  183.                         MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  184.                         Sleep($loadtime)
  185.                      EndIf
  186.                   Else
  187.                      MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  188.                      Sleep($loadtime)
  189.                      $Window = False ; reset the flag so it doesn't think a window is always up
  190.                   EndIf
  191.             EndIf
  192.       EndIf
  193.    WEnd
  194.    Call("RestartRun")
  195. EndFunc
  196.  
  197. Func CheckDead()
  198. Call("CheckWindow")
  199. $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"
  200. If Not @error Then
  201.    If Not $Window Then
  202.       $Dead = True
  203.       Sleep(100)
  204.       Send("{Escape}")
  205.       Sleep(10)
  206.       MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  207.       Sleep(11000)
  208.       Sleep($loadtime)
  209.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  210.       Sleep($loadtime)
  211.    Else
  212.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  213.       Sleep($loadtime)
  214.       $Dead = False
  215.    EndIf
  216. Else
  217.    $Dead = False
  218. EndIf
  219. $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
  220. If Not @error Then
  221.    Sleep(11000)
  222.    Sleep($loadtime)
  223.    If Not $Window Then
  224.       $Dead = True
  225.       $Logout = True
  226.       Sleep($loadtime)
  227.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  228.       Sleep($loadtime)
  229.    Else
  230.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  231.       Sleep($loadtime)
  232.       $Logout = False
  233.    EndIf
  234. Else
  235.    $Logout = False
  236. EndIf
  237. EndFunc
  238.  
  239. Func CheckWindow()
  240. $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
  241. If Not @error Then
  242.    Sleep(200)
  243.    Send("{SPACE}") ;close any open windows
  244.    $Window = True
  245. Else
  246.    $Window = False
  247. EndIf
  248. EndFunc
  249.  
  250. Func CheckExit()
  251. $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
  252. If Not @error Then
  253.    Send("{ESCAPE}")
  254.    Sleep(100)
  255.    Send("{SPACE}") ;close any open windows
  256.    Sleep(200)
  257.    MouseMove(1,1) ; reset cursor position before checking for button
  258.    $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
  259.    If $Resume == "400900" Or $Resume == "380900" Then
  260.       Sleep(200)
  261.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  262.       Sleep($loadtime)
  263.    EndIf
  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(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  299.    Sleep($loadtime)
  300.    MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  301.    Sleep($loadtime)
  302. EndIf
  303. EndFunc
  304.  
  305. Func CheckLoot()
  306. MouseMove(14,14,0)
  307. Sleep(Random(500,2000))
  308. If Not $ImgLoot Then
  309.    $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  310.    If Not @error Then
  311.       MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
  312.       Sleep(Random(1000,1200))
  313.       MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  314.       $i+= 1
  315.       If $i <= 6 Then
  316.          Call("CheckLoot")
  317.       EndIf
  318.    EndIf
  319.    $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  320.    If Not @error Then
  321.       MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
  322.       Sleep(Random(1000,1200))
  323.       MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  324.       $i+= 1
  325.       If $i <= 6 Then
  326.          Call("CheckLoot")
  327.       EndIf
  328.    EndIf
  329.    If $LootRares Then
  330.       $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  331.       If Not @error Then
  332.          MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
  333.          Sleep(Random(1000,1200))
  334.          MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  335.          $i+= 1
  336.          If $i <= 6 Then
  337.             Call("CheckLoot")
  338.          EndIf
  339.       EndIf
  340.    EndIf
  341. Else
  342.    Call("pickItems")
  343. EndIf
  344. EndFunc
  345.  
  346. Func pickItems()
  347. $currentArrayItem = 0
  348. For $gI = 0 to ($totalItems - 1)
  349.    $array = StringSplit($pick[$gI],"|")
  350.    $file = $array[1]
  351.    $accuracy = $array[2]
  352.    $urlString = $directory & $file
  353.    $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  354.    While $i <= 12 ; max: 13 gems and pieces of gear to loot
  355.       If $Target And ($gX > 15) And ($gY > 15) Then
  356.          ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
  357.          MouseClick("left", $gX, $gY, 1, 0)
  358.          Sleep(Random(1200,1400))
  359.          MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  360.          Sleep(5)
  361.          $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  362.          $i+= 1
  363.       Else
  364.          ExitLoop
  365.       EndIf
  366.    WEnd
  367. Next
  368. EndFunc
  369.  
  370. Func RandomSleep()
  371.    If $Timer And Random(1,20) = 20 Then
  372.       Sleep(Random(30000,60000)
  373.    EndIf
  374. EndFunc
  375.  
  376. Func Pause()
  377.    $Leave = False
  378. EndFunc
  379.  
  380. Func Stop() ;to allow the script to stop
  381.     Exit
  382. EndFunc
  383.  
  384. Func Leave()
  385.    $Leave = True
  386. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement