Advertisement
BlackSack

Blaksack's mod 1.93x

Jul 5th, 2012
2,781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 88.42 KB | None | 0 0
  1. ; Blaksack's mod 1.93x
  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.3x ", $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(300)
  477.                         Send($Skill2)
  478.                         Sleep(300)
  479.                         Send($Skill4)
  480.                         Sleep(200)
  481.                         MouseClick("right", Round(694 * $x_ratio), Round(929 * $y_ratio)) ;cancel aura thanks to LATM
  482.                         If CheckDead() Then
  483.                                 Return
  484.                         EndIf
  485.                        
  486.                         Sleep(Random($SarkothKillTime, $SarkothKillTime + 400))
  487.                        
  488.                         RandClick("middle", Round(730 * $x_ratio), Round(585 * $y_ratio), 1, 1) ;move to left top corner for gold
  489.                         Sleep(Random(850, 1350))
  490.                         RandClick("middle", Round(1205 * $x_ratio), Round(380 * $y_ratio), 1, 1) ;move to right top corner for gold
  491.                         Sleep(Random(900, 1400))
  492.                         RandClick("middle", Round(1121 * $x_ratio), Round(805 * $y_ratio), 1, 1) ;move to middle before looting
  493.                         Sleep(Random(900, 1150))
  494.                        
  495.                         GUICtrlSetData($lblStatus, "Status: Looting")
  496.                        
  497.                         $numgem = 0
  498.                         $numtomb = 0
  499.                         $numgold = 0
  500.                         $numpot = 0
  501.                         $numitem = 0
  502.                        
  503.                         DoSprint()
  504.                        
  505.                         Call("Loot")
  506.                         RandSleep(0, 6, 30)
  507.                         If $CheckLootWhilePorting Then
  508.                                 Send($TownPortalButton)
  509.                         EndIf
  510.                        
  511.                         Sleep(200)
  512.                         Send($Inventory)
  513.                         Sleep(200)
  514.                        
  515.                         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  516.                        
  517.                         $mon = CleanOCR($mon)
  518.                         $mondelt = Number($mon) - Number($monold)
  519.                         If $mondelt > 15000 Then $mondelt = 5000
  520.                         If $monstart = 0 Then $monstart = Number($mon) - $mondelt
  521.                        
  522.                         Send($Inventory)
  523.                         Sleep(50)
  524.                         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Run: " & $mondelt & ", Gain: " & Number($mon) - $monstart)
  525.                         $monold = $mon
  526.                        
  527.                         If $CheckLootWhilePorting Then
  528.                                
  529.                                 $lootany = 0
  530.                                
  531.                                 For $retryloot = 1 To 4
  532.  
  533.                                         Sleep(450)
  534.                                         Loot(True)
  535.                                         If $lootany > 0 Then
  536.                                                 Call("AddLog", 'Got extra loot on attempt ' & $retryloot)
  537.                                                 Call("TownPortal")
  538.                                                 ExitLoop
  539.                                         EndIf
  540.                                 Next
  541.                         Else
  542.                                 Call("TownPortal")
  543.                                
  544.                         EndIf
  545.                        
  546.                         Call("AddLog", 'Gold: ' & $mon & ', Gold Delt: ' & $mondelt & ', Items: ' & $numitem & ', Gems: ' & $numgem & ', Books: ' & $numtomb & ', Potions: ' & $numpot & ', GoldPick: ' & $numgold)
  547.                        
  548.                 Else
  549.                         If $TryRecover = 1 Then
  550.                                 Call("AddLog", 'OnCellar Recovery Failure')
  551.                         EndIf
  552.                         If $CellarWasFound = 1 Then
  553.                                 Call("AddLog", 'Cellar was found but didnt end up there')
  554.                         EndIf
  555.                         If $TakeMissShots Then
  556.                                 CaptureToTIFF("", "", "", "shots\MissCell_" & String($run) & ".tif", 1, 0, 0, 0, 0)
  557.                         EndIf
  558.                         Sleep(10)
  559.                         Send("{SHIFTDOWN}")
  560.                         RandClick("left", Round(900 * $x_ratio), Round(600 * $y_ratio), 100, 100) ;earthquake
  561.                         Send("{SHIFTUP}")
  562.                         Sleep(620)
  563.                         Call("TownPortal")
  564.                         If Not CheckDead() Then
  565.                                 Call("LeaveGame")
  566.                         EndIf
  567.                         Return
  568.                 EndIf
  569.                 ;After successful run
  570.                 If Not CheckDead() Then
  571.                         Sleep(600)
  572.                         If $mLootIn = 1 And CheckFor("NewTristram", "Area") Then ;If its time to manage loot and we are in town
  573.                                 $mLootIn = Round(Random($mLoot - $mLootOff, $mLoot + $mLootOff)) ;Reset Counter
  574.                                
  575.                                 If $UseiLVL Then
  576.                                         Call("AnalyseLoots")
  577.                                 Else
  578.                                         If $Identify Then Call("Identify")
  579.                                         If $StashLoot Then Call("StashLoot")
  580.                                        
  581.                                         If $SalvageLoot Then
  582.                                                 Call("SalvageLoot")
  583.                                         Else
  584.                                                 If $VendorLoot Then Call("VendorLoot")
  585.                                         EndIf
  586.                                 EndIf
  587.                                
  588.                         ElseIf Not CheckFor("NewTristram", "Area") Then
  589.                                 GUICtrlSetData($lblStatus, "Status: Skipping vendor, not in New Tristram")
  590.                                 Sleep(3000)
  591.                         ElseIf $mLootIn <= 0 Then
  592.                                 $mLootIn = 1
  593.                         Else
  594.                                 $mLootIn -= 1
  595.                         EndIf
  596.                         If Not CheckDead() Then
  597.                                 Call("LeaveGame")
  598.                         EndIf
  599.                        
  600.                         If ($RunsUntilMenuWaitCnt = 1) And ($RunsUntilMenuWait > 0) Then
  601.                                
  602.                                 $RunsUntilMenuWaitCnt = $RunsUntilMenuWait
  603.                                 Sleep(Random(3550000, 3650000)) ;wait 1 hour
  604.                         Else
  605.                                 $RunsUntilMenuWaitCnt -= 1
  606.                         EndIf
  607.                        
  608.                        
  609.                         Return
  610.                 Else
  611.                         Return
  612.                 EndIf
  613.         EndIf
  614. EndFunc   ;==>RestartRun
  615.  
  616. ;Helper Functions
  617. Func EnhancedFind($x1 = 0, $y1 = 0, $x2 = 577, $y2 = 220, $xpos = 367, $ypos = 135, $recov = False)
  618.  
  619.         For $retry = 1 To 3
  620.                 ; take 2 snapshots and black out everything that did not change
  621.                 FFSnapShot($x1 * $x_ratio, $y1 * $y_ratio, $x2 * $x_ratio, $y2 * $y_ratio, 2)
  622.                 Sleep(50)
  623.                 FFSnapShot($x1 * $x_ratio, $y1 * $y_ratio, $x2 * $x_ratio, $y2 * $y_ratio, 3)
  624.                 FFKeepChanges(3, 2, 25)
  625.                 ;FFSaveBMP("CellarOpen_" & @HOUR & @MIN & @SEC, false) ->uncomment if you wanna see  the cellar minimap motion map
  626.  
  627.                 ; do special search for the color in our motionmap
  628.                 Local $aColorArray[3] = [0x7897EB, 0x404E9E, 0x536CB6]
  629.                 FFAddColor($aColorArray) ; add color to find array
  630.                 ;Func FFBestSpot($SizeSearch, $MinNbPixel, $OptNbPixel, $PosX, $PosY, $Color, $ShadeVariation = 0, $ForceNewSnap = True, $Left = 0, $Top = 0, $Right = 0, $Bottom = 0, $NoSnapShot = $FFLastSnap, $WindowHandle = -1)
  631.                 Local $cellarCoords = FFBestSpot(10, 1, 4, $xpos * $x_ratio, $ypos * $y_ratio, -1, 25, False) ; search for the opening
  632.                
  633.                 If @error Or Not IsArray($cellarCoords) Then
  634.                         Call("AddLog", "The motionmap failed on try " & $retry & " with code " & @error)
  635.                         FFResetColors()
  636.                 Else
  637.                         ExitLoop
  638.                 EndIf
  639.  
  640.         Next
  641.  
  642.         If (Not @error) And IsArray($cellarCoords) Then
  643.                 FFResetColors()
  644.                 If Not $recov Then GUICtrlSetData($lblStatus, "Status: Cellar - Found position " & $cellarCoords[0] * $x_ratio & ", " & $cellarCoords[1] * $y_ratio)
  645.                 If Not $recov Then Call("AddLog", "Cellar - Found position " & $cellarCoords[0] * $x_ratio & ", " & $cellarCoords[1] * $y_ratio)
  646.         Else
  647.                 If $TakeMissShots Then
  648.                         CaptureToTIFF("", "", "", "shots\NoCell_" & String($run) & ".tif", 1, 0, 0, 0, 0)
  649.                 EndIf
  650.                 Dim $cellarCoords[2]
  651.                 $cellarCoords[0] = 1000 * $x_ratio
  652.                 $cellarCoords[1] = 500 * $y_ratio
  653.         EndIf
  654.        
  655.         Return $cellarCoords
  656.        
  657. EndFunc   ;==>EnhancedFind
  658.  
  659. Func SetupGUI()
  660.         $frmBot = GUICreate($title & $ver & " - Updating", 290, 140, Round(1580 * $x_ratio), Round(900 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  661.         GUISetBkColor(0xC0C0C0)
  662.         $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  663.         GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  664.         GUICtrlSetColor(-1, 0xFF0000)
  665.         $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  666.         $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  667.         $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  668.         $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  669.         $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  670.         $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  671.         $lblGold = GUICtrlCreateLabel("Gold: 0", 12, 110, 240, 17)
  672.         GUISetState(@SW_SHOW)
  673. EndFunc   ;==>SetupGUI
  674.  
  675.  
  676. Func CheckDead()
  677.         $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
  678.         If Not @error Then
  679.                
  680.                 Call("AddLog", "Logged out")
  681.                 GUICtrlSetData($lblStatus, "Status: Logging out")
  682.                 CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), $loadtime / 1000)
  683.  
  684.                 Return 1
  685.         EndIf
  686.  
  687.         $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
  688.         If Not @error Then
  689.                 GUICtrlSetData($lblStatus, "Status: Open Window")
  690.                 Call("AddLog", "Open Window")
  691.                 Sleep(200)
  692.                 Send("{SPACE}") ;close any open windows
  693.                 Return 1
  694.         EndIf
  695.         $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"
  696.         If Not @error Then
  697.                 GUICtrlSetData($lblStatus, "Status: Dead")
  698.                 Call("AddLog", "You have died")
  699.                 $deathCount += 1
  700.                 Call("LeaveGame")
  701.                 For $c = 1 To 110 + $loadtime / 100
  702.                         Sleep(100)
  703.                         If CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), 0.1) Then ExitLoop
  704.                 Next
  705.                 Return 1
  706.         Else
  707.                 Return 0
  708.         EndIf
  709. EndFunc   ;==>CheckDead
  710.  
  711. Func CheckRepair()
  712.         $RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
  713.         If Not @error Then
  714.                 Call("DoRepair")
  715.         EndIf
  716.         $RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
  717.         If Not @error Then
  718.                 Call("DoRepair")
  719.         EndIf
  720. EndFunc   ;==>CheckRepair
  721.  
  722. Func DoRepair()
  723.         Sleep(Random(75, 150))
  724.         Call("TownPortal")
  725.         If CheckDead() Then
  726.                 Return
  727.         EndIf
  728.         If CheckFor("NewTristram", "Area") Then
  729.                 RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
  730.                 Moving(1875)
  731.                 RandClick("left", Round(1316 * $x_ratio), Round(206 * $y_ratio), 1, 1) ;moves to get merchant in screen
  732.                 Moving(1875)
  733.                 RandClick("left", Round(845 * $x_ratio), Round(225 * $y_ratio), 1, 1) ;NPC Merchant to the right of cain's home
  734.                 Sleep(1200)
  735.                 RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  736.                 Sleep(400)
  737.                 RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  738.                 Sleep(200)
  739.                 Send("{Escape}")
  740.                 Call("AddLog", "Repair")
  741.                 If Not CheckDead() Then
  742.                         Call("LeaveGame")
  743.                 EndIf
  744.         EndIf
  745. EndFunc   ;==>DoRepair
  746.  
  747. Func CalcTime()
  748.         $srt = TimerDiff($rt)
  749.         GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  750.         $trt = TimerDiff($t)
  751.         $total = Round((($trt / 1000) / 60) / 60, 4)
  752.  
  753.         Call("AddLog", "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  754.  
  755.         ;Total runtime calculation.
  756.         $hours = Floor((($trt / 1000) / 60) / 60)
  757.         $minutes = (($trt / 1000) / 60)
  758.         ;trim minutes if runtime is more then 1 hour.
  759.         If $minutes > 60 Then
  760.                 While $minutes > 60
  761.                         $minutes -= 60
  762.                 WEnd
  763.         EndIf
  764.         GUICtrlSetData($lblRuntime, "Runtime: " & $hours & ":" & Ceiling($minutes) & ", GPH: " & Ceiling((Number($mon) - $monstart) / ($trt / 3600000)))
  765. EndFunc   ;==>CalcTime
  766.  
  767. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 6, $tolerance = 140)
  768.         If $type = "Area" Then
  769.                 $startX = 1500 * $x_ratio
  770.                 $startY = 0 * $y_ratio
  771.                 $endX = 1920 * $x_ratio
  772.                 $endY = 90 * $y_ratio
  773.                 If $seconds = 6 Then $seconds = 2.5
  774.         EndIf
  775.  
  776.         $c = 0
  777.         $string = $pngLoc & $img & ".png"
  778.         Do
  779.                 $c += 1
  780.                 Sleep(200)
  781.                 If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
  782.                         If $type = "Area" Then
  783.                                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  784.                         EndIf
  785.                         Return False
  786.                 EndIf
  787.         Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  788.         GUICtrlSetData($lblStatus, "Status: Area found! " & $img)
  789.         Return True
  790. EndFunc   ;==>CheckFor
  791.  
  792. Func DoSprint()
  793.         RandClick("right", Round(15 * $x_ratio), Round(1055 * $y_ratio)) ;sprint
  794.         $SprintStart = TimerInit()
  795. EndFunc   ;==>DoSprint
  796.  
  797. Func WalkTime($lootx, $looty, $extra = 0, $returnv = False)
  798.  
  799.         $PPmSsprint = (960 / 2100) * $movementSpeed
  800.         $PPmSwalk = (960 / 3000) * $movementSpeed
  801.         Dim $BarbFeet[2] = [960 * $x_ratio, 505 * $y_ratio]
  802.        
  803.         $dist = Sqrt(($BarbFeet[0] - $lootx) ^ 2 + ($BarbFeet[1] - $looty) ^ 2)
  804.         $sprintremain = 3000 - TimerDiff($SprintStart)
  805.  
  806.         ;determine if sprint is still active to choose run speed
  807.         If $sprintremain > 0 Then ;duration of sprint - 100 for safty
  808.                 ;calculate milliseconds per pixel for this run, return delay
  809.                 ;calculate composite sleep time
  810.                 If $dist < $PPmSsprint * $sprintremain Then
  811.                         $stime = ($dist / $PPmSsprint + $extra)
  812.                 Else
  813.                         $stime = (($sprintremain + ($dist - $sprintremain * $PPmSsprint) / $PPmSwalk) + $extra)
  814.                 EndIf
  815.         Else
  816.                 $stime = ($dist / $PPmSwalk + $extra)
  817.         EndIf
  818.  
  819.         If $stime < 0 Then $stime = 0
  820.  
  821.         If Not $returnv Then
  822.  
  823.                 Sleep($stime)
  824.  
  825.         EndIf
  826.  
  827.         Return $stime
  828.  
  829. EndFunc   ;==>WalkTime
  830.  
  831. Func Loot($extra = False)
  832.  
  833.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  834.        
  835.         If Not $extra Then
  836.                
  837.                 If $LootGems Then
  838.                         LootImage("square.png", 90, 10)
  839.                 EndIf
  840.                 If $LootTomes Then
  841.                         LootImage("tome.png", 90, 10)
  842.                 EndIf
  843.                 If $LootMagic Then
  844.                         $mac = LootGear(0x6969FF, 0)
  845.                         $MagicCount += $mac
  846.                         $numitem -= $mac
  847.                 EndIf
  848.                
  849.         EndIf
  850.        
  851.         If $LootRares Then
  852.                 $RareCount += LootGear(0xBBBB00, 1)
  853.         EndIf
  854.        
  855.         If Not $extra Then
  856.                
  857.                 If $LootLegendaries Then
  858.  
  859.                         If $ReduceLegendSearch Then
  860.                                 $LegendaryCount += LootGear(0xBF642F, 1, 365, 442, 380)
  861.                                 $LegendaryCount += LootGear(0xBF642F, 1, 442, 1690, 115)
  862.                         Else
  863.                                 $LegendaryCount += LootGear(0xBF642F, 1)
  864.                         EndIf
  865.                        
  866.                 EndIf
  867.                
  868.         EndIf
  869.        
  870.         If $LootSets Then
  871.                 $SetCount += LootGear(0x02CE01, 2)
  872.         EndIf
  873.        
  874.         If $LootCustom Then
  875.                 Call("LootCustom")
  876.         EndIf
  877.  
  878.         Call("ShowLoot")
  879. EndFunc   ;==>Loot
  880.  
  881. Func LootGear($color, $tolerance = 2, $x1 = 400, $x2 = 1690, $y1 = 20, $y2 = 900)
  882.         $count = 0
  883.         $Loot = PixelSearch(Round($x1 * $x_ratio), Round($y1 * $y_ratio), Round($x2 * $x_ratio), Round($y2 * $y_ratio), $color, $tolerance)
  884.         If Not @error Then
  885.                 While Not @error
  886.                         $count += 1
  887.                         MouseClick('left', $Loot[0], $Loot[1], 1, 1)
  888.                         Sleep(20)
  889.                         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  890.                         WalkTime($Loot[0], $Loot[1])
  891.                         ;Sleep(Random(700, 800))
  892.                         ;Run at max 10 times per quality
  893.                         $lootany += 1
  894.                         If $count >= 10 Then
  895.                                 ExitLoop
  896.                         EndIf
  897.                         $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  898.                 WEnd
  899.         EndIf
  900.         $numitem += $count;
  901.         Return $count
  902. EndFunc   ;==>LootGear
  903.  
  904. Func LootImage($img, $tol, $max = 10, $x1 = 0, $y1 = 0, $x2 = @DesktopWidth, $y2 = @DesktopHeight)
  905.         $count = 0
  906.         $gX = 0
  907.         $gY = 0
  908.         GUICtrlSetData($lblStatus, "Status: Looting - " & $img)
  909.         While _ImageSearchArea($pngLoc & $img, 1, $x1, $y1, $x2, $y2, $gX, $gY, $tol)
  910.                 $count += 1
  911.                 MouseClick("left", $gX, $gY - 3, 1, 1)
  912.                 Sleep(50)
  913.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  914.                 $lootany += 1
  915.                 If $img == "square.png" Then
  916.                         $GemCount += 1
  917.                         $numgem += 1
  918.                 ElseIf $img == "tome.png" Then
  919.                         $TomeCount += 1
  920.                         $numtomb += 1
  921.                 ElseIf $img == "gold.png" Then
  922.                         $numgold += 1
  923.                 ElseIf $img == "mythic.png" Then
  924.                         $numpot += 1
  925.                 EndIf
  926.                 If $img == "gold.png" Then
  927.                         WalkTime($gX, $gY, -500)
  928.                 Else
  929.                         WalkTime($gX, $gY)
  930.                 EndIf
  931.                 If $count >= $max Then
  932.                         ExitLoop
  933.                 EndIf
  934.         WEnd
  935.         Return $count
  936. EndFunc   ;==>LootImage
  937.  
  938. Func LootCustom()
  939.         For $i = 0 To ($totalItems - 1)
  940.                 $array = StringSplit($pick[$i], "|")
  941.                 LootImage($array[1], $array[2], 5)
  942.         Next
  943. EndFunc   ;==>LootCustom
  944.  
  945. Func Identify()
  946.         Send($Inventory)
  947.         Sleep(1300)
  948.         $count = 0
  949.         While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 120)
  950.                 $count += 1
  951.                 GUICtrlSetData($lblStatus, "Status: Identifying")
  952.                 MouseClick("right", $gX, $gY, 1, 4)
  953.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  954.                 Sleep(Random(3000, 3500))
  955.                 If $count >= 30 Then
  956.                         ExitLoop
  957.                 EndIf
  958.         WEnd
  959.         Send($Inventory)
  960.         Sleep(200)
  961. EndFunc   ;==>Identify
  962.  
  963. Func CleanOCR($text)
  964.         $out = ""
  965.         For $i = 1 To StringLen($text)
  966.                 $chr = Asc(StringMid($text, $i, 1))
  967.                 If $chr >= 48 And $chr <= 57 Then $out = $out & Chr($chr)
  968.                 If $chr = 79 Then $out = $out & '0'
  969.         Next
  970.         Return $out
  971. EndFunc   ;==>CleanOCR
  972.  
  973. Func ClickTab($Tabno)
  974.         If $Tabno = 1 Then RandClick("left", Round(517 * $x_ratio), Round(229 * $y_ratio), 3, 4)
  975.         If $Tabno = 2 Then RandClick("left", Round(517 * $x_ratio), Round(361 * $y_ratio), 3, 4)
  976.         If $Tabno = 3 Then RandClick("left", Round(517 * $x_ratio), Round(486 * $y_ratio), 3, 4)
  977.         Sleep(Random(100, 200))
  978.  
  979. EndFunc   ;==>ClickTab
  980.  
  981. Func UseNextTab()
  982.         If $ItemTab = $NextItemTab Then
  983.                 Call("AddLog", "Stash full Both tabs full, disabling stashing")
  984.                 $StashLegendary = False
  985.                 $StashRare = False
  986.                 $StashMagic = False
  987.         Else
  988.                 Call("AddLog", "Stash full Using next tab")
  989.                 $ItemTab = $NextItemTab
  990.         EndIf
  991. EndFunc   ;==>UseNextTab
  992.  
  993. Func AddLog($logtxt)
  994.         Local $file = FileOpen("log.txt", 1)
  995.         $msg = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ': ' & $logtxt & @CRLF
  996.         FileWrite($file, $msg)
  997.         FileClose($file)
  998.         ConsoleWrite($msg)
  999. EndFunc   ;==>AddLog
  1000.  
  1001. Func StashLoot()
  1002.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  1003.         MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  1004.         Sleep(Random(800, 1000))
  1005.  
  1006.         ClickTab($GemTab)
  1007.         ;Tomes
  1008.         If $StashTomes Then
  1009.                 GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  1010.                 ClickImage("TomeIcon.png", 140, 1)
  1011.         EndIf
  1012.        
  1013.         ;Gems (DOESN'T STASH BOTTOM ROW!)
  1014.         If $StashGems Then
  1015.                 GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  1016.                 For $i = 0 To 7
  1017.                         ClickImage($gems[$i], 150, 1)
  1018.                 Next
  1019.         EndIf
  1020.        
  1021.         $numstashed = 0;
  1022.         ClickTab($ItemTab)
  1023.  
  1024.         If $StashLegendary Then
  1025.                 ClickItems(0xFF7F00, 2, True, 5)
  1026.                 ClickItems(0x8F5C25, 2, True, 5)
  1027.         EndIf
  1028.  
  1029.         If $StashRare Then
  1030.                 ClickItems(0x4A3C0B, 1, True, 20)
  1031.         EndIf
  1032.        
  1033.         If $StashMagic Then
  1034.                 ClickItems(0x182037, 1, True, 30)
  1035.         EndIf
  1036.  
  1037.         Call("AddLog", "Stashed Items: " & $numstashed)
  1038.        
  1039.         Sleep(Random(300, 400))
  1040.        
  1041.        
  1042.         Send("{SPACE}")
  1043. EndFunc   ;==>StashLoot
  1044.  
  1045. Func VendorLoot()
  1046.         GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  1047.         Sleep(Random(200, 300))
  1048.         Send($Skill3)
  1049.         Sleep(Random(200, 300))
  1050.         DoSprint()
  1051.        
  1052.         If Not $StashLoot Then ;Move from TP towards vendor
  1053.                 Sleep(Random(100, 300))
  1054.                 MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  1055.                 walktime(1565 * $x_ratio, 50 * $y_ratio, 100)
  1056.         Else ;Move from Stash towards vendor
  1057.                 Sleep(Random(100, 300))
  1058.                 MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  1059.                 walktime(1560 * $x_ratio, 120 * $y_ratio, 100)
  1060.         EndIf
  1061.  
  1062.         MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  1063.         walktime(1030 * $x_ratio, 210 * $y_ratio, 250)
  1064.        
  1065.         $numsold = 0;
  1066.  
  1067.         ;All
  1068.         If $vendorAll Then
  1069.                 For $c = 1 To $vendorCols
  1070.                         For $r = 1 To $vendorRows
  1071.                                 RandClick("right", (((($c - 1) * 50) + 32 + 1400) * $x_ratio), (((($r - 1) * 51) + 32 + 580) * $y_ratio), 2, 2, 1, 2.5)
  1072.                         Next
  1073.                 Next
  1074.         EndIf
  1075.        
  1076.         ;Rares
  1077.         If $VendorRare Then
  1078.                 ClickItems(0x4A3C0B, 2)
  1079.         EndIf
  1080.         ;Magic
  1081.         If $VendorMagic Then
  1082.                 ClickItems(0x182037, 2)
  1083.         EndIf
  1084.        
  1085.         $montmp = $mon
  1086.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1087.         $mon = CleanOCR($mon)
  1088.        
  1089.         If $mon > 0 Then
  1090.                 $mondelt = Number($mon) - Number($monold)
  1091.                 GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
  1092.                 $monold = $mon
  1093.                 Call("AddLog", "Sold Items: " & $numsold & ", Sold value: " & $mondelt)
  1094.         Else
  1095.                 $mLootIn = 1
  1096.                 $mon = $montmp
  1097.                 Call("AddLog", "Somthing went wrong in town, retrying next time")
  1098.                 GUICtrlSetData($lblGold, "Vend fail, retry next run")
  1099.                 Return
  1100.         EndIf
  1101.        
  1102.         Sleep(200)
  1103.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  1104.         Sleep(300)
  1105.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  1106.         Sleep(400)
  1107.  
  1108.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1109.         $mon = CleanOCR($mon)
  1110.         $mondelt = Number($mon) - Number($monold)
  1111.         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
  1112.         $monold = $mon
  1113.         Call("AddLog", "Repair Cost: " & - $mondelt)
  1114.  
  1115.         GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  1116.         Send("{ESCAPE}")
  1117. EndFunc   ;==>VendorLoot
  1118.  
  1119. Func ClickItems($color, $tolerance, $checkfull = False, $max = 30)
  1120.         $c = 0
  1121.         While $c < $max
  1122.                 RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  1123.                 Sleep(Random(60, 120))
  1124.                 $StashPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  1125.                 If Not @error Then
  1126.                         MouseClick("right", $StashPixel[0], $StashPixel[1], 1, 4)
  1127.                         $c += 1
  1128.                         If $checkfull Then
  1129.                                 $numstashed += 1
  1130.                         Else
  1131.                                 $numsold += 1
  1132.                         EndIf
  1133.                 Else
  1134.                         ExitLoop
  1135.                 EndIf
  1136.         WEnd
  1137.         Sleep(Random(60, 120))
  1138.         If $checkfull Then
  1139.                 If $c = $max Then Call("UseNextTab")
  1140.                 ClickTab($ItemTab)
  1141.         EndIf
  1142. EndFunc   ;==>ClickItems
  1143.  
  1144. Func ClickImage($image, $tolerance, $max = 20)
  1145.         For $c = 1 To $max
  1146.                 RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  1147.                 Sleep(Random(100, 300))
  1148.                 If _ImageSearchArea($pngLoc & $image, 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, $tolerance) Then
  1149.                         MouseClick("right", $gX, $gY, 1, 4)
  1150.                         Sleep(120)
  1151.                 Else
  1152.                         ExitLoop
  1153.                 EndIf
  1154.         Next
  1155. EndFunc   ;==>ClickImage
  1156.  
  1157. Func SalvageLoot()
  1158.  
  1159.         DoSprint()
  1160.  
  1161.         GUICtrlSetData($lblStatus, "Status: Salvaging Items")
  1162.         Sleep(Random(300, 500))
  1163.         MouseClick("middle", 1786 * $x_ratio, 535 * $y_ratio)
  1164.         walktime(1786 * $x_ratio, 535 * $y_ratio, 100)
  1165.         ;Sleep(2000)
  1166.         MouseClick("left", 1430 * $x_ratio, 390 * $y_ratio) ;Talk to anvil
  1167.         ;Sleep(3000)
  1168.         walktime(1430 * $x_ratio, 390 * $y_ratio, 100)
  1169.  
  1170.         $c = 0
  1171.         While $c <= 20
  1172.                 Sleep(Random(200, 300))
  1173.                 $MagicPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 830 * $y_ratio, 0x182037, 1)
  1174.                 If Not @error Then
  1175.                         MouseClick("left", 265 * $x_ratio, 291 * $y_ratio, 1, 4)
  1176.                         Sleep(Random(200, 300))
  1177.                         MouseClick("left", $MagicPixel[0], $MagicPixel[1], 1, 4)
  1178.                         Sleep(Random(200, 300))
  1179.                         MouseClick("left", 1072 * $x_ratio, 375 * $y_ratio, 1, 4)
  1180.                         RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  1181.                         Sleep(40)
  1182.                         $c += 1
  1183.                 Else
  1184.                         ExitLoop
  1185.                 EndIf
  1186.         WEnd
  1187.         Call("AddLog", "Salvaged Items: " & $c)
  1188.  
  1189.         Send("{ESCAPE}")
  1190.         Sleep(Random(300, 500))
  1191. EndFunc   ;==>SalvageLoot
  1192.  
  1193. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  1194.         If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  1195.         $findImage = "*TRANSBLACK " & $findImage
  1196.         If @AutoItX64 Then
  1197.                 $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1198.         Else
  1199.                 $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1200.         EndIf
  1201.         If $result = "0" Then
  1202.                 Return 0
  1203.         EndIf
  1204.  
  1205.         ; Otherwise get the x,y location of the match and the size of the image to
  1206.         ; compute the centre of search
  1207.         $array = StringSplit($result[0], "|")
  1208.         If (UBound($array) >= 4) Then
  1209.                 $x = Int(Number($array[2]))
  1210.                 $y = Int(Number($array[3]))
  1211.                 If $resultPosition = 1 Then
  1212.                         $x = $x + Int(Number($array[4]) / 2)
  1213.                         $y = $y + Int(Number($array[5]) / 2)
  1214.                 EndIf
  1215.                 Return 1
  1216.         EndIf
  1217. EndFunc   ;==>_ImageSearchArea
  1218.  
  1219. Func LeaveGame()
  1220.  
  1221.         Call("RandSleep")
  1222.         GUICtrlSetData($lblStatus, "Status: Leaving Game")
  1223.         Send("{Escape}")
  1224.         Sleep(200)
  1225.         RandClick("left", Round(956 * $x_ratio), Round(579 * $y_ratio), 120, 20) ;Random Click on the leave button
  1226.         Call("CalcTime")
  1227.         CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), $loadtime / 1000)
  1228. EndFunc   ;==>LeaveGame
  1229.  
  1230. Func TownPortalShort()
  1231.  
  1232.         $gX = 0
  1233.         $gY = 0
  1234.         $c = 0
  1235.         GUICtrlSetData($lblStatus, "Status: Waiting for TP bar")
  1236.         Do
  1237.                 $c += 1
  1238.                 Sleep(200)
  1239.                 If $c > 4 Then Return
  1240.         Until _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
  1241.  
  1242.         $seconds = $TPProtectTime
  1243.         $c = 0
  1244.  
  1245.         Do
  1246.                 $c += 1
  1247.                 GUICtrlSetData($lblStatus, "Status: Prepared for inturrupt, " & $seconds * 5 - $c)
  1248.                 Sleep(200)
  1249.                 If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
  1250.                         GUICtrlSetData($lblStatus, "Status: safe, doing long wait for town")
  1251.                         Sleep($tptime - $seconds * 1000 - 1200)
  1252.                         GUICtrlSetData($lblStatus, "Status: detecting town")
  1253.                         CheckFor("NewTristram", "Area")
  1254.                         Sleep(300)
  1255.                         Return
  1256.                 EndIf
  1257.         Until Not _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
  1258.  
  1259. EndFunc   ;==>TownPortalShort
  1260.  
  1261. Func TownPortal()
  1262.  
  1263.         GUICtrlSetData($lblStatus, "Status: Returning to Town")
  1264.         Send($TownPortalButton)
  1265.        
  1266.         If $DetectTPFail Then
  1267.                 Call("TownPortalShort")
  1268.         Else
  1269.                 Sleep(Random($tptime, $tptime + 500))
  1270.         EndIf
  1271.        
  1272. EndFunc   ;==>TownPortal
  1273.  
  1274. #region OtherStuff
  1275.  
  1276. Func Moving($time)
  1277.         Sleep($time / $movementSpeed)
  1278. EndFunc   ;==>Moving
  1279.  
  1280. Func RandClick($clickType, $xpos, $ypos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
  1281.         If $xOff < 1 Then $xOff = 1
  1282.         If $yOff < 1 Then $yOff = 1
  1283.         $randX = Round(Random($xpos - ($xOff * $x_ratio), $xpos + ($xOff * $x_ratio)))
  1284.         $randY = Round(Random($ypos - ($yOff * $y_ratio), $ypos + ($yOff * $y_ratio)))
  1285.         MouseClick($clickType, $randX, $randY, $clicks, $speed)
  1286. EndFunc   ;==>RandClick
  1287.  
  1288. Func RandMove($xpos, $ypos, $xOff = 10, $yOff = 10, $speed = 1)
  1289.         $randX = Round(Random($xpos - ($xOff * $x_ratio), $xpos + ($xOff * $x_ratio)))
  1290.         $randY = Round(Random($ypos - ($yOff * $y_ratio), $ypos + ($yOff * $y_ratio)))
  1291.         MouseMove($randX, $randY, $speed)
  1292. EndFunc   ;==>RandMove
  1293.  
  1294. Func RandSleep($min = 5, $max = 45, $chance = 3)
  1295.         $randNum = Round(Random(1, 100))
  1296.         If $Timer And $randNum <= $chance Then
  1297.                 $sleepTime = Random($min * 1000, $max * 1000)
  1298.                 GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime / 1000) & " secs")
  1299.                 For $c = 0 To 10
  1300.                         Sleep($sleepTime / 10)
  1301.                 Next
  1302.         EndIf
  1303. EndFunc   ;==>RandSleep
  1304. ;Hotkey Functions
  1305.  
  1306. Func Begin()
  1307.         $Go = Not $Go
  1308.         If Not $Go Then WinSetTitle($title, "", $title & $ver & " - Halted")
  1309. EndFunc   ;==>Begin
  1310.  
  1311. Func TogglePause()
  1312.         $Paused = Not $Paused
  1313.         While $Paused
  1314.                 Sleep(100)
  1315.                 WinSetTitle($title, "", $title & $ver & " - Paused")
  1316.                 ToolTip('[PAUSED] - Deaths: ' & $deathCount & ' | Cellars: ' & $cellarCount, 0, 0)
  1317.         WEnd
  1318.         WinSetTitle($title, "", $title & $ver & " - Running")
  1319.         ToolTip("")
  1320. EndFunc   ;==>TogglePause
  1321.  
  1322. Func ShowLoot()
  1323.         GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  1324.         GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  1325. EndFunc   ;==>ShowLoot
  1326.  
  1327. Func Stop() ;to allow the script to stop
  1328.         Exit
  1329. EndFunc   ;==>Stop
  1330. Func GoTown()
  1331.         $mLootIn = 1
  1332. EndFunc   ;==>GoTown
  1333.  
  1334. Func AnalyseLoots() ; Grid search + ilvl detection, a little bit slower than old method but computes db for fast stashing/vendoring/new salvaging
  1335.         ;ConsoleWrite("---- NEW ANALYSIS ----" & @crlf)
  1336.         $str_Stash = ""
  1337.         $str_StashGems = ""
  1338.         $str_StashMisc = ""
  1339.         $str_Vendor = ""
  1340.         $str_Salvage = ""
  1341.         $int_TownPosition = 0
  1342.         $int_emptygrid = 0
  1343.         $str_Ignore = ""
  1344.         $nX = 0
  1345.         $nY = 0
  1346.         GUICtrlSetData($lblStatus, "Status: Analysing loots")
  1347.         Send("c")
  1348.         Sleep(500)
  1349.         For $y = 0 To 5
  1350.                 $int_emptygrid = 0
  1351.                 MouseMove(1435, Round(609 + (45 * $y)), 1)
  1352.                 Sleep(500)
  1353.                 For $x = 0 To 9
  1354.                         If StringInStr($str_Ignore, 1435 + (48 * $x) & "," & 609 + (45 * $y)) Then ContinueLoop
  1355.                         MouseMove(1435 + (48 * $x), 609 + (45 * $y), 1)
  1356.                         Sleep(300)
  1357.                         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
  1358.                                 $int_emptygrid = 0
  1359.                                 If _ImageSearchArea($pngLoc & "tt_unidentified.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) And $Identify Then ; Identify items.
  1360.                                         MouseClick("secondary")
  1361.                                         Sleep(Random(3000, 3500, 1))
  1362.                                 EndIf
  1363.                                 If _ImageSearchArea($pngLoc & "tt_square.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Gem, automatic stashing.
  1364.                                         $str_StashGems = $str_StashGems & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1365.                                         ContinueLoop
  1366.                                 EndIf
  1367.                                 If _ImageSearchArea($pngLoc & "tt_tome.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Tome, automatic stashing.
  1368.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1369.                                         ContinueLoop
  1370.                                 EndIf
  1371.                                 If _ImageSearchArea($pngLoc & "tt_exquisite.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
  1372.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1373.                                         ContinueLoop
  1374.                                 EndIf
  1375.                                 If _ImageSearchArea($pngLoc & "tt_iridescent.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
  1376.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1377.                                         ContinueLoop
  1378.                                 EndIf
  1379.                                 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).
  1380.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1381.                                         ContinueLoop
  1382.                                 EndIf
  1383.                                 If _ImageSearchArea($pngLoc & "tt_plan.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 60) Then ; Plans, automatic stashing.
  1384.                                         $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1385.                                         ContinueLoop
  1386.                                 EndIf
  1387.                                 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
  1388.                                         $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * ($y + 1))
  1389.                                 EndIf
  1390.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x00FF00, 1) ; Set, no ilvl check since they drop rarely. Goes to stash.
  1391.                                 If Not @error Then
  1392.                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1393.                                         ContinueLoop
  1394.                                 EndIf
  1395.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xBF642F, 1) ; Legendary, no ilvl check since they drop rarely. Goes to stash.
  1396.                                 If Not @error Then
  1397.                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1398.                                         ContinueLoop
  1399.                                 EndIf
  1400.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xFFFF00, 1) ; Rare
  1401.                                 If Not @error Then
  1402.                                         If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 59
  1403.                                                 If (getOption("i59r") == 1) Then
  1404.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1405.                                                 ElseIf (getOption("i59r") == 2) Then
  1406.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1407.                                                 Else
  1408.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1409.                                                 EndIf
  1410.                                                 ContinueLoop
  1411.                                         EndIf
  1412.                                         If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 60,  goes to salvage
  1413.                                                 If (getOption("i60r") == 1) Then
  1414.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1415.                                                 ElseIf (getOption("i60r") == 2) Then
  1416.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1417.                                                 Else
  1418.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1419.                                                 EndIf
  1420.                                                 ContinueLoop
  1421.                                         EndIf
  1422.                                         If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 61,  goes to salvage
  1423.                                                 If (getOption("i61r") == 1) Then
  1424.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1425.                                                 ElseIf (getOption("i61r") == 2) Then
  1426.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1427.                                                 Else
  1428.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1429.                                                 EndIf
  1430.                                                 ContinueLoop
  1431.                                         EndIf
  1432.                                         If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 62,  goes to salvage
  1433.                                                 If (getOption("i62r") == 1) Then
  1434.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1435.                                                 ElseIf (getOption("i62r") == 2) Then
  1436.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1437.                                                 Else
  1438.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
  1439.                                                 EndIf
  1440.                                                 ContinueLoop
  1441.                                         EndIf
  1442.                                         If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 63,  goes to stash
  1443.                                                 If (getOption("i63r") == 1) Then
  1444.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1445.                                                 ElseIf (getOption("i63r") == 2) Then
  1446.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1447.                                                 Else
  1448.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1449.                                                 EndIf
  1450.                                                 ContinueLoop
  1451.                                         EndIf
  1452.                                         ; Below ilvl 59
  1453.                                         If $StashRare Then
  1454.                                                 $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1455.                                         ElseIf $VendorRare Then
  1456.                                                 $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1457.                                         Else
  1458.                                                 $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1459.                                         EndIf
  1460.                                         ContinueLoop
  1461.                                 EndIf
  1462.                                
  1463.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 40, 0xFF0000, 1) ; unusable rares, legendaries & sets. Goes to stash.
  1464.                                 If Not @error Then
  1465.                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1466.                                         ContinueLoop
  1467.                                 EndIf
  1468.                                
  1469.                                 $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x6969FF, 1) ; Magic
  1470.                                 If Not @error Then
  1471.                                         If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 59
  1472.                                                 If (getOption("i59m") == 1) Then
  1473.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1474.                                                 ElseIf (getOption("i59m") == 2) Then
  1475.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1476.                                                 Else
  1477.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1478.                                                 EndIf
  1479.                                                 ContinueLoop
  1480.                                         EndIf
  1481.                                         If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 60, goes to salvage
  1482.                                                 If (getOption("i60m") == 1) Then
  1483.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1484.                                                 ElseIf (getOption("i60m") == 2) Then
  1485.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1486.                                                 Else
  1487.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1488.                                                 EndIf
  1489.                                                 ContinueLoop
  1490.                                         EndIf
  1491.                                         If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 61, goes to salvage
  1492.                                                 If (getOption("i61m") == 1) Then
  1493.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1494.                                                 ElseIf (getOption("i61m") == 2) Then
  1495.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1496.                                                 Else
  1497.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1498.                                                 EndIf
  1499.                                                 ContinueLoop
  1500.                                         EndIf
  1501.                                         If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 62, goes to salvage
  1502.                                                 If (getOption("i62m") == 1) Then
  1503.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1504.                                                 ElseIf (getOption("i62m") == 2) Then
  1505.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1506.                                                 Else
  1507.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1508.                                                 EndIf
  1509.                                                 ContinueLoop
  1510.                                         EndIf
  1511.                                         If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 63, goes to stash
  1512.                                                 If (getOption("i63m") == 1) Then
  1513.                                                         $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1514.                                                 ElseIf (getOption("i63m") == 2) Then
  1515.                                                         $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1516.                                                 Else
  1517.                                                         $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1518.                                                 EndIf
  1519.                                                 ContinueLoop
  1520.                                         EndIf
  1521.                                         ; Below ilvl 59
  1522.                                         If $StashMagic Then
  1523.                                                 $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1524.                                         ElseIf $VendorMagic Then
  1525.                                                 $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1526.                                         Else
  1527.                                                 $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1528.                                         EndIf
  1529.                                         ContinueLoop
  1530.                                 EndIf
  1531.                                 ; Probably white/gray trash bugged pick, add to vendor string
  1532.                                 $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
  1533.                         Else
  1534.                                 $int_emptygrid += 1
  1535.                                 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.
  1536.                                         $int_emptygrid = 0
  1537.                                         ExitLoop
  1538.                                 Else
  1539.                                         ContinueLoop
  1540.                                 EndIf
  1541.                         EndIf
  1542.                 Next
  1543.         Next
  1544.         Send("c")
  1545.         Sleep(500)
  1546.         ;Call("AddLog", "Stash gear : "  & $str_Stash )
  1547.         ;Call("AddLog", "Stash misc : "  & $str_StashMisc )
  1548.         ;Call("AddLog", "Stash gems : "  & $str_StashGems )
  1549.         ;Call("AddLog", "Salvage : "  & $str_Salvage )
  1550.         ;Call("AddLog", "Vendor : "  & $str_Vendor )
  1551.         ;Call("AddLog", "Ignored Square : "  & $str_Ignore )
  1552.  
  1553.  
  1554.         Call("AddLog", "Stashed Items: " & UBound(StringSplit($str_Stash, "|")))
  1555.  
  1556.         If $str_Stash <> "" Or $str_StashGems <> "" Or $str_StashMisc <> "" Then Call("StashLoot_new")
  1557.         If $str_Salvage <> "" Then Call("SalvageLoot_new")
  1558.         If $str_Vendor <> "" Then Call("VendorLoot_new")
  1559. EndFunc   ;==>AnalyseLoots
  1560.  
  1561. Func StashLoot_new()
  1562.         $arr_split = ""
  1563.         $pos_split = ""
  1564.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  1565.         MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  1566.         Moving(1600)
  1567.         $int_TownPosition = 1
  1568.  
  1569.         ;Gems Page 1
  1570.         If $str_StashGems <> "" Then
  1571.                 ClickTab($GemTab)
  1572.                 $str_StashGems = StringMid($str_StashGems, 2)
  1573.                 $arr_split = StringSplit($str_StashGems, "|")
  1574.                 For $i = 1 To $arr_split[0]
  1575.                         Sleep(Random(300, 350))
  1576.                         $pos_split = StringSplit($arr_split[$i], ",", 2)
  1577.                         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1578.                 Next
  1579.         EndIf
  1580.  
  1581.         ;Tomes/Crafting Materials/Plans/Etc Page 2
  1582.         If $str_StashMisc <> "" Then
  1583.                 ClickTab($GemTab)
  1584.                 $str_StashMisc = StringMid($str_StashMisc, 2)
  1585.                 $arr_split = StringSplit($str_StashMisc, "|")
  1586.                 For $i = 1 To $arr_split[0]
  1587.                         Sleep(Random(300, 350))
  1588.                         $pos_split = StringSplit($arr_split[$i], ",", 2)
  1589.                         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1590.                 Next
  1591.         EndIf
  1592.  
  1593.         ;Gears Page 2
  1594.         If $str_Stash <> "" Then
  1595.                 $str_Stash = StringMid($str_Stash, 2)
  1596.                 $arr_split = StringSplit($str_Stash, "|")
  1597.                 For $i = 1 To $arr_split[0]
  1598.                         Sleep(Random(80, 100))
  1599.                         If Random() < 0.5 Then
  1600.                                 ClickTab($ItemTab)
  1601.                         Else
  1602.                                 ClickTab($NextItemTab)
  1603.                         EndIf
  1604.                        
  1605.                         Sleep(Random(300, 350))
  1606.                         $pos_split = StringSplit($arr_split[$i], ",", 2)
  1607.                         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1608.                 Next
  1609.         EndIf
  1610.  
  1611.         Sleep(Random(100, 150))
  1612.         Send("{SPACE}")
  1613. EndFunc   ;==>StashLoot_new
  1614.  
  1615. Func SalvageLoot_new()
  1616.         $arr_split = ""
  1617.         $pos_split = ""
  1618.         GUICtrlSetData($lblStatus, "Status: Salvaging loots")
  1619.         If $int_TownPosition = 0 Then ; Starting from TP
  1620.                 MouseClick("middle", 1582 * $x_ratio, 527 * $y_ratio)
  1621.                 Moving(2000)
  1622.                 MouseClick("left", 1661 * $x_ratio, 409 * $y_ratio)
  1623.                 Moving(2500)
  1624.         Else ; Starting from Stash
  1625.                 MouseClick("middle", 1484 * $x_ratio, 583 * $y_ratio)
  1626.                 Moving(2000)
  1627.                 MouseClick("left", 1773 * $x_ratio, 484 * $y_ratio)
  1628.                 Moving(2500)
  1629.         EndIf
  1630.         $int_TownPosition = 2
  1631.         MouseClick("left", 263 * $x_ratio, 287 * $y_ratio)
  1632.         $str_Salvage = StringMid($str_Salvage, 2)
  1633.         $arr_split = StringSplit($str_Salvage, "|")
  1634.         For $i = 1 To $arr_split[0]
  1635.                 Sleep(Random(300, 400))
  1636.                 $pos_split = StringSplit($arr_split[$i], ",")
  1637.                 MouseClick("left", $pos_split[1], $pos_split[2], 1, 3)
  1638.                 If $pos_split[0] == 3 Then
  1639.                         Send("{ENTER}")
  1640.                         Sleep(1000)
  1641.                 EndIf
  1642.         Next
  1643.         Sleep(Random(300, 400))
  1644.         Send("{SPACE}")
  1645. EndFunc   ;==>SalvageLoot_new
  1646.  
  1647. Func VendorLoot_new()
  1648.         $arr_split = ""
  1649.         $pos_split = ""
  1650.         GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  1651.         If $int_TownPosition = 0 Then ; Starting from TP
  1652.                 MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  1653.         ElseIf $int_TownPosition = 1 Then ; Starting from Stash
  1654.                 MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  1655.         Else ; Starting from Blacksmith
  1656.                 MouseClick("middle", 738 * $x_ratio, 64 * $y_ratio)
  1657.         EndIf
  1658.         Moving(3000)
  1659.         MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  1660.         Moving(3000)
  1661.         $str_Vendor = StringMid($str_Vendor, 2)
  1662.         $arr_split = StringSplit($str_Vendor, "|")
  1663.         For $i = 1 To $arr_split[0]
  1664.                 Sleep(Random(100, 300))
  1665.                 $pos_split = StringSplit($arr_split[$i], ",", 2)
  1666.                 MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  1667.                 If PixelGetColor(819 * $x_ratio, 375 * $y_ratio) == 0x370C00 Then Send("{ENTER}")
  1668.         Next
  1669.         Sleep(Random(100, 200))
  1670.        
  1671.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1672.         $mon = CleanOCR($mon)
  1673.         $mondelt = Number($mon) - Number($monold)
  1674.         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
  1675.         $monold = $mon
  1676.         Call("AddLog", "Sold Items: " & $arr_split[0] & ", Sold value: " & $mondelt)
  1677.        
  1678.         Sleep(Random(200, 300))
  1679.        
  1680.  
  1681.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  1682.         Sleep(200)
  1683.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  1684.         Sleep(400)
  1685.        
  1686.         $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
  1687.         $mon = CleanOCR($mon)
  1688.         $mondelt = Number($mon) - Number($monold)
  1689.         GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
  1690.         $monold = $mon
  1691.         Call("AddLog", "Repair Cost: " & - $mondelt)
  1692.        
  1693.  
  1694.         GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  1695.        
  1696.         Send("{SPACE}")
  1697.        
  1698. EndFunc   ;==>VendorLoot_new
  1699.  
  1700. Func getOption($option) ;Gets the correct INI settings corrisponding to the vend/stash/salvage of items.
  1701.  
  1702.         If ($option == "i59r") Then
  1703.                 If ($i59Rare = "salvage") Then
  1704.                         Return 1
  1705.                 ElseIf ($i59Rare = "vend") Then
  1706.                         Return 2
  1707.                 Else
  1708.                         Return 0
  1709.                 EndIf
  1710.         ElseIf ($option == "i60r") Then
  1711.                 If ($i60Rare = "salvage") Then
  1712.                         Return 1
  1713.                 ElseIf ($i60Rare = "vend") Then
  1714.                         Return 2
  1715.                 Else
  1716.                         Return 0
  1717.                 EndIf
  1718.         ElseIf ($option == "i61r") Then
  1719.                 If ($i61Rare = "salvage") Then
  1720.                         Return 1
  1721.                 ElseIf ($i61Rare = "vend") Then
  1722.                         Return 2
  1723.                 Else
  1724.                         Return 0
  1725.                 EndIf
  1726.         ElseIf ($option == "i62r") Then
  1727.                 If ($i62Rare = "salvage") Then
  1728.                         Return 1
  1729.                 ElseIf ($i62Rare = "vend") Then
  1730.                         Return 2
  1731.                 Else
  1732.                         Return 0
  1733.                 EndIf
  1734.         ElseIf ($option == "i63r") Then
  1735.                 If ($i63Rare = "salvage") Then
  1736.                         Return 1
  1737.                 ElseIf ($i63Rare = "vend") Then
  1738.                         Return 2
  1739.                 Else
  1740.                         Return 0
  1741.                 EndIf
  1742.         ElseIf ($option == "i59m") Then
  1743.                 If ($i59Magic = "salvage") Then
  1744.                         Return 1
  1745.                 ElseIf ($i59Magic = "vend") Then
  1746.                         Return 2
  1747.                 Else
  1748.                         Return 0
  1749.                 EndIf
  1750.         ElseIf ($option == "i60m") Then
  1751.                 If ($i60Magic = "salvage") Then
  1752.                         Return 1
  1753.                 ElseIf ($i60Magic = "vend") Then
  1754.                         Return 2
  1755.                 Else
  1756.                         Return 0
  1757.                 EndIf
  1758.         ElseIf ($option == "i61m") Then
  1759.                 If ($i61Magic = "salvage") Then
  1760.                         Return 1
  1761.                 ElseIf ($i61Magic = "vend") Then
  1762.                         Return 2
  1763.                 Else
  1764.                         Return 0
  1765.                 EndIf
  1766.         ElseIf ($option == "i62m") Then
  1767.                 If ($i62Magic = "salvage") Then
  1768.                         Return 1
  1769.                 ElseIf ($i62Magic = "vend") Then
  1770.                         Return 2
  1771.                 Else
  1772.                         Return 0
  1773.                 EndIf
  1774.         ElseIf ($option == "i63m") Then
  1775.                 If ($i63Magic = "salvage") Then
  1776.                         Return 1
  1777.                 ElseIf ($i63Magic = "vend") Then
  1778.                         Return 2
  1779.                 Else
  1780.                         Return 0
  1781.                 EndIf
  1782.         Else
  1783.                 Return 0
  1784.         EndIf
  1785.  
  1786. EndFunc   ;==>getOption
  1787. #endregion OtherStuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement