Guest User

notAres' Sarkoth DH Gold Script 1.7 for BARB with gold OCR

a guest
Jun 15th, 2012
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 27.76 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:\Program Files (x86)\AutoIt3\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 = 2800 ; 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.     If CheckFor("OldRuins", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  165.         GUICtrlSetData($lblLocation, "Location: Old Ruins")
  166.         ;Check if player needs to repair
  167.         Call("CheckRepair")
  168.         ;Start Run
  169.          MouseClick("middle", Round(587 * $x_ratio),Round(333 * $y_ratio)) ;starts the main run
  170.          Send("3")
  171.          Sleep(1390)
  172.          MouseMove(Round(96*$x_ratio),Round(383*$y_ratio),1)
  173.          Sleep(10)
  174.          Send("1")
  175.          Sleep(800)
  176.          MouseClick("middle", Round(56 * $x_ratio),Round(290 * $y_ratio))
  177.          Sleep(2900)
  178.          MouseMove(Round(335*$x_ratio),Round(260*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  179.          Sleep(600)
  180.         If Call("CheckDead") Then
  181.             Return
  182.         EndIf
  183.  
  184.         ;Checks if Dank Cellar is Open
  185.         $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
  186.         If Not @error Then
  187.         GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  188.             $run += 1
  189.             MouseClick("left",Round(335*$x_ratio),Round(260*$y_ratio)) ;Entrance to cellar
  190.             Sleep(1400)
  191.             Sleep($walktime)
  192.         Else ;ABORT RUN
  193.             GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  194.             Call("AddLog",'No Cellar')
  195.             Sleep(10)
  196.             Send("{SHIFTDOWN}")
  197.             RandClick("left", Round(1100*$x_ratio), Round(600*$y_ratio)) ;ancients
  198.             Send("{SHIFTUP}")
  199.             RandClick("middle", Round(1100*$x_ratio), Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  200.             Moving(250)
  201.             Sleep(620)
  202.             Call("TownPortal")
  203.             If Not Call("CheckDead") Then
  204.                 Call("LeaveGame")
  205.             EndIf
  206.             Return
  207.         EndIf
  208.     Else
  209.         Call("TownPortal")
  210.         If Not Call("CheckDead") Then
  211.             Call("LeaveGame")
  212.         EndIf
  213.         Return
  214.     EndIf
  215.  
  216.     ;Checks that the player is in the Dank Cellar
  217.     If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
  218.       GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  219.       MouseClick("middle",Round(80*$x_ratio),Round(830*$y_ratio)) ;moves to doorway leading to rare inside cellar
  220.       Sleep(2500)
  221.       GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  222.       MouseMove(Round(350*$x_ratio),Round(60*$y_ratio),1) ;hovers over the rare Sarkoth
  223.       Sleep(5)
  224.       Send("1")
  225.       Sleep(10)
  226.       MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
  227.       Sleep(140)
  228.       MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
  229.       Sleep(140)
  230.       MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
  231.       Sleep(1000)
  232.       Send("2")
  233.       Sleep(120)
  234.       Send("2")
  235.       Sleep(120)
  236.       Send("2")
  237.       Sleep(120)
  238.       Send("4")
  239.       Sleep(140)
  240.       Send("4")
  241.       Sleep(140)
  242.       Send("4")
  243.       Send("{SHIFTDOWN}")
  244.       RandClick("left", Round(1100*$x_ratio), Round(600*$y_ratio)) ;ancients
  245.       Send("{SHIFTUP}")
  246.       Sleep(120)
  247.       Send("{SHIFTDOWN}")
  248.       RandClick("left", Round(1100*$x_ratio), Round(600*$y_ratio)) ;ancients
  249.       Send("{SHIFTUP}")
  250.       Sleep(120)
  251.       Send("{SHIFTDOWN}")
  252.       RandClick("left", Round(1100*$x_ratio), Round(600*$y_ratio)) ;ancients
  253.       Send("{SHIFTUP}")
  254.       Sleep(120)
  255.       Send("{SHIFTDOWN}")
  256.       RandClick("left", Round(1100*$x_ratio), Round(600*$y_ratio)) ;ancients
  257.       Send("{SHIFTUP}")
  258.       Sleep(140)
  259.       Sleep(1400)
  260.       MouseClick("middle",Round(730*$x_ratio),Round(585*$y_ratio)) ;move to left top corner for gold
  261.       Sleep(900)
  262.       MouseClick("middle",Round(1205*$x_ratio),Round(380*$y_ratio)) ;move to right top corner for gold
  263.       Sleep(900)
  264.       MouseClick("middle",Round(1020*$x_ratio),Round(773*$y_ratio)) ;move to middle before looting
  265.       Sleep(900)
  266.       MouseClick("middle",Round(900*$x_ratio),Round(400*$y_ratio)) ;move to chest middle
  267.  
  268.       $numitem =0
  269.       $numgem=0
  270.       $numtomb=0
  271.       $numgold=0
  272.       $numpot=0
  273.       GUICtrlSetData($lblStatus, "Status: Looting")
  274.      
  275.       Call("Loot")
  276.       RandSleep(1, 6, 50)
  277.       Send("i")
  278.       Sleep(140)
  279.       $mon = _TesseractScreenCapture( 0, "", 1,  2,1454,508,1920-1571,1080-525, 0)
  280.       $mon = StringReplace($mon , ",", "")
  281.       $mon = StringReplace($mon , @CRLF, "")
  282.       $mon = StringReplace($mon , " ", "")
  283.      
  284.       $mondelt = Number($mon) - Number($monold)
  285.      
  286.       Call("AddLog",'Gold: ' & $mon & ', Gold Delt: ' & $mondelt & ', Items: ' & $numitem & ', Gems: ' & $numgem & ', Books: ' & $numtomb  & ', Potions: ' & $numpot & ', GoldPick: ' & $numgold)
  287.       Send("i")
  288.      
  289.       GUICtrlSetData($lblGold, "Gold: " & $mon & ", This Run: " & $mondelt)
  290.      
  291.       $monold=$mon
  292.      
  293.       Call("TownPortal")
  294.     Else
  295.         Sleep(620)
  296.         Sleep(40)
  297.         Call("TownPortal")
  298.         If Not Call("CheckDead") Then
  299.             Call("LeaveGame")
  300.         EndIf
  301.     EndIf
  302.     ;After successful run
  303.     If Not $Logout And Not $Dead Then
  304.         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
  305.             If $StashLoot Then
  306.                 Call("StashLoot")
  307.             EndIf
  308.             If $VendorLoot Then
  309.                 Call("VendorLoot")
  310.             EndIf
  311.             $mLootIn = Round(Random($mLoot-$mLootOff, $mLoot+$mLootOff)) ;Reset Counter
  312.         ElseIf Not CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  313.             GUICtrlSetData($lblStatus, "Status: Skipping vendor")
  314.             Sleep(1000)
  315.         Else
  316.             $mLootIn -= 1
  317.         EndIf
  318.         If Not Call("CheckDead") Then
  319.             Call("LeaveGame")
  320.         EndIf
  321.         Return
  322.     Else
  323.         Return
  324.     EndIf
  325. EndIf
  326. EndFunc
  327.  
  328. ;Helper Functions
  329.  
  330. Func AddLog($logtxt)
  331.    Local $file = FileOpen("log.txt", 1)
  332.    $msg = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ': ' & $logtxt & @CRLF
  333.    FileWrite($file, $msg )
  334.    FileClose($file)
  335.    ConsoleWrite( $msg)
  336. EndFunc
  337.  
  338.  
  339. Func CheckDead()
  340.     $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
  341.     If Not @error Then
  342.         $Logout = True
  343.         Call("AddLog","Logged out")
  344.         GUICtrlSetData($lblStatus, "Status: Logging out")
  345.         Sleep(11000)
  346.         Sleep($loadtime)
  347.         Return 1
  348.     EndIf
  349.  
  350.     $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"
  351.     If Not @error Then
  352.         GUICtrlSetData($lblStatus, "Status: Dead")
  353.         Call("AddLog","You have died")
  354.         $Dead = True
  355.         Call("LeaveGame")
  356.         Sleep(11000)
  357.         Return 1
  358.     Else
  359.         $Dead = False
  360.         Return 0
  361.     EndIf
  362. EndFunc
  363.  
  364. Func CheckRepair()
  365. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  366.    If Not @error Then
  367.       Call("DoRepair")
  368.    EndIf
  369. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  370.    If Not @error Then
  371.       Call("DoRepair")
  372.    EndIf
  373. EndFunc
  374.  
  375. Func DoRepair()
  376.     Sleep(Random(75, 150))
  377.     Call("TownPortal")
  378.     If Call("CheckDead") Then
  379.         Return
  380.     EndIf
  381.     If CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  382.         RandClick("left", Round(1480*$x_ratio),Round(281*$y_ratio),1,1) ;begin movement towards merchant
  383.         Moving(1875)
  384.         RandClick("left", Round(1316*$x_ratio),Round(206*$y_ratio),1,1) ;moves to get merchant in screen
  385.         Moving(1875)
  386.         RandClick("left", Round(845*$x_ratio),Round(225*$y_ratio),1,1) ;NPC Merchant to the right of cain's home
  387.         Sleep(1200)
  388.         RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  389.         Sleep(400)
  390.         RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  391.         Sleep(200)
  392.         Send("{Escape}")
  393.         Call("AddLog","Repair")
  394.         If Not Call("CheckDead") Then
  395.             Call("LeaveGame")
  396.         EndIf
  397.     EndIf
  398. EndFunc
  399.  
  400. Func CalcTime()
  401.     $srt = TimerDiff($rt)
  402.     GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt/1000,2) & " seconds.")
  403.     $trt = TimerDiff($t)
  404.     $total = Round((($trt/1000)/60)/60,4)
  405.  
  406.     ;Total runtiume calculation.
  407.     $hours = Floor((($trt/1000)/60)/60)
  408.     $minutes = (($trt/1000)/60)
  409.     ;trim minutes if runtime is more then 1 hour.
  410.     If $minutes > 60 Then
  411.         While $minutes > 60
  412.             $minutes -=60
  413.         WEnd
  414.     EndIf
  415.     GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, "& Ceiling($minutes) &" minutes")
  416.  EndFunc
  417.  
  418.  Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 5 ,$tolerance = 130)
  419.     $c = 0
  420.     $string = $pngLoc & $img & ".png"
  421.     Do
  422.         $c +=1
  423.         Sleep(100)
  424.         If $c > ($seconds*10) Then ;Make sure we never get stuck here for infinity.
  425.             If $type = "Area" Then
  426.                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  427.             EndIf
  428.             Return False
  429.         EndIf
  430.     Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  431.     Return True
  432. EndFunc
  433.  
  434. Func LeaveGame()
  435.     $Logout = True
  436.     Call("RandSleep")
  437.     GUICtrlSetData($lblStatus, "Status: Leaving Game")
  438.     Sleep(Random(100, 500))
  439.     Send("{Escape}")
  440.     Sleep(Random(100, 500))
  441.     RandClick("left", Round(956*$x_ratio), Round(579*$y_ratio), 120, 20) ;Random Click on the leave button
  442.     Call("CalcTime")
  443. EndFunc
  444.  
  445. Func Loot()
  446.     Sleep(Random(500,2000))
  447.     MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  448.     If $LootSets Then
  449.       $SetCount += LootGear(0x02CE01, 2)
  450.     EndIf
  451.     If $LootLegendaries Then
  452.       $LegendaryCount += LootGear(0xBF642F, 0)
  453.     EndIf
  454.     If $LootRares Then
  455.       $RareCount += LootGear(0xBBBB00, 2)
  456.     EndIf
  457.     If $LootGems Then
  458.       Call("LootGems")
  459.     EndIf
  460.     If $LootTomes Then
  461.       Call("LootTomes")
  462.    EndIf
  463.    If $LootMagic Then
  464.       $MagicCount += LootGear(0x6969FF, 2)
  465.     EndIf
  466.     If $LootCustom Then
  467.       Call("LootCustom")
  468.     EndIf
  469.  
  470.     Call("ShowLoot")
  471.  EndFunc
  472.  
  473. Func LootGear($color, $tolerance = 2)
  474.    $count = 0
  475.    $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance)
  476.    If Not @error Then
  477.       While Not @error
  478.          $count += 1
  479.          MouseClick ('left', $Loot[0], $Loot[1])
  480.          Sleep(Random(700,900))
  481.          MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  482.          ;Run at max 10 times per quality
  483.          If $count >= 10 Then
  484.             ExitLoop
  485.          EndIf
  486.          $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance)
  487.       WEnd
  488.    EndIf
  489.    $numitem += $count;
  490.    Return $count
  491. EndFunc
  492.  
  493. Func LootCustom()
  494.     $gX = 0
  495.     $gY = 0
  496.     for $i = 0 to ($totalItems - 1)
  497.         $array = StringSplit($pick[$i],"|")
  498.         $file = $array[1]
  499.         $accuracy = $array[2]
  500.         $urlString = $pngLoc & $file
  501.         $count = 0
  502.         While _ImageSearchArea($pngLoc & $file,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,$accuracy)
  503.             $count += 1
  504.             if $i = 0 then $numpot+=1
  505.             if $i = 1 then $numgold+=1
  506.             sleep(Random(75, 150))
  507.             MouseClick("left",$gX,$gY,1,1)
  508.             sleep(Random(800, 1200))
  509.             MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  510.             If $count >= 10 Then
  511.                ExitLoop
  512.          EndIf
  513.         WEnd
  514.     next
  515. EndFunc
  516.  
  517. Func LootGems()
  518.     $gX = 0
  519.     $gY = 0
  520.     While _ImageSearchArea($pngLoc & "square.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90)
  521.         sleep(Random(75, 150))
  522.         MouseClick("left",$gX,$gY)
  523.         $GemCount += 1
  524.         $numgem += 1
  525.         sleep(Random(800, 1200))
  526.         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  527.     WEnd
  528. EndFunc
  529.  
  530. Func LootTomes()
  531.     $gX = 0
  532.     $gY = 0
  533.     While _ImageSearchArea($pngLoc & "tome.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90)
  534.         sleep(Random(75, 150))
  535.         MouseClick("left",$gX,$gY)
  536.         $TomeCount += 1
  537.         $numtomb += 1
  538.         sleep(Random(800, 1200))
  539.         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  540.     WEnd
  541. EndFunc
  542.  
  543. Func Moving($time)
  544.     Sleep($time/$movementSpeed)
  545. EndFunc
  546.  
  547. Func RandClick($clickType, $xPos, $yPos, $xOff = 20, $yOff = 20)
  548.     $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  549.     $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  550.     MouseClick($clickType, $randX, $randY)
  551. EndFunc
  552.  
  553. Func RandMove($xPos, $yPos, $xOff = 20, $yOff = 20)
  554.     $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  555.     $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  556.     MouseMove($randX, $randY)
  557. EndFunc
  558.  
  559. Func RandSleep($min = 30, $max = 45, $chance = 5)
  560.     $randNum = Round(Random(1, 100))
  561.     If $Timer And $randNum <= $chance Then
  562.         $sleepTime = Random($min*1000, $max*1000)
  563.         GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime/1000) & " secs")
  564.  
  565.         For $c = 0 To 10
  566.             Sleep($sleepTime/10)
  567.         Next
  568.     EndIf
  569. EndFunc
  570.  
  571. Func TownPortal()
  572.     GUICtrlSetData($lblStatus, "Status: Returning to Town")
  573.     Send("t")
  574.     Sleep(Random($tptime, $tptime+500))
  575. EndFunc
  576.  
  577. Func StashLoot()
  578.     GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  579.     Sleep(Random(1000, 1500))
  580.     MouseClick("left", 1064*$x_ratio, 256*$y_ratio)
  581.     Sleep(Random(1500, 2000))
  582.  
  583.    $numstashed=0;
  584.  
  585.     ;Legendaries
  586.     if $StashLegendary then
  587.     $sc = 0
  588.     While $sc < 5
  589.         Sleep(Random(200, 300))
  590.         $LegendPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4D2C0D, 0)
  591.         If Not @error Then
  592.             GUICtrlSetData($lblStatus, "Status: Stashing Legendaries")
  593.             MouseClick("right", $LegendPixel[0], $LegendPixel[1])
  594.             $numstashed += 1;
  595.         Else
  596.             ExitLoop
  597.          EndIf
  598.          $sc += 1
  599.     WEnd
  600.     if $sc=5 then Call("AddLog","Stash full")
  601.     EndIf
  602.  
  603.     ;Rares
  604.     if $StashRare then
  605.        $sc = 0
  606.     While $sc < 10
  607.         Sleep(Random(200, 300))
  608.         $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  609.         If Not @error Then
  610.             GUICtrlSetData($lblStatus, "Status: Stashing Rares")
  611.             MouseClick("right", $RarePixel[0], $RarePixel[1])
  612.             $numstashed += 1;
  613.         Else
  614.             ExitLoop
  615.          EndIf
  616.          $sc += 1
  617.     WEnd
  618.     if $sc=10 then Call("AddLog","Stash full")
  619. EndIf
  620.     ;Tomes
  621.     If _ImageSearchArea($pngLoc & "TomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,200) Then
  622.         GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  623.  
  624.         MouseClick("right",$gX,$gY,1,1)
  625.         Sleep(Random(400, 600))
  626.  
  627.     EndIf
  628.  
  629.     ;Magic
  630.     if $StashMagic then
  631.        $sc = 0
  632.     While $sc < 20
  633.         Sleep(Random(100, 300))
  634.         $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  635.         If Not @error Then
  636.             GUICtrlSetData($lblStatus, "Status: Stashing Magic")
  637.             MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  638.             $numstashed += 1;
  639.         Else
  640.             ExitLoop
  641.          EndIf
  642.          $sc += 1
  643.     WEnd
  644.     if $sc=20 then Call("AddLog","Stash full")
  645.  EndIf
  646.  
  647.     Call("AddLog","Stashed Items: " & $numstashed )
  648.  
  649.     ;Gems
  650.     If $StashGems Then
  651.        GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  652.        
  653.        for $gemtype = 1 to 8
  654.          
  655.          if $gemtype = 1 then $gemnane = "Ru1.png"
  656.          if $gemtype = 2 then $gemnane = "Ru2.png"
  657.          if $gemtype = 3 then $gemnane = "Em1.png"
  658.          if $gemtype = 4 then $gemnane = "Em2.png"
  659.          if $gemtype = 5 then $gemnane = "To1.png"
  660.          if $gemtype = 6 then $gemnane = "To2.png"
  661.          if $gemtype = 7 then $gemnane = "Am1.png"
  662.          if $gemtype = 8 then $gemnane = "Am2.png"
  663.      
  664.          If _ImageSearchArea($pngLoc & $gemnane ,1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,180) Then
  665.             GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  666.             MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  667.             Sleep(Random(200, 500))
  668.             MouseClick("right",$gX,$gY,1,1)
  669.             Sleep(Random(400, 600))
  670.             MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  671.             Sleep(Random(200, 500))
  672.          EndIf
  673.          
  674.       Next
  675.        
  676.     EndIf
  677.     Sleep(Random(1000, 3000))
  678.     Send("{SPACE}")
  679. EndFunc
  680.  
  681. Func VendorLoot()
  682.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  683.     If Not $StashLoot Then ;Move from TP towards vendor
  684.         Sleep(Random(300, 500))
  685.         MouseClick("middle", 1565*$x_ratio, 50*$y_ratio)
  686.     Else ;Move from Stash towards vendor
  687.         Sleep(Random(300, 500))
  688.         MouseClick("middle", 1560*$x_ratio, 120*$y_ratio)
  689.     EndIf
  690.     Sleep(3000)
  691.     Send("c")
  692.     Sleep(700)
  693.     While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, $gX, $gY, 120)
  694.         GUICtrlSetData($lblStatus, "Status: Identifying")
  695.         Sleep(Random(75, 150))
  696.         RandClick("right",$gX,$gY,1,1)
  697.         Sleep(Random(2400, 2800))
  698.     WEnd
  699.     Send("c")
  700.     Sleep(600)
  701.     MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
  702.     Sleep(3000)
  703.  
  704. $numsold=0;
  705.     ;Rares
  706.     If $VendorRare Then
  707.         $c = 0
  708.         While $c <= 10
  709.             Sleep(Random(200, 300))
  710.             $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  711.             If Not @error Then
  712.                 MouseClick("right", $RarePixel[0], $RarePixel[1])
  713.                 $numsold += 1
  714.                 $c += 1
  715.             Else
  716.                 ExitLoop
  717.             EndIf
  718.         WEnd
  719.     EndIf
  720.  
  721.     ;Magic
  722.     If $VendorMagic Then
  723.         $c = 0
  724.         While $c <= 25
  725.             Sleep(Random(200, 300))
  726.             $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  727.             If Not @error Then
  728.                 MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  729.                 $numsold += 1
  730.                 $c += 1
  731.             Else
  732.                 ExitLoop
  733.             EndIf
  734.         WEnd
  735.      EndIf
  736.      
  737.      Call("AddLog","Sold Items: " & $numsold )
  738.  
  739.     Sleep(200)
  740.     RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  741.     Sleep(300)
  742.     RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  743.     Sleep(200)
  744.     Call("AddLog","Sell and Repair")
  745.     Sleep(Random(1000, 3000))
  746.     GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  747.     Send("{ESCAPE}")
  748. EndFunc
  749.  
  750.  
  751. Func DoUpdate()
  752. $Ini = InetGet($VersionsInfo,@ScriptDir & "\version.ini")                                           ;download version.ini
  753. If $Ini = 0 Then                                                                                    ;was the download of version.ini successful?
  754.     MsgBox(0,"ERROR","The server seems to be offline. No update will be done.")
  755. Else
  756.     $newVersion = IniRead (@ScriptDir & "\version.ini","Version","Version","")                      ;reads the new version out of version.ini
  757.     If $NewVersion = $oldVersion Then                                                               ;compare old and new
  758.         ;MsgBox (0,"No update","There is no update available!")
  759.         FileDelete(@ScriptDir & "\version.ini")
  760.     Else
  761.         $msg = MsgBox (4,"Update","There is a new version existing: " & $newVersion & " ! You are using: " & $oldVersion & ". Do you want to download the new version?")
  762.         If $msg = 7 Then                                                                            ;No was pressed
  763.             FileDelete(@ScriptDir & "\version.ini")
  764.         ElseIf $msg = 6 Then                                                                        ;OK was pressed
  765.             $downloadLink = IniRead(@ScriptDir & "\version.ini","Version","download","NotFound")
  766.             $dlhandle = InetGet($downloadLink,@ScriptDir & "\Update.au3",1,1)
  767.             ProgressOn("Update", "Downloading Updates", "",-1,-1,16)                                                        ;creates an progressbar
  768.  
  769.             $Size = InetGetSize($downloadLink,1)                                                    ;get the size of the update
  770.             While Not InetGetInfo($dlhandle, 2)
  771.                 $Percent = (InetGetInfo($dlhandle,0)/$Size)*100
  772.                 ProgressSet( $Percent, $Percent & " percent")                                       ;update progressbar
  773.                 Sleep(1)
  774.             WEnd
  775.             ProgressSet(100 , "Done", "Complete")                                                   ;show complete progressbar
  776.              sleep(500)
  777.             ProgressOff()                                                                           ;close progress window
  778.             IniWrite("updater.ini","version","version",$NewVersion)
  779.             InetClose($dlhandle)
  780.             $iniMsg = IniRead(@ScriptDir & "\version.ini","Version","message","Exiting...")
  781.             MsgBox(-1,"Success","Download Complete! Please restart the bot by running Update.au3" & @CRLF & $iniMsg)
  782.             FileDelete(@ScriptDir & "\version.ini")
  783.             Exit
  784.         EndIf
  785.     EndIf
  786. EndIf
  787. EndFunc
  788.  
  789. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  790.     If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  791.     $findImage = "*TRANSBLACK " & $findImage
  792.     If @AutoItX64 Then
  793.         $result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  794.     Else
  795.         $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  796.     EndIf
  797.     If $result = "0" Then
  798.         Return 0
  799.     EndIf
  800.  
  801.     ; Otherwise get the x,y location of the match and the size of the image to
  802.     ; compute the centre of search
  803.    $array = StringSplit($result[0],"|")
  804.    If(UBound($array) >= 4) Then
  805.       $x=Int(Number($array[2]))
  806.       $y=Int(Number($array[3]))
  807.       If $resultPosition = 1 Then
  808.          $x=$x + Int(Number($array[4])/2)
  809.          $y=$y + Int(Number($array[5])/2)
  810.       EndIf
  811.       Return 1
  812.    EndIf
  813. EndFunc
  814.  
  815. ;Hotkey Functions
  816. Func Leave()
  817.    $Leave = True
  818. EndFunc
  819.  
  820. Func Pause()
  821.    $Leave = False
  822. EndFunc
  823.  
  824. Func ShowLoot()
  825.     GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  826.     GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  827. EndFunc
  828.  
  829. Func Stop() ;to allow the script to stop
  830.     Exit
  831. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment