Guest User

wizworm

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