Advertisement
Guest User

[Goldfarming] [Monk] NotAres' Sarkoth Script [AutoIT

a guest
Jun 27th, 2012
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 27.98 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.                 Send(2)
  233.                 Sleep(10)
  234.                 MouseClick("right",Round(960*$x_ratio),Round(502*$y_ratio),2)
  235.                 Sleep(100)
  236.                 Send("{SHIFTUP}")
  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.     $sc = 0
  565.     While $sc < 5
  566.         Sleep(Random(200, 300))
  567.         $LegendPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4D2C0D, 0)
  568.         If Not @error Then
  569.             GUICtrlSetData($lblStatus, "Status: Stashing Legendaries")
  570.             MouseClick("right", $LegendPixel[0], $LegendPixel[1])
  571.             $numstashed += 1;
  572.         Else
  573.             ExitLoop
  574.          EndIf
  575.          $sc += 1
  576.     WEnd
  577.     if $sc=5 then Call("AddLog","Stash full")
  578.     EndIf
  579.  
  580.     ;Rares
  581.     if $StashRare then
  582.        $sc = 0
  583.     While $sc < 10
  584.         Sleep(Random(200, 300))
  585.         $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  586.         If Not @error Then
  587.             GUICtrlSetData($lblStatus, "Status: Stashing Rares")
  588.             MouseClick("right", $RarePixel[0], $RarePixel[1])
  589.             $numstashed += 1;
  590.         Else
  591.             ExitLoop
  592.          EndIf
  593.          $sc += 1
  594.     WEnd
  595.     if $sc=10 then Call("AddLog","Stash full")
  596. EndIf
  597.     ;Tomes
  598.     If _ImageSearchArea($pngLoc & "TomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,200) Then
  599.         GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  600.  
  601.         MouseClick("right",$gX,$gY,1,1)
  602.         Sleep(Random(400, 600))
  603.  
  604.     EndIf
  605.  
  606.     ;Magic
  607.     if $StashMagic then
  608.        $sc = 0
  609.     While $sc < 20
  610.         Sleep(Random(100, 300))
  611.         $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  612.         If Not @error Then
  613.             GUICtrlSetData($lblStatus, "Status: Stashing Magic")
  614.             MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  615.             $numstashed += 1;
  616.         Else
  617.             ExitLoop
  618.          EndIf
  619.          $sc += 1
  620.     WEnd
  621.     if $sc=20 then Call("AddLog","Stash full")
  622.  EndIf
  623.  
  624.     Call("AddLog","Stashed Items: " & $numstashed )
  625.  
  626.     ;Gems
  627.     If $StashGems Then
  628.        GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  629.        
  630.        for $gemtype = 1 to 8
  631.          
  632.          if $gemtype = 1 then $gemnane = "Ru1.png"
  633.          if $gemtype = 2 then $gemnane = "Ru2.png"
  634.          if $gemtype = 3 then $gemnane = "Em1.png"
  635.          if $gemtype = 4 then $gemnane = "Em2.png"
  636.          if $gemtype = 5 then $gemnane = "To1.png"
  637.          if $gemtype = 6 then $gemnane = "To2.png"
  638.          if $gemtype = 7 then $gemnane = "Am1.png"
  639.          if $gemtype = 8 then $gemnane = "Am2.png"
  640.      
  641.          If _ImageSearchArea($pngLoc & $gemnane ,1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,180) Then
  642.             GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  643.             MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  644.             Sleep(Random(200, 500))
  645.             MouseClick("right",$gX,$gY,1,1)
  646.             Sleep(Random(400, 600))
  647.             MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  648.             Sleep(Random(200, 500))
  649.          EndIf
  650.          
  651.       Next
  652.        
  653.     EndIf
  654.     Sleep(Random(1000, 3000))
  655.     Send("{SPACE}")
  656. EndFunc
  657.  
  658. Func VendorLoot()
  659.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  660.     If Not $StashLoot Then ;Move from TP towards vendor
  661.         Sleep(Random(300, 500))
  662.         MouseClick("middle", 1565*$x_ratio, 50*$y_ratio)
  663.     Else ;Move from Stash towards vendor
  664.         Sleep(Random(300, 500))
  665.         MouseClick("middle", 1560*$x_ratio, 120*$y_ratio)
  666.     EndIf
  667.     Sleep(3000)
  668.     Send("c")
  669.     Sleep(700)
  670.     While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, $gX, $gY, 120)
  671.         GUICtrlSetData($lblStatus, "Status: Identifying")
  672.         Sleep(Random(75, 150))
  673.         RandClick("right",$gX,$gY,1,1)
  674.         Sleep(Random(2400, 2800))
  675.     WEnd
  676.     Send("c")
  677.     Sleep(600)
  678.     MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
  679.     Sleep(3000)
  680.  
  681. $numsold=0;
  682.     ;Rares
  683.     If $VendorRare Then
  684.         $c = 0
  685.         While $c <= 10
  686.             Sleep(Random(200, 300))
  687.             $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  688.             If Not @error Then
  689.                 MouseClick("right", $RarePixel[0], $RarePixel[1])
  690.                 $numsold += 1
  691.                 $c += 1
  692.             Else
  693.                 ExitLoop
  694.             EndIf
  695.         WEnd
  696.     EndIf
  697.  
  698.     ;Magic
  699.     If $VendorMagic Then
  700.         $c = 0
  701.         While $c <= 25
  702.             Sleep(Random(200, 300))
  703.             $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  704.             If Not @error Then
  705.                 MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  706.                 $numsold += 1
  707.                 $c += 1
  708.             Else
  709.                 ExitLoop
  710.             EndIf
  711.         WEnd
  712.      EndIf
  713.      
  714.      Call("AddLog","Sold Items: " & $numsold )
  715.  
  716.     Sleep(200)
  717.     RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  718.     Sleep(300)
  719.     RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  720.     Sleep(200)
  721.     Call("AddLog","Sell and Repair")
  722.     Sleep(Random(1000, 3000))
  723.     GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  724.     Send("{ESCAPE}")
  725. EndFunc
  726.  
  727.  
  728. Func DoUpdate()
  729. $Ini = InetGet($VersionsInfo,@ScriptDir & "\version.ini")                                           ;download version.ini
  730. If $Ini = 0 Then                                                                                    ;was the download of version.ini successful?
  731.     MsgBox(0,"ERROR","The server seems to be offline. No update will be done.")
  732. Else
  733.     $newVersion = IniRead (@ScriptDir & "\version.ini","Version","Version","")                      ;reads the new version out of version.ini
  734.     If $NewVersion = $oldVersion Then                                                               ;compare old and new
  735.         ;MsgBox (0,"No update","There is no update available!")
  736.         FileDelete(@ScriptDir & "\version.ini")
  737.     Else
  738.         $msg = MsgBox (4,"Update","There is a new version existing: " & $newVersion & " ! You are using: " & $oldVersion & ". Do you want to download the new version?")
  739.         If $msg = 7 Then                                                                            ;No was pressed
  740.             FileDelete(@ScriptDir & "\version.ini")
  741.         ElseIf $msg = 6 Then                                                                        ;OK was pressed
  742.             $downloadLink = IniRead(@ScriptDir & "\version.ini","Version","download","NotFound")
  743.             $dlhandle = InetGet($downloadLink,@ScriptDir & "\Update.au3",1,1)
  744.             ProgressOn("Update", "Downloading Updates", "",-1,-1,16)                                                        ;creates an progressbar
  745.  
  746.             $Size = InetGetSize($downloadLink,1)                                                    ;get the size of the update
  747.             While Not InetGetInfo($dlhandle, 2)
  748.                 $Percent = (InetGetInfo($dlhandle,0)/$Size)*100
  749.                 ProgressSet( $Percent, $Percent & " percent")                                       ;update progressbar
  750.                 Sleep(1)
  751.             WEnd
  752.             ProgressSet(100 , "Done", "Complete")                                                   ;show complete progressbar
  753.              sleep(500)
  754.             ProgressOff()                                                                           ;close progress window
  755.             IniWrite("updater.ini","version","version",$NewVersion)
  756.             InetClose($dlhandle)
  757.             $iniMsg = IniRead(@ScriptDir & "\version.ini","Version","message","Exiting...")
  758.             MsgBox(-1,"Success","Download Complete! Please restart the bot by running Update.au3" & @CRLF & $iniMsg)
  759.             FileDelete(@ScriptDir & "\version.ini")
  760.             Exit
  761.         EndIf
  762.     EndIf
  763. EndIf
  764. EndFunc
  765.  
  766. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  767.     If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  768.     $findImage = "*TRANSBLACK " & $findImage
  769.     If @AutoItX64 Then
  770.         $result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  771.     Else
  772.         $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  773.     EndIf
  774.     If $result = "0" Then
  775.         Return 0
  776.     EndIf
  777.  
  778.     ; Otherwise get the x,y location of the match and the size of the image to
  779.     ; compute the centre of search
  780.    $array = StringSplit($result[0],"|")
  781.    If(UBound($array) >= 4) Then
  782.       $x=Int(Number($array[2]))
  783.       $y=Int(Number($array[3]))
  784.       If $resultPosition = 1 Then
  785.          $x=$x + Int(Number($array[4])/2)
  786.          $y=$y + Int(Number($array[5])/2)
  787.       EndIf
  788.       Return 1
  789.    EndIf
  790. EndFunc
  791.  
  792. ;Hotkey Functions
  793. Func Leave()
  794.    $Leave = True
  795. EndFunc
  796.  
  797. Func Pause()
  798.    $Leave = False
  799. EndFunc
  800.  
  801. Func TogglePause()
  802.     $Paused = Not $Paused
  803.     While $Paused
  804.         Sleep(100)
  805.                 WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Paused")
  806.         ToolTip('Script is "Paused"', 0, 0)
  807.     WEnd
  808.         WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Running")
  809.     ToolTip("")
  810. EndFunc
  811.  
  812. Func ShowLoot()
  813.     GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  814.     GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  815. EndFunc
  816.  
  817. Func Stop() ;to allow the script to stop
  818.     Exit
  819. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement