Advertisement
Guest User

Don DooBee Monk 1.1

a guest
Jun 28th, 2012
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 29.01 KB | None | 0 0
  1. ;notAres' Sarkoth DH Gold Script 1.6e - 6/14/2012 - Gem stashing added. Multiple fixes with new functions. Added exit game check.
  2. ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN NOW!
  3. ;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkoth-dh-gold-script-autoit-script-1920x1080.html
  4. ;;;;;
  5. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  6. ;Required build: http://us.battle.net/d3/en/calculator/demon-hunter#aRYXVT!aTW!YcaZbY
  7. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  8. ;Official supported resolution: 1920x1080
  9. ;;;;;
  10. ;Original by mackus101 @ ownedcore
  11. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  12. ;Refactoring and additional functions by Shimizoki
  13.  
  14. ;=========== DO NOT TOUCH ===========;
  15. #RequireAdmin
  16. ;#include <ImageSearch.au3> ;NO LONGER INCLUDED! Function added to script. Duh. :)
  17. #include <GUIConstantsEx.au3>
  18. #include <StaticConstants.au3>
  19. #include <WindowsConstants.au3>
  20.  
  21. ;=========== OCR ===========;
  22. #include <Tesseract.au3>
  23. Global $numitem, $numgem, $numtomb, $numgold, $numpot, $monold = 0
  24. ;====================================;
  25.  
  26. Opt('MouseCoordMode', 2)
  27. Opt('PixelCoordMode', 2)
  28. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "1.6e", $Paused, $go = True, $Leave = False, $Dead = False, $Logout = False, $i = 0, $gX = 0, $gY = 0, $LegendaryCount = 0, $SetCount = 0, $RareCount = 0, $MagicCount = 0, $GemCount = 0, $TomeCount = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000
  29. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  30. If $size = 0 Then
  31.    MsgBox(16,"Error","Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  32.    Exit
  33. EndIf
  34. ;====================================;
  35.  
  36.  
  37. ;============= SETTINGS =============;
  38.  
  39. ;Change to match your abilities (1-4 by default)z
  40. $skillCaltrops = "1"
  41. $skillSmokeScreen = "2"
  42. $skillPreparation = "3"
  43. $skillCompanion = "4"
  44.  
  45. $movementSpeed = 0      ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
  46.  
  47. ;Custom Loot
  48. $pngLoc = "C:\pics\"    ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  49. $totalItems = 1         ;Number of items in the pick array
  50. Global $pick[$totalItems]   ;DONT CHANGE THIS
  51.  
  52. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  53. $pick[0] = "mythic.png|120" ;png|Tolerance
  54.  
  55.  
  56. ;Looting
  57. $LootSets = True        ;True if you want to pick up Sets
  58. $LootLegendaries = True ;True if you want to pick up Legendaries
  59. $LootRares = True       ;True if you want to pick up Rares
  60. $LootMagic = True       ;True if you want to pick up Magic
  61. $LootGems = True        ;True if you want to pick up Gems
  62. $LootTomes = True       ;True if you want to pick up Tome of Secrets
  63. $LootCustom = false     ;True if you want to pick up Custom Items (The items in the pick array above)
  64.  
  65. ;Manage Loot
  66. $mLoot = 6              ;Nuber of successful runs until Stash and Vendor
  67. $mLootOff = 2           ;Stash and Vendor after mLoot +- X number of runs (Variability)
  68.  
  69. ;Stashing
  70. $StashLoot = True       ;True if you want to store Items in the stash
  71. $StashLegendary = True  ;True if you want to store Legendary items in the stash
  72. $StashRare = True       ;True if you want to store Rare items in the stash
  73. $StashMagic = False     ;True if you want to store Magic items in the stash
  74. $StashTomes = True      ;True if you want to store Tomes items in the stash
  75. $StashGems = True       ;True if you want to store Gems items in the stash
  76.  
  77. ;Vendoring
  78. $VendorLoot = True      ;True if you want to vendor Items
  79. $VendorRare = False     ;True if you want to vendor Rares
  80. $VendorMagic = True     ;True if you want to vendor Magic
  81.  
  82. ;Variability
  83. $Timer = False          ;True and the bot will add random sleep intervals
  84. $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
  85. $loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  86. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  87. ;====================================;
  88.  
  89. $x_ratio = $size[0] / 1920
  90. $y_ratio = $size[1] / 1080
  91. $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
  92. $movementSpeed = 1+($movementSpeed/100)
  93.  
  94. $VersionsInfo = "http://pastebin.com/raw.php?i=L8hHSZJi"
  95. $oldVersion = IniRead("updater.ini","Version","Version",$ver)
  96. $newVersion = "0.0"
  97. ;Call("DoUpdate")
  98. HotKeySet("=","Leave")  ;script started by pressing =
  99. HotKeySet("-", "Pause") ;script paused by pressing -
  100. HotKeySet("x", "Stop") ;script stopped by pressing x
  101. HotKeySet("z", "ShowLoot") ;script stopped by pressing z
  102.  
  103. #Region ### START Koda GUI section ###
  104. $frmBot = GUICreate("notAres' Sarkoth Extension v" & $ver, 350, 136, Round(1540*$x_ratio), Round(900*$y_ratio), -1, BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
  105. GUISetBkColor(0xC0C0C0)
  106. $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  107. GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  108. GUICtrlSetColor(-1, 0xFF0000)
  109. $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  110. $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  111. $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  112. $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  113. $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  114. $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  115. $lblGold = GUICtrlCreateLabel("Gold: 0", 12, 110, 240, 17)
  116. GUISetState(@SW_SHOW)
  117. #EndRegion ### END Koda GUI section ###
  118.  
  119. If Not FileExists($pngLoc & "MainMenu.png") Then
  120.     MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  121.     Exit
  122.  EndIf
  123.    
  124. While $go
  125.    
  126.     Call("RestartRun")
  127. WEnd
  128.  
  129. Func RestartRun()
  130.  
  131.     If($Leave) Then
  132.         $i = 0
  133.         ;Checks if the player is in the Main Menu
  134.         If CheckFor("MainMenu", "", Round(40*$x_ratio), Round(300*$y_ratio), Round(400*$x_ratio), Round(600*$y_ratio), 6, 100) Then
  135.            
  136.             GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till vendor: " & $mLootIn)
  137.             GUICtrlSetData($lblLocation, "Location: Main Menu")
  138.             GUICtrlSetData($lblStatus, "Status: Starting Game")
  139.             While True
  140.                 RandClick("left", Round(230*$x_ratio), Round(416*$y_ratio), 120, 20) ;Random Click on the resume button
  141.                 If CheckFor("LimitError", "", Round(720*$x_ratio), Round(480*$y_ratio), Round(960*$x_ratio), Round(600*$y_ratio), 3, 60) Then
  142.                     Sleep(Random(1000, 2000))
  143.                     RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 50 ,10)
  144.                     $rand = Random(40000, 80000)
  145.                     GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand/1000) & " seconds.")
  146.                     Sleep($rand)
  147.                 Else
  148.                     ExitLoop
  149.                 EndIf
  150.             WEnd
  151.             $rt = TimerInit()
  152.             $Logout = False
  153.         ElseIf Call("CheckDead") Then
  154.             Return
  155.         ElseIf CheckFor("ExitGame", "", Round(700*$x_ratio), Round(340*$y_ratio), Round(1200*$x_ratio), Round(500*$y_ratio), 3, 60) Then
  156.             MouseClick("left", Round(1064*$x_ratio), Round(632*$y_ratio))
  157.             Sleep(100)
  158.             Send("{SPACE}")
  159.             Return
  160.         Else
  161.             GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  162.             Return
  163.         EndIf
  164.          
  165.     If CheckFor("OldRuins", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  166.                 GUICtrlSetData($lblLocation, "Location: Old Ruins")
  167.                 ;Check if player needs to repair
  168.                 Call("CheckRepair")
  169.                 ;Start Run
  170.                 MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  171.                 Send("{4 DOWN}")
  172.                 Sleep(3500)
  173.                 Send("{4 UP}")
  174.                 Sleep(100)
  175.                 MouseMove(Round(356*$x_ratio),Round(200*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  176.                 Sleep(790)
  177.                 If Call("CheckDead") Then
  178.                         Return
  179.                 EndIf
  180.  
  181.         ;Checks if Dank Cellar is Open
  182.                 $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
  183.                 If Not @error Then
  184.                 GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  185.                 $run += 1
  186.                         MouseClick("left", Round(356*$x_ratio), Round(200*$y_ratio), 1) ;Entrance to cellar
  187.                         Moving(550)
  188.                         Send($skillSmokeScreen)
  189.                         Moving($walktime)
  190.                 Else ;ABORT RUN
  191.                         GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  192.                         Sleep(10)
  193.                         RandClick("middle", Round(1100*$x_ratio), Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  194.                         Moving(250)
  195.                         Send($skillCaltrops)
  196.                         Sleep(620)
  197.                         Send($skillSmokeScreen)
  198.                         Sleep(40)
  199.                         Call("TownPortal")
  200.                         If Not Call("CheckDead") Then
  201.                                 Call("LeaveGame")
  202.                         EndIf
  203.                         Return
  204.                
  205.         EndIf
  206.     Else
  207.         Call("TownPortal")
  208.         If Not Call("CheckDead") Then
  209.             Call("LeaveGame")
  210.         EndIf
  211.         Return
  212.      EndIf
  213.      
  214.         ;Checks that the player is in the Dank Cellar
  215.         If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
  216.                 GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  217.                 MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  218.                 Sleep(Random(2200, 2800))
  219.                 Send(3)
  220.                 Sleep(30)
  221.                 MouseClick("middle",Round(440*$x_ratio),Round(80*$y_ratio), 1) ;attacks the rare Sarkoth
  222.                 Sleep(2100)
  223.                 Send("{SHIFTDOWN}")
  224.                 Sleep(10)
  225.                 GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  226.                 MouseClick("left")
  227.                 Sleep(10)
  228.                 Send(2)
  229.                 Sleep(10)
  230.                 MouseDown("right") ;attack middle
  231.                 Sleep(3500)
  232.                 MouseClick("right",Round(960*$x_ratio),Round(502*$y_ratio),2)
  233.                 Sleep(100)
  234.                 Send("{SHIFTUP}")
  235.                 Sleep(10)
  236.                 Send(3)
  237.                 Sleep(10)
  238.                 GUICtrlSetData($lblStatus, "Status: Looting")
  239.                 MouseClick("middle",Round(637*$x_ratio),Round(540*$y_ratio)) ;move to left top corner for gold
  240.                 Sleep(1100)
  241.                 MouseClick("middle",Round(1320*$x_ratio),Round(310*$y_ratio)) ;move to right top corner for gold
  242.                 Sleep(1100)
  243.                 MouseClick("middle",Round(975*$x_ratio),Round(827*$y_ratio)) ;move to middle before
  244.  
  245.       $numitem =0
  246.       $numgem=0
  247.       $numtomb=0
  248.       $numgold=0
  249.       $numpot=0
  250.       GUICtrlSetData($lblStatus, "Status: Looting")
  251.      
  252.       Call("Loot")
  253.       RandSleep(1, 6, 50)
  254.       Send("i")
  255.       Sleep(140)
  256.       $mon = _TesseractScreenCapture( 0, "", 1,  2,1454,508,1920-1571,1080-525, 0)
  257.       $mon = StringReplace($mon , ",", "")
  258.       $mon = StringReplace($mon , @CRLF, "")
  259.       $mon = StringReplace($mon , " ", "")
  260.      
  261.       $mondelt = Number($mon) - Number($monold)
  262.      
  263.       Call("AddLog",'Gold: ' & $mon & ', Gold Delt: ' & $mondelt & ', Items: ' & $numitem & ', Gems: ' & $numgem & ', Books: ' & $numtomb  & ', Potions: ' & $numpot & ', GoldPick: ' & $numgold)
  264.       Send("i")
  265.      
  266.       GUICtrlSetData($lblGold, "Gold: " & $mon & ", This Run: " & $mondelt)
  267.      
  268.       $monold=$mon
  269.      
  270.       Call("TownPortal")
  271.     Else
  272.         Sleep(620)
  273.         Sleep(40)
  274.         Call("TownPortal")
  275.         If Not Call("CheckDead") Then
  276.             Call("LeaveGame")
  277.         EndIf
  278.     EndIf
  279.     ;After successful run
  280.     If Not $Logout And Not $Dead Then
  281.         If $mLootIn == 1 And CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then ;If its time to manage loot and we are in town
  282.             If $StashLoot Then
  283.                 Call("StashLoot")
  284.             EndIf
  285.             If $VendorLoot Then
  286.                 Call("VendorLoot")
  287.             EndIf
  288.             $mLootIn = Round(Random($mLoot-$mLootOff, $mLoot+$mLootOff)) ;Reset Counter
  289.         ElseIf Not CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  290.             GUICtrlSetData($lblStatus, "Status: Skipping vendor")
  291.             Sleep(1000)
  292.         Else
  293.             $mLootIn -= 1
  294.         EndIf
  295.         If Not Call("CheckDead") Then
  296.             Call("LeaveGame")
  297.         EndIf
  298.         Return
  299.     Else
  300.         Return
  301.     EndIf
  302. EndIf
  303. EndFunc
  304.  
  305. ;Helper Functions
  306.  
  307. Func AddLog($logtxt)
  308.    Local $file = FileOpen("log.txt", 1)
  309.    $msg = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ': ' & $logtxt & @CRLF
  310.    FileWrite($file, $msg )
  311.    FileClose($file)
  312.    ConsoleWrite( $msg)
  313. EndFunc
  314.  
  315.  
  316. Func CheckDead()
  317.     $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
  318.     If Not @error Then
  319.         $Logout = True
  320.         Call("AddLog","Logged out")
  321.         GUICtrlSetData($lblStatus, "Status: Logging out")
  322.         Sleep(11000)
  323.         Sleep($loadtime)
  324.         Return 1
  325.     EndIf
  326.  
  327.     $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"
  328.     If Not @error Then
  329.         GUICtrlSetData($lblStatus, "Status: Dead")
  330.         Call("AddLog","You have died")
  331.         $Dead = True
  332.         Call("LeaveGame")
  333.         Sleep(11000)
  334.         Return 1
  335.     Else
  336.         $Dead = False
  337.         Return 0
  338.     EndIf
  339. EndFunc
  340.  
  341. Func CheckRepair()
  342. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  343.    If Not @error Then
  344.       Call("DoRepair")
  345.    EndIf
  346. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  347.    If Not @error Then
  348.       Call("DoRepair")
  349.    EndIf
  350. EndFunc
  351.  
  352. Func DoRepair()
  353.     Sleep(Random(75, 150))
  354.     Call("TownPortal")
  355.     If Call("CheckDead") Then
  356.         Return
  357.     EndIf
  358.     If CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  359.         RandClick("left", Round(1480*$x_ratio),Round(281*$y_ratio),1,1) ;begin movement towards merchant
  360.         Moving(1875)
  361.         RandClick("left", Round(1316*$x_ratio),Round(206*$y_ratio),1,1) ;moves to get merchant in screen
  362.         Moving(1875)
  363.         RandClick("left", Round(845*$x_ratio),Round(225*$y_ratio),1,1) ;NPC Merchant to the right of cain's home
  364.         Sleep(1200)
  365.         RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  366.         Sleep(400)
  367.         RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  368.         Sleep(200)
  369.         Send("{Escape}")
  370.         Call("AddLog","Repair")
  371.         If Not Call("CheckDead") Then
  372.             Call("LeaveGame")
  373.         EndIf
  374.     EndIf
  375. EndFunc
  376.  
  377. Func CalcTime()
  378.     $srt = TimerDiff($rt)
  379.     GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt/1000,2) & " seconds.")
  380.     $trt = TimerDiff($t)
  381.     $total = Round((($trt/1000)/60)/60,4)
  382.  
  383.     ;Total runtiume calculation.
  384.     $hours = Floor((($trt/1000)/60)/60)
  385.     $minutes = (($trt/1000)/60)
  386.     ;trim minutes if runtime is more then 1 hour.
  387.     If $minutes > 60 Then
  388.         While $minutes > 60
  389.             $minutes -=60
  390.         WEnd
  391.     EndIf
  392.     GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, "& Ceiling($minutes) &" minutes")
  393.  EndFunc
  394.  
  395.  Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 5 ,$tolerance = 130)
  396.     $c = 0
  397.     $string = $pngLoc & $img & ".png"
  398.     Do
  399.         $c +=1
  400.         Sleep(100)
  401.         If $c > ($seconds*10) Then ;Make sure we never get stuck here for infinity.
  402.             If $type = "Area" Then
  403.                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  404.             EndIf
  405.             Return False
  406.         EndIf
  407.     Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  408.     Return True
  409. EndFunc
  410.  
  411. Func LeaveGame()
  412.     $Logout = True
  413.     Call("RandSleep")
  414.     GUICtrlSetData($lblStatus, "Status: Leaving Game")
  415.     Sleep(Random(100, 500))
  416.     Send("{Escape}")
  417.     Sleep(Random(100, 500))
  418.     RandClick("left", Round(956*$x_ratio), Round(579*$y_ratio), 120, 20) ;Random Click on the leave button
  419.     Call("CalcTime")
  420. EndFunc
  421.  
  422. Func Loot()
  423.     Sleep(Random(500,2000))
  424.     MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  425.     If $LootSets Then
  426.       $SetCount += LootGear(0x02CE01, 2)
  427.     EndIf
  428.     If $LootLegendaries Then
  429.       $LegendaryCount += LootGear(0xBF642F, 0)
  430.     EndIf
  431.     If $LootRares Then
  432.       $RareCount += LootGear(0xBBBB00, 2)
  433.     EndIf
  434.     If $LootMagic Then
  435.       $MagicCount += LootGear(0x6969FF, 2)
  436.     EndIf
  437.     If $LootGems Then
  438.       Call("LootGems")
  439.     EndIf
  440.     If $LootTomes Then
  441.       Call("LootTomes")
  442.    EndIf
  443.     If $LootCustom Then
  444.       Call("LootCustom")
  445.     EndIf
  446.  
  447.     Call("ShowLoot")
  448.  EndFunc
  449.  
  450. Func LootGear($color, $tolerance = 2)
  451.    $count = 0
  452.    $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance)
  453.    If Not @error Then
  454.       While Not @error
  455.          $count += 1
  456.          MouseClick ('left', $Loot[0], $Loot[1])
  457.          Sleep(Random(700,900))
  458.          MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  459.          ;Run at max 10 times per quality
  460.          If $count >= 10 Then
  461.             ExitLoop
  462.          EndIf
  463.          $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance)
  464.       WEnd
  465.    EndIf
  466.    $numitem += $count;
  467.    Return $count
  468. EndFunc
  469.  
  470. Func LootCustom()
  471.     $gX = 0
  472.     $gY = 0
  473.     for $i = 0 to ($totalItems - 1)
  474.         $array = StringSplit($pick[$i],"|")
  475.         $file = $array[1]
  476.         $accuracy = $array[2]
  477.         $urlString = $pngLoc & $file
  478.         $count = 0
  479.         While _ImageSearchArea($pngLoc & $file,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,$accuracy)
  480.             $count += 1
  481.             if $i = 0 then $numpot+=1
  482.             if $i = 1 then $numgold+=1
  483.             sleep(Random(75, 150))
  484.             MouseClick("left",$gX,$gY,1,1)
  485.             sleep(Random(800, 1200))
  486.             MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  487.             If $count >= 10 Then
  488.                ExitLoop
  489.          EndIf
  490.         WEnd
  491.     next
  492. EndFunc
  493.  
  494. Func LootGems()
  495.     $gX = 0
  496.     $gY = 0
  497.     While _ImageSearchArea($pngLoc & "square.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90)
  498.         sleep(Random(75, 150))
  499.         MouseClick("left",$gX,$gY)
  500.         $GemCount += 1
  501.         $numgem += 1
  502.         sleep(Random(800, 1200))
  503.         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  504.     WEnd
  505. EndFunc
  506.  
  507. Func LootTomes()
  508.     $gX = 0
  509.     $gY = 0
  510.     While _ImageSearchArea($pngLoc & "tome.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90)
  511.         sleep(Random(75, 150))
  512.         MouseClick("left",$gX,$gY)
  513.         $TomeCount += 1
  514.         $numtomb += 1
  515.         sleep(Random(800, 1200))
  516.         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  517.     WEnd
  518. EndFunc
  519.  
  520. Func Moving($time)
  521.     Sleep($time/$movementSpeed)
  522. EndFunc
  523.  
  524. Func RandClick($clickType, $xPos, $yPos, $xOff = 20, $yOff = 20)
  525.     $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  526.     $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  527.     MouseClick($clickType, $randX, $randY)
  528. EndFunc
  529.  
  530. Func RandMove($xPos, $yPos, $xOff = 20, $yOff = 20)
  531.     $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  532.     $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  533.     MouseMove($randX, $randY)
  534. EndFunc
  535.  
  536. Func RandSleep($min = 30, $max = 45, $chance = 5)
  537.     $randNum = Round(Random(1, 100))
  538.     If $Timer And $randNum <= $chance Then
  539.         $sleepTime = Random($min*1000, $max*1000)
  540.         GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime/1000) & " secs")
  541.  
  542.         For $c = 0 To 10
  543.             Sleep($sleepTime/10)
  544.         Next
  545.     EndIf
  546. EndFunc
  547.  
  548. Func TownPortal()
  549.     GUICtrlSetData($lblStatus, "Status: Returning to Town")
  550.     Send("t")
  551.     Sleep(Random($tptime, $tptime+500))
  552. EndFunc
  553.  
  554. Func StashLoot()
  555.     GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  556.     Sleep(Random(1000, 1500))
  557.     MouseClick("left", 1064*$x_ratio, 256*$y_ratio)
  558.     Sleep(Random(1500, 2000))
  559.  
  560.    $numstashed=0;
  561.  
  562.     ;Legendaries
  563.     if $StashLegendary then
  564.        StashItems(0xFF7F00, 0)
  565.        StashItems(0x8F5C25, 1)
  566.     EndIf
  567.     ;$sc = 0
  568.     ;While $sc < 5
  569.         ;Sleep(Random(200, 300))
  570.         ;$LegendPixel = PixelSearch(1400*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0xFF7F00, 0)
  571.         ;$LegendPixel = PixelSearch(1400*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0xFF7F00, 0)
  572.         ;If Not @error Then
  573.             ;GUICtrlSetData($lblStatus, "Status: Stashing Legendaries")
  574.             ;MouseClick("right", $LegendPixel[0], $LegendPixel[1])
  575.             ;$numstashed += 1;
  576.         ;Else
  577.             ;ExitLoop
  578.          ;EndIf
  579.          ;$sc += 1
  580.     ;WEnd
  581.     ;if $sc=5 then Call("AddLog","Stash full")
  582.     ;EndIf
  583.    
  584.        ;==>StashItems
  585.  
  586.     ;Rares
  587.     if $StashRare then
  588.        $sc = 0
  589.     While $sc < 10
  590.         Sleep(Random(200, 300))
  591.         $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  592.         If Not @error Then
  593.             GUICtrlSetData($lblStatus, "Status: Stashing Rares")
  594.             MouseClick("right", $RarePixel[0], $RarePixel[1])
  595.             $numstashed += 1;
  596.         Else
  597.             ExitLoop
  598.          EndIf
  599.          $sc += 1
  600.     WEnd
  601.     if $sc=10 then Call("AddLog","Stash full")
  602. EndIf
  603.     ;Tomes
  604.    
  605.     While $StashTomes == True
  606.         Sleep(Random(100, 300))
  607.         If _ImageSearchArea($pngLoc & "TomeIcon.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 140) Then
  608.             GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  609.             MouseClick("left", 500 * $x_ratio, 360 * $y_ratio, 1, 4)
  610.             MouseClick("right", $gX, $gY, 1, 4)
  611.             Sleep(80)
  612.             MouseClick("left", 500 * $x_ratio, 200 * $y_ratio, 1, 4)
  613.         Else
  614.             ExitLoop
  615.         EndIf
  616.     WEnd
  617.    
  618.     ;old tomes
  619.     ;If _ImageSearchArea($pngLoc & "TomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,200) Then
  620.     ;   GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  621.  
  622.     ;   MouseClick("right",$gX,$gY,1,1)
  623.     ;   Sleep(Random(400, 600))
  624.  
  625.     ;EndIf
  626.  
  627.     ;Magic
  628.     if $StashMagic then
  629.        $sc = 0
  630.     While $sc < 20
  631.         Sleep(Random(100, 300))
  632.         $MagicPixel = PixelSearch(1400*$x_ratio, 580*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 1)
  633.         If Not @error Then
  634.             GUICtrlSetData($lblStatus, "Status: Stashing Magic")
  635.             MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  636.             $numstashed += 1;
  637.         Else
  638.             ExitLoop
  639.          EndIf
  640.          $sc += 1
  641.     WEnd
  642.     if $sc=20 then Call("AddLog","Stash full")
  643.  EndIf
  644.  
  645.     Call("AddLog","Stashed Items: " & $numstashed )
  646.  
  647.     ;Gems
  648.     If $StashGems Then
  649.        GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  650.        
  651.        for $gemtype = 1 to 8
  652.          
  653.          if $gemtype = 1 then $gemnane = "Ru1.png"
  654.          if $gemtype = 2 then $gemnane = "Ru2.png"
  655.          if $gemtype = 3 then $gemnane = "Em1.png"
  656.          if $gemtype = 4 then $gemnane = "Em2.png"
  657.          if $gemtype = 5 then $gemnane = "To1.png"
  658.          if $gemtype = 6 then $gemnane = "To2.png"
  659.          if $gemtype = 7 then $gemnane = "Am1.png"
  660.          if $gemtype = 8 then $gemnane = "Am2.png"
  661.      
  662.          If _ImageSearchArea($pngLoc & $gemnane ,1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,180) Then
  663.             GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  664.             MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  665.             Sleep(Random(200, 500))
  666.             MouseClick("right",$gX,$gY,1,1)
  667.             Sleep(Random(400, 600))
  668.             MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  669.             Sleep(Random(200, 500))
  670.          EndIf
  671.          
  672.       Next
  673.        
  674.     EndIf
  675.     Sleep(Random(1000, 3000))
  676.     Send("{SPACE}")
  677.  EndFunc
  678.  
  679. Func StashItems($color, $tolerance)
  680.     $sc = 0
  681.     While $sc <= 20
  682.         Sleep(Random(20, 100))
  683.         $StashPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  684.         If Not @error Then
  685.             MouseClick("right", $StashPixel[0] + 4, $StashPixel[1], 1, 4)
  686.             $sc += 1
  687.         Else
  688.             ExitLoop
  689.         EndIf
  690.     WEnd
  691. EndFunc
  692.  
  693. Func VendorLoot()
  694.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  695.     If Not $StashLoot Then ;Move from TP towards vendor
  696.         Sleep(Random(300, 500))
  697.         MouseClick("middle", 1565*$x_ratio, 50*$y_ratio)
  698.     Else ;Move from Stash towards vendor
  699.         Sleep(Random(300, 500))
  700.         MouseClick("middle", 1560*$x_ratio, 120*$y_ratio)
  701.     EndIf
  702.     Sleep(3000)
  703.     Send("c")
  704.     Sleep(700)
  705.     While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, $gX, $gY, 120)
  706.         GUICtrlSetData($lblStatus, "Status: Identifying")
  707.         Sleep(Random(75, 150))
  708.         RandClick("right",$gX,$gY,1,1)
  709.         Sleep(Random(2400, 2800))
  710.     WEnd
  711.     Send("c")
  712.     Sleep(600)
  713.     MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
  714.     Sleep(3000)
  715.  
  716. $numsold=0;
  717.     ;Rares
  718.     If $VendorRare Then
  719.         $c = 0
  720.         While $c <= 10
  721.             Sleep(Random(200, 300))
  722.             $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  723.             If Not @error Then
  724.                 MouseClick("right", $RarePixel[0], $RarePixel[1])
  725.                 $numsold += 1
  726.                 $c += 1
  727.             Else
  728.                 ExitLoop
  729.             EndIf
  730.         WEnd
  731.     EndIf
  732.  
  733.     ;Magic
  734.     If $VendorMagic Then
  735.         $c = 0
  736.         While $c <= 25
  737.             Sleep(Random(200, 300))
  738.             $MagicPixel = PixelSearch(1400*$x_ratio, 580*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 1)
  739.             If Not @error Then
  740.                 MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  741.                 $numsold += 1
  742.                 $c += 1
  743.             Else
  744.                 ExitLoop
  745.             EndIf
  746.         WEnd
  747.      EndIf
  748.      
  749.      Call("AddLog","Sold Items: " & $numsold )
  750.  
  751.     Sleep(200)
  752.     RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  753.     Sleep(300)
  754.     RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  755.     Sleep(200)
  756.     Call("AddLog","Sell and Repair")
  757.     Sleep(Random(1000, 3000))
  758.     GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  759.     Send("{ESCAPE}")
  760. EndFunc
  761.  
  762.  
  763. Func DoUpdate()
  764. $Ini = InetGet($VersionsInfo,@ScriptDir & "\version.ini")                                           ;download version.ini
  765. If $Ini = 0 Then                                                                                    ;was the download of version.ini successful?
  766.     MsgBox(0,"ERROR","The server seems to be offline. No update will be done.")
  767. Else
  768.     $newVersion = IniRead (@ScriptDir & "\version.ini","Version","Version","")                      ;reads the new version out of version.ini
  769.     If $NewVersion = $oldVersion Then                                                               ;compare old and new
  770.         ;MsgBox (0,"No update","There is no update available!")
  771.         FileDelete(@ScriptDir & "\version.ini")
  772.     Else
  773.         $msg = MsgBox (4,"Update","There is a new version existing: " & $newVersion & " ! You are using: " & $oldVersion & ". Do you want to download the new version?")
  774.         If $msg = 7 Then                                                                            ;No was pressed
  775.             FileDelete(@ScriptDir & "\version.ini")
  776.         ElseIf $msg = 6 Then                                                                        ;OK was pressed
  777.             $downloadLink = IniRead(@ScriptDir & "\version.ini","Version","download","NotFound")
  778.             $dlhandle = InetGet($downloadLink,@ScriptDir & "\Update.au3",1,1)
  779.             ProgressOn("Update", "Downloading Updates", "",-1,-1,16)                                                        ;creates an progressbar
  780.  
  781.             $Size = InetGetSize($downloadLink,1)                                                    ;get the size of the update
  782.             While Not InetGetInfo($dlhandle, 2)
  783.                 $Percent = (InetGetInfo($dlhandle,0)/$Size)*100
  784.                 ProgressSet( $Percent, $Percent & " percent")                                       ;update progressbar
  785.                 Sleep(1)
  786.             WEnd
  787.             ProgressSet(100 , "Done", "Complete")                                                   ;show complete progressbar
  788.              sleep(500)
  789.             ProgressOff()                                                                           ;close progress window
  790.             IniWrite("updater.ini","version","version",$NewVersion)
  791.             InetClose($dlhandle)
  792.             $iniMsg = IniRead(@ScriptDir & "\version.ini","Version","message","Exiting...")
  793.             MsgBox(-1,"Success","Download Complete! Please restart the bot by running Update.au3" & @CRLF & $iniMsg)
  794.             FileDelete(@ScriptDir & "\version.ini")
  795.             Exit
  796.         EndIf
  797.     EndIf
  798. EndIf
  799. EndFunc
  800.  
  801. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  802.     If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  803.     $findImage = "*TRANSBLACK " & $findImage
  804.     If @AutoItX64 Then
  805.         $result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  806.     Else
  807.         $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  808.     EndIf
  809.     If $result = "0" Then
  810.         Return 0
  811.     EndIf
  812.  
  813.     ; Otherwise get the x,y location of the match and the size of the image to
  814.     ; compute the centre of search
  815.    $array = StringSplit($result[0],"|")
  816.    If(UBound($array) >= 4) Then
  817.       $x=Int(Number($array[2]))
  818.       $y=Int(Number($array[3]))
  819.       If $resultPosition = 1 Then
  820.          $x=$x + Int(Number($array[4])/2)
  821.          $y=$y + Int(Number($array[5])/2)
  822.       EndIf
  823.       Return 1
  824.    EndIf
  825. EndFunc
  826.  
  827. ;Hotkey Functions
  828. Func Leave()
  829.    $Leave = True
  830. EndFunc
  831.  
  832. Func Pause()
  833.    $Leave = False
  834. EndFunc
  835.  
  836. Func TogglePause()
  837.     $Paused = Not $Paused
  838.     While $Paused
  839.         Sleep(100)
  840.                 WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Paused")
  841.         ToolTip('Script is "Paused"', 0, 0)
  842.     WEnd
  843.         WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Running")
  844.     ToolTip("")
  845. EndFunc
  846.  
  847. Func ShowLoot()
  848.     GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  849.     GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  850. EndFunc
  851.  
  852. Func Stop() ;to allow the script to stop
  853.     Exit
  854. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement