Advertisement
goofinator

Untitled

Jun 9th, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 12.62 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. #include <ImageSearch.au3>
  23.  
  24. Global $Paused
  25. HotKeySet("=","Leave")  ;script started by pressing =
  26. HotKeySet("-", "Pause") ;script paused by pressing -
  27. HotKeySet("x", "Stop") ;script stopped by pressing x
  28.  
  29. $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
  30. $loadtime = 4000 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  31. $tptime =   6900 ; time in ms the script waits for teleport before exiting the game
  32. $yellow =   0xFFF000 ; yellow color code (repair icon)
  33. $red =      0xD90000 ; red color code (repair icon)
  34.  
  35.  
  36. $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)
  37. $LootGems = True ; Change this to true if you want to pick up gems (messy, can fill up bag with whites/blues)
  38. $Amethyst = 0xAC7FFF
  39. $Ruby = 0xB01D2D
  40. $Emerald = 0x58EE33
  41. $Topaz = 0xFFFF59
  42.  
  43. $go = True
  44. $Leave = False
  45. $Dead = False
  46. $Logout = False
  47. $Window = False
  48. $default_resolutionX = 1920
  49. $default_resolutionY = 1080
  50. $x_ratio = @Desktopwidth / $default_resolutionX
  51. $y_ratio = @Desktopheight / $default_resolutionY
  52. $i = 0
  53.  
  54. $currentArrayItem = 0
  55. $totalItems = 2 ;you need to change this to the number of items in the array
  56. $gX = 0
  57. $gY = 0
  58.  
  59. Global $pick[$totalItems] ;change the 3 to the amount of items in your array
  60. $pick[0] = "tome.png" ;this is self explanatory
  61. $pick[1] = "uare.png"
  62. $urlString = ""
  63.  
  64. Call("RestartRun")
  65.  
  66. Func RestartRun()
  67.    While $go
  68.       if($Leave) Then
  69.          $i = 0
  70.          Sleep(800) ;had to add this since the icon doesn't show up RIGHT away in game
  71.          Call("CheckDead")
  72.          Call("CheckRepair")
  73.          If $Window Then
  74.             MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  75.             Sleep($loadtime)
  76.             $Window = False
  77.             ExitLoop
  78.          ElseIf $Dead or $Logout Then
  79.             ExitLoop
  80.          EndIf
  81.          MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
  82.          Sleep(900)
  83.          Send("2")
  84.          Sleep(250)
  85.          MouseClick("middle", 1, Round(370*$y_ratio)) ;waits ~1 second then [waypoint 2]
  86.          Sleep(1500)
  87.          MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard [waypoint 3]
  88.          Sleep(40)
  89.          Send("2")
  90.          Sleep(20)
  91.          Send("3")
  92.          Sleep(600)
  93.          Send("1")
  94.          Sleep(300)
  95.          MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  96.          Sleep(790)
  97.          Call("CheckDead")
  98.          If $Window Then
  99.             MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  100.             Sleep($loadtime)
  101.             $Window = False
  102.             ExitLoop
  103.          ElseIf $Dead or $Logout Then
  104.             ExitLoop
  105.          EndIf
  106.          $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)
  107.                If Not @error Then
  108.                   MouseClick("left",Round(300*$x_ratio),Round(100*$y_ratio)) ;Entrance to cellar
  109.                   Sleep(300)
  110.                   Send("2")
  111.                   Sleep($walktime)
  112.                   MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  113.                   Sleep(2500)
  114.                   MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  115.                   Sleep(10)
  116.                   Send("{SHIFTDOWN}")
  117.                   MouseDown("right") ;attack middle
  118.                   Sleep(1200)
  119.                   Send("4")
  120.                   Sleep(3000)
  121.                   MouseUp("right")
  122.                   MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  123.                   MouseMove(Round(240*$x_ratio),Round(75*$y_ratio),1) ;attack left
  124.                   Sleep(40)
  125.                   MouseDown("right")
  126.                   Sleep(2800)
  127.                   MouseUp("right")
  128.                   MouseMove(Round(590*$x_ratio),Round(50*$y_ratio),1) ;attack right
  129.                   MouseDown("right")
  130.                   Sleep(1800)
  131.                   MouseUp("right")
  132.                   MouseDown("left")
  133.                   MouseMove(Round(Random(240,260)*$x_ratio),Round(75*$y_ratio),1) ;attack left
  134.                   Sleep(1200)
  135.                   MouseMove(Round(Random(560,600)*$x_ratio),Round(50*$y_ratio),1) ;attack right
  136.                   Sleep(1200)
  137.                   MouseUP("left")
  138.                   Sleep(10)
  139.                   MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  140.                   Sleep(10)
  141.                   Send("{SHIFTUP}")
  142.                   Sleep(400)
  143.                   MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  144.                   Sleep(2100)
  145.                   MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
  146.                   Sleep(1100)
  147.                   MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
  148.                   Sleep(1100)
  149.                   Send("4")
  150.                   MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
  151.                   Call("CheckLoot")
  152.                   Send("t")
  153.                   Sleep($tptime)
  154.                   Call("CheckDead")
  155.                   If Not $Logout And Not $Dead And Not $Window Then
  156.                      Sleep(300)
  157.                      Send("{ESCAPE}") ;menu
  158.                      Sleep(200)
  159.                      MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  160.                      Sleep($loadtime)
  161.                      Call("CheckDead")
  162.                      If Not $Logout Then
  163.                         MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  164.                         Sleep($loadtime)
  165.                      EndIf
  166.                   Else
  167.                      MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  168.                      Sleep($loadtime)
  169.                      $Window = False ; reset the flag so it doesn't think a window is always up
  170.                   EndIf
  171.                Else
  172.                   Sleep(10)
  173.                   MouseClick("middle",Round(1100*$x_ratio),Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  174.                   Sleep(200)
  175.                   Send("1")
  176.                   Sleep(620)
  177.                   Send("2")
  178.                   Sleep(40)
  179.                   Send("t")
  180.                   Sleep($tptime)
  181.                   Call("CheckDead")
  182.                   If Not $Logout And Not $Dead And Not $Window Then
  183.                      Sleep(300)
  184.                      Send("{ESCAPE}") ;menu
  185.                      Sleep(200)
  186.                      MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  187.                      Sleep($loadtime)
  188.                      Call("CheckDead")
  189.                      If Not $Logout Then
  190.                         MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  191.                         Sleep($loadtime)
  192.                      EndIf
  193.                   Else
  194.                      MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  195.                      Sleep($loadtime)
  196.                      $Window = False ; reset the flag so it doesn't think a window is always up
  197.                   EndIf
  198.             EndIf
  199.       EndIf
  200.    WEnd
  201.    Call("RestartRun")
  202. EndFunc
  203.  
  204. Func CheckDead()
  205. Call("CheckWindow")
  206. $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"
  207. If Not @error Then
  208.    If Not $Window Then
  209.       $Dead = True
  210.       Sleep(100)
  211.       Send("{Escape}")
  212.       Sleep(10)
  213.       MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  214.       Sleep(11000)
  215.       Sleep($loadtime)
  216.       MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  217.       Sleep($loadtime)
  218.    Else
  219.       MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  220.       Sleep($loadtime)
  221.       $Dead = False
  222.    EndIf
  223. Else
  224.    $Dead = False
  225. EndIf
  226. $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
  227. If Not @error Then
  228.    Sleep(11000)
  229.    Sleep($loadtime)
  230.    If Not $Window Then
  231.       $Dead = True
  232.       $Logout = True
  233.       Sleep($loadtime)
  234.       MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  235.       Sleep($loadtime)
  236.    Else
  237.       MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  238.       Sleep($loadtime)
  239.       $Logout = False
  240.    EndIf
  241. Else
  242.    $Logout = False
  243. EndIf
  244. EndFunc
  245.  
  246. Func CheckWindow()
  247. $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
  248. If Not @error Then
  249.    Sleep(200)
  250.    Send("{SPACE}") ;close any open windows
  251.    $Window = True
  252. Else
  253.    $Window = False
  254. EndIf
  255. EndFunc
  256.  
  257. Func CheckRepair()
  258. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  259.    If Not @error Then
  260.       Call("DoRepair")
  261.    EndIf
  262. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  263.    If Not @error Then
  264.       Call("DoRepair")
  265.    EndIf
  266. EndFunc
  267.  
  268. Func DoRepair()
  269. Sleep(100)
  270. Send("t")
  271. Sleep($tptime)
  272. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  273. Sleep(1500)
  274. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  275. Sleep(1500)
  276. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  277. Sleep(1200)
  278. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  279. Sleep(400)
  280. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  281. Sleep(200)
  282. Call("CheckDead")
  283. If Not $Dead and Not $Logout Then
  284.    Send("{ESCAPE}") ;closes repair tab
  285.    Sleep(100)
  286.    Send("{ESCAPE}") ;menu
  287.    Sleep(10)
  288.    MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  289.    Sleep($loadtime)
  290.    MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  291.    Sleep($loadtime)
  292. EndIf
  293. EndFunc
  294.  
  295. Func CheckLoot()
  296. Send("{ALTDOWN}")
  297. Sleep(Random(500,2000))
  298. $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  299. If Not @error Then
  300.    MouseClick ('left', $SetLoot[0], $SetLoot[1])
  301.    Sleep(Random(800,1200))
  302.    $i+= 1
  303.    If $i <= 6 Then
  304.       Call("CheckLoot")
  305.    EndIf
  306. EndIf
  307. $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  308. If Not @error Then
  309.    MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1])
  310.    Sleep(Random(800,1200))
  311.    $i+= 1
  312.    If $i <= 6 Then
  313.       Call("CheckLoot")
  314.    EndIf
  315. EndIf
  316. If $LootRares Then
  317.    $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  318.    If Not @error Then
  319.       MouseClick ('left', $RareLoot[0], $RareLoot[1])
  320.       Sleep(Random(700,900))
  321.       $i+= 1
  322.       If $i <= 6 Then
  323.          Call("CheckLoot")
  324.       EndIf
  325.    EndIf
  326. EndIf
  327. If $LootGems Then
  328.  
  329. Send("{ALTDOWN}")
  330.    pickItems()
  331. Send("{ALTUP}")
  332. SLeep(10)
  333. EndIf
  334.  
  335. EndFunc
  336.  
  337.  
  338. Func pickItems()
  339.         $currentArrayItem = 0
  340.         $gX = 0
  341.         $gY = 0
  342.         for $i = 0 to ($totalItems - 1)
  343.                 $urlString = "C:\Users\Chris\Desktop\AutoIt_Images\" & $pick[$i] ;once again, change the path
  344.                ; MsgBox("","",$urlString)
  345.                 $Search = _ImageSearchArea($urlString,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,100)
  346.                 if $search = 1 then
  347.                         MouseMove($gX, $gY, 3)
  348.                         sleep(100)
  349.                         MouseClick("left",$gX,$gY,1,1)
  350.                 Else
  351.                 EndIf
  352.         next
  353. EndFunc
  354.  
  355. Func Pause()
  356.    $Leave = False
  357. EndFunc
  358.  
  359. Func Stop() ;to allow the script to stop
  360.     Exit
  361. EndFunc
  362.  
  363. Func Leave()
  364.    $Leave = True
  365. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement