Advertisement
Guest User

Don DooBee v1.3b

a guest
Jun 30th, 2012
1,263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 53.45 KB | None | 0 0
  1. ; Don DooBee's v1.3b
  2. ; + rep @ ownedcore if you enjoy the script
  3.  
  4.  
  5. ; you will need tesseract from https://tesseract-ocr.googlecode.com/files/tesseract-ocr-setup-3.01-1.exe
  6. ; and you will need tesserect library to in your auto it include folder from https://dl.dropbox.com/u/22203901/Tesseract.au3
  7. ; you will also need image files and search dlls from https://dl.dropbox.com/u/9955791/BotFiles.zip
  8. ; and http://www45.zippyshare.com/v/15622375/file.html
  9.  
  10.  
  11. ;notAres' Gold Script for Monk - 6/30/2012
  12. ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
  13. ;;;;;
  14. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  15. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  16. ;Official supported resolution: 1920x1080
  17. ;;;;;
  18. ;Original by mackus101 @ ownedcore
  19. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  20. ;Refactoring and additional functions by Shimizoki
  21.  
  22. ;=========== DO NOT TOUCH ===========;
  23. #RequireAdmin
  24. #include <GUIConstantsEx.au3>
  25. #include <StaticConstants.au3>
  26. #include <WindowsConstants.au3>
  27.  
  28.  
  29. ;=========== mypart ===========;
  30. #include <Tesseract.au3>
  31. Global $numitem, $numgem, $numtomb, $numgold, $numpot, $lblGold, $numsold, $numstashed, $monold = 0, $mon = 0, $monstart = 0, $SprintStart
  32.  
  33. Opt('MouseCoordMode', 2)
  34. Opt('PixelCoordMode', 2)
  35. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "Don DooBee's ", $hFont = 0, $title, $Paused, $Go = False, $i = 0, $gX = 0, $gY = 0, $LegendaryCount = 0, $SetCount = 0, $RareCount = 0, $MagicCount = 0, $GemCount = 0, $TomeCount = 0, $deathCount = 0, $cellarCount = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000, $lblRun, $lblLocation, $lblStatus, $lblLast, $lblRuntime, $lblGear, $lblItems
  36. Global $str_Stash, $str_StashGems, $str_StashMisc, $str_Vendor, $str_Salvage, $int_TownPosition
  37. For $i = 0 To Random(0, 3, 1)
  38.     $title &= Chr(Random(97, 122, 1))
  39. Next
  40. For $i = 0 To Random(2, 5, 1)
  41.     $title &= Chr(Random(65, 90, 1))
  42. Next
  43. $title &= " "
  44. Global $gems[8] = ["Ru1.png", "Ru2.png", "Em1.png", "Em2.png", "To1.png", "To2.png", "Am1.png", "Am2.png"]
  45. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  46. If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
  47. If $size = 0 Then
  48.     MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  49.     Exit
  50. EndIf
  51. ;====================================;
  52.  
  53.  
  54. ;============= SETTINGS =============;
  55. HotKeySet("=", "Begin") ;script toggled on/off by pressing =
  56. HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
  57. HotKeySet("x", "Stop") ;script stopped by pressing x
  58. HotKeySet("0", "GoTown") ;script stopped by pressing x
  59.  
  60. $movementSpeed = 0 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
  61.  
  62. ;Custom Loot
  63. $pngLoc = "C:\Program Files (x86)\AutoIt3\pics\" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  64. $totalItems = 2 ;Number of items in the pick array
  65. Global $pick[$totalItems] ;DONT CHANGE THIS
  66.  
  67. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  68. $pick[0] = "mythic.png|50" ;png|Tolerance
  69. $pick[1] = "gold.png|50"
  70. ;$pick[2] = "item3.png"
  71.  
  72. ;General
  73. $ExtraSafeExit = True ;use ancients when you port back to prevent death if you have low HP
  74. $RunsUntilMenuWait = 0 ;wait for 1 hour at menu after x successful runs, set to 0 to disable
  75. $TakeMissShots = False ;take screenshots into \shots folder on every cellar miss for finding positions
  76. $SarkothKillTime = 800 ;additional time delay to wait for sarkoth to die use 2800 for 10K dps 800 for 15kdps etc
  77. $DetectTPFail = False ;set true to immediatly exit game if TP is inturrupted (requires TP.png)
  78. $TPProtectTime = 2.5 ;number of seconds to check for TP inturrupt if TPfail detection is enabled if your pc is slow reduce this number
  79. $BlankLamps = True ;enable/disable putting boxes over the lamps before looting legendaries to reduce false positives
  80. $ReduceLegendSearch = False ; limit legendary searching to lower part of screen to reduce false finds
  81.  
  82. ;define your own cellar co-ords here, list the most likely ones first for efficiency
  83. ;change the [4] to how many co-ords you listed
  84. Dim $celx[4] = [300, 210, 190, 250]
  85. Dim $cely[4] = [179, 179, 224, 160]
  86.  
  87. ;Buttons
  88. $skillCaltrops = "1"
  89. $skillSmokeScreen = "2"
  90. $skillPreparation = "3"
  91. $skillCompanion = "4"
  92. $TownPortalButton = "t"
  93. $Inventory = "i"
  94.  
  95. ;Looting
  96. $LootSets = True ;True if you want to pick up Sets
  97. $LootLegendaries = True;True if you want to pick up Legendaries
  98. $LootRares = True ;True if you want to pick up Rares
  99. $LootMagic = True ;True if you want to pick up Magic
  100. $LootGems = True ;True if you want to pick up Gems
  101. $LootTomes = True ;True if you want to pick up Tome of Secrets
  102. $LootCustom = false ;True if you want to pick up Custom Items (The items in the $pick array above)
  103.  
  104. ;Manage Loot
  105. $Identify = True ;True to enable identifying items before stashing/vendoring
  106. $mLoot = 8 ;Nuber of successful runs until Stash and Vendor
  107. $mLootOff = 2 ;Stash and Vendor after mLoot +- X number of runs (Variability)
  108.  
  109. ;Variability ==NEW SETTINGS==
  110. $Timer = False ;True and the bot will add random sleep intervals
  111. $walktime = 2400 ;Time (in ms) the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  112. $loadtime = 3400 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  113. $tptime = 6900 ;Time (in ms) the script waits for teleport before exiting the game
  114.  
  115. ;Stashing/vendoring COMMON
  116. $StashRare = True ;True if you want to store Rare items in the stash
  117. $StashMagic = False ;True if you want to store Magic items in the stash
  118.  
  119. $VendorRare = False ;True if you want to vendor Rares
  120. $VendorMagic = True ;True if you want to vendor Magic
  121.  
  122.  
  123. $GemTab = 1;Tab to put gems and tombs in
  124. $ItemTab = 2 ;Tab to put any items in
  125. $NextItemTab = 3 ;Next Tab to put any items in when first one is full
  126.  
  127. ;--------------------------------------------TRADITIONAL----------------------------------------------------
  128. ;Stashing/vendoring TRADITIONAL METHOD to enable set line 155 to FALSE
  129. $StashLoot = True ;True if you want to store Items in the stash
  130. $StashLegendary = True;True if you want to store Legendary items in the stash
  131. $StashTomes = True ;True if you want to store Tomes items in the stash
  132. $StashGems = True ;True if you want to store Gems items in the stash
  133.  
  134. ;SALVAGE - setting this will OVERRIDE traditional vendoring options - it will be skipped
  135. ; make sure you have a stack of each material in your bottom row( which is not scanned )for it to add To
  136. ; otherwise it will start tying to salvage your craft items and do nothing!
  137. $SalvageLoot = False
  138.  
  139. ;Vendoring ==NEW SETTINGS==
  140. $VendorLoot = True ;True if you want to vendor anything
  141. $vendorAll = False ;True if you want to right click all items when talking to vendor
  142. $vendorRows = 6 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
  143. $vendorCols = 10 ;# of columns to vendor, starting from left
  144. ;--------------------------------------------TRADITIONAL----------------------------------------------------
  145.  
  146.  
  147. ;--------------------------------------------iLVL----------------------------------------------------
  148. $UseiLVL = True ;set true or false to enable the iLVL system THIS OVERRIDES ALL "TRADITIONAL" SETTINGS
  149. ;====================================;
  150. ;New Analyze Loot Settings Options are "salvage", "stash", and "vend"
  151. $i59Rare = "vend"
  152. $i60Rare = "stash"
  153. $i61Rare = "stash"
  154. $i62Rare = "stash"
  155. $i63Rare = "stash"
  156.  
  157. $i59Magic = "vend"
  158. $i60Magic = "vend"
  159. $i61Magic = "vend"
  160. $i62Magic = "vend"
  161. $i63Magic = "stash"
  162. ;====================================;
  163. ;--------------------------------------------iLVL----------------------------------------------------
  164. $x_ratio = $size[0] / 1920
  165. $y_ratio = $size[1] / 1080
  166.  
  167. $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
  168. $RunsUntilMenuWaitCnt = $RunsUntilMenuWait
  169. If $totalItems < 1 Then $LootCustom = False
  170. $movementSpeed = 1 + ($movementSpeed / 100)
  171.  
  172. If $TakeMissShots Then
  173.     DirCreate("shots")
  174. EndIf
  175.  
  176. If Not FileExists($pngLoc & "MainMenu.png") Then
  177.     $pngLoc = "C:\pics\"
  178.     If Not FileExists($pngLoc & "MainMenu.png") Then
  179.         MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  180.         Exit
  181.     EndIf
  182. EndIf
  183.  
  184.  
  185.  
  186. Call("SetupGUI")
  187. While 1
  188.     Call("RestartRun")
  189. WEnd
  190.  
  191. Func RestartRun()
  192.     If ($Go) Then
  193.         $i = 0
  194.         Send("{SPACE}")
  195.         WinSetTitle($title, "", $title & $ver & " - Running")
  196.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  197.         ;Checks if the player is Dead/Logout/Window, then if in Main Menu, etc.
  198.         If CheckDead() Then
  199.             Return
  200.         ElseIf CheckFor("ExitGame", "", Round(860 * $x_ratio), Round(400 * $y_ratio), Round(1040 * $x_ratio), Round(450 * $y_ratio), 0.5, 140) Then
  201.             GUICtrlSetData($lblStatus, "Status: Exit window up")
  202.             MouseClick("left", Round(1064 * $x_ratio), Round(632 * $y_ratio))
  203.             Sleep(100)
  204.             Send("{SPACE}")
  205.             Return
  206.         ElseIf CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio)) Then
  207.             GUICtrlSetData($lblRun, "Runs till vendor: " & $mLootIn & ", Run Number: " & $run)
  208.             GUICtrlSetData($lblLocation, "Location: Main Menu")
  209.             GUICtrlSetData($lblStatus, "Status: Starting Game")
  210.            
  211.             RandClick("left", Round(230 * $x_ratio), Round(416 * $y_ratio), 120, 20, 1, 6) ;Random Click on the resume button
  212.             CheckFor("OldRuins", "Area", 0, 0, 0, 0, $loadtime / 1000)
  213.             ;Sleep($loadtime)
  214.             $rt = TimerInit()
  215.             $run += 1
  216.         ElseIf CheckFor("OldRuins", "Area") Or CheckFor("NewTristram", "Area") Or CheckFor("DankCellar", "Area") Then
  217.             Call("TownPortal")
  218.             Call("LeaveGame")
  219.             Return
  220.         ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  221.             MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio))
  222.             $rand = Random(40000, 80000)
  223.             GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
  224.             Sleep($rand)
  225.             Send("{SPACE}")
  226.             Return
  227.         ElseIf CheckFor("Disconnect", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  228.             GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
  229.             MouseClick("left", Round(960 * $x_ratio), Round(632 * $y_ratio))
  230.             Sleep(100)
  231.             Send("{SPACE}")
  232.             Return
  233.         Else
  234.             GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  235.             Return
  236.         EndIf
  237.        
  238.         $CellarWasFound = 0
  239.          
  240.     If CheckFor("OldRuins", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  241.                 GUICtrlSetData($lblLocation, "Location: Old Ruins")
  242.                 ;Check if player needs to repair
  243.                 Call("CheckRepair")
  244.                 ;Start Run
  245.                 MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  246.                 Send("{4 DOWN}")
  247.                 Sleep(3500)
  248.                 Send("{4 UP}")
  249.                 Sleep(100)
  250.                 MouseMove(Round(356*$x_ratio),Round(200*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  251.                 Sleep(790)
  252.                 If Call("CheckDead") Then
  253.                         Return
  254.                 EndIf
  255.  
  256.         ;Checks if Dank Cellar is Open
  257.                 $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
  258.                 If Not @error Then
  259.                 GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  260.                 $run += 1
  261.                         MouseClick("left", Round(356*$x_ratio), Round(200*$y_ratio), 1) ;Entrance to cellar
  262.                         Moving(550)
  263.                         Send($skillSmokeScreen)
  264.                         Moving($walktime)
  265.                 Else ;ABORT RUN
  266.                         GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  267.                         Sleep(10)
  268.                         Send($skillPreparation)
  269.                         sleep(40)
  270.                         RandClick("middle", Round(1100*$x_ratio), Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  271.                         Moving(250)
  272.                         Send($skillCaltrops)
  273.                         Sleep(620)
  274.                         Send($skillSmokeScreen)
  275.                         Sleep(40)
  276.                         Call("TownPortal")
  277.                         sleep(600)
  278.                         If Not Call("CheckDead") Then
  279.                                 Call("LeaveGame")
  280.                         EndIf
  281.                         Return
  282.                
  283.         EndIf
  284.     Else
  285.         Call("TownPortal")
  286.         If Not Call("CheckDead") Then
  287.             Call("LeaveGame")
  288.         EndIf
  289.         Return
  290.      EndIf
  291.      
  292.         ;Checks that the player is in the Dank Cellar
  293.         If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
  294.                 GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  295.                 MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  296.                 Sleep(Random(2200, 2800))
  297.                 Send(3)
  298.                 Sleep(30)
  299.                 MouseClick("middle",Round(440*$x_ratio),Round(80*$y_ratio), 1) ;attacks the rare Sarkoth
  300.                 Sleep(2100)
  301.                 Send("{SHIFTDOWN}")
  302.                 Sleep(10)
  303.                 GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  304.                 MouseClick("left")
  305.                 Sleep(10)
  306.                 Send(2)
  307.                 Sleep(10)
  308.                 MouseDown("right") ;attack middle
  309.                 Sleep(3500)
  310.                 MouseClick("right",Round(960*$x_ratio),Round(502*$y_ratio),2)
  311.                 Sleep(100)
  312.                 Send("{SHIFTUP}")
  313.                 Sleep(10)
  314.                 Send(3)
  315.                 Sleep(10)
  316.                 GUICtrlSetData($lblStatus, "Status: Looting")
  317.                 MouseClick("middle",Round(637*$x_ratio),Round(540*$y_ratio)) ;move to left top corner for gold
  318.                 Sleep(1100)
  319.                 MouseClick("middle",Round(1320*$x_ratio),Round(310*$y_ratio)) ;move to right top corner for gold
  320.                 Sleep(1100)
  321.                 MouseClick("middle",Round(975*$x_ratio),Round(827*$y_ratio)) ;move to middle before looting
  322.                 Sleep(1500)
  323.  
  324.       $numitem =0
  325.       $numgem=0
  326.       $numtomb=0
  327.       $numgold=0
  328.       $numpot=0
  329.       GUICtrlSetData($lblStatus, "Status: Looting")
  330.      
  331.       Call("Loot")
  332.       RandSleep(1, 6, 50)
  333.       Send("i")
  334.       Sleep(140)
  335.       $mon = _TesseractScreenCapture( 0, "", 1,  2,1454,508,1920-1571,1080-525, 0)
  336.       $mon = StringReplace($mon , ",", "")
  337.       $mon = StringReplace($mon , @CRLF, "")
  338.       $mon = StringReplace($mon , " ", "")
  339.      
  340.       $mondelt = Number($mon) - Number($monold)
  341.      
  342.       Call("AddLog",'Gold: ' & $mon & ', Gold Delt: ' & $mondelt & ', Items: ' & $numitem & ', Gems: ' & $numgem & ', Books: ' & $numtomb  & ', Potions: ' & $numpot & ', GoldPick: ' & $numgold)
  343.       Send("i")
  344.      
  345.       GUICtrlSetData($lblGold, "Gold: " & $mon & ", This Run: " & $mondelt)
  346.      
  347.       $monold=$mon
  348.      
  349.       Call("TownPortal")
  350.     Else
  351.         Sleep(620)
  352.         Sleep(40)
  353.         Call("TownPortal")
  354.         If Not Call("CheckDead") Then
  355.             Call("LeaveGame")
  356.         EndIf
  357.     EndIf
  358.     ;After successful run
  359.     If Not CheckDead() Then
  360.         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
  361.            
  362.             If $UseiLVL Then
  363.                     Call("AnalyseLoots") ;ilvl discriminatory stashing
  364.            
  365.             Else
  366.                     If $Identify Then Call("Identify")
  367.                     If $StashLoot Then Call("StashLoot")
  368.                    
  369.                     If $SalvageLoot Then
  370.                         Call("SalvageLoot")
  371.                     Else
  372.                         If $VendorLoot Then Call("VendorLoot")
  373.                     EndIf
  374.             EndIf
  375.                  
  376.             $mLootIn = Round(Random($mLoot-$mLootOff, $mLoot+$mLootOff)) ;Reset Counter
  377.         ElseIf Not CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  378.             GUICtrlSetData($lblStatus, "Status: Skipping vendor")
  379.             Sleep(1000)
  380.         Else
  381.             $mLootIn -= 1
  382.         EndIf
  383.         If Not Call("CheckDead") Then
  384.             Call("LeaveGame")
  385.         EndIf
  386.         Return
  387.     Else
  388.         Return
  389.     EndIf
  390. EndIf
  391. EndFunc
  392.  
  393. ;Helper Functions
  394.  
  395. Func SetupGUI()
  396.     $frmBot = GUICreate($title & $ver & "Waiting...", 290, 140, Round(1580 * $x_ratio), Round(900 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  397.     GUISetBkColor(0xC0C0C0)
  398.     $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  399.     GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  400.     GUICtrlSetColor(-1, 0xFF0000)
  401.     $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  402.     $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  403.     $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  404.     $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  405.     $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  406.     $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  407.     $lblGold = GUICtrlCreateLabel("Gold: 0", 12, 110, 240, 17)
  408.     GUISetState(@SW_SHOW)
  409. EndFunc   ;==>SetupGUI
  410.  
  411.  
  412. Func CheckDead()
  413.     $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
  414.     If Not @error Then
  415.        
  416.         Call("AddLog", "Logged out")
  417.         GUICtrlSetData($lblStatus, "Status: Logging out")
  418.         CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), $loadtime / 1000)
  419.  
  420.         Return 1
  421.     EndIf
  422.  
  423.     $CloseButton = PixelSearch(Round(1570 * $x_ratio), Round(110 * $y_ratio), Round(1590 * $x_ratio), Round(120 * $y_ratio), 0x8C2300) ; checks for the red color of the "X" on an open window
  424.     If Not @error Then
  425.         GUICtrlSetData($lblStatus, "Status: Open Window")
  426.         Call("AddLog", "Open Window")
  427.         Sleep(200)
  428.         Send("{SPACE}") ;close any open windows
  429.         Return 1
  430.     EndIf
  431.     $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"
  432.     If Not @error Then
  433.         GUICtrlSetData($lblStatus, "Status: Dead")
  434.         Call("AddLog", "You have died")
  435.         $deathCount += 1
  436.         Call("LeaveGame")
  437.         For $c = 1 To 110 + $loadtime / 100
  438.             Sleep(100)
  439.             If CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), 0.1) Then ExitLoop
  440.         Next
  441.         Return 1
  442.     Else
  443.         Return 0
  444.     EndIf
  445. EndFunc   ;==>CheckDead
  446.  
  447. Func CheckRepair()
  448.     $RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
  449.     If Not @error Then
  450.         Call("DoRepair")
  451.     EndIf
  452.     $RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
  453.     If Not @error Then
  454.         Call("DoRepair")
  455.     EndIf
  456. EndFunc   ;==>CheckRepair
  457.  
  458. Func DoRepair()
  459.     Sleep(Random(75, 150))
  460.     Call("TownPortal")
  461.     If CheckDead() Then
  462.         Return
  463.     EndIf
  464.     If CheckFor("NewTristram", "Area") Then
  465.         RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
  466.         Moving(1875)
  467.         RandClick("left", Round(1316 * $x_ratio), Round(206 * $y_ratio), 1, 1) ;moves to get merchant in screen
  468.         Moving(1875)
  469.         RandClick("left", Round(845 * $x_ratio), Round(225 * $y_ratio), 1, 1) ;NPC Merchant to the right of cain's home
  470.         Sleep(1200)
  471.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  472.         Sleep(400)
  473.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  474.         Sleep(200)
  475.         Send("{Escape}")
  476.         Call("AddLog", "Repair")
  477.         If Not CheckDead() Then
  478.             Call("LeaveGame")
  479.         EndIf
  480.     EndIf
  481. EndFunc   ;==>DoRepair
  482.  
  483. Func CalcTime()
  484.     $srt = TimerDiff($rt)
  485.     GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  486.     $trt = TimerDiff($t)
  487.     $total = Round((($trt / 1000) / 60) / 60, 4)
  488.  
  489.     Call("AddLog", "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  490.  
  491.     ;Total runtime calculation.
  492.     $hours = Floor((($trt / 1000) / 60) / 60)
  493.     $minutes = (($trt / 1000) / 60)
  494.     ;trim minutes if runtime is more then 1 hour.
  495.     If $minutes > 60 Then
  496.         While $minutes > 60
  497.             $minutes -= 60
  498.         WEnd
  499.     EndIf
  500.     GUICtrlSetData($lblRuntime, "Runtime: " & $hours & ":" & Ceiling($minutes) & ", GPH: " & Ceiling((Number($mon) - $monstart) / ($trt / 3600000)))
  501. EndFunc   ;==>CalcTime
  502.  
  503. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 6, $tolerance = 140)
  504.     If $type = "Area" Then
  505.         $startX = 1500 * $x_ratio
  506.         $startY = 0 * $y_ratio
  507.         $endX = 1920 * $x_ratio
  508.         $endY = 90 * $y_ratio
  509.         If $seconds = 6 Then $seconds = 2.5
  510.     EndIf
  511.    
  512.     If $seconds > 20 Then
  513.         MsgBox(1, "uhoh", "we got a problem " & $seconds)
  514.     EndIf
  515.     $c = 0
  516.     $string = $pngLoc & $img & ".png"
  517.     Do
  518.         $c += 1
  519.         Sleep(200)
  520.         If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
  521.             If $type = "Area" Then
  522.                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  523.             EndIf
  524.             Return False
  525.         EndIf
  526.     Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  527.     GUICtrlSetData($lblStatus, "Status: Area found! " & $img)
  528.     Return True
  529. EndFunc   ;==>CheckFor
  530.  
  531. Func DoSprint()
  532.     RandClick("right", Round(15 * $x_ratio), Round(1055 * $y_ratio)) ;sprint
  533.     $SprintStart = TimerInit()
  534. EndFunc   ;==>DoSprint
  535.  
  536. Func WalkTime($lootx, $looty, $extra = 0)
  537.  
  538.     $PPmSsprint = (960 / 2200) * $movementSpeed
  539.     $PPmSwalk = (960 / 3100) * $movementSpeed
  540.     Dim $BarbFeet[2] = [960 * $x_ratio, 505 * $y_ratio]
  541.    
  542.     $dist = Sqrt(($BarbFeet[0] - $lootx) ^ 2 + ($BarbFeet[1] - $looty) ^ 2)
  543.     $sprintremain = 3000 - TimerDiff($SprintStart)
  544.  
  545.     ;determine if sprint is still active to choose run speed
  546.     If $sprintremain > 0 Then ;duration of sprint - 100 for safty
  547.         ;calculate milliseconds per pixel for this run, return delay
  548.         ;calculate composite sleep time
  549.         If $dist < $PPmSsprint * $sprintremain Then
  550.             Sleep($dist / $PPmSsprint + $extra)
  551.         Else
  552.             Sleep(($sprintremain + ($dist - $sprintremain * $PPmSsprint) / $PPmSwalk) + $extra)
  553.         EndIf
  554.     Else
  555.         Sleep($dist / $PPmSwalk + $extra)
  556.     EndIf
  557.  
  558. EndFunc   ;==>WalkTime
  559.  
  560. Func Loot()
  561.     $numgem = 0
  562.     $numtomb = 0
  563.     $numgold = 0
  564.     $numpot = 0
  565.    
  566.     Send("{ALTDOWN}")
  567.    
  568.     MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  569.    
  570.     If $LootLegendaries Then
  571.         If $BlankLamps Then
  572.             $frmBlock = GUICreate("block", 250 * $x_ratio, (250 - 20) * $y_ratio, Round(150 * $x_ratio), Round(225 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  573.             GUISetState(@SW_SHOW)
  574.             $frmBlock2 = GUICreate("block", 200 * $x_ratio, (100 - 20) * $y_ratio, Round(700 * $x_ratio), Round(0 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  575.             GUISetState(@SW_SHOW)
  576.             WinActivate("Diablo III")
  577.             WinWaitActive("Diablo III", "", 1)
  578.         EndIf
  579.        
  580.         If $ReduceLegendSearch Then
  581.             $LegendaryCount += LootGear(0xBF642F, 1, 365, 442, 380)
  582.             $LegendaryCount += LootGear(0xBF642F, 1, 442, 1690, 115)
  583.         Else
  584.             $LegendaryCount += LootGear(0xBF642F, 1)
  585.         EndIf
  586.        
  587.         If $BlankLamps Then
  588.             GUIDelete($frmBlock)
  589.             GUIDelete($frmBlock2)
  590.         EndIf
  591.      EndIf
  592.      
  593.         If $LootSets Then
  594.         $SetCount += LootGear(0x02CE01, 2)
  595.     EndIf
  596.      
  597.      If $LootRares Then
  598.         $RareCount += LootGear(0xBBBB00, 1)
  599.     EndIf
  600.      
  601.      If $LootMagic Then
  602.         $mac = LootGear(0x6969FF, 0)
  603.         $MagicCount += $mac
  604.         $numitem -= $mac
  605.     EndIf
  606.      
  607.     If $LootGems Then
  608.         Call("LootGems")
  609.         LootImage("square.png", 90, 10)
  610.      EndIf
  611.      
  612.     If $LootTomes Then
  613.         Call("LootTomes")
  614.         LootImage("tome.png", 90, 10)
  615.     EndIf
  616.    
  617.    
  618.     If $LootCustom Then
  619.         Call("LootCustom")
  620.     EndIf
  621.  
  622.     Send("{ALTUP}")
  623.    
  624.     Call("ShowLoot")
  625. EndFunc   ;==>Loot
  626.  
  627. Func LootGear($color, $tolerance = 2, $x1 = 400, $x2 = 1690, $y1 = 20, $y2 = 900)
  628.     $count = 0
  629.     $Loot = PixelSearch(Round($x1 * $x_ratio), Round($y1 * $y_ratio), Round($x2 * $x_ratio), Round($y2 * $y_ratio), $color, $tolerance)
  630.     If Not @error Then
  631.         While Not @error
  632.             $count += 1
  633.             MouseClick('left', $Loot[0], $Loot[1], 1, 1)
  634.             Sleep(20)
  635.             MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  636.             WalkTime($Loot[0], $Loot[1])
  637.             ;Sleep(Random(700, 800))
  638.             ;Run at max 10 times per quality
  639.             If $count >= 10 Then
  640.                 ExitLoop
  641.             EndIf
  642.             $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  643.         WEnd
  644.     EndIf
  645.     $numitem += $count;
  646.     Return $count
  647. EndFunc   ;==>LootGear
  648.  
  649. Func LootImage($img, $tol, $max = 10)
  650.     $count = 0
  651.     $gX = 0
  652.     $gY = 0
  653.     GUICtrlSetData($lblStatus, "Status: Looting - " & $img)
  654.     While _ImageSearchArea($pngLoc & $img, 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, $tol)
  655.         $count += 1
  656.         MouseClick("left", $gX, $gY - 3, 1, 1)
  657.         Sleep(50)
  658.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  659.         If $img == "square.png" Then
  660.             $GemCount += 1
  661.             $numgem += 1
  662.         ElseIf $img == "tome.png" Then
  663.             $TomeCount += 1
  664.             $numtomb += 1
  665.         ElseIf $img == "gold.png" Then
  666.             $numgold += 1
  667.         ElseIf $img == "mythic.png" Then
  668.             $numpot += 1
  669.         EndIf
  670.         WalkTime($gX, $gY)
  671.         If $count >= $max Then
  672.             ExitLoop
  673.         EndIf
  674.     WEnd
  675. EndFunc   ;==>LootImage
  676.  
  677. Func LootCustom()
  678.     For $i = 0 To ($totalItems - 1)
  679.         $array = StringSplit($pick[$i], "|")
  680.         LootImage($array[1], $array[2], 5)
  681.     Next
  682. EndFunc   ;==>LootCustom
  683.  
  684. Func Identify()
  685.     Send($Inventory)
  686.     Sleep(1300)
  687.     $count = 0
  688.     While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 120)
  689.         $count += 1
  690.         GUICtrlSetData($lblStatus, "Status: Identifying")
  691.         MouseClick("right", $gX, $gY, 1, 4)
  692.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  693.         Sleep(Random(3000, 3500))
  694.         If $count >= 30 Then
  695.             ExitLoop
  696.         EndIf
  697.     WEnd
  698.     Send($Inventory)
  699.     Sleep(200)
  700. EndFunc   ;==>Identify
  701.  
  702. Func CleanOCR($text)
  703.     $out = ""
  704.     For $i = 1 To StringLen($text)
  705.         $chr = Asc(StringMid($text, $i, 1))
  706.         If $chr >= 48 And $chr <= 57 Then $out = $out & Chr($chr)
  707.         If $chr = 79 Then $out = $out & '0'
  708.     Next
  709.     Return $out
  710. EndFunc   ;==>CleanOCR
  711.  
  712. Func ClickTab($Tabno)
  713.     If $Tabno = 1 Then RandClick("left", Round(517 * $x_ratio), Round(229 * $y_ratio), 3, 4)
  714.     If $Tabno = 2 Then RandClick("left", Round(517 * $x_ratio), Round(361 * $y_ratio), 3, 4)
  715.     If $Tabno = 3 Then RandClick("left", Round(517 * $x_ratio), Round(486 * $y_ratio), 3, 4)
  716.     Sleep(Random(100, 200))
  717.  
  718. EndFunc   ;==>ClickTab
  719.  
  720. Func UseNextTab()
  721.     If $ItemTab = $NextItemTab Then
  722.         Call("AddLog", "Stash full Both tabs full, disabling stashing")
  723.         $StashLegendary = False
  724.         $StashRare = False
  725.         $StashMagic = False
  726.     Else
  727.         Call("AddLog", "Stash full Using next tab")
  728.         $ItemTab = $NextItemTab
  729.     EndIf
  730. EndFunc   ;==>UseNextTab
  731.  
  732. Func AddLog($logtxt)
  733.     Local $file = FileOpen("log.txt", 1)
  734.     $msg = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ': ' & $logtxt & @CRLF
  735.     FileWrite($file, $msg)
  736.     FileClose($file)
  737.     ConsoleWrite($msg)
  738. EndFunc   ;==>AddLog
  739.  
  740. Func StashLoot()
  741.     GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  742.     MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  743.     Sleep(Random(800, 1000))
  744.  
  745.     ClickTab($GemTab)
  746.     ;Tomes
  747.     If $StashTomes Then
  748.         GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  749.         ClickImage("TomeIcon.png", 140, 1)
  750.     EndIf
  751.    
  752.     ;Gems (DOESN'T STASH BOTTOM ROW!)
  753.     If $StashGems Then
  754.         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  755.         For $i = 0 To 7
  756.             ClickImage($gems[$i], 150, 1)
  757.         Next
  758.     EndIf
  759.    
  760.     $numstashed = 0;
  761.     ClickTab($ItemTab)
  762.  
  763.     If $StashLegendary Then
  764.         ClickItems(0xFF7F00, 2, True, 5)
  765.         ClickItems(0x8F5C25, 2, True, 5)
  766.     EndIf
  767.  
  768.     If $StashRare Then
  769.         ClickItems(0x4A3C0B, 1, True, 20)
  770.     EndIf
  771.    
  772.     If $StashMagic Then
  773.         ClickItems(0x182037, 1, True, 30)
  774.     EndIf
  775.  
  776.     Call("AddLog", "Stashed Items: " & $numstashed)
  777.    
  778.     Sleep(Random(500, 600))
  779.     Send("{SPACE}")
  780. EndFunc   ;==>StashLoot
  781.  
  782. Func VendorLoot()
  783.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  784.    
  785.     DoSprint()
  786.    
  787.     If Not $StashLoot Then ;Move from TP towards vendor
  788.         Sleep(Random(100, 300))
  789.         MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  790.         walktime(1565 * $x_ratio, 50 * $y_ratio)
  791.     Else ;Move from Stash towards vendor
  792.         Sleep(Random(100, 300))
  793.         MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  794.         walktime(1560 * $x_ratio, 120 * $y_ratio)
  795.     EndIf
  796.  
  797.     MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  798.     walktime(1030 * $x_ratio, 210 * $y_ratio, 200)
  799.    
  800.     $numsold = 0;
  801.  
  802.     ;All
  803.     If $vendorAll Then
  804.         For $c = 1 To $vendorCols
  805.             For $r = 1 To $vendorRows
  806.                 RandClick("right", (((($c - 1) * 50) + 32 + 1400) * $x_ratio), (((($r - 1) * 51) + 32 + 580) * $y_ratio), 2, 2, 1, 2.5)
  807.             Next
  808.         Next
  809.     EndIf
  810.    
  811.     ;Rares
  812.     If $VendorRare Then
  813.         ClickItems(0x4A3C0B, 2)
  814.     EndIf
  815.     ;Magic
  816.     If $VendorMagic Then
  817.         ClickItems(0x182037, 2)
  818.     EndIf
  819.    
  820.     $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  821.     $mon = CleanOCR($mon)
  822.     $mondelt = Number($mon) - Number($monold)
  823.     GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
  824.     $monold = $mon
  825.     Call("AddLog", "Sold Items: " & $numsold & ", Sold value: " & $mondelt)
  826.  
  827.     Sleep(200)
  828.     RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  829.     Sleep(300)
  830.     RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  831.     Sleep(400)
  832.  
  833.     $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  834.     $mon = CleanOCR($mon)
  835.     $mondelt = Number($mon) - Number($monold)
  836.     GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
  837.     $monold = $mon
  838.     Call("AddLog", "Repair Cost: " & - $mondelt)
  839.  
  840.     GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  841.     Send("{ESCAPE}")
  842. EndFunc   ;==>VendorLoot
  843.  
  844. Func ClickItems($color, $tolerance, $checkfull = False, $max = 30)
  845.     $c = 0
  846.     While $c < $max
  847.         RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  848.         Sleep(Random(60, 120))
  849.         $StashPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  850.         If Not @error Then
  851.             MouseClick("right", $StashPixel[0], $StashPixel[1], 1, 4)
  852.             $c += 1
  853.             If $checkfull Then
  854.                 $numstashed += 1
  855.             Else
  856.                 $numsold += 1
  857.             EndIf
  858.         Else
  859.             ExitLoop
  860.         EndIf
  861.     WEnd
  862.     Sleep(Random(60, 120))
  863.     If $checkfull Then
  864.         If $c = $max Then Call("UseNextTab")
  865.         ClickTab($ItemTab)
  866.     EndIf
  867. EndFunc   ;==>ClickItems
  868.  
  869. Func ClickImage($image, $tolerance, $max = 20)
  870.     For $c = 1 To $max
  871.         RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  872.         Sleep(Random(100, 300))
  873.         If _ImageSearchArea($pngLoc & $image, 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, $tolerance) Then
  874.             MouseClick("right", $gX, $gY, 1, 4)
  875.             Sleep(120)
  876.         Else
  877.             ExitLoop
  878.         EndIf
  879.     Next
  880. EndFunc   ;==>ClickImage
  881.  
  882. Func SalvageLoot()
  883.  
  884.     DoSprint()
  885.  
  886.     GUICtrlSetData($lblStatus, "Status: Salvaging Items")
  887.     Sleep(Random(300, 500))
  888.     MouseClick("middle", 1786 * $x_ratio, 535 * $y_ratio)
  889.     walktime(1786 * $x_ratio, 535 * $y_ratio, 100)
  890.     ;Sleep(2000)
  891.     MouseClick("left", 1430 * $x_ratio, 390 * $y_ratio) ;Talk to anvil
  892.     ;Sleep(3000)
  893.     walktime(1430 * $x_ratio, 390 * $y_ratio, 100)
  894.  
  895.     $c = 0
  896.     While $c <= 20
  897.         Sleep(Random(200, 300))
  898.         $MagicPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 830 * $y_ratio, 0x182037, 1)
  899.         If Not @error Then
  900.             MouseClick("left", 265 * $x_ratio, 291 * $y_ratio, 1, 4)
  901.             Sleep(Random(200, 300))
  902.             MouseClick("left", $MagicPixel[0], $MagicPixel[1], 1, 4)
  903.             Sleep(Random(200, 300))
  904.             MouseClick("left", 1072 * $x_ratio, 375 * $y_ratio, 1, 4)
  905.             RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  906.             Sleep(40)
  907.             $c += 1
  908.         Else
  909.             ExitLoop
  910.         EndIf
  911.     WEnd
  912.     Call("AddLog", "Salvaged Items: " & $c)
  913.  
  914.     Send("{SPACE}")
  915.     Sleep(Random(300, 500))
  916. EndFunc   ;==>SalvageLoot
  917.  
  918. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  919.     If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  920.     $findImage = "*TRANSBLACK " & $findImage
  921.     If @AutoItX64 Then
  922.         $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  923.     Else
  924.         $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  925.     EndIf
  926.     If $result = "0" Then
  927.         Return 0
  928.     EndIf
  929.  
  930.     ; Otherwise get the x,y location of the match and the size of the image to
  931.     ; compute the centre of search
  932.     $array = StringSplit($result[0], "|")
  933.     If (UBound($array) >= 4) Then
  934.         $x = Int(Number($array[2]))
  935.         $y = Int(Number($array[3]))
  936.         If $resultPosition = 1 Then
  937.             $x = $x + Int(Number($array[4]) / 2)
  938.             $y = $y + Int(Number($array[5]) / 2)
  939.         EndIf
  940.         Return 1
  941.     EndIf
  942. EndFunc   ;==>_ImageSearchArea
  943.  
  944. Func LeaveGame()
  945.  
  946.     Call("RandSleep")
  947.     GUICtrlSetData($lblStatus, "Status: Leaving Game")
  948.     Send("{Escape}")
  949.     Sleep(200)
  950.     RandClick("left", Round(956 * $x_ratio), Round(579 * $y_ratio), 120, 20) ;Random Click on the leave button
  951.     Call("CalcTime")
  952.     Sleep($loadtime)
  953. EndFunc   ;==>LeaveGame
  954.  
  955. Func TownPortalShort()
  956.  
  957.     $gX = 0
  958.     $gY = 0
  959.     $c = 0
  960.     GUICtrlSetData($lblStatus, "Status: Waiting for TP bar")
  961.     Do
  962.         $c += 1
  963.         Sleep(200)
  964.         If $c > 4 Then Return
  965.     Until _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
  966.  
  967.     $seconds = $TPProtectTime
  968.     $c = 0
  969.  
  970.     Do
  971.         $c += 1
  972.         GUICtrlSetData($lblStatus, "Status: Prepared for inturrupt, " & $seconds * 5 - $c)
  973.         Sleep(200)
  974.         If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
  975.             GUICtrlSetData($lblStatus, "Status: safe, doing long wait for town")
  976.             Sleep($tptime - $seconds * 1000 - 1200)
  977.             GUICtrlSetData($lblStatus, "Status: detecting town")
  978.             CheckFor("NewTristram", "Area")
  979.             Sleep(300)
  980.             Return
  981.         EndIf
  982.     Until Not _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
  983.  
  984. EndFunc   ;==>TownPortalShort
  985.  
  986. Func TownPortal()
  987.  
  988.     GUICtrlSetData($lblStatus, "Status: Returning to Town")
  989.     Send($TownPortalButton)
  990.    
  991.     If $DetectTPFail Then
  992.         Call("TownPortalShort")
  993.     Else
  994.         Sleep(Random($tptime, $tptime + 500))
  995.     EndIf
  996.    
  997. EndFunc   ;==>TownPortal
  998.  
  999. #region OtherStuff
  1000.  
  1001. Func Moving($time)
  1002.     Sleep($time / $movementSpeed)
  1003. EndFunc   ;==>Moving
  1004.  
  1005. Func RandClick($clickType, $xPos, $yPos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
  1006.     If $xOff < 1 Then $xOff = 1
  1007.     If $yOff < 1 Then $yOff = 1
  1008.     $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1009.     $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1010.     MouseClick($clickType, $randX, $randY, $clicks, $speed)
  1011. EndFunc   ;==>RandClick
  1012.  
  1013. Func RandMove($xPos, $yPos, $xOff = 10, $yOff = 10, $speed = 1)
  1014.     $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1015.     $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1016.     MouseMove($randX, $randY, $speed)
  1017. EndFunc   ;==>RandMove
  1018.  
  1019. Func RandSleep($min = 5, $max = 45, $chance = 3)
  1020.     $randNum = Round(Random(1, 100))
  1021.     If $Timer And $randNum <= $chance Then
  1022.         $sleepTime = Random($min * 1000, $max * 1000)
  1023.         GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime / 1000) & " secs")
  1024.         For $c = 0 To 10
  1025.             Sleep($sleepTime / 10)
  1026.         Next
  1027.     EndIf
  1028. EndFunc   ;==>RandSleep
  1029. ;Hotkey Functions
  1030.  
  1031. Func Begin()
  1032.     $Go = Not $Go
  1033.     If Not $Go Then WinSetTitle($title, "", $title & $ver & " - Halted")
  1034. EndFunc   ;==>Begin
  1035.  
  1036. Func TogglePause()
  1037.     $Paused = Not $Paused
  1038.     While $Paused
  1039.         Sleep(100)
  1040.         WinSetTitle($title, "", $title & $ver & " - Paused")
  1041.         ToolTip('[PAUSED] - Deaths: ' & $deathCount & ' | Cellars: ' & $cellarCount, 0, 0)
  1042.     WEnd
  1043.     WinSetTitle($title, "", $title & $ver & " - Running")
  1044.     ToolTip("")
  1045. EndFunc   ;==>TogglePause
  1046.  
  1047. Func ShowLoot()
  1048.     GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  1049.     GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  1050. EndFunc   ;==>ShowLoot
  1051.  
  1052. Func Stop() ;to allow the script to stop
  1053.     Exit
  1054. EndFunc   ;==>Stop
  1055. Func GoTown()
  1056.     $mLootIn = 1
  1057. EndFunc   ;==>GoTown
  1058.  
  1059. Func AnalyseLoots() ; Grid search + ilvl detection, a little bit slower than old method but computes db for fast stashing/vendoring/new salvaging
  1060.     ;ConsoleWrite("---- NEW ANALYSIS ----" & @crlf)
  1061.     $str_Stash = ""
  1062.     $str_StashGems = ""
  1063.     $str_StashMisc = ""
  1064.     $str_Vendor = ""
  1065.     $str_Salvage = ""
  1066.     $int_TownPosition = 0
  1067.     $int_emptygrid = 0
  1068.     $str_Ignore = ""
  1069.     $nX = 0
  1070.     $nY = 0
  1071.     GUICtrlSetData($lblStatus, "Status: Analysing loots")
  1072.     Send("c")
  1073.     Sleep(500)
  1074.     For $y = 0 To 5
  1075.         $int_emptygrid = 0
  1076.         MouseMove(1435, Round(609 + (45 * $y)), 1)
  1077.         Sleep(500)
  1078.         For $x = 0 To 9
  1079.             If StringInStr($str_Ignore, 1435 + (48 * $x) & "," & 609 + (45 * $y)) Then ContinueLoop
  1080.             MouseMove(1435 + (48 * $x), 609 + (45 * $y), 1)
  1081.             Sleep(300)
  1082.             If _ImageSearchArea($pngLoc & "tt_check.png", 0, Round((1435 + (48 * $x) - 455) * $x_ratio), Round((609 + (45 * $y) - 500) * $y_ratio), Round((1435 + (48 * $x) - 35) * $x_ratio), Round(1080 * $y_ratio), $gX, $gY, 10) Then ; If tooltip exists
  1083.                 $int_emptygrid = 0
  1084.                 If _ImageSearchArea($pngLoc & "tt_unidentified.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) And $Identify Then ; Identify items.
  1085.                     MouseClick("secondary")
  1086.                     Sleep(Random(3000, 3500, 1))
  1087.                 EndIf
  1088.                 If _ImageSearchArea($pngLoc & "tt_square.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Gem, automatic stashing.
  1089.                     $str_StashGems = $str_StashGems & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1090.                     ContinueLoop
  1091.                 EndIf
  1092.                 If _ImageSearchArea($pngLoc & "tt_tome.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Tome, automatic stashing.
  1093.                     $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1094.                     ContinueLoop
  1095.                 EndIf
  1096.                 If _ImageSearchArea($pngLoc & "tt_exquisite.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
  1097.                     $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1098.                     ContinueLoop
  1099.                 EndIf
  1100.                 If _ImageSearchArea($pngLoc & "tt_iridescent.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
  1101.                     $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1102.                     ContinueLoop
  1103.                 EndIf
  1104.                 If _ImageSearchArea($pngLoc & "tt_fiery.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing (faster than the pixel detection below).
  1105.                     $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1106.                     ContinueLoop
  1107.                 EndIf
  1108.                 If _ImageSearchArea($pngLoc & "tt_plan.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 60) Then ; Plans, automatic stashing.
  1109.                     $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1110.                     ContinueLoop
  1111.                 EndIf
  1112.                 If _ImageSearchArea($pngLoc & "tt_neck.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 And _ImageSearchArea($pngLoc & "tt_waist.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 And _ImageSearchArea($pngLoc & "tt_finger.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 And _ImageSearchArea($pngLoc & "tt_follower.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 Then
  1113.                     $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * ($y + 1))
  1114.                 EndIf
  1115.                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x00FF00, 1) ; Set, no ilvl check since they drop rarely. Goes to stash.
  1116.                 If Not @error Then
  1117.                     $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1118.                     ContinueLoop
  1119.                 EndIf
  1120.                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xBF642F, 1) ; Legendary, no ilvl check since they drop rarely. Goes to stash.
  1121.                 If Not @error Then
  1122.                     $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1123.                     ContinueLoop
  1124.                 EndIf
  1125.                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xFFFF00, 1) ; Rare
  1126.                 If Not @error Then
  1127.                     If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 59
  1128.                         If (getOption("i59r") == 1) Then
  1129.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1130.                         ElseIf (getOption("i59r") == 2) Then
  1131.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1132.                         Else
  1133.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1134.                         EndIf
  1135.                         ContinueLoop
  1136.                     EndIf
  1137.                     If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 60,  goes to salvage
  1138.                         If (getOption("i60r") == 1) Then
  1139.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1140.                         ElseIf (getOption("i60r") == 2) Then
  1141.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1142.                         Else
  1143.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1144.                         EndIf
  1145.                         ContinueLoop
  1146.                     EndIf
  1147.                     If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 61,  goes to salvage
  1148.                         If (getOption("i61r") == 1) Then
  1149.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1150.                         ElseIf (getOption("i61r") == 2) Then
  1151.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1152.                         Else
  1153.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1154.                         EndIf
  1155.                         ContinueLoop
  1156.                     EndIf
  1157.                     If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 62,  goes to salvage
  1158.                         If (getOption("i62r") == 1) Then
  1159.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1160.                         ElseIf (getOption("i62r") == 2) Then
  1161.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1162.                         Else
  1163.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1164.                         EndIf
  1165.                         ContinueLoop
  1166.                     EndIf
  1167.                     If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 63,  goes to stash
  1168.                         If (getOption("i63r") == 1) Then
  1169.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1170.                         ElseIf (getOption("i63r") == 2) Then
  1171.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1172.                         Else
  1173.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1174.                         EndIf
  1175.                         ContinueLoop
  1176.                     EndIf
  1177.                     ; Below ilvl 59
  1178.                     If $StashRare Then
  1179.                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1180.                     ElseIf $VendorRare Then
  1181.                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1182.                     Else
  1183.                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1184.                     EndIf
  1185.                     ContinueLoop
  1186.                 EndIf
  1187.                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x6969FF, 1) ; Magic
  1188.                 If Not @error Then
  1189.                     If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 59
  1190.                         If (getOption("i59m") == 1) Then
  1191.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1192.                         ElseIf (getOption("i59m") == 2) Then
  1193.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1194.                         Else
  1195.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1196.                         EndIf
  1197.                         ContinueLoop
  1198.                     EndIf
  1199.                     If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 60, goes to salvage
  1200.                         If (getOption("i60m") == 1) Then
  1201.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1202.                         ElseIf (getOption("i60m") == 2) Then
  1203.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1204.                         Else
  1205.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1206.                         EndIf
  1207.                         ContinueLoop
  1208.                     EndIf
  1209.                     If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 61, goes to salvage
  1210.                         If (getOption("i61m") == 1) Then
  1211.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1212.                         ElseIf (getOption("i61m") == 2) Then
  1213.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1214.                         Else
  1215.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1216.                         EndIf
  1217.                         ContinueLoop
  1218.                     EndIf
  1219.                     If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 62, goes to salvage
  1220.                         If (getOption("i62m") == 1) Then
  1221.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1222.                         ElseIf (getOption("i62m") == 2) Then
  1223.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1224.                         Else
  1225.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1226.                         EndIf
  1227.                         ContinueLoop
  1228.                     EndIf
  1229.                     If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 63, goes to stash
  1230.                         If (getOption("i63m") == 1) Then
  1231.                             $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1232.                         ElseIf (getOption("i63m") == 2) Then
  1233.                             $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1234.                         Else
  1235.                             $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1236.                         EndIf
  1237.                         ContinueLoop
  1238.                     EndIf
  1239.                     ; Below ilvl 59
  1240.                     If $StashMagic Then
  1241.                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1242.                     ElseIf $VendorMagic Then
  1243.                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1244.                     Else
  1245.                         $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1246.                     EndIf
  1247.                     ContinueLoop
  1248.                 EndIf
  1249.                 ; Probably white/gray trash bugged pick, add to vendor string
  1250.                 $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1251.             Else
  1252.                 $int_emptygrid += 1
  1253.                 If $int_emptygrid == 2 Then ; If there's nothing 2 times in a row in a row (see wut i did thar?), it probably ends here, skip to the next row.
  1254.                     $int_emptygrid = 0
  1255.                     ExitLoop
  1256.                 Else
  1257.                     ContinueLoop
  1258.                 EndIf
  1259.             EndIf
  1260.         Next
  1261.     Next
  1262.     Send("c")
  1263.     Sleep(500)
  1264.     ;Call("AddLog", "Stash gear : "  & $str_Stash )
  1265.     ;Call("AddLog", "Stash misc : "  & $str_StashMisc )
  1266.     ;Call("AddLog", "Stash gems : "  & $str_StashGems )
  1267.     ;Call("AddLog", "Salvage : "  & $str_Salvage )
  1268.     ;Call("AddLog", "Vendor : "  & $str_Vendor )
  1269.     ;Call("AddLog", "Ignored Square : "  & $str_Ignore )
  1270.  
  1271.  
  1272.     Call("AddLog", "Stashed Items: " & UBound(StringSplit($str_Stash, "|")))
  1273.  
  1274.     If $str_Stash <> "" Or $str_StashGems <> "" Or $str_StashMisc <> "" Then Call("StashLoot_new")
  1275.     If $str_Salvage <> "" Then Call("SalvageLoot_new")
  1276.     If $str_Vendor <> "" Then Call("VendorLoot_new")
  1277. EndFunc   ;==>AnalyseLoots
  1278.  
  1279. Func StashLoot_new()
  1280.     $arr_split = ""
  1281.     $pos_split = ""
  1282.     GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  1283.     MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  1284.     Moving(1600)
  1285.     $int_TownPosition = 1
  1286.  
  1287.     ;Gems Page 1
  1288.     If $str_StashGems <> "" Then
  1289.         ClickTab($GemTab)
  1290.         $str_StashGems = StringMid($str_StashGems, 2)
  1291.         $arr_split = StringSplit($str_StashGems, "|")
  1292.         For $i = 1 To $arr_split[0]
  1293.             Sleep(Random(300, 350))
  1294.             $pos_split = StringSplit($arr_split[$i], ",", 2)
  1295.             MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1296.         Next
  1297.     EndIf
  1298.  
  1299.     ;Tomes/Crafting Materials/Plans/Etc Page 2
  1300.     If $str_StashMisc <> "" Then
  1301.         ClickTab($GemTab)
  1302.         $str_StashMisc = StringMid($str_StashMisc, 2)
  1303.         $arr_split = StringSplit($str_StashMisc, "|")
  1304.         For $i = 1 To $arr_split[0]
  1305.             Sleep(Random(300, 350))
  1306.             $pos_split = StringSplit($arr_split[$i], ",", 2)
  1307.             MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1308.         Next
  1309.     EndIf
  1310.  
  1311.     ;Gears Page 2
  1312.     If $str_Stash <> "" Then
  1313.         $str_Stash = StringMid($str_Stash, 2)
  1314.         $arr_split = StringSplit($str_Stash, "|")
  1315.         For $i = 1 To $arr_split[0]
  1316.             Sleep(Random(80, 100))
  1317.             If Random() < 0.5 Then
  1318.                 ClickTab($ItemTab)
  1319.             Else
  1320.                 ClickTab($NextItemTab)
  1321.             EndIf
  1322.            
  1323.             Sleep(Random(300, 350))
  1324.             $pos_split = StringSplit($arr_split[$i], ",", 2)
  1325.             MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1326.         Next
  1327.     EndIf
  1328.  
  1329.     Sleep(Random(100, 150))
  1330.     Send("{SPACE}")
  1331. EndFunc   ;==>StashLoot_new
  1332.  
  1333. Func SalvageLoot_new()
  1334.     $arr_split = ""
  1335.     $pos_split = ""
  1336.     GUICtrlSetData($lblStatus, "Status: Salvaging loots")
  1337.     If $int_TownPosition = 0 Then ; Starting from TP
  1338.         MouseClick("middle", 1582 * $x_ratio, 527 * $y_ratio)
  1339.         Moving(2000)
  1340.         MouseClick("left", 1661 * $x_ratio, 409 * $y_ratio)
  1341.         Moving(2500)
  1342.     Else ; Starting from Stash
  1343.         MouseClick("middle", 1484 * $x_ratio, 583 * $y_ratio)
  1344.         Moving(2000)
  1345.         MouseClick("left", 1773 * $x_ratio, 484 * $y_ratio)
  1346.         Moving(2500)
  1347.     EndIf
  1348.     $int_TownPosition = 2
  1349.     MouseClick("left", 263 * $x_ratio, 287 * $y_ratio)
  1350.     $str_Salvage = StringMid($str_Salvage, 2)
  1351.     $arr_split = StringSplit($str_Salvage, "|")
  1352.     For $i = 1 To $arr_split[0]
  1353.         Sleep(Random(300, 400))
  1354.         $pos_split = StringSplit($arr_split[$i], ",")
  1355.         MouseClick("left", $pos_split[1], $pos_split[2], 1, 3)
  1356.         If $pos_split[0] == 3 Then
  1357.             Send("{ENTER}")
  1358.             Sleep(1000)
  1359.         EndIf
  1360.     Next
  1361.     Sleep(Random(300, 400))
  1362.     Send("{SPACE}")
  1363. EndFunc   ;==>SalvageLoot_new
  1364.  
  1365. Func VendorLoot_new()
  1366.     $arr_split = ""
  1367.     $pos_split = ""
  1368.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  1369.     If $int_TownPosition = 0 Then ; Starting from TP
  1370.         MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  1371.     ElseIf $int_TownPosition = 1 Then ; Starting from Stash
  1372.         MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  1373.     Else ; Starting from Blacksmith
  1374.         MouseClick("middle", 738 * $x_ratio, 64 * $y_ratio)
  1375.     EndIf
  1376.     Moving(3000)
  1377.     MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  1378.     Moving(3000)
  1379.     $str_Vendor = StringMid($str_Vendor, 2)
  1380.     $arr_split = StringSplit($str_Vendor, "|")
  1381.     For $i = 1 To $arr_split[0]
  1382.         Sleep(Random(100, 300))
  1383.         $pos_split = StringSplit($arr_split[$i], ",", 2)
  1384.         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1385.         If PixelGetColor(819 * $x_ratio, 375 * $y_ratio) == 0x370C00 Then Send("{ENTER}")
  1386.     Next
  1387.     Sleep(Random(100, 200))
  1388.    
  1389.     $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1390.     $mon = CleanOCR($mon)
  1391.     $mondelt = Number($mon) - Number($monold)
  1392.     GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
  1393.     $monold = $mon
  1394.     Call("AddLog", "Sold Items: " & $arr_split[0] & ", Sold value: " & $mondelt)
  1395.    
  1396.     Sleep(Random(200, 300))
  1397.    
  1398.  
  1399.     RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  1400.     Sleep(200)
  1401.     RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  1402.     Sleep(400)
  1403.    
  1404.     $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1405.     $mon = CleanOCR($mon)
  1406.     $mondelt = Number($mon) - Number($monold)
  1407.     GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
  1408.     $monold = $mon
  1409.     Call("AddLog", "Repair Cost: " & - $mondelt)
  1410.    
  1411.  
  1412.     GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  1413.    
  1414.     Send("{SPACE}")
  1415.    
  1416. EndFunc   ;==>VendorLoot_new
  1417.  
  1418. Func getOption($option) ;Gets the correct INI settings corrisponding to the vend/stash/salvage of items.
  1419.  
  1420.     If ($option == "i59r") Then
  1421.         If ($i59Rare = "salvage") Then
  1422.             Return 1
  1423.         ElseIf ($i59Rare = "vend") Then
  1424.             Return 2
  1425.         Else
  1426.             Return 0
  1427.         EndIf
  1428.     ElseIf ($option == "i60r") Then
  1429.         If ($i60Rare = "salvage") Then
  1430.             Return 1
  1431.         ElseIf ($i60Rare = "vend") Then
  1432.             Return 2
  1433.         Else
  1434.             Return 0
  1435.         EndIf
  1436.     ElseIf ($option == "i61r") Then
  1437.         If ($i61Rare = "salvage") Then
  1438.             Return 1
  1439.         ElseIf ($i61Rare = "vend") Then
  1440.             Return 2
  1441.         Else
  1442.             Return 0
  1443.         EndIf
  1444.     ElseIf ($option == "i62r") Then
  1445.         If ($i62Rare = "salvage") Then
  1446.             Return 1
  1447.         ElseIf ($i62Rare = "vend") Then
  1448.             Return 2
  1449.         Else
  1450.             Return 0
  1451.         EndIf
  1452.     ElseIf ($option == "i63r") Then
  1453.         If ($i63Rare = "salvage") Then
  1454.             Return 1
  1455.         ElseIf ($i63Rare = "vend") Then
  1456.             Return 2
  1457.         Else
  1458.             Return 0
  1459.         EndIf
  1460.     ElseIf ($option == "i59m") Then
  1461.         If ($i59Magic = "salvage") Then
  1462.             Return 1
  1463.         ElseIf ($i59Magic = "vend") Then
  1464.             Return 2
  1465.         Else
  1466.             Return 0
  1467.         EndIf
  1468.     ElseIf ($option == "i60m") Then
  1469.         If ($i60Magic = "salvage") Then
  1470.             Return 1
  1471.         ElseIf ($i60Magic = "vend") Then
  1472.             Return 2
  1473.         Else
  1474.             Return 0
  1475.         EndIf
  1476.     ElseIf ($option == "i61m") Then
  1477.         If ($i61Magic = "salvage") Then
  1478.             Return 1
  1479.         ElseIf ($i61Magic = "vend") Then
  1480.             Return 2
  1481.         Else
  1482.             Return 0
  1483.         EndIf
  1484.     ElseIf ($option == "i62m") Then
  1485.         If ($i62Magic = "salvage") Then
  1486.             Return 1
  1487.         ElseIf ($i62Magic = "vend") Then
  1488.             Return 2
  1489.         Else
  1490.             Return 0
  1491.         EndIf
  1492.     ElseIf ($option == "i63m") Then
  1493.         If ($i63Magic = "salvage") Then
  1494.             Return 1
  1495.         ElseIf ($i63Magic = "vend") Then
  1496.             Return 2
  1497.         Else
  1498.             Return 0
  1499.         EndIf
  1500.     Else
  1501.         Return 0
  1502.     EndIf
  1503.  
  1504. EndFunc   ;==>getOption
  1505. #endregion OtherStuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement