Don't like ads? PRO users don't see any ads ;-)

1.9.3w

By: soulhack on Jul 4th, 2012  |  syntax: AutoIt  |  size: 62.71 KB  |  hits: 62  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ; Blaksack's mod 1.93w
  2. ; added TP fail detection
  3. ; made ilvl optional
  4. ; timing improvements
  5. ;- optional cellar grid search
  6. ;- optional hour wait after X runs
  7. ;-Added latest changes from NotAres 1.93 including all the iLVL60-63 stuff dont forget new images: http://www45.zippyshare.com/v/15622375/file.html
  8. ;-Fixed the OCR bug where 0 is seen as O
  9. ;-Added option to use another war shout and call ancients before warping out on failed runs called $ExtraSafeExit
  10. ;-Added LATMs legendary item count fix
  11. ;-cleaned up cellar detection code - i hate repeated lines! you can define your own cellar co-ords at line 234ish
  12. ; enhanced cellar find
  13. ; item salvaging
  14. ; stash tab choosing
  15. ; full logging
  16. ; gold income OCR
  17. ; custom keys for skills
  18.  
  19. ; for latest version see http://pastebin.com/PtE6XJ4W
  20. ; you will need tesseract from https://tesseract-ocr.googlecode.com/files/tesseract-ocr-setup-3.01-1.exe
  21. ; and you will need tesserect library to in your auto it include folder from https://dl.dropbox.com/u/22203901/Tesseract.au3
  22. ; you will also need image files and search dlls from https://dl.dropbox.com/u/9955791/BotFiles.zip
  23. ; and http://www45.zippyshare.com/v/15622375/file.html
  24. ; see for instructions http://www.ownedcore.com/forums/diablo-3/diablo-3-bots-programs/d3-gold-profiles/354464-goldfarming-notares-sarkoth-dh-gold-script-autoit-script-1920x1080.html
  25. ; use this build http://us.battle.net/d3/en/calculator/barbarian#TUXgkj!ghV!bYcbZa
  26.  
  27. ;notAres' Gold Script for BARBARIAN 1.9 - 6/16/2012
  28. ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
  29. ;Thread: http://www.ownedcore.com/forums/diablo-3/diablo-3-bots-programs/d3-gold-profiles/355316-goldfarming-barbarian-sarkoth-goldfarming-script-autoit-script-1920x1080.html
  30. ;;;;;
  31. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  32. ;Required build: http://us.battle.net/d3/en/calculator/barbarian#TUXgkj!ghV!bYcbZa
  33. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  34. ;Official supported resolution: 1920x1080
  35. ;;;;;
  36. ;Original by mackus101 @ ownedcore
  37. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  38. ;Refactoring and additional functions by Shimizoki
  39.  
  40. ;=========== DO NOT TOUCH ===========;
  41. #RequireAdmin
  42. #include <GUIConstantsEx.au3>
  43. #include <StaticConstants.au3>
  44. #include <WindowsConstants.au3>
  45.  
  46.  
  47. ; YOU MUST ALSO UNCOMMENT THE #include LINE TO ENABLE ENHANCED CELLAR FIND
  48. $UseEnhancedCellarFind = True
  49. #include <FastFind.au3>
  50.  
  51. ;=========== mypart ===========;
  52. #include <Tesseract.au3>
  53.  
  54. If $UseEnhancedCellarFind Then
  55.         FFSetDebugMode(0)
  56.         AutoItSetOption("WinTitleMatchMode", 4)
  57.         Global $FFhWnd = WinGetHandle("Diablo III")
  58. EndIf
  59.  
  60. Global $numitem, $numgem, $numtomb, $numgold, $numpot, $lblGold, $numsold, $numstashed, $monold = 0, $mon = 0, $monstart = 0, $SprintStart, $lootany
  61.  
  62. Opt('MouseCoordMode', 2)
  63. Opt('PixelCoordMode', 2)
  64. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "BlackSack 1.9.3w ", $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
  65. Global $str_Stash, $str_StashGems, $str_StashMisc, $str_Vendor, $str_Salvage, $int_TownPosition
  66. For $i = 0 To Random(0, 3, 1)
  67.         $title &= Chr(Random(97, 122, 1))
  68. Next
  69. For $i = 0 To Random(2, 5, 1)
  70.         $title &= Chr(Random(65, 90, 1))
  71. Next
  72. $title &= " "
  73. Global $gems[8] = ["Ru1.png", "Ru2.png", "Em1.png", "Em2.png", "To1.png", "To2.png", "Am1.png", "Am2.png"]
  74. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  75. If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
  76. If $size = 0 Then
  77.         MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  78.         Exit
  79. EndIf
  80. ;====================================;
  81.  
  82.  
  83. ;============= SETTINGS =============;
  84. HotKeySet("=", "Begin") ;script toggled on/off by pressing =
  85. HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
  86. HotKeySet("x", "Stop") ;script stopped by pressing x
  87. HotKeySet("0", "GoTown") ;script stopped by pressing x
  88.  
  89. $movementSpeed = 11 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
  90.  
  91. ;Custom Loot
  92. $pngLoc = "C:\Program Files (x86)\AutoIt3\pics\" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  93.  
  94. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  95. Global $pick[1] = ["gold.png|50"]
  96. ;$pick[0] = "gold.png|50"
  97. ;$pick[1] = "mythic.png|50" ;png|Tolerance
  98. ;$pick[2] = "item3.png"
  99.  
  100. ;General
  101. $ExtraSafeExit = True ;use ancients when you port back to prevent death if you have low HP
  102. $RunsUntilMenuWait = 0 ;wait for 1 hour at menu after x successful runs, set to 0 to disable
  103. $TakeMissShots = False ;take screenshots into \shots folder on every cellar miss for finding positions
  104. $SarkothKillTime = 200 ;additional time delay to wait for sarkoth to die use 2800 for 10K dps 800 for 15kdps etc
  105. $DetectTPFail = False ;set true to immediatly exit game if TP is inturrupted (requires TP.png)
  106. $TPProtectTime = 2.2 ;number of seconds to check for TP inturrupt if TPfail detection is enabled if your pc is slow reduce this number
  107. $ReduceLegendSearch = True ; limit legendary searching to lower part of screen to reduce false finds
  108. $CheckLootWhilePorting = False; continue scanning for loot while you port back incase sakroth dies late
  109.  
  110.  
  111. ;define your own cellar co-ords here, list the most likely ones first for efficiency
  112. ;change the [4] to how many co-ords you listed
  113. Dim $celx[5] = [300, 210, 190, 250, 230]
  114. Dim $cely[5] = [179, 179, 224, 160, 210]
  115.  
  116. ;Buttons
  117. $Skill1 = "1"
  118. $Skill2 = "2"
  119. $Skill3 = "3"
  120. $Skill4 = "4"
  121. $TownPortalButton = "t"
  122. $Inventory = "i"
  123.  
  124. ;Looting
  125. $LootSets = True ;True if you want to pick up Sets
  126. $LootLegendaries = True;True if you want to pick up Legendaries
  127. $LootRares = True ;True if you want to pick up Rares
  128. $LootMagic = True ;True if you want to pick up Magic
  129. $LootGems = True ;True if you want to pick up Gems
  130. $LootTomes = True ;True if you want to pick up Tome of Secrets
  131. $LootCustom = True ;True if you want to pick up Custom Items (The items in the $pick array above)
  132.  
  133. ;Manage Loot
  134. $Identify = True ;True to enable identifying items before stashing/vendoring
  135. $mLoot = 15 ;Nuber of successful runs until Stash and Vendor
  136. $mLootOff = 2 ;Stash and Vendor after mLoot +- X number of runs (Variability)
  137.  
  138. ;Variability ==NEW SETTINGS==
  139. $Timer = False ;True and the bot will add random sleep intervals
  140. $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
  141. $loadtime = 3400 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  142. $tptime = 6000 ;Time (in ms) the script waits for teleport before exiting the game
  143.  
  144. ;Stashing/vendoring COMMON
  145. $StashRare = True ;True if you want to store Rare items in the stash
  146. $StashMagic = False ;True if you want to store Magic items in the stash
  147.  
  148. $VendorRare = False ;True if you want to vendor Rares
  149. $VendorMagic = True ;True if you want to vendor Magic
  150.  
  151. $GemTab = 1 ;Tab to put gems and tombs in
  152. $ItemTab = 2 ;Tab to put any items in
  153. $NextItemTab = 3 ;Next Tab to put any items in when first one is full
  154.  
  155. ;--------------------------------------------TRADITIONAL----------------------------------------------------
  156. ;Stashing/vendoring TRADITIONAL METHOD to enable set line 155 to FALSE
  157. $StashLoot = True ;True if you want to store Items in the stash
  158. $StashLegendary = True;True if you want to store Legendary items in the stash
  159. $StashTomes = True ;True if you want to store Tomes items in the stash
  160. $StashGems = True ;True if you want to store Gems items in the stash
  161.  
  162. ;SALVAGE - setting this will OVERRIDE traditional vendoring options - it will be skipped
  163. ; make sure you have a stack of each material in your bottom row( which is not scanned )for it to add To
  164. ; otherwise it will start tying to salvage your craft items and do nothing!
  165. $SalvageLoot = False
  166.  
  167. ;Vendoring ==NEW SETTINGS==
  168. $VendorLoot = True ;True if you want to vendor anything
  169. $vendorAll = False ;True if you want to right click all items when talking to vendor
  170. $vendorRows = 6 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
  171. $vendorCols = 10 ;# of columns to vendor, starting from left
  172. ;--------------------------------------------TRADITIONAL----------------------------------------------------
  173.  
  174.  
  175. ;--------------------------------------------iLVL----------------------------------------------------
  176. $UseiLVL = False ;set true or false to enable the iLVL system THIS OVERRIDES ALL "TRADITIONAL" SETTINGS
  177. ;====================================;
  178. ;New Analyze Loot Settings Options are "salvage", "stash", and "vend"
  179. $i59Rare = "stash"
  180. $i60Rare = "stash"
  181. $i61Rare = "stash"
  182. $i62Rare = "stash"
  183. $i63Rare = "stash"
  184.  
  185. $i59Magic = "vend"
  186. $i60Magic = "vend"
  187. $i61Magic = "vend"
  188. $i62Magic = "vend"
  189. $i63Magic = "stash"
  190. ;====================================;
  191. ;--------------------------------------------iLVL----------------------------------------------------
  192. $x_ratio = $size[0] / 1920
  193. $y_ratio = $size[1] / 1080
  194.  
  195. $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
  196. $RunsUntilMenuWaitCnt = $RunsUntilMenuWait
  197. $totalItems = UBound($pick) ;Number of items in the pick array
  198. If $totalItems < 1 Then $LootCustom = False
  199. $movementSpeed = 1 + ($movementSpeed / 100)
  200.  
  201. If $TakeMissShots Then
  202.         DirCreate("shots")
  203. EndIf
  204.  
  205. If Not FileExists($pngLoc & "MainMenu.png") Then
  206.         $pngLoc = @ScriptDir & "\pics\"
  207.         If Not FileExists($pngLoc & "MainMenu.png") Then
  208.                 MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  209.                 Exit
  210.         EndIf
  211. EndIf
  212.  
  213. Call("SetupGUI")
  214. While 1
  215.         Call("RestartRun")
  216. WEnd
  217.  
  218. Func RestartRun()
  219.         If ($Go) Then
  220.                 $i = 0
  221.                 Send("{SPACE}")
  222.                 WinSetTitle($title, "", $title & $ver & " - Running")
  223.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 1) ;Moves mouse out of the way
  224.                 ;Checks if the player is Dead/Logout/Window, then if in Main Menu, etc.
  225.                 If CheckDead() Then
  226.                         Return
  227.                 ElseIf CheckFor("ExitGame", "", Round(860 * $x_ratio), Round(400 * $y_ratio), Round(1040 * $x_ratio), Round(450 * $y_ratio), 0.2, 140) Then
  228.                         GUICtrlSetData($lblStatus, "Status: Exit window up")
  229.                         MouseClick("left", Round(1064 * $x_ratio), Round(632 * $y_ratio))
  230.                         Sleep(100)
  231.                         Send("{SPACE}")
  232.                         Return
  233.                 ElseIf CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio)) Then
  234.                         GUICtrlSetData($lblRun, "Runs till vendor: " & $mLootIn & ", Run Number: " & $run)
  235.                         GUICtrlSetData($lblLocation, "Location: Main Menu")
  236.                         GUICtrlSetData($lblStatus, "Status: Starting Game")
  237.                         RandClick("left", Round(230 * $x_ratio), Round(416 * $y_ratio), 120, 20, 1, 2) ;Random Click on the resume button
  238.                         CheckFor("OldRuins", "Area", 0, 0, 0, 0, $loadtime / 1000)
  239.                         ;Sleep($loadtime)
  240.                         $rt = TimerInit()
  241.                         $run += 1
  242.                 ElseIf CheckFor("OldRuins", "Area") Or CheckFor("NewTristram", "Area") Or CheckFor("DankCellar", "Area") Then
  243.                         Call("TownPortal")
  244.                         Call("LeaveGame")
  245.                         Return
  246.                 ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  247.                         MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio))
  248.                         $rand = Random(40000, 80000)
  249.                         GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
  250.                         Sleep($rand)
  251.                         Send("{SPACE}")
  252.                         Return
  253.                 ElseIf CheckFor("Disconnect", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  254.                         GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
  255.                         MouseClick("left", Round(960 * $x_ratio), Round(632 * $y_ratio))
  256.                         Sleep(100)
  257.                         Send("{SPACE}")
  258.                         Return
  259.                 Else
  260.                         GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  261.                         Return
  262.                 EndIf
  263.                
  264.                 $CellarWasFound = 0
  265.                
  266.                 ;Make sure we are in the right area before beginning run
  267.                 If CheckFor("OldRuins", "Area") Then
  268.                         Sleep(200)
  269.                         Send($Skill3)
  270.                         Sleep(100)
  271.                         GUICtrlSetData($lblLocation, "Location: Old Ruins")
  272.                         Call("CheckRepair")
  273.                        
  274.                         $cellfoundat = -1
  275.                        
  276.                         If $UseEnhancedCellarFind Then
  277.                                
  278.                                 RandClick("middle", Round(587 * $x_ratio), Round(350 * $y_ratio), 2, 2) ;starts the main run
  279.                                 Sleep(Random(700, 710))
  280.                                 RandMove(Round(16 * $x_ratio), Round(350 * $y_ratio), 2, 2)
  281.                                 Sleep(Random(5, 10))
  282.                                 Send($Skill1) ;leap
  283.                                 Sleep(700)
  284.                                 DoSprint()
  285.                                 Sleep(50)
  286.                                 RandClick("middle", Round(2 * $x_ratio), Round(350 * $y_ratio), 1, 1, 1, 1)
  287.                                 Sleep(800)
  288.                                 RandClick("middle", Round(2 * $x_ratio), Round(400 * $y_ratio), 1, 1)
  289.                                 walktime(Round(2 * $x_ratio), Round(400 * $y_ratio))
  290.                                
  291.                                 ; cellar check on minimap
  292.                                 FFSnapShot(1593 * $x_ratio, 62 * $y_ratio, 1880 * $x_ratio, 350 * $y_ratio, 0)
  293.                                 Local $bColorArray[3] = [0x692A09, 0x5A2408, 0x6A2A0A]
  294.  
  295.                                 FFAddColor($bColorArray)
  296.                                 FFAddExcludedArea(1824 * $x_ratio, 80 * $y_ratio, 1912 * $x_ratio, 353 * $y_ratio)
  297.                                 ;FFSaveBMP("CellarMinimap_" & @HOUR & @MIN & @SEC, false) ;->uncomment if you wanna see  the cellar minimap detection bmp ( gets saved where the script runs )
  298.                                 Local $aCoords = FFBestSpot(2, 1, 4, 367 * $x_ratio, 135 * $y_ratio, -1, 25, False)
  299.                                
  300.                                 If Not @error And IsArray($aCoords) Then
  301.                                         $cellfoundat = 1 ;found the cellar
  302.                                         FFResetColors()
  303.                                 Else
  304.                                         AddLog("enhanced fail")
  305.                                 EndIf
  306.                                
  307.                         Else
  308.                                 ;Start Run
  309.                                 RandClick("middle", Round(587 * $x_ratio), Round(333 * $y_ratio), 2, 2) ;starts the main run
  310.                                 Sleep(Random(990, 1140) / $movementSpeed)
  311.                                 RandMove(Round(96 * $x_ratio), Round(383 * $y_ratio), 2, 2)
  312.                                 Sleep(Random(5, 10))
  313.                                 Send($Skill1) ;leap
  314.                                 Sleep(700)
  315.                                 DoSprint()
  316.                                 Sleep(50)
  317.                                 RandClick("middle", Round(56 * $x_ratio), Round(360 * $y_ratio), 1, 1)
  318.                                 walktime(Round(56 * $x_ratio), Round(360 * $y_ratio))
  319.                                
  320.                                 For $i = 0 To UBound($celx) - 1
  321.                                         MouseMove(Round($celx[$i] * $x_ratio), Round($cely[$i] * $y_ratio), 1) ;moves cursor over to the cellar
  322.                                         Sleep(120)
  323.                                         ;$Pixel2 = PixelSearch(600, 0, Round(1000 * $x_ratio), Round(300 * $y_ratio), 0xffffff, 5)
  324.                                         $Pixel2 = PixelSearch(0, 0, Round(600 * $x_ratio), Round(600 * $y_ratio), 0x334FB7, 3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
  325.                                         If Not @error Then
  326.                                                 $cellfoundat = $i
  327.                                                 ExitLoop
  328.                                         EndIf
  329.                                 Next
  330.                                
  331.                                 Sleep(100)
  332.                                
  333.                         EndIf
  334.                        
  335.                         If CheckDead() Then
  336.                                 Return
  337.                         EndIf
  338.  
  339.                         ;Checks if Dank Cellar is Open
  340.                         If $cellfoundat > -1 Then
  341.                                 GUICtrlSetData($lblStatus, "Status: Cellar - Found at " & $cellfoundat + 1)
  342.                                 Call("AddLog", "Cellar Found at: " & $cellfoundat + 1)
  343.                                 $cellarCount += 1
  344.                                
  345.                                 $cellaratx = 1000 * $x_ratio
  346.                                 $cellaraty = 500 * $y_ratio
  347.                                
  348.                                 DoSprint()
  349.                                 If $UseEnhancedCellarFind Then
  350.                                        
  351.                                         RandClick("middle", Round(400 * $x_ratio), Round(400 * $y_ratio), 1, 1)
  352.                                         walktime(Round(400 * $x_ratio), Round(400 * $y_ratio))
  353.                                        
  354.                                         Local $cellpos = EnhancedFind(0, 0, 1300, 300, 1090, 280)
  355.                                         $cellaratx = $cellpos[0]
  356.                                         $cellaraty = $cellpos[1]
  357.                                         RandClick("left", Round($cellaratx), Round($cellaraty), 1, 1, 2, 2) ;Entrance to cellar
  358.                                         walktime(Round($cellaratx), Round($cellaraty))
  359.                                         ;Call("AddLog",walktime(Round($cellaratx), Round($cellaraty),0,True))
  360.                                         ;RandClick("left", Round(993 * $x_ratio), Round(469 * $y_ratio), 1, 1, 2, 2) ;Entrance to cellar
  361.                                        
  362.                                 Else
  363.                                         ;standard method co-ords
  364.                                         $cellaratx = $celx[$cellfoundat] * $x_ratio
  365.                                         $cellaraty = $cely[$cellfoundat] * $y_ratio
  366.                                         RandClick("left", Round($cellaratx), Round($cellaraty), 1, 1, 2, 2) ;Entrance to cellar
  367.                                         walktime(Round($cellaratx), Round($cellaraty), 1000)
  368.                                 EndIf
  369.  
  370.                                
  371.                                 CheckFor("DankCellar", "Area", 0, 0, 0, 0, 1)
  372.                                 $CellarWasFound = 1
  373.                         Else ;ABORT RUN
  374.                                 GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  375.                                 Call("AddLog", 'No Cellar')
  376.                                
  377.                                 If $TakeMissShots Then
  378.                                         CaptureToTIFF("", "", "", "shots\NoCell_" & String($run) & ".tif", 1, 0, 0, 0, 0)
  379.                                 EndIf
  380.                                
  381.                                 If $ExtraSafeExit Then
  382.                                         Send($Skill2) ;grim harvest
  383.                                         Sleep(200)
  384.                                         Send($Skill4) ;ancients
  385.                                         Sleep(500)
  386.                                 EndIf
  387.                                 Send("{SHIFTDOWN}")
  388.                                 RandClick("left", Round(900 * $x_ratio), Round(600 * $y_ratio), 100, 100) ;earthquake
  389.                                 Send("{SHIFTUP}")
  390.                                 Sleep(600)
  391.                                
  392.                                 If $CheckLootWhilePorting Then
  393.                                         Send($TownPortalButton)
  394.                                         Sleep(200)
  395.  
  396.                                         For $retryloot = 1 To 4
  397.                                                 Sleep(450)
  398.                                                 If LootImage("gold.png", 50, 2, 600, 200, 1400, 800) > 0 Then
  399.                                                         GUICtrlSetData($lblStatus, "GOLD!" & @CRLF)
  400.                                                         Call("AddLog", 'Got gold on failrun on pass ' & $retryloot)
  401.                                                         Call("TownPortal")
  402.                                                         ExitLoop
  403.                                                 EndIf
  404.                                                 If Not _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50) Then
  405.                                                         GUICtrlSetData($lblStatus, "INTURRUPTED" & @CRLF)
  406.                                                         Sleep(500)
  407.                                                         Call("TownPortal")
  408.                                                         ExitLoop
  409.                                                        
  410.                                                 EndIf
  411.                                         Next
  412.                                         GUICtrlSetData($lblStatus, "END SEARCH" & @CRLF)
  413.                                         CheckFor("NewTristram", "Area", 0, 0, 0, 0, 3)
  414.                                         Sleep(300)
  415.                                        
  416.                                 Else
  417.                                         Call("TownPortal")
  418.                                 EndIf
  419.                                
  420.                                 If Not CheckDead() Then
  421.                                         Call("LeaveGame")
  422.                                 EndIf
  423.                                 Return
  424.                         EndIf
  425.                 Else
  426.                         Call("TownPortal")
  427.                         If Not CheckDead() Then
  428.                                 Call("LeaveGame")
  429.                         EndIf
  430.                         Return
  431.                 EndIf
  432.                
  433.                 $TryRecover = 0
  434.                 If Not CheckFor("DankCellar", "Area", 0, 0, 0, 0, .5) Then
  435.                         ;600 450 3s
  436.                         RandClick("left", Round(993 * $x_ratio), Round(469 * $y_ratio), 1) ;Entrance to cellar
  437.                         $TryRecover = 1
  438.                        
  439.                         If Not CheckFor("DankCellar", "Area", 0, 0, 0, 0, 1.5) Then
  440.                                
  441.                                 If $UseEnhancedCellarFind Then
  442.                                         $TryRecover = 3
  443.                                         $cellpos = EnhancedFind(0, 0, 1300, 450, 1000, 350, True)
  444.                                         RandClick("left", Round($cellpos[0]), Round($cellpos[1]), 1) ;Entrance to cellar
  445.                                 Else
  446.                                         $TryRecover = 2
  447.                                         RandClick("left", Round(600 * $x_ratio), Round(450 * $y_ratio), 1)
  448.                                        
  449.                                 EndIf
  450.  
  451.                                 CheckFor("DankCellar", "Area", 0, 0, 0, 0, 4)
  452.                                
  453.                         EndIf
  454.                        
  455.                 EndIf
  456.  
  457.                 ;Checks that the player is in the Dank Cellar
  458.                 If CheckFor("DankCellar", "Area") Then
  459.                         GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  460.                         If $TryRecover = 1 Then Call("AddLog", 'OnCellar Recovery Success from ontop')
  461.                         If $TryRecover = 2 Then Call("AddLog", 'OnCellar Recovery Success From wall')
  462.                         If $TryRecover = 3 Then Call("AddLog", 'OnCellar Recovery Success using enhanced find')
  463.                        
  464.                         RandClick("middle", Round(80 * $x_ratio), Round(830 * $y_ratio), 1, 1) ;moves to doorway leading to rare inside cellar
  465.                         walktime(Round(80 * $x_ratio), Round(830 * $y_ratio), -100)
  466.                         ;Sleep(Random(2250, 2300))
  467.                         GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  468.                         RandMove(Round(350 * $x_ratio), Round(60 * $y_ratio), 1) ;hovers over the rare Sarkoth
  469.                         Send($Skill1)
  470.                         Sleep(200)
  471.                         Send("{SHIFTDOWN}")
  472.                         RandClick("left", Round(11 * $x_ratio), Round(1037 * $y_ratio), 10, 10) ;earthquake
  473.                         Sleep(200)
  474.                         RandClick("left", Round(11 * $x_ratio), Round(1037 * $y_ratio), 10, 10) ;earthquake
  475.                         Send("{SHIFTUP}")
  476.                         Sleep(800)
  477.                         Send($Skill2)
  478.                         Sleep(140)
  479.                         Send($Skill2)
  480.                         Sleep(100)
  481.                         Send($Skill2)
  482.                         Sleep(100)
  483.                         Send($Skill4)
  484.                         Sleep(100)
  485.                         Send($Skill4)
  486.                         Sleep(100)
  487.                         Send($Skill4)
  488.                         Sleep(200)
  489.                         MouseClick("right", Round(694 * $x_ratio), Round(929 * $y_ratio)) ;cancel aura thanks to LATM
  490.                         If CheckDead() Then
  491.                                 Return
  492.                         EndIf
  493.                        
  494.                         Sleep(Random($SarkothKillTime, $SarkothKillTime + 400))
  495.                        
  496.                         RandClick("middle", Round(730 * $x_ratio), Round(585 * $y_ratio), 1, 1) ;move to left top corner for gold
  497.                         Sleep(Random(850, 1350))
  498.                         RandClick("middle", Round(1205 * $x_ratio), Round(380 * $y_ratio), 1, 1) ;move to right top corner for gold
  499.                         Sleep(Random(900, 1400))
  500.                         RandClick("middle", Round(1121 * $x_ratio), Round(805 * $y_ratio), 1, 1) ;move to middle before looting
  501.                         Sleep(Random(900, 1150))
  502.                        
  503.                         GUICtrlSetData($lblStatus, "Status: Looting")
  504.                        
  505.                         $numgem = 0
  506.                         $numtomb = 0
  507.                         $numgold = 0
  508.                         $numpot = 0
  509.                         $numitem = 0
  510.                        
  511.                         DoSprint()
  512.                        
  513.                         Call("Loot")
  514.                         RandSleep(0, 6, 30)
  515.                         If $CheckLootWhilePorting Then
  516.                                 Send($TownPortalButton)
  517.                         EndIf
  518.                        
  519.                         Sleep(200)
  520.                         Send($Inventory)
  521.                         Sleep(200)
  522.                        
  523.                         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  524.                        
  525.                         $mon = CleanOCR($mon)
  526.                         $mondelt = Number($mon) - Number($monold)
  527.                         If $mondelt > 15000 Then $mondelt = 5000
  528.                         If $monstart = 0 Then $monstart = Number($mon) - $mondelt
  529.                        
  530.                         Send($Inventory)
  531.                         Sleep(50)
  532.                         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Run: " & $mondelt & ", Gain: " & Number($mon) - $monstart)
  533.                         $monold = $mon
  534.                        
  535.                         If $CheckLootWhilePorting Then
  536.                                
  537.                                 $lootany = 0
  538.                                
  539.                                 For $retryloot = 1 To 4
  540.  
  541.                                         Sleep(450)
  542.                                         Loot(True)
  543.                                         If $lootany > 0 Then
  544.                                                 Call("AddLog", 'Got extra loot on attempt ' & $retryloot)
  545.                                                 Call("TownPortal")
  546.                                                 ExitLoop
  547.                                         EndIf
  548.                                 Next
  549.                         Else
  550.                                 Call("TownPortal")
  551.                                
  552.                         EndIf
  553.                        
  554.                         Call("AddLog", 'Gold: ' & $mon & ', Gold Delt: ' & $mondelt & ', Items: ' & $numitem & ', Gems: ' & $numgem & ', Books: ' & $numtomb & ', Potions: ' & $numpot & ', GoldPick: ' & $numgold)
  555.                        
  556.                 Else
  557.                         If $TryRecover = 1 Then
  558.                                 Call("AddLog", 'OnCellar Recovery Failure')
  559.                         EndIf
  560.                         If $CellarWasFound = 1 Then
  561.                                 Call("AddLog", 'Cellar was found but didnt end up there')
  562.                         EndIf
  563.                         If $TakeMissShots Then
  564.                                 CaptureToTIFF("", "", "", "shots\MissCell_" & String($run) & ".tif", 1, 0, 0, 0, 0)
  565.                         EndIf
  566.                         Sleep(10)
  567.                         Send("{SHIFTDOWN}")
  568.                         RandClick("left", Round(900 * $x_ratio), Round(600 * $y_ratio), 100, 100) ;earthquake
  569.                         Send("{SHIFTUP}")
  570.                         Sleep(620)
  571.                         Call("TownPortal")
  572.                         If Not CheckDead() Then
  573.                                 Call("LeaveGame")
  574.                         EndIf
  575.                         Return
  576.                 EndIf
  577.                 ;After successful run
  578.                 If Not CheckDead() Then
  579.                         Sleep(600)
  580.                         If $mLootIn = 1 And CheckFor("NewTristram", "Area") Then ;If its time to manage loot and we are in town
  581.                                 $mLootIn = Round(Random($mLoot - $mLootOff, $mLoot + $mLootOff)) ;Reset Counter
  582.                                
  583.                                 If $UseiLVL Then
  584.                                         Call("AnalyseLoots")
  585.                                 Else
  586.                                         If $Identify Then Call("Identify")
  587.                                         If $StashLoot Then Call("StashLoot")
  588.                                        
  589.                                         If $SalvageLoot Then
  590.                                                 Call("SalvageLoot")
  591.                                         Else
  592.                                                 If $VendorLoot Then Call("VendorLoot")
  593.                                         EndIf
  594.                                 EndIf
  595.                                
  596.                         ElseIf Not CheckFor("NewTristram", "Area") Then
  597.                                 GUICtrlSetData($lblStatus, "Status: Skipping vendor, not in New Tristram")
  598.                                 Sleep(3000)
  599.                         ElseIf $mLootIn <= 0 Then
  600.                                 $mLootIn = 1
  601.                         Else
  602.                                 $mLootIn -= 1
  603.                         EndIf
  604.                         If Not CheckDead() Then
  605.                                 Call("LeaveGame")
  606.                         EndIf
  607.                        
  608.                         If ($RunsUntilMenuWaitCnt = 1) And ($RunsUntilMenuWait > 0) Then
  609.                                
  610.                                 $RunsUntilMenuWaitCnt = $RunsUntilMenuWait
  611.                                 Sleep(Random(3550000, 3650000)) ;wait 1 hour
  612.                         Else
  613.                                 $RunsUntilMenuWaitCnt -= 1
  614.                         EndIf
  615.                        
  616.                        
  617.                         Return
  618.                 Else
  619.                         Return
  620.                 EndIf
  621.         EndIf
  622. EndFunc   ;==>RestartRun
  623.  
  624. ;Helper Functions
  625. Func EnhancedFind($x1 = 0, $y1 = 0, $x2 = 577, $y2 = 220, $xpos = 367, $ypos = 135, $recov = False)
  626.  
  627.         For $retry = 1 To 3
  628.                 ; take 2 snapshots and black out everything that did not change
  629.                 FFSnapShot($x1 * $x_ratio, $y1 * $y_ratio, $x2 * $x_ratio, $y2 * $y_ratio, 2)
  630.                 Sleep(50)
  631.                 FFSnapShot($x1 * $x_ratio, $y1 * $y_ratio, $x2 * $x_ratio, $y2 * $y_ratio, 3)
  632.                 FFKeepChanges(3, 2, 25)
  633.                 ;FFSaveBMP("CellarOpen_" & @HOUR & @MIN & @SEC, false) ->uncomment if you wanna see  the cellar minimap motion map
  634.  
  635.                 ; do special search for the color in our motionmap
  636.                 Local $aColorArray[3] = [0x7897EB, 0x404E9E, 0x536CB6]
  637.                 FFAddColor($aColorArray) ; add color to find array
  638.                 ;Func FFBestSpot($SizeSearch, $MinNbPixel, $OptNbPixel, $PosX, $PosY, $Color, $ShadeVariation = 0, $ForceNewSnap = True, $Left = 0, $Top = 0, $Right = 0, $Bottom = 0, $NoSnapShot = $FFLastSnap, $WindowHandle = -1)
  639.                 Local $cellarCoords = FFBestSpot(10, 1, 4, $xpos * $x_ratio, $ypos * $y_ratio, -1, 25, False) ; search for the opening
  640.                
  641.                 If @error Or Not IsArray($cellarCoords) Then
  642.                         Call("AddLog", "The motionmap failed on try " & $retry & " with code " & @error)
  643.                         FFResetColors()
  644.                 Else
  645.                         ExitLoop
  646.                 EndIf
  647.  
  648.         Next
  649.  
  650.         If (Not @error) And IsArray($cellarCoords) Then
  651.                 FFResetColors()
  652.                 If Not $recov Then GUICtrlSetData($lblStatus, "Status: Cellar - Found position " & $cellarCoords[0] * $x_ratio & ", " & $cellarCoords[1] * $y_ratio)
  653.                 If Not $recov Then Call("AddLog", "Cellar - Found position " & $cellarCoords[0] * $x_ratio & ", " & $cellarCoords[1] * $y_ratio)
  654.         Else
  655.                 If $TakeMissShots Then
  656.                         CaptureToTIFF("", "", "", "shots\NoCell_" & String($run) & ".tif", 1, 0, 0, 0, 0)
  657.                 EndIf
  658.                 $cellarCoords[0] = 1000 * $x_ratio
  659.                 $cellarCoords[1] = 500 * $y_ratio
  660.         EndIf
  661.        
  662.         Return $cellarCoords
  663.        
  664. EndFunc   ;==>EnhancedFind
  665.  
  666. Func SetupGUI()
  667.         $frmBot = GUICreate($title & $ver & " - Updating", 290, 140, Round(1580 * $x_ratio), Round(900 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  668.         GUISetBkColor(0xC0C0C0)
  669.         $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  670.         GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  671.         GUICtrlSetColor(-1, 0xFF0000)
  672.         $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  673.         $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  674.         $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  675.         $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  676.         $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  677.         $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  678.         $lblGold = GUICtrlCreateLabel("Gold: 0", 12, 110, 240, 17)
  679.         GUISetState(@SW_SHOW)
  680. EndFunc   ;==>SetupGUI
  681.  
  682.  
  683. Func CheckDead()
  684.         $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
  685.         If Not @error Then
  686.                
  687.                 Call("AddLog", "Logged out")
  688.                 GUICtrlSetData($lblStatus, "Status: Logging out")
  689.                 CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), $loadtime / 1000)
  690.  
  691.                 Return 1
  692.         EndIf
  693.  
  694.         $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
  695.         If Not @error Then
  696.                 GUICtrlSetData($lblStatus, "Status: Open Window")
  697.                 Call("AddLog", "Open Window")
  698.                 Sleep(200)
  699.                 Send("{SPACE}") ;close any open windows
  700.                 Return 1
  701.         EndIf
  702.         $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"
  703.         If Not @error Then
  704.                 GUICtrlSetData($lblStatus, "Status: Dead")
  705.                 Call("AddLog", "You have died")
  706.                 $deathCount += 1
  707.                 Call("LeaveGame")
  708.                 For $c = 1 To 110 + $loadtime / 100
  709.                         Sleep(100)
  710.                         If CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), 0.1) Then ExitLoop
  711.                 Next
  712.                 Return 1
  713.         Else
  714.                 Return 0
  715.         EndIf
  716. EndFunc   ;==>CheckDead
  717.  
  718. Func CheckRepair()
  719.         $RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
  720.         If Not @error Then
  721.                 Call("DoRepair")
  722.         EndIf
  723.         $RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
  724.         If Not @error Then
  725.                 Call("DoRepair")
  726.         EndIf
  727. EndFunc   ;==>CheckRepair
  728.  
  729. Func DoRepair()
  730.         Sleep(Random(75, 150))
  731.         Call("TownPortal")
  732.         If CheckDead() Then
  733.                 Return
  734.         EndIf
  735.         If CheckFor("NewTristram", "Area") Then
  736.                 RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
  737.                 Moving(1875)
  738.                 RandClick("left", Round(1316 * $x_ratio), Round(206 * $y_ratio), 1, 1) ;moves to get merchant in screen
  739.                 Moving(1875)
  740.                 RandClick("left", Round(845 * $x_ratio), Round(225 * $y_ratio), 1, 1) ;NPC Merchant to the right of cain's home
  741.                 Sleep(1200)
  742.                 RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  743.                 Sleep(400)
  744.                 RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  745.                 Sleep(200)
  746.                 Send("{Escape}")
  747.                 Call("AddLog", "Repair")
  748.                 If Not CheckDead() Then
  749.                         Call("LeaveGame")
  750.                 EndIf
  751.         EndIf
  752. EndFunc   ;==>DoRepair
  753.  
  754. Func CalcTime()
  755.         $srt = TimerDiff($rt)
  756.         GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  757.         $trt = TimerDiff($t)
  758.         $total = Round((($trt / 1000) / 60) / 60, 4)
  759.  
  760.         Call("AddLog", "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  761.  
  762.         ;Total runtime calculation.
  763.         $hours = Floor((($trt / 1000) / 60) / 60)
  764.         $minutes = (($trt / 1000) / 60)
  765.         ;trim minutes if runtime is more then 1 hour.
  766.         If $minutes > 60 Then
  767.                 While $minutes > 60
  768.                         $minutes -= 60
  769.                 WEnd
  770.         EndIf
  771.         GUICtrlSetData($lblRuntime, "Runtime: " & $hours & ":" & Ceiling($minutes) & ", GPH: " & Ceiling((Number($mon) - $monstart) / ($trt / 3600000)))
  772. EndFunc   ;==>CalcTime
  773.  
  774. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 6, $tolerance = 140)
  775.         If $type = "Area" Then
  776.                 $startX = 1500 * $x_ratio
  777.                 $startY = 0 * $y_ratio
  778.                 $endX = 1920 * $x_ratio
  779.                 $endY = 90 * $y_ratio
  780.                 If $seconds = 6 Then $seconds = 2.5
  781.         EndIf
  782.  
  783.         $c = 0
  784.         $string = $pngLoc & $img & ".png"
  785.         Do
  786.                 $c += 1
  787.                 Sleep(200)
  788.                 If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
  789.                         If $type = "Area" Then
  790.                                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  791.                         EndIf
  792.                         Return False
  793.                 EndIf
  794.         Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  795.         GUICtrlSetData($lblStatus, "Status: Area found! " & $img)
  796.         Return True
  797. EndFunc   ;==>CheckFor
  798.  
  799. Func DoSprint()
  800.         RandClick("right", Round(15 * $x_ratio), Round(1055 * $y_ratio)) ;sprint
  801.         $SprintStart = TimerInit()
  802. EndFunc   ;==>DoSprint
  803.  
  804. Func WalkTime($lootx, $looty, $extra = 0, $returnv = False)
  805.  
  806.         $PPmSsprint = (960 / 2100) * $movementSpeed
  807.         $PPmSwalk = (960 / 3000) * $movementSpeed
  808.         Dim $BarbFeet[2] = [960 * $x_ratio, 505 * $y_ratio]
  809.        
  810.         $dist = Sqrt(($BarbFeet[0] - $lootx) ^ 2 + ($BarbFeet[1] - $looty) ^ 2)
  811.         $sprintremain = 3000 - TimerDiff($SprintStart)
  812.  
  813.         ;determine if sprint is still active to choose run speed
  814.         If $sprintremain > 0 Then ;duration of sprint - 100 for safty
  815.                 ;calculate milliseconds per pixel for this run, return delay
  816.                 ;calculate composite sleep time
  817.                 If $dist < $PPmSsprint * $sprintremain Then
  818.                         $stime = ($dist / $PPmSsprint + $extra)
  819.                 Else
  820.                         $stime = (($sprintremain + ($dist - $sprintremain * $PPmSsprint) / $PPmSwalk) + $extra)
  821.                 EndIf
  822.         Else
  823.                 $stime = ($dist / $PPmSwalk + $extra)
  824.         EndIf
  825.  
  826.         If $stime < 0 Then $stime = 0
  827.  
  828.         If Not $returnv Then
  829.  
  830.                 Sleep($stime)
  831.  
  832.         EndIf
  833.  
  834.         Return $stime
  835.  
  836. EndFunc   ;==>WalkTime
  837.  
  838. Func Loot($extra = False)
  839.  
  840.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  841.        
  842.         If Not $extra Then
  843.                
  844.                 If $LootGems Then
  845.                         LootImage("square.png", 90, 10)
  846.                 EndIf
  847.                 If $LootTomes Then
  848.                         LootImage("tome.png", 90, 10)
  849.                 EndIf
  850.                 If $LootMagic Then
  851.                         $mac = LootGear(0x6969FF, 0)
  852.                         $MagicCount += $mac
  853.                         $numitem -= $mac
  854.                 EndIf
  855.                
  856.         EndIf
  857.        
  858.         If $LootRares Then
  859.                 $RareCount += LootGear(0xBBBB00, 1)
  860.         EndIf
  861.        
  862.         If Not $extra Then
  863.                
  864.                 If $LootLegendaries Then
  865.  
  866.                         If $ReduceLegendSearch Then
  867.                                 $LegendaryCount += LootGear(0xBF642F, 1, 365, 442, 380)
  868.                                 $LegendaryCount += LootGear(0xBF642F, 1, 442, 1690, 115)
  869.                         Else
  870.                                 $LegendaryCount += LootGear(0xBF642F, 1)
  871.                         EndIf
  872.                        
  873.                 EndIf
  874.                
  875.         EndIf
  876.        
  877.         If $LootSets Then
  878.                 $SetCount += LootGear(0x02CE01, 2)
  879.         EndIf
  880.        
  881.         If $LootCustom Then
  882.                 Call("LootCustom")
  883.         EndIf
  884.  
  885.         Call("ShowLoot")
  886. EndFunc   ;==>Loot
  887.  
  888. Func LootGear($color, $tolerance = 2, $x1 = 400, $x2 = 1690, $y1 = 20, $y2 = 900)
  889.         $count = 0
  890.         $Loot = PixelSearch(Round($x1 * $x_ratio), Round($y1 * $y_ratio), Round($x2 * $x_ratio), Round($y2 * $y_ratio), $color, $tolerance)
  891.         If Not @error Then
  892.                 While Not @error
  893.                         $count += 1
  894.                         MouseClick('left', $Loot[0], $Loot[1], 1, 1)
  895.                         Sleep(20)
  896.                         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  897.                         WalkTime($Loot[0], $Loot[1])
  898.                         ;Sleep(Random(700, 800))
  899.                         ;Run at max 10 times per quality
  900.                         $lootany += 1
  901.                         If $count >= 10 Then
  902.                                 ExitLoop
  903.                         EndIf
  904.                         $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  905.                 WEnd
  906.         EndIf
  907.         $numitem += $count;
  908.         Return $count
  909. EndFunc   ;==>LootGear
  910.  
  911. Func LootImage($img, $tol, $max = 10, $x1 = 0, $y1 = 0, $x2 = @DesktopWidth, $y2 = @DesktopHeight)
  912.         $count = 0
  913.         $gX = 0
  914.         $gY = 0
  915.         GUICtrlSetData($lblStatus, "Status: Looting - " & $img)
  916.         While _ImageSearchArea($pngLoc & $img, 1, $x1, $y1, $x2, $y2, $gX, $gY, $tol)
  917.                 $count += 1
  918.                 MouseClick("left", $gX, $gY - 3, 1, 1)
  919.                 Sleep(50)
  920.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  921.                 $lootany += 1
  922.                 If $img == "square.png" Then
  923.                         $GemCount += 1
  924.                         $numgem += 1
  925.                 ElseIf $img == "tome.png" Then
  926.                         $TomeCount += 1
  927.                         $numtomb += 1
  928.                 ElseIf $img == "gold.png" Then
  929.                         $numgold += 1
  930.                 ElseIf $img == "mythic.png" Then
  931.                         $numpot += 1
  932.                 EndIf
  933.                 If $img == "gold.png" Then
  934.                         WalkTime($gX, $gY, -500)
  935.                 Else
  936.                         WalkTime($gX, $gY)
  937.                 EndIf
  938.                 If $count >= $max Then
  939.                         ExitLoop
  940.                 EndIf
  941.         WEnd
  942.         Return $count
  943. EndFunc   ;==>LootImage
  944.  
  945. Func LootCustom()
  946.         For $i = 0 To ($totalItems - 1)
  947.                 $array = StringSplit($pick[$i], "|")
  948.                 LootImage($array[1], $array[2], 5)
  949.         Next
  950. EndFunc   ;==>LootCustom
  951.  
  952. Func Identify()
  953.         Send($Inventory)
  954.         Sleep(1300)
  955.         $count = 0
  956.         While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 120)
  957.                 $count += 1
  958.                 GUICtrlSetData($lblStatus, "Status: Identifying")
  959.                 MouseClick("right", $gX, $gY, 1, 4)
  960.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  961.                 Sleep(Random(3000, 3500))
  962.                 If $count >= 30 Then
  963.                         ExitLoop
  964.                 EndIf
  965.         WEnd
  966.         Send($Inventory)
  967.         Sleep(200)
  968. EndFunc   ;==>Identify
  969.  
  970. Func CleanOCR($text)
  971.         $out = ""
  972.         For $i = 1 To StringLen($text)
  973.                 $chr = Asc(StringMid($text, $i, 1))
  974.                 If $chr >= 48 And $chr <= 57 Then $out = $out & Chr($chr)
  975.                 If $chr = 79 Then $out = $out & '0'
  976.         Next
  977.         Return $out
  978. EndFunc   ;==>CleanOCR
  979.  
  980. Func ClickTab($Tabno)
  981.         If $Tabno = 1 Then RandClick("left", Round(517 * $x_ratio), Round(229 * $y_ratio), 3, 4)
  982.         If $Tabno = 2 Then RandClick("left", Round(517 * $x_ratio), Round(361 * $y_ratio), 3, 4)
  983.         If $Tabno = 3 Then RandClick("left", Round(517 * $x_ratio), Round(486 * $y_ratio), 3, 4)
  984.         Sleep(Random(100, 200))
  985.  
  986. EndFunc   ;==>ClickTab
  987.  
  988. Func UseNextTab()
  989.         If $ItemTab = $NextItemTab Then
  990.                 Call("AddLog", "Stash full Both tabs full, disabling stashing")
  991.                 $StashLegendary = False
  992.                 $StashRare = False
  993.                 $StashMagic = False
  994.         Else
  995.                 Call("AddLog", "Stash full Using next tab")
  996.                 $ItemTab = $NextItemTab
  997.         EndIf
  998. EndFunc   ;==>UseNextTab
  999.  
  1000. Func AddLog($logtxt)
  1001.         Local $file = FileOpen("log.txt", 1)
  1002.         $msg = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ': ' & $logtxt & @CRLF
  1003.         FileWrite($file, $msg)
  1004.         FileClose($file)
  1005.         ConsoleWrite($msg)
  1006. EndFunc   ;==>AddLog
  1007.  
  1008. Func StashLoot()
  1009.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  1010.         MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  1011.         Sleep(Random(800, 1000))
  1012.  
  1013.         ClickTab($GemTab)
  1014.         ;Tomes
  1015.         If $StashTomes Then
  1016.                 GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  1017.                 ClickImage("TomeIcon.png", 140, 1)
  1018.         EndIf
  1019.        
  1020.         ;Gems (DOESN'T STASH BOTTOM ROW!)
  1021.         If $StashGems Then
  1022.                 GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  1023.                 For $i = 0 To 7
  1024.                         ClickImage($gems[$i], 150, 1)
  1025.                 Next
  1026.         EndIf
  1027.        
  1028.         $numstashed = 0;
  1029.         ClickTab($ItemTab)
  1030.  
  1031.         If $StashLegendary Then
  1032.                 ClickItems(0xFF7F00, 2, True, 5)
  1033.                 ClickItems(0x8F5C25, 2, True, 5)
  1034.         EndIf
  1035.  
  1036.         If $StashRare Then
  1037.                 ClickItems(0x4A3C0B, 1, True, 20)
  1038.         EndIf
  1039.        
  1040.         If $StashMagic Then
  1041.                 ClickItems(0x182037, 1, True, 30)
  1042.         EndIf
  1043.  
  1044.         Call("AddLog", "Stashed Items: " & $numstashed)
  1045.        
  1046.         Sleep(Random(300, 400))
  1047.        
  1048.        
  1049.         Send("{SPACE}")
  1050. EndFunc   ;==>StashLoot
  1051.  
  1052. Func VendorLoot()
  1053.         GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  1054.         Sleep(Random(200, 300))
  1055.         Send($Skill3)
  1056.         Sleep(Random(200, 300))
  1057.         DoSprint()
  1058.        
  1059.         If Not $StashLoot Then ;Move from TP towards vendor
  1060.                 Sleep(Random(100, 300))
  1061.                 MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  1062.                 walktime(1565 * $x_ratio, 50 * $y_ratio, 100)
  1063.         Else ;Move from Stash towards vendor
  1064.                 Sleep(Random(100, 300))
  1065.                 MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  1066.                 walktime(1560 * $x_ratio, 120 * $y_ratio, 100)
  1067.         EndIf
  1068.  
  1069.         MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  1070.         walktime(1030 * $x_ratio, 210 * $y_ratio, 250)
  1071.        
  1072.         $numsold = 0;
  1073.  
  1074.         ;All
  1075.         If $vendorAll Then
  1076.                 For $c = 1 To $vendorCols
  1077.                         For $r = 1 To $vendorRows
  1078.                                 RandClick("right", (((($c - 1) * 50) + 32 + 1400) * $x_ratio), (((($r - 1) * 51) + 32 + 580) * $y_ratio), 2, 2, 1, 2.5)
  1079.                         Next
  1080.                 Next
  1081.         EndIf
  1082.        
  1083.         ;Rares
  1084.         If $VendorRare Then
  1085.                 ClickItems(0x4A3C0B, 2)
  1086.         EndIf
  1087.         ;Magic
  1088.         If $VendorMagic Then
  1089.                 ClickItems(0x182037, 2)
  1090.         EndIf
  1091.        
  1092.         $montmp = $mon
  1093.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1094.         $mon = CleanOCR($mon)
  1095.        
  1096.         If $mon > 0 Then
  1097.                 $mondelt = Number($mon) - Number($monold)
  1098.                 GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
  1099.                 $monold = $mon
  1100.                 Call("AddLog", "Sold Items: " & $numsold & ", Sold value: " & $mondelt)
  1101.         Else
  1102.                 $mLootIn = 1
  1103.                 $mon = $montmp
  1104.                 Call("AddLog", "Somthing went wrong in town, retrying next time")
  1105.                 GUICtrlSetData($lblGold, "Vend fail, retry next run")
  1106.                 Return
  1107.         EndIf
  1108.        
  1109.         Sleep(200)
  1110.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  1111.         Sleep(300)
  1112.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  1113.         Sleep(400)
  1114.  
  1115.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1116.         $mon = CleanOCR($mon)
  1117.         $mondelt = Number($mon) - Number($monold)
  1118.         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
  1119.         $monold = $mon
  1120.         Call("AddLog", "Repair Cost: " & - $mondelt)
  1121.  
  1122.         GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  1123.         Send("{ESCAPE}")
  1124. EndFunc   ;==>VendorLoot
  1125.  
  1126. Func ClickItems($color, $tolerance, $checkfull = False, $max = 30)
  1127.         $c = 0
  1128.         While $c < $max
  1129.                 RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  1130.                 Sleep(Random(60, 120))
  1131.                 $StashPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  1132.                 If Not @error Then
  1133.                         MouseClick("right", $StashPixel[0], $StashPixel[1], 1, 4)
  1134.                         $c += 1
  1135.                         If $checkfull Then
  1136.                                 $numstashed += 1
  1137.                         Else
  1138.                                 $numsold += 1
  1139.                         EndIf
  1140.                 Else
  1141.                         ExitLoop
  1142.                 EndIf
  1143.         WEnd
  1144.         Sleep(Random(60, 120))
  1145.         If $checkfull Then
  1146.                 If $c = $max Then Call("UseNextTab")
  1147.                 ClickTab($ItemTab)
  1148.         EndIf
  1149. EndFunc   ;==>ClickItems
  1150.  
  1151. Func ClickImage($image, $tolerance, $max = 20)
  1152.         For $c = 1 To $max
  1153.                 RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  1154.                 Sleep(Random(100, 300))
  1155.                 If _ImageSearchArea($pngLoc & $image, 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, $tolerance) Then
  1156.                         MouseClick("right", $gX, $gY, 1, 4)
  1157.                         Sleep(120)
  1158.                 Else
  1159.                         ExitLoop
  1160.                 EndIf
  1161.         Next
  1162. EndFunc   ;==>ClickImage
  1163.  
  1164. Func SalvageLoot()
  1165.  
  1166.         DoSprint()
  1167.  
  1168.         GUICtrlSetData($lblStatus, "Status: Salvaging Items")
  1169.         Sleep(Random(300, 500))
  1170.         MouseClick("middle", 1786 * $x_ratio, 535 * $y_ratio)
  1171.         walktime(1786 * $x_ratio, 535 * $y_ratio, 100)
  1172.         ;Sleep(2000)
  1173.         MouseClick("left", 1430 * $x_ratio, 390 * $y_ratio) ;Talk to anvil
  1174.         ;Sleep(3000)
  1175.         walktime(1430 * $x_ratio, 390 * $y_ratio, 100)
  1176.  
  1177.         $c = 0
  1178.         While $c <= 20
  1179.                 Sleep(Random(200, 300))
  1180.                 $MagicPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 830 * $y_ratio, 0x182037, 1)
  1181.                 If Not @error Then
  1182.                         MouseClick("left", 265 * $x_ratio, 291 * $y_ratio, 1, 4)
  1183.                         Sleep(Random(200, 300))
  1184.                         MouseClick("left", $MagicPixel[0], $MagicPixel[1], 1, 4)
  1185.                         Sleep(Random(200, 300))
  1186.                         MouseClick("left", 1072 * $x_ratio, 375 * $y_ratio, 1, 4)
  1187.                         RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  1188.                         Sleep(40)
  1189.                         $c += 1
  1190.                 Else
  1191.                         ExitLoop
  1192.                 EndIf
  1193.         WEnd
  1194.         Call("AddLog", "Salvaged Items: " & $c)
  1195.  
  1196.         Send("{ESCAPE}")
  1197.         Sleep(Random(300, 500))
  1198. EndFunc   ;==>SalvageLoot
  1199.  
  1200. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  1201.         If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  1202.         $findImage = "*TRANSBLACK " & $findImage
  1203.         If @AutoItX64 Then
  1204.                 $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1205.         Else
  1206.                 $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1207.         EndIf
  1208.         If $result = "0" Then
  1209.                 Return 0
  1210.         EndIf
  1211.  
  1212.         ; Otherwise get the x,y location of the match and the size of the image to
  1213.         ; compute the centre of search
  1214.         $array = StringSplit($result[0], "|")
  1215.         If (UBound($array) >= 4) Then
  1216.                 $x = Int(Number($array[2]))
  1217.                 $y = Int(Number($array[3]))
  1218.                 If $resultPosition = 1 Then
  1219.                         $x = $x + Int(Number($array[4]) / 2)
  1220.                         $y = $y + Int(Number($array[5]) / 2)
  1221.                 EndIf
  1222.                 Return 1
  1223.         EndIf
  1224. EndFunc   ;==>_ImageSearchArea
  1225.  
  1226. Func LeaveGame()
  1227.  
  1228.         Call("RandSleep")
  1229.         GUICtrlSetData($lblStatus, "Status: Leaving Game")
  1230.         Send("{Escape}")
  1231.         Sleep(200)
  1232.         RandClick("left", Round(956 * $x_ratio), Round(579 * $y_ratio), 120, 20) ;Random Click on the leave button
  1233.         Call("CalcTime")
  1234.         CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), $loadtime / 1000)
  1235. EndFunc   ;==>LeaveGame
  1236.  
  1237. Func TownPortalShort()
  1238.  
  1239.         $gX = 0
  1240.         $gY = 0
  1241.         $c = 0
  1242.         GUICtrlSetData($lblStatus, "Status: Waiting for TP bar")
  1243.         Do
  1244.                 $c += 1
  1245.                 Sleep(200)
  1246.                 If $c > 4 Then Return
  1247.         Until _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
  1248.  
  1249.         $seconds = $TPProtectTime
  1250.         $c = 0
  1251.  
  1252.         Do
  1253.                 $c += 1
  1254.                 GUICtrlSetData($lblStatus, "Status: Prepared for inturrupt, " & $seconds * 5 - $c)
  1255.                 Sleep(200)
  1256.                 If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
  1257.                         GUICtrlSetData($lblStatus, "Status: safe, doing long wait for town")
  1258.                         Sleep($tptime - $seconds * 1000 - 1200)
  1259.                         GUICtrlSetData($lblStatus, "Status: detecting town")
  1260.                         CheckFor("NewTristram", "Area")
  1261.                         Sleep(300)
  1262.                         Return
  1263.                 EndIf
  1264.         Until Not _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
  1265.  
  1266. EndFunc   ;==>TownPortalShort
  1267.  
  1268. Func TownPortal()
  1269.  
  1270.         GUICtrlSetData($lblStatus, "Status: Returning to Town")
  1271.         Send($TownPortalButton)
  1272.        
  1273.         If $DetectTPFail Then
  1274.                 Call("TownPortalShort")
  1275.         Else
  1276.                 Sleep(Random($tptime, $tptime + 500))
  1277.         EndIf
  1278.        
  1279. EndFunc   ;==>TownPortal
  1280.  
  1281. #region OtherStuff
  1282.  
  1283. Func Moving($time)
  1284.         Sleep($time / $movementSpeed)
  1285. EndFunc   ;==>Moving
  1286.  
  1287. Func RandClick($clickType, $xpos, $ypos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
  1288.         If $xOff < 1 Then $xOff = 1
  1289.         If $yOff < 1 Then $yOff = 1
  1290.         $randX = Round(Random($xpos - ($xOff * $x_ratio), $xpos + ($xOff * $x_ratio)))
  1291.         $randY = Round(Random($ypos - ($yOff * $y_ratio), $ypos + ($yOff * $y_ratio)))
  1292.         MouseClick($clickType, $randX, $randY, $clicks, $speed)
  1293. EndFunc   ;==>RandClick
  1294.  
  1295. Func RandMove($xpos, $ypos, $xOff = 10, $yOff = 10, $speed = 1)
  1296.         $randX = Round(Random($xpos - ($xOff * $x_ratio), $xpos + ($xOff * $x_ratio)))
  1297.         $randY = Round(Random($ypos - ($yOff * $y_ratio), $ypos + ($yOff * $y_ratio)))
  1298.         MouseMove($randX, $randY, $speed)
  1299. EndFunc   ;==>RandMove
  1300.  
  1301. Func RandSleep($min = 5, $max = 45, $chance = 3)
  1302.         $randNum = Round(Random(1, 100))
  1303.         If $Timer And $randNum <= $chance Then
  1304.                 $sleepTime = Random($min * 1000, $max * 1000)
  1305.                 GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime / 1000) & " secs")
  1306.                 For $c = 0 To 10
  1307.                         Sleep($sleepTime / 10)
  1308.                 Next
  1309.         EndIf
  1310. EndFunc   ;==>RandSleep
  1311. ;Hotkey Functions
  1312.  
  1313. Func Begin()
  1314.         $Go = Not $Go
  1315.         If Not $Go Then WinSetTitle($title, "", $title & $ver & " - Halted")
  1316. EndFunc   ;==>Begin
  1317.  
  1318. Func TogglePause()
  1319.         $Paused = Not $Paused
  1320.         While $Paused
  1321.                 Sleep(100)
  1322.                 WinSetTitle($title, "", $title & $ver & " - Paused")
  1323.                 ToolTip('[PAUSED] - Deaths: ' & $deathCount & ' | Cellars: ' & $cellarCount, 0, 0)
  1324.         WEnd
  1325.         WinSetTitle($title, "", $title & $ver & " - Running")
  1326.         ToolTip("")
  1327. EndFunc   ;==>TogglePause
  1328.  
  1329. Func ShowLoot()
  1330.         GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  1331.         GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  1332. EndFunc   ;==>ShowLoot
  1333.  
  1334. Func Stop() ;to allow the script to stop
  1335.         Exit
  1336. EndFunc   ;==>Stop
  1337. Func GoTown()
  1338.         $mLootIn = 1
  1339. EndFunc   ;==>GoTown
  1340.  
  1341. Func AnalyseLoots() ; Grid search + ilvl detection, a little bit slower than old method but computes db for fast stashing/vendoring/new salvaging
  1342.         ;ConsoleWrite("---- NEW ANALYSIS ----" & @crlf)
  1343.         $str_Stash = ""
  1344.         $str_StashGems = ""
  1345.         $str_StashMisc = ""
  1346.         $str_Vendor = ""
  1347.         $str_Salvage = ""
  1348.         $int_TownPosition = 0
  1349.         $int_emptygrid = 0
  1350.         $str_Ignore = ""
  1351.         $nX = 0
  1352.         $nY = 0
  1353.         GUICtrlSetData($lblStatus, "Status: Analysing loots")
  1354.         Send("c")
  1355.         Sleep(500)
  1356.         For $y = 0 To 5
  1357.                 $int_emptygrid = 0
  1358.                 MouseMove(1435, Round(609 + (45 * $y)), 1)
  1359.                 Sleep(500)
  1360.                 For $x = 0 To 9
  1361.                         If StringInStr($str_Ignore, 1435 + (48 * $x) & "," & 609 + (45 * $y)) Then ContinueLoop
  1362.                         MouseMove(1435 + (48 * $x), 609 + (45 * $y), 1)
  1363.                         Sleep(300)
  1364.                         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
  1365.                                 $int_emptygrid = 0
  1366.                                 If _ImageSearchArea($pngLoc & "tt_unidentified.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) And $Identify Then ; Identify items.
  1367.                                         MouseClick("secondary")
  1368.                                         Sleep(Random(3000, 3500, 1))
  1369.                                 EndIf
  1370.                                 If _ImageSearchArea($pngLoc & "tt_square.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Gem, automatic stashing.
  1371.                                         $str_StashGems = $str_StashGems & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1372.                                         ContinueLoop
  1373.                                 EndIf
  1374.                                 If _ImageSearchArea($pngLoc & "tt_tome.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Tome, automatic stashing.
  1375.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1376.                                         ContinueLoop
  1377.                                 EndIf
  1378.                                 If _ImageSearchArea($pngLoc & "tt_exquisite.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
  1379.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1380.                                         ContinueLoop
  1381.                                 EndIf
  1382.                                 If _ImageSearchArea($pngLoc & "tt_iridescent.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
  1383.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1384.                                         ContinueLoop
  1385.                                 EndIf
  1386.                                 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).
  1387.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1388.                                         ContinueLoop
  1389.                                 EndIf
  1390.                                 If _ImageSearchArea($pngLoc & "tt_plan.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 60) Then ; Plans, automatic stashing.
  1391.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1392.                                         ContinueLoop
  1393.                                 EndIf
  1394.                                 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
  1395.                                         $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * ($y + 1))
  1396.                                 EndIf
  1397.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x00FF00, 1) ; Set, no ilvl check since they drop rarely. Goes to stash.
  1398.                                 If Not @error Then
  1399.                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1400.                                         ContinueLoop
  1401.                                 EndIf
  1402.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xBF642F, 1) ; Legendary, no ilvl check since they drop rarely. Goes to stash.
  1403.                                 If Not @error Then
  1404.                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1405.                                         ContinueLoop
  1406.                                 EndIf
  1407.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xFFFF00, 1) ; Rare
  1408.                                 If Not @error Then
  1409.                                         If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 59
  1410.                                                 If (getOption("i59r") == 1) Then
  1411.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1412.                                                 ElseIf (getOption("i59r") == 2) Then
  1413.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1414.                                                 Else
  1415.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1416.                                                 EndIf
  1417.                                                 ContinueLoop
  1418.                                         EndIf
  1419.                                         If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 60,  goes to salvage
  1420.                                                 If (getOption("i60r") == 1) Then
  1421.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1422.                                                 ElseIf (getOption("i60r") == 2) Then
  1423.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1424.                                                 Else
  1425.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1426.                                                 EndIf
  1427.                                                 ContinueLoop
  1428.                                         EndIf
  1429.                                         If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 61,  goes to salvage
  1430.                                                 If (getOption("i61r") == 1) Then
  1431.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1432.                                                 ElseIf (getOption("i61r") == 2) Then
  1433.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1434.                                                 Else
  1435.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1436.                                                 EndIf
  1437.                                                 ContinueLoop
  1438.                                         EndIf
  1439.                                         If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 62,  goes to salvage
  1440.                                                 If (getOption("i62r") == 1) Then
  1441.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1442.                                                 ElseIf (getOption("i62r") == 2) Then
  1443.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1444.                                                 Else
  1445.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1446.                                                 EndIf
  1447.                                                 ContinueLoop
  1448.                                         EndIf
  1449.                                         If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 63,  goes to stash
  1450.                                                 If (getOption("i63r") == 1) Then
  1451.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1452.                                                 ElseIf (getOption("i63r") == 2) Then
  1453.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1454.                                                 Else
  1455.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1456.                                                 EndIf
  1457.                                                 ContinueLoop
  1458.                                         EndIf
  1459.                                         ; Below ilvl 59
  1460.                                         If $StashRare Then
  1461.                                                 $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1462.                                         ElseIf $VendorRare Then
  1463.                                                 $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1464.                                         Else
  1465.                                                 $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1466.                                         EndIf
  1467.                                         ContinueLoop
  1468.                                 EndIf
  1469.                                
  1470.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 40, 0xFF0000, 1) ; unusable rares, legendaries & sets. Goes to stash.
  1471.                                 If Not @error Then
  1472.                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1473.                                         ContinueLoop
  1474.                                 EndIf
  1475.                                
  1476.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x6969FF, 1) ; Magic
  1477.                                 If Not @error Then
  1478.                                         If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 59
  1479.                                                 If (getOption("i59m") == 1) Then
  1480.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1481.                                                 ElseIf (getOption("i59m") == 2) Then
  1482.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1483.                                                 Else
  1484.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1485.                                                 EndIf
  1486.                                                 ContinueLoop
  1487.                                         EndIf
  1488.                                         If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 60, goes to salvage
  1489.                                                 If (getOption("i60m") == 1) Then
  1490.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1491.                                                 ElseIf (getOption("i60m") == 2) Then
  1492.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1493.                                                 Else
  1494.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1495.                                                 EndIf
  1496.                                                 ContinueLoop
  1497.                                         EndIf
  1498.                                         If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 61, goes to salvage
  1499.                                                 If (getOption("i61m") == 1) Then
  1500.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1501.                                                 ElseIf (getOption("i61m") == 2) Then
  1502.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1503.                                                 Else
  1504.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1505.                                                 EndIf
  1506.                                                 ContinueLoop
  1507.                                         EndIf
  1508.                                         If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 62, goes to salvage
  1509.                                                 If (getOption("i62m") == 1) Then
  1510.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1511.                                                 ElseIf (getOption("i62m") == 2) Then
  1512.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1513.                                                 Else
  1514.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1515.                                                 EndIf
  1516.                                                 ContinueLoop
  1517.                                         EndIf
  1518.                                         If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 63, goes to stash
  1519.                                                 If (getOption("i63m") == 1) Then
  1520.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1521.                                                 ElseIf (getOption("i63m") == 2) Then
  1522.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1523.                                                 Else
  1524.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1525.                                                 EndIf
  1526.                                                 ContinueLoop
  1527.                                         EndIf
  1528.                                         ; Below ilvl 59
  1529.                                         If $StashMagic Then
  1530.                                                 $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1531.                                         ElseIf $VendorMagic Then
  1532.                                                 $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1533.                                         Else
  1534.                                                 $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1535.                                         EndIf
  1536.                                         ContinueLoop
  1537.                                 EndIf
  1538.                                 ; Probably white/gray trash bugged pick, add to vendor string
  1539.                                 $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1540.                         Else
  1541.                                 $int_emptygrid += 1
  1542.                                 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.
  1543.                                         $int_emptygrid = 0
  1544.                                         ExitLoop
  1545.                                 Else
  1546.                                         ContinueLoop
  1547.                                 EndIf
  1548.                         EndIf
  1549.                 Next
  1550.         Next
  1551.         Send("c")
  1552.         Sleep(500)
  1553.         ;Call("AddLog", "Stash gear : "  & $str_Stash )
  1554.         ;Call("AddLog", "Stash misc : "  & $str_StashMisc )
  1555.         ;Call("AddLog", "Stash gems : "  & $str_StashGems )
  1556.         ;Call("AddLog", "Salvage : "  & $str_Salvage )
  1557.         ;Call("AddLog", "Vendor : "  & $str_Vendor )
  1558.         ;Call("AddLog", "Ignored Square : "  & $str_Ignore )
  1559.  
  1560.  
  1561.         Call("AddLog", "Stashed Items: " & UBound(StringSplit($str_Stash, "|")))
  1562.  
  1563.         If $str_Stash <> "" Or $str_StashGems <> "" Or $str_StashMisc <> "" Then Call("StashLoot_new")
  1564.         If $str_Salvage <> "" Then Call("SalvageLoot_new")
  1565.         If $str_Vendor <> "" Then Call("VendorLoot_new")
  1566. EndFunc   ;==>AnalyseLoots
  1567.  
  1568. Func StashLoot_new()
  1569.         $arr_split = ""
  1570.         $pos_split = ""
  1571.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  1572.         MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  1573.         Moving(1600)
  1574.         $int_TownPosition = 1
  1575.  
  1576.         ;Gems Page 1
  1577.         If $str_StashGems <> "" Then
  1578.                 ClickTab($GemTab)
  1579.                 $str_StashGems = StringMid($str_StashGems, 2)
  1580.                 $arr_split = StringSplit($str_StashGems, "|")
  1581.                 For $i = 1 To $arr_split[0]
  1582.                         Sleep(Random(300, 350))
  1583.                         $pos_split = StringSplit($arr_split[$i], ",", 2)
  1584.                         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1585.                 Next
  1586.         EndIf
  1587.  
  1588.         ;Tomes/Crafting Materials/Plans/Etc Page 2
  1589.         If $str_StashMisc <> "" Then
  1590.                 ClickTab($GemTab)
  1591.                 $str_StashMisc = StringMid($str_StashMisc, 2)
  1592.                 $arr_split = StringSplit($str_StashMisc, "|")
  1593.                 For $i = 1 To $arr_split[0]
  1594.                         Sleep(Random(300, 350))
  1595.                         $pos_split = StringSplit($arr_split[$i], ",", 2)
  1596.                         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1597.                 Next
  1598.         EndIf
  1599.  
  1600.         ;Gears Page 2
  1601.         If $str_Stash <> "" Then
  1602.                 $str_Stash = StringMid($str_Stash, 2)
  1603.                 $arr_split = StringSplit($str_Stash, "|")
  1604.                 For $i = 1 To $arr_split[0]
  1605.                         Sleep(Random(80, 100))
  1606.                         If Random() < 0.5 Then
  1607.                                 ClickTab($ItemTab)
  1608.                         Else
  1609.                                 ClickTab($NextItemTab)
  1610.                         EndIf
  1611.                        
  1612.                         Sleep(Random(300, 350))
  1613.                         $pos_split = StringSplit($arr_split[$i], ",", 2)
  1614.                         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1615.                 Next
  1616.         EndIf
  1617.  
  1618.         Sleep(Random(100, 150))
  1619.         Send("{SPACE}")
  1620. EndFunc   ;==>StashLoot_new
  1621.  
  1622. Func SalvageLoot_new()
  1623.         $arr_split = ""
  1624.         $pos_split = ""
  1625.         GUICtrlSetData($lblStatus, "Status: Salvaging loots")
  1626.         If $int_TownPosition = 0 Then ; Starting from TP
  1627.                 MouseClick("middle", 1582 * $x_ratio, 527 * $y_ratio)
  1628.                 Moving(2000)
  1629.                 MouseClick("left", 1661 * $x_ratio, 409 * $y_ratio)
  1630.                 Moving(2500)
  1631.         Else ; Starting from Stash
  1632.                 MouseClick("middle", 1484 * $x_ratio, 583 * $y_ratio)
  1633.                 Moving(2000)
  1634.                 MouseClick("left", 1773 * $x_ratio, 484 * $y_ratio)
  1635.                 Moving(2500)
  1636.         EndIf
  1637.         $int_TownPosition = 2
  1638.         MouseClick("left", 263 * $x_ratio, 287 * $y_ratio)
  1639.         $str_Salvage = StringMid($str_Salvage, 2)
  1640.         $arr_split = StringSplit($str_Salvage, "|")
  1641.         For $i = 1 To $arr_split[0]
  1642.                 Sleep(Random(300, 400))
  1643.                 $pos_split = StringSplit($arr_split[$i], ",")
  1644.                 MouseClick("left", $pos_split[1], $pos_split[2], 1, 3)
  1645.                 If $pos_split[0] == 3 Then
  1646.                         Send("{ENTER}")
  1647.                         Sleep(1000)
  1648.                 EndIf
  1649.         Next
  1650.         Sleep(Random(300, 400))
  1651.         Send("{SPACE}")
  1652. EndFunc   ;==>SalvageLoot_new
  1653.  
  1654. Func VendorLoot_new()
  1655.         $arr_split = ""
  1656.         $pos_split = ""
  1657.         GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  1658.         If $int_TownPosition = 0 Then ; Starting from TP
  1659.                 MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  1660.         ElseIf $int_TownPosition = 1 Then ; Starting from Stash
  1661.                 MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  1662.         Else ; Starting from Blacksmith
  1663.                 MouseClick("middle", 738 * $x_ratio, 64 * $y_ratio)
  1664.         EndIf
  1665.         Moving(3000)
  1666.         MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  1667.         Moving(3000)
  1668.         $str_Vendor = StringMid($str_Vendor, 2)
  1669.         $arr_split = StringSplit($str_Vendor, "|")
  1670.         For $i = 1 To $arr_split[0]
  1671.                 Sleep(Random(100, 300))
  1672.                 $pos_split = StringSplit($arr_split[$i], ",", 2)
  1673.                 MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1674.                 If PixelGetColor(819 * $x_ratio, 375 * $y_ratio) == 0x370C00 Then Send("{ENTER}")
  1675.         Next
  1676.         Sleep(Random(100, 200))
  1677.        
  1678.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1679.         $mon = CleanOCR($mon)
  1680.         $mondelt = Number($mon) - Number($monold)
  1681.         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
  1682.         $monold = $mon
  1683.         Call("AddLog", "Sold Items: " & $arr_split[0] & ", Sold value: " & $mondelt)
  1684.        
  1685.         Sleep(Random(200, 300))
  1686.        
  1687.  
  1688.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  1689.         Sleep(200)
  1690.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  1691.         Sleep(400)
  1692.        
  1693.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1694.         $mon = CleanOCR($mon)
  1695.         $mondelt = Number($mon) - Number($monold)
  1696.         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
  1697.         $monold = $mon
  1698.         Call("AddLog", "Repair Cost: " & - $mondelt)
  1699.        
  1700.  
  1701.         GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  1702.        
  1703.         Send("{SPACE}")
  1704.        
  1705. EndFunc   ;==>VendorLoot_new
  1706.  
  1707. Func getOption($option) ;Gets the correct INI settings corrisponding to the vend/stash/salvage of items.
  1708.  
  1709.         If ($option == "i59r") Then
  1710.                 If ($i59Rare = "salvage") Then
  1711.                         Return 1
  1712.                 ElseIf ($i59Rare = "vend") Then
  1713.                         Return 2
  1714.                 Else
  1715.                         Return 0
  1716.                 EndIf
  1717.         ElseIf ($option == "i60r") Then
  1718.                 If ($i60Rare = "salvage") Then
  1719.                         Return 1
  1720.                 ElseIf ($i60Rare = "vend") Then
  1721.                         Return 2
  1722.                 Else
  1723.                         Return 0
  1724.                 EndIf
  1725.         ElseIf ($option == "i61r") Then
  1726.                 If ($i61Rare = "salvage") Then
  1727.                         Return 1
  1728.                 ElseIf ($i61Rare = "vend") Then
  1729.                         Return 2
  1730.                 Else
  1731.                         Return 0
  1732.                 EndIf
  1733.         ElseIf ($option == "i62r") Then
  1734.                 If ($i62Rare = "salvage") Then
  1735.                         Return 1
  1736.                 ElseIf ($i62Rare = "vend") Then
  1737.                         Return 2
  1738.                 Else
  1739.                         Return 0
  1740.                 EndIf
  1741.         ElseIf ($option == "i63r") Then
  1742.                 If ($i63Rare = "salvage") Then
  1743.                         Return 1
  1744.                 ElseIf ($i63Rare = "vend") Then
  1745.                         Return 2
  1746.                 Else
  1747.                         Return 0
  1748.                 EndIf
  1749.         ElseIf ($option == "i59m") Then
  1750.                 If ($i59Magic = "salvage") Then
  1751.                         Return 1
  1752.                 ElseIf ($i59Magic = "vend") Then
  1753.                         Return 2
  1754.                 Else
  1755.                         Return 0
  1756.                 EndIf
  1757.         ElseIf ($option == "i60m") Then
  1758.                 If ($i60Magic = "salvage") Then
  1759.                         Return 1
  1760.                 ElseIf ($i60Magic = "vend") Then
  1761.                         Return 2
  1762.                 Else
  1763.                         Return 0
  1764.                 EndIf
  1765.         ElseIf ($option == "i61m") Then
  1766.                 If ($i61Magic = "salvage") Then
  1767.                         Return 1
  1768.                 ElseIf ($i61Magic = "vend") Then
  1769.                         Return 2
  1770.                 Else
  1771.                         Return 0
  1772.                 EndIf
  1773.         ElseIf ($option == "i62m") Then
  1774.                 If ($i62Magic = "salvage") Then
  1775.                         Return 1
  1776.                 ElseIf ($i62Magic = "vend") Then
  1777.                         Return 2
  1778.                 Else
  1779.                         Return 0
  1780.                 EndIf
  1781.         ElseIf ($option == "i63m") Then
  1782.                 If ($i63Magic = "salvage") Then
  1783.                         Return 1
  1784.                 ElseIf ($i63Magic = "vend") Then
  1785.                         Return 2
  1786.                 Else
  1787.                         Return 0
  1788.                 EndIf
  1789.         Else
  1790.                 Return 0
  1791.         EndIf
  1792.  
  1793. EndFunc   ;==>getOption
  1794. #endregion OtherStuff