Guest User

Wizard Sarkoth

a guest
Jun 10th, 2012
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 18.14 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 = 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
  28.     $loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  29.     $tptime =       6900 ; 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.     $blueInventory =            0x161D35
  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.     $LootBlues = True
  35.     $LootGems = False ; Change this to true if you want to pick up gems (messy, can fill up bag with whites/blues)
  36.     $BluesPickedUp = 0
  37.     $MaxBluesBeforeSell = 15
  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.     $runsSinceLastSell = 0
  54.     Call("RestartRun")
  55.  
  56.     Func RestartRun()
  57.        While $go
  58.               if($Leave) Then
  59.                      $i = 0
  60.                      Sleep(1000) ;had to add this since the icon doesn't show up RIGHT away in game
  61.                      Call("CheckDead")
  62.                      Call("CheckRepair")
  63.                      if $BluesPickedUp >= $MaxBluesBeforeSell and $LootBlues Then
  64.                         Call("DoSellBlues")
  65.                      EndIf
  66.                      If $Window Then
  67.                             MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  68.                             Sleep($loadtime)
  69.                             $Window = False
  70.                             ExitLoop
  71.                      ElseIf $Dead or $Logout Then
  72.                             ExitLoop
  73.                      EndIf
  74.                      MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  75.                      Send("4")
  76.                      Sleep(140)
  77.                      Send("4")
  78.                      Sleep(140)
  79.                      Send("4")
  80.                      Sleep(140)
  81.                      Send("4")
  82.                      Sleep(80)
  83.                      Send("4")
  84.                      Sleep(80)
  85.                      Send("4")
  86.                      Sleep(80)
  87.                      Send("4")
  88.                      Sleep(80)
  89.                      Send("4")
  90.                      Sleep(80)
  91.                      Send("1")
  92.                      Send("3")
  93.                      Sleep(300)
  94.                      MouseMove(Round(245*$x_ratio),Round(280*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  95.                      Sleep(700)
  96.                      Call("CheckDead")
  97.                      If $Window Then
  98.                             MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  99.                             Sleep($loadtime)
  100.                             $Window = False
  101.                             ExitLoop
  102.                      ElseIf $Dead or $Logout Then
  103.                             ExitLoop
  104.                      EndIf
  105.                      $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)
  106.                                If Not @error Then
  107.                                       MouseClick("left",Round(245*$x_ratio),Round(280*$y_ratio)) ;Entrance to cellar
  108.                                       Sleep(400)
  109.                                       ;Send("2")
  110.                                       Sleep($walktime)
  111.                                       MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  112.                                       Sleep(2500)
  113.                                       MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  114.                                       Sleep(10)
  115.                                       Send("{SHIFTDOWN}")
  116.                                       MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  117.                                       MouseDown("right") ;attack middle
  118.                                       Sleep(10000)
  119.                                       MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  120.                                       Sleep(10)
  121.                                       Send("{SHIFTUP}")
  122.                                       Sleep(400)
  123.                                       MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  124.                                       Sleep(2100)
  125.                                       MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
  126.                                       Sleep(1100)
  127.                                       MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
  128.                                       Sleep(1100)
  129.                                       MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
  130.                                       Call("CheckLoot")
  131.                                       $runsSinceLastSell += 1
  132.                                       Send("t")
  133.                                       Sleep($tptime)
  134.                                       Call("CheckDead")
  135.                                       If Not $Logout And Not $Dead And Not $Window Then
  136.                                              Sleep(300)
  137.                                              Send("{ESCAPE}") ;menu
  138.                                              Sleep(200)
  139.                                              MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  140.                                              Sleep($loadtime)
  141.                                              Call("CheckDead")
  142.                                              If Not $Logout Then
  143.                                                     MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  144.                                                     Sleep($loadtime)
  145.                                              EndIf
  146.                                       Else
  147.                                              MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  148.                                              Sleep($loadtime)
  149.                                              $Window = False ; reset the flag so it doesn't think a window is always up
  150.                                       EndIf
  151.                                Else
  152.                                       Send("2")
  153.                                       Sleep(700)
  154.                                       Send("t")
  155.                                       Sleep($tptime)
  156.                                       Call("CheckDead")
  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.  
  244.     Func DoSellBlues()
  245.         Sleep(100)
  246.         Send("t")
  247.         Sleep($tptime)
  248.         MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  249.         Sleep(1500)
  250.         MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  251.         Sleep(1500)
  252.         MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  253.         Sleep(1200)
  254.         ;Send("i")
  255.         For $xInv = 1417 To 1846 Step 48
  256.             For $yInv = 588 To 825 Step 48
  257.                 $bluePixel = PixelSearch(Round($xInv * $x_ratio),Round($yInv*$y_ratio),Round(($xInv + 48)*$x_ratio),Round($yInv +48*$y_ratio), $blueInventory,15)
  258.                 If @error Then
  259.                     ToolTip("No more blues!? or its a rare !?",0,0)
  260.                 Else
  261.                     MouseClick("right", $bluePixel[0], $bluePixel[1])
  262.                     sleep(1000)
  263.                 EndIf
  264.             Next
  265.         Next
  266.         $BluesPickedUp = 0
  267.         Call("CheckDead")
  268.         If Not $Dead and Not $Logout Then
  269.            Send("{ESCAPE}") ;closes repair tab
  270.            Sleep(100)
  271.            Send("{ESCAPE}") ;menu
  272.            Sleep(10)
  273.            MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  274.            Sleep($loadtime)
  275.            MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  276.            Sleep($loadtime)
  277.         EndIf
  278.     EndFunc
  279.  
  280.     Func DoRepair()
  281.     Sleep(100)
  282.     Send("t")
  283.     Sleep($tptime)
  284.     MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  285.     Sleep(1500)
  286.     MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  287.     Sleep(1500)
  288.     MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  289.     Sleep(1200)
  290.     MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  291.     Sleep(400)
  292.     MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  293.     Sleep(200)
  294.     Call("CheckDead")
  295.     If Not $Dead and Not $Logout Then
  296.        Send("{ESCAPE}") ;closes repair tab
  297.        Sleep(100)
  298.        Send("{ESCAPE}") ;menu
  299.        Sleep(10)
  300.        MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  301.        Sleep($loadtime)
  302.        MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  303.        Sleep($loadtime)
  304.     EndIf
  305.     EndFunc
  306.  
  307.     Func CheckLoot()
  308.     Sleep(Random(500,2000))
  309.     $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  310.     If Not @error Then
  311.        MouseClick ('left', $SetLoot[0], $SetLoot[1])
  312.        Sleep(Random(800,1200))
  313.        $i+= 1
  314.        If $i <= 6 Then
  315.               Call("CheckLoot")
  316.        EndIf
  317.     EndIf
  318.     $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  319.     If Not @error Then
  320.        MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1])
  321.        Sleep(Random(800,1200))
  322.        $i+= 1
  323.        If $i <= 6 Then
  324.               Call("CheckLoot")
  325.        EndIf
  326.     EndIf
  327.     If $LootBlues Then
  328.        $BlueLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x5555CD, 2) ; blue loot (darker for compatibility)
  329.        If Not @error Then
  330.               MouseClick ('left', $BlueLoot[0], $BlueLoot[1])
  331.               Sleep(Random(700,900))
  332.               $i+= 1
  333.               $BluesPickedUp +=1
  334.               If $i <= 6 Then
  335.                      Call("CheckLoot")
  336.               EndIf
  337.        EndIf
  338.     EndIf
  339.     If $LootRares Then
  340.        $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  341.        If Not @error Then
  342.               MouseClick ('left', $RareLoot[0], $RareLoot[1])
  343.               Sleep(Random(700,900))
  344.               $i+= 1
  345.               If $i <= 6 Then
  346.                      Call("CheckLoot")
  347.               EndIf
  348.        EndIf
  349.     EndIf
  350.     If $LootGems Then
  351.        $AmethystDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Amethyst,8)
  352.        If Not @error Then
  353.               MouseClick("left", $AmethystDrop[0], $AmethystDrop[1])
  354.               Sleep(Random(900,1400))
  355.               $i+= 1
  356.               If $i <= 10 Then
  357.                      Call("CheckLoot")
  358.               EndIf
  359.        EndIf
  360.        $RubyDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Ruby,6)
  361.        If Not @error Then
  362.               MouseClick("left", $RubyDrop[0], $RubyDrop[1])
  363.               Sleep(Random(900,1400))
  364.               $i+= 1
  365.               If $i <= 10 Then
  366.                      Call("CheckLoot")
  367.               EndIf
  368.        EndIf
  369.        $EmeraldDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Emerald,11)
  370.        If Not @error Then
  371.               MouseClick("left", $EmeraldDrop[0], $EmeraldDrop[1])
  372.               Sleep(Random(900,1400))
  373.               $i+= 1
  374.               If $i <= 10 Then
  375.                      Call("CheckLoot")
  376.               EndIf
  377.        EndIf
  378.        $TopazDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Topaz,2)
  379.        If Not 1 = 1 Then ; change to 'If Not @error Then' if you want to search for topazes
  380.               MouseClick("left", $TopazDrop[0], $TopazDrop[1])
  381.               Sleep(Random(900,1400))
  382.               $i+= 1
  383.               If $i <= 10 Then
  384.                      Call("CheckLoot")
  385.               EndIf
  386.           EndIf
  387.     EndIf
  388.     EndFunc
  389.  
  390.     Func Pause()
  391.        $Leave = False
  392.     EndFunc
  393.  
  394.     Func Stop() ;to allow the script to stop
  395.         Exit
  396.     EndFunc
  397.  
  398.     Func Leave()
  399.        $Leave = True
  400.     EndFunc
Advertisement
Add Comment
Please, Sign In to add comment