Advertisement
Guest User

notares modified new loot analysis + ini

a guest
Jun 21st, 2012
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 50.97 KB | None | 0 0
  1. ;Added a basic INI for new loot system, among a couple of other small things 6/21/2012 21:00
  2. ;new loot system updated 6/21/2012 11:22
  3. ;notAres' DH Gold Script 1.9.3 - 6/18/2012 - New INI option: Identify. Added VendItems() and StashItems() to simplify code and added 2 colors of legendaries to stash (highlighted/not highlighted). Trimmed down all "Area" CheckFor() calls. Fixed CheckFor("ExitGame"). Moves mouse out of the way while looting. Added deaths/cellars to PAUSED tooltip.
  4. ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
  5. ;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkoth-dh-gold-script-autoit-script-1920x1080.html
  6. ;;;;;
  7. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  8. ;Suggested build: http://us.battle.net/d3/en/calculator/demon-hunter#aRYXVT!aYW!YaaabY
  9. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  10. ;Official supported resolution: 1920x1080
  11. ;;;;;
  12. ;Original by mackus101 @ ownedcore
  13. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  14. ;Refactoring and additional functions by Shimizoki
  15.  
  16. ;=========== DO NOT TOUCH ===========;
  17. #RequireAdmin
  18. #include <GUIConstantsEx.au3>
  19. #include <StaticConstants.au3>
  20. #include <WindowsConstants.au3>
  21. Opt('MouseCoordMode', 2)
  22. Opt('PixelCoordMode', 2)
  23. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "1.9.3", $ini = "DH.ini", $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, $str_Stash, $str_StashGems, $str_StashMisc, $str_Vendor, $str_Salvage, $int_TownPosition
  24. For $i = 0 To Random(0, 7, 1)
  25.     $title &= Chr(Random(97, 122, 1))
  26. Next
  27. For $i = 0 To Random(5, 10, 1)
  28.     $title &= Chr(Random(65, 90, 1))
  29. Next
  30. $title &= " "
  31. Global $gems[8] = ["Ru1.png", "Ru2.png", "Em1.png", "Em2.png", "To1.png", "To2.png", "Am1.png", "Am2.png"]
  32. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  33. If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
  34. If $size = 0 Then
  35.     MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  36.     Exit
  37. EndIf
  38. ;====================================;
  39.  
  40. ;============= SETTINGS: DONT CHANGE HERE, CHANGE DH.INI =============;
  41. HotKeySet("=", "Begin") ;script toggled on/off by pressing =
  42. HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
  43. HotKeySet("x", "Stop") ;script stopped by pressing x
  44. HotKeySet("{F3}","AnalyseLoots") ; Debug
  45.  
  46. ;Change to match your abilities (1-4 by default)z
  47. $skillCaltrops = "1"
  48. $skillSmokeScreen = "2"
  49. $skillPreparation = "3"
  50. $skillCompanion = "4"
  51.  
  52. $movementSpeed = 25 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0% (25% is the movement cap but SS + Displacement avg = 32%)
  53.  
  54. ;Custom Loot
  55. $pngLoc = "@ScriptDir" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  56. $totalItems = 1 ;Number of items in the pick array
  57. Global $pick[$totalItems] ;DONT CHANGE THIS
  58.  
  59. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  60. $pick[0] = "mythic.png|40" ;png|Tolerance
  61. ;$pick[1] = "item2.png|0"
  62. ;$pick[2] = "item3.png|0"
  63.  
  64. ;Looting
  65. $LootSets = "True" ;True if you want to pick up Sets
  66. $LootLegendaries = "True";True if you want to pick up Legendaries
  67. $LootRares = "True" ;True if you want to pick up Rares
  68. $LootMagic = "True" ;True if you want to pick up Magic
  69. $LootGems = "True" ;True if you want to pick up Gems
  70. $LootTomes = "True" ;True if you want to pick up Tome of Secrets
  71. $LootCustom = "False" ;True if you want to pick up Custom Items (The items in the $pick array above)
  72.  
  73. ;Manage Loot
  74. $Identify = "True" ;True to enable identifying items before stashing/vendoring
  75. $mLoot = 5 ;Nuber of successful runs until Stash and Vendor
  76. $mLootOff = 2 ;Stash and Vendor after mLoot +- X number of runs (Variability)
  77.  
  78. ;Salvage
  79. $SalvageLoot = "True" ;True if you want to salvage items
  80.  
  81. ;Stashing
  82. $StashLoot = "True" ;True if you want to store Items in the stash
  83. ;---
  84. $StashLegendary = "True";True if you want to store Legendary items in the stash
  85. $StashRare = "True" ;True if you want to store Rare items in the stash
  86. $StashMagic = "False" ;True if you want to store Magic items in the stash
  87. $StashTomes = "True" ;True if you want to store Tomes items in the stash
  88. $StashGems = "True" ;True if you want to store Gems items in the stash
  89.  
  90. ;Vendoring ==NEW SETTINGS==
  91. $VendorLoot = "True" ;True if you want to vendor anything
  92. ;---
  93. $VendorRare = "True" ;True if you want to vendor Rares
  94. $VendorMagic = "True" ;True if you want to vendor Magic
  95. $vendorAll = "False" ;True if you want to right click all items when talking to vendor
  96. $vendorRows = 5 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
  97. $vendorCols = 10 ;# of columns to vendor, starting from left
  98.  
  99. ;Variability ==NEW SETTINGS==
  100. $Timer = "True" ;True and the bot will add random sleep intervals
  101. ;---
  102. $attackTime = 3900 ;Time (in ms) the script will shoot sarkoth with the right button
  103. $attackMulti = "True" ;True if you want to shoot both left and right in addition to the middle (False for Lightning Ball)
  104. $walktime = 2800 ;Time (in ms) the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  105. $loadtime = 3400 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  106. $tptime = 6900 ;Time (in ms) the script waits for teleport before exiting the game
  107.  
  108. ;New Analyze Loot Settings Options are "salvage", "stash", and "vend"
  109. $i59Rare = "stash"
  110. $i60Rare = "stash"
  111. $i61Rare = "stash"
  112. $i62Rare = "stash"
  113. $i63Rare = "stash"
  114.  
  115. $i59Magic = "vend"
  116. $i60Magic = "vend"
  117. $i61Magic = "salvage"
  118. $i62Magic = "salvage"
  119. $i63Magic = "stash"
  120. ;====================================;
  121.  
  122. $x_ratio = $size[0] / 1920
  123. $y_ratio = $size[1] / 1080
  124.  
  125. If FileExists($ini) Then
  126.     Call("ReadINI")
  127.     Call("CreateINI")
  128. Else
  129.     Call("CreateINI")
  130. EndIf
  131.  
  132. If $pngLoc == "@ScriptDir" Then $pngLoc = @ScriptDir & "\pics\"
  133. If $totalItems < 1 Then $LootCustom = "False"
  134. $mLootIn = $mLoot
  135. $movementSpeed = 1 + ($movementSpeed / 100)
  136. $VersionsInfo = "http://dl.dropbox.com/u/9955791/version.ini"
  137. $oldVersion = IniRead("updater.ini", "Version", "Version", $ver)
  138. $newVersion = "0.0"
  139.  
  140. If Not FileExists($pngLoc & "MainMenu.png") Then
  141.     MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  142.     Exit
  143. EndIf
  144.  
  145. Call("SetupGUI")
  146. Call("DoUpdate")
  147.  
  148. While 1
  149.     Call("RestartRun")
  150. WEnd
  151.  
  152. Func RestartRun()
  153.     If ($Go) Then
  154.         $i = 0
  155.         WinSetTitle($title, "", $title & $ver & " - Running")
  156.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  157.         ;Checks if the player is Dead/Logout/Window, then if in Main Menu, etc.
  158.         If CheckDead() Then
  159.             Return
  160.         ElseIf CheckFor("ExitGame", "", Round(860 * $x_ratio), Round(400 * $y_ratio), Round(1040 * $x_ratio), Round(450 * $y_ratio), 0.5, 140) Then
  161.             GUICtrlSetData($lblStatus, "Status: Exit window up")
  162.             MouseClick("left", Round(1064 * $x_ratio), Round(632 * $y_ratio))
  163.             Sleep(100)
  164.             Send("{SPACE}")
  165.             Return
  166.         ElseIf CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(440 * $x_ratio), Round(550 * $y_ratio)) Then
  167.             GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till vendor: " & $mLootIn)
  168.             GUICtrlSetData($lblLocation, "Location: Main Menu")
  169.             GUICtrlSetData($lblStatus, "Status: Starting Game")
  170.             RandClick("left", Round(230 * $x_ratio), Round(416 * $y_ratio), 120, 20, 1, 6) ;Random Click on the resume button
  171.             Sleep($loadtime)
  172.             $rt = TimerInit()
  173.             $run += 1
  174.         ElseIf CheckFor("OldRuins", "Area") Or CheckFor("NewTristram", "Area") Or CheckFor("DankCellar", "Area") Then
  175.             Call("TownPortal")
  176.             Call("LeaveGame")
  177.             Return
  178.         ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  179.             MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio))
  180.             $rand = Random(40000, 80000)
  181.             GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
  182.             Sleep($rand)
  183.             Send("{SPACE}")
  184.             Return
  185.         ElseIf CheckFor("Disconnect", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  186.             GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
  187.             MouseClick("left", Round(960 * $x_ratio), Round(632 * $y_ratio))
  188.             Sleep(100)
  189.             Send("{SPACE}")
  190.             Return
  191.         Else
  192.             GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  193.             Return
  194.         EndIf
  195.         ;Make sure we are in the right area before beginning run
  196.         If CheckFor("OldRuins", "Area") Then
  197.             Sleep(200)
  198.             GUICtrlSetData($lblLocation, "Location: Old Ruins")
  199.             Call("CheckRepair")
  200.             ;Start Run
  201.             RandClick("middle", Round(500 * $x_ratio), Round(250 * $y_ratio), 2, 2) ;starts the run [waypoint 1]
  202.             Moving(900)
  203.             Send($skillSmokeScreen)
  204.             Moving(600)
  205.             RandClick("middle", Round(3 * $y_ratio), Round(370 * $y_ratio), 2, 2) ;waits ~1 second then [waypoint 2]
  206.             Moving(1850)
  207.             RandClick("middle", Round(400 * $x_ratio), Round(600 * $y_ratio), 2, 2) ;middle of courtyard [waypoint 3]
  208.             Moving(100)
  209.             Send($skillSmokeScreen)
  210.             Moving(100)
  211.             Send($skillPreparation)
  212.             Moving(750)
  213.             Send($skillCaltrops)
  214.             Moving(100)
  215.             RandMove(Round(300 * $x_ratio), Round(70 * $y_ratio), 1, 1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  216.             Sleep(350)
  217.             If CheckDead() Then
  218.                 Return
  219.             EndIf
  220.  
  221.             ;Checks if Dank Cellar is Open
  222.             $Pixel2 = PixelSearch(0, 0, Round(600 * $x_ratio), Round(600 * $y_ratio), 0x334FB7, 3)
  223.             If Not @error Then
  224.                 GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  225.                 $cellarCount += 1
  226.                 MouseClick("left", Round(300 * $x_ratio), Round(70 * $y_ratio), 1) ;Entrance to cellar
  227.                 Sleep(800 * $movementSpeed)
  228.                 Send($skillSmokeScreen)
  229.                 Moving($walktime)
  230.             Else ;ABORT RUN
  231.                 GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  232.                 Sleep(10)
  233.                 RandClick("middle", Round(1100 * $x_ratio), Round(600 * $y_ratio)) ;moves between caltrops for safety before teleporting back to town
  234.                 Moving(250)
  235.                 Send($skillCaltrops)
  236.                 Sleep(620)
  237.                 Send($skillSmokeScreen)
  238.                 Sleep(40)
  239.                 Call("TownPortal")
  240.                 If Not CheckDead() Then
  241.                     Call("LeaveGame")
  242.                 EndIf
  243.                 Return
  244.             EndIf
  245.         Else
  246.             Call("TownPortal")
  247.             If Not CheckDead() Then
  248.                 Call("LeaveGame")
  249.             EndIf
  250.             Return
  251.         EndIf
  252.  
  253.         ;Checks that the player is in the Dank Cellar
  254.         If CheckFor("DankCellar", "Area") Then
  255.             GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  256.             RandClick("middle", Round(110 * $x_ratio), Round(1000 * $y_ratio), 1, 1) ;moves to doorway leading to rare inside cellar
  257.             Sleep(Random(2200, 2800))
  258.             RandMove(Round(460 * $x_ratio), Round(80 * $y_ratio), 1, 1) ;hovers over the rare Sarkoth
  259.             Sleep(10)
  260.             Send("{SHIFTDOWN}")
  261.             GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  262.             MouseDown("right") ;ATTACK
  263.             Sleep(1100)
  264.             Send($skillCompanion)
  265.             Sleep($attackTime)
  266.             MouseUp("right")
  267.             RandClick("left", Round(460 * $x_ratio), Round(80 * $y_ratio), 1, 1)
  268.             RandMove(Round(240 * $x_ratio), Round(75 * $y_ratio), 1, 1) ;attack left
  269.             Sleep(40)
  270.             MouseDown("right")
  271.             If $attackMulti == True Then Sleep($attackTime / 2)
  272.             MouseUp("right")
  273.             MouseMove(Round(590 * $x_ratio), Round(50 * $y_ratio), 1) ;attack right
  274.             MouseDown("right")
  275.             If $attackMulti == True Then Sleep($attackTime / 2)
  276.             MouseUp("right")
  277.             MouseDown("left")
  278.             MouseMove(Round(Random(240, 260) * $x_ratio), Round(75 * $y_ratio), 1) ;attack left
  279.             If $attackMulti == True Then Sleep($attackTime / 2.5)
  280.             MouseMove(Round(Random(560, 600) * $x_ratio), Round(50 * $y_ratio), 1) ;attack right
  281.             If $attackMulti == True Then Sleep($attackTime / 2.5)
  282.             MouseUp("left")
  283.             Sleep(400)
  284.             MouseClick("right", Round(630 * $x_ratio), Round(18 * $y_ratio), 1, 8) ;break the table & chair
  285.             Sleep(200)
  286.             Send("{SHIFTUP}")
  287.             Moving(200)
  288.             RandClick("middle", Round(530 * $x_ratio), Round(190 * $y_ratio)) ;location of sarkoth after death
  289.             Moving(2700)
  290.             GUICtrlSetData($lblStatus, "Status: Looting")
  291.             Send($skillCompanion)
  292.             Call("Loot")
  293.             RandSleep(0, 6, 30)
  294.             Send($skillCompanion)
  295.             Call("TownPortal")
  296.         Else
  297.             Send($skillCaltrops)
  298.             Sleep(400)
  299.             Send($skillSmokeScreen)
  300.             Sleep(40)
  301.             Call("TownPortal")
  302.             If Not CheckDead() Then
  303.                 Call("LeaveGame")
  304.             EndIf
  305.             Return
  306.         EndIf
  307.         ;After successful run
  308.         If Not CheckDead() Then
  309.             Sleep(600)
  310.             If $mLootIn = 1 And CheckFor("NewTristram", "Area") Then ;If its time to manage loot and we are in town
  311.                 ;If $Identify == True Then Call("Identify")
  312.                 Call("AnalyseLoots")
  313.                 ;If $StashLoot == True Then Call("StashLoot")
  314.                 ;If $VendorLoot == True Then    Call("VendorLoot")
  315.                 ;If $SalvageLoot == True  Then Call("SalvageLoot")
  316.                 $mLootIn = Round(Random($mLoot - $mLootOff, $mLoot + $mLootOff)) ;Reset Counter
  317.             ElseIf Not CheckFor("NewTristram", "Area") Then
  318.                 GUICtrlSetData($lblStatus, "Status: Skipping vendor, not in New Tristram")
  319.                 Sleep(3000)
  320.             ElseIf $mLootIn <= 0 Then
  321.                 $mLootIn = 1
  322.             Else
  323.                 $mLootIn -= 1
  324.             EndIf
  325.             If Not CheckDead() Then
  326.                 Call("LeaveGame")
  327.             EndIf
  328.             Return
  329.         Else
  330.             Return
  331.         EndIf
  332.     EndIf
  333. EndFunc   ;==>RestartRun
  334.  
  335. ;Helper Functions
  336.  
  337. Func SetupGUI()
  338.     $frmBot = GUICreate($title & $ver & " - Updating", 280, 121, Round(1630 * $x_ratio), Round(930 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  339.     GUISetBkColor(0xC0C0C0)
  340.     $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  341.     GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  342.     GUICtrlSetColor(-1, 0xFF0000)
  343.     $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  344.     $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  345.     $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  346.     $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  347.     $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  348.     $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  349.     GUISetState(@SW_SHOW)
  350. EndFunc   ;==>SetupGUI
  351.  
  352. Func CheckDead()
  353.     $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
  354.     If Not @error Then
  355.         GUICtrlSetData($lblStatus, "Status: Logging out")
  356.         Sleep(11000)
  357.         Sleep($loadtime)
  358.         Return 1
  359.     EndIf
  360.  
  361.     $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
  362.     If Not @error Then
  363.         GUICtrlSetData($lblStatus, "Status: Open Window")
  364.         Sleep(200)
  365.         Send("{SPACE}") ;close any open windows
  366.         Return 1
  367.     EndIf
  368.  
  369.     $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"
  370.     If Not @error Then
  371.         GUICtrlSetData($lblStatus, "Status: Dead")
  372.         $deathCount += 1
  373.         Call("LeaveGame")
  374.         Sleep(11000)
  375.         Sleep($loadtime)
  376.         Return 1
  377.     Else
  378.         Return 0
  379.     EndIf
  380. EndFunc   ;==>CheckDead
  381.  
  382. Func CheckRepair()
  383.     $RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
  384.     If Not @error Then
  385.         Call("DoRepair")
  386.     EndIf
  387.     $RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
  388.     If Not @error Then
  389.         Call("DoRepair")
  390.     EndIf
  391. EndFunc   ;==>CheckRepair
  392.  
  393. Func DoRepair()
  394.     Sleep(Random(75, 150))
  395.     Call("TownPortal")
  396.     If CheckDead() Then
  397.         Return
  398.     EndIf
  399.     If CheckFor("NewTristram", "Area") Then
  400.         RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
  401.         Moving(1875)
  402.         RandClick("left", Round(1316 * $x_ratio), Round(206 * $y_ratio), 1, 1) ;moves to get merchant in screen
  403.         Moving(1875)
  404.         RandClick("left", Round(845 * $x_ratio), Round(225 * $y_ratio), 1, 1) ;NPC Merchant to the right of cain's home
  405.         Sleep(1200)
  406.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  407.         Sleep(400)
  408.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  409.         Sleep(200)
  410.         Send("{Escape}")
  411.         If Not CheckDead() Then
  412.             Call("LeaveGame")
  413.         EndIf
  414.     EndIf
  415. EndFunc   ;==>DoRepair
  416.  
  417. Func CalcTime()
  418.     $srt = TimerDiff($rt)
  419.     GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  420.     $trt = TimerDiff($t)
  421.     $total = Round((($trt / 1000) / 60) / 60, 4)
  422.  
  423.     ;Total runtime calculation.
  424.     $hours = Floor((($trt / 1000) / 60) / 60)
  425.     $minutes = (($trt / 1000) / 60)
  426.     ;trim minutes if runtime is more then 1 hour.
  427.     If $minutes > 60 Then
  428.         While $minutes > 60
  429.             $minutes -= 60
  430.         WEnd
  431.     EndIf
  432.     GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, " & Ceiling($minutes) & " minutes")
  433. EndFunc   ;==>CalcTime
  434.  
  435. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 6, $tolerance = 140)
  436.     If $type = "Area" Then
  437.         $startX = 1500 * $x_ratio
  438.         $startY = 0 * $y_ratio
  439.         $endX = 1920 * $x_ratio
  440.         $endY = 90 * $y_ratio
  441.         $seconds = 2.5
  442.     EndIf
  443.     $c = 0
  444.     $string = $pngLoc & $img & ".png"
  445.     Do
  446.         $c += 1
  447.         Sleep(100)
  448.         If $c > ($seconds * 10) Then ;Make sure we never get stuck here for infinity.
  449.             If $type = "Area" Then
  450.                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  451.             EndIf
  452.             Return False
  453.         EndIf
  454.     Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  455.     Return True
  456. EndFunc   ;==>CheckFor
  457.  
  458. Func Loot()
  459.     Sleep(Random(500, 1200))
  460.     MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  461.     If $LootSets == True Then
  462.         $SetCount += LootGear(0x02CE01)
  463.     EndIf
  464.     If $LootLegendaries == True Then
  465.         $LegendaryCount += LootGear(0xBF642F, 0)
  466.     EndIf
  467.     If $LootRares == True Then
  468.         $RareCount += LootGear(0xBBBB00)
  469.     EndIf
  470.     If $LootGems == True Then
  471.         Call("LootGems")
  472.     EndIf
  473.     If $LootTomes == True Then
  474.         Call("LootTomes")
  475.     EndIf
  476.     If $LootCustom == True Then
  477.         Call("LootCustom")
  478.     EndIf
  479.     If $LootMagic == True Then
  480.         $MagicCount += LootGear(0x6969FF)
  481.     EndIf
  482.     Call("ShowLoot")
  483. EndFunc   ;==>Loot
  484.  
  485. Func LootGear($color, $tolerance = 2)
  486.     $count = 0
  487.     $Loot = PixelSearch(Round(450 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  488.     If Not @error Then
  489.         While Not @error
  490.             $count += 1
  491.             MouseClick('left', $Loot[0], $Loot[1], 1, 3)
  492.             Sleep(50)
  493.             MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  494.             Sleep(1000)
  495.             ;Run at max 10 times per quality
  496.             If $count >= 10 Then
  497.                 ExitLoop
  498.             EndIf
  499.             $Loot = PixelSearch(Round(450 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  500.         WEnd
  501.     EndIf
  502.     Return $count
  503. EndFunc   ;==>LootGear
  504.  
  505. Func LootCustom()
  506.     $count = 0
  507.     $gX = 0
  508.     $gY = 0
  509.     For $i = 0 To ($totalItems - 1)
  510.         $array = StringSplit($pick[$i], "|")
  511.         $file = $array[1]
  512.         $accuracy = $array[2]
  513.         $urlString = $pngLoc & $file
  514.         While _ImageSearchArea($pngLoc & $file, 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, $accuracy)
  515.             $count += 1
  516.             MouseClick("left", $gX, $gY, 1, 3)
  517.             Sleep(50)
  518.             MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  519.             Sleep(1000)
  520.             If $count >= 10 Then
  521.                 ExitLoop
  522.             EndIf
  523.         WEnd
  524.     Next
  525. EndFunc   ;==>LootCustom
  526.  
  527. Func LootGems()
  528.     $count = 0
  529.     $gX = 0
  530.     $gY = 0
  531.     While _ImageSearchArea($pngLoc & "square.png", 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, 90)
  532.         $count += 1
  533.         MouseClick("left", $gX, $gY - 3, 1, 3)
  534.         Sleep(50)
  535.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  536.         $GemCount += 1
  537.         Sleep(1000)
  538.         If $count >= 10 Then
  539.             ExitLoop
  540.         EndIf
  541.     WEnd
  542. EndFunc   ;==>LootGems
  543.  
  544. Func LootTomes()
  545.     $count = 0
  546.     $gX = 0
  547.     $gY = 0
  548.     While _ImageSearchArea($pngLoc & "tome.png", 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, 90)
  549.         $count += 1
  550.         MouseClick("left", $gX, $gY - 3, 1, 3)
  551.         Sleep(50)
  552.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  553.         $TomeCount += 1
  554.         Sleep(1000)
  555.         If $count >= 10 Then
  556.             ExitLoop
  557.         EndIf
  558.     WEnd
  559. EndFunc   ;==>LootTomes
  560.  
  561. Func Identify()
  562.     Send("c")
  563.     Sleep(1300)
  564.     While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 120)
  565.         GUICtrlSetData($lblStatus, "Status: Identifying")
  566.         MouseClick("right", $gX, $gY, 1, 4)
  567.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  568.         Sleep(Random(3000, 3500))
  569.     WEnd
  570.     Send("c")
  571.     Sleep(200)
  572. EndFunc   ;==>Identify
  573.  
  574. Func AnalyseLoots() ; Grid search + ilvl detection, a little bit slower than old method but computes db for fast stashing/vendoring/new salvaging
  575.     ;ConsoleWrite("---- NEW ANALYSIS ----" & @crlf)
  576.     $str_Stash = ""
  577.     $str_StashGems = ""
  578.     $str_StashMisc = ""
  579.     $str_Vendor = ""
  580.     $str_Salvage = ""
  581.     $int_TownPosition = 0
  582.     $int_emptygrid = 0
  583.     $str_Ignore = ""
  584.     $nX = 0
  585.     $nY = 0
  586.    GUICtrlSetData($lblStatus, "Status: Analysing loots")
  587.    Send("c")
  588.    Sleep(500)
  589.     For $y = 0 to 5
  590.         $int_emptygrid = 0
  591.        Mousemove(1435,Round(609+(45*$y)),1)
  592.        Sleep(500)
  593.       For $x = 0 to 9
  594.         if StringInStr($str_Ignore,1435+(48*$x) & "," & 609+(45*$y)) Then ContinueLoop
  595.          Mousemove(1435+(48*$x),609+(45*$y),1)
  596.          Sleep(300)
  597.          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
  598.             $int_emptygrid = 0
  599.             if _ImageSearchArea($pngLoc & "tt_unidentified.png", 0, $gX, $gY, $gX+425, $gY+70,$gX,$gY,40) and $Identify == True Then ; Identify items.
  600.                 MouseClick("secondary")
  601.                 Sleep(Random(3000,3500,1))
  602.             endif
  603.             if _ImageSearchArea($pngLoc & "tt_square.png", 0, $gX, $gY, $gX+425, $gY+70,$gX,$gY,40) Then ; Gem, automatic stashing.
  604.                 $str_StashGems = $str_StashGems & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  605.                 ContinueLoop
  606.             endif
  607.             if _ImageSearchArea($pngLoc & "tt_tome.png", 0, $gX, $gY, $gX+425, $gY+70,$gX,$gY,40) Then ; Tome, automatic stashing.
  608.                 $str_StashMisc = $str_StashMisc & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  609.                 ContinueLoop
  610.             endif
  611.             if _ImageSearchArea($pngLoc & "tt_exquisite.png", 0, $gX, $gY, $gX+425, $gY+70,$gX,$gY,40) Then ; Crafting, automatic stashing.
  612.                 $str_StashMisc = $str_StashMisc & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  613.                 ContinueLoop
  614.             endif
  615.             if _ImageSearchArea($pngLoc & "tt_iridescent.png", 0, $gX, $gY, $gX+425, $gY+70,$gX,$gY,40) Then ; Crafting, automatic stashing.
  616.                 $str_StashMisc = $str_StashMisc & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  617.                 ContinueLoop
  618.             endif
  619.             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).
  620.                 $str_StashMisc = $str_StashMisc & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  621.                 ContinueLoop
  622.             endif
  623.             if _ImageSearchArea($pngLoc & "tt_plan.png", 0, $gX, $gY, $gX+425, $gY+70,$gX,$gY,60) Then ; Plans, automatic stashing.
  624.                 $str_StashMisc = $str_StashMisc & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  625.                 ContinueLoop
  626.             endif
  627.             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
  628.                 $str_Ignore = $str_Ignore & "|" & 1435+(48*$x) & "," & 609+(45*($y+1))
  629.             endif
  630.             $tt_title = PixelSearch($gX, $gY, $gX+425, $gY+70, 0x00FF00, 1) ; Set, no ilvl check since they drop rarely. Goes to stash.
  631.             if not @error then
  632.                 $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  633.                 ContinueLoop
  634.             endif
  635.             $tt_title = PixelSearch($gX, $gY, $gX+425, $gY+70, 0xBF642F, 1) ; Legendary, no ilvl check since they drop rarely. Goes to stash.
  636.             if not @error then
  637.                 $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  638.                 ContinueLoop
  639.             endif
  640.             $tt_title = PixelSearch($gX, $gY, $gX+425, $gY+70, 0xFFFF00, 1) ; Rare
  641.             if not @error then
  642.                 if _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Rare ilvl 59
  643.                     If(getOption("i59r") == 1) Then
  644.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  645.                     ElseIf(getOption("i59r") == 2) Then
  646.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  647.                     Else
  648.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  649.                     EndIf
  650.                     ContinueLoop
  651.                 endif
  652.                 if _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Rare ilvl 60,  goes to salvage
  653.                     If(getOption("i60r") == 1) Then
  654.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  655.                     ElseIf(getOption("i60r") == 2) Then
  656.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  657.                     Else
  658.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  659.                     EndIf
  660.                     ContinueLoop
  661.                 endif
  662.                 if _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Rare ilvl 61,  goes to salvage
  663.                     If(getOption("i61r") == 1) Then
  664.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  665.                     ElseIf(getOption("i61r") == 2) Then
  666.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  667.                     Else
  668.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  669.                     EndIf
  670.                     ContinueLoop
  671.                 endif
  672.                 if _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Rare ilvl 62,  goes to salvage
  673.                     If(getOption("i62r") == 1) Then
  674.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  675.                     ElseIf(getOption("i62r") == 2) Then
  676.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  677.                     Else
  678.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y) & ",r"
  679.                     EndIf
  680.                     ContinueLoop
  681.                 endif
  682.                 if _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Rare ilvl 63,  goes to stash
  683.                     If(getOption("i63r") == 1) Then
  684.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  685.                     ElseIf(getOption("i63r") == 2) Then
  686.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  687.                     Else
  688.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  689.                     EndIf
  690.                     ContinueLoop
  691.                 endif
  692.                 ; Below ilvl 59
  693.                 if $StashRare == True Then
  694.                     $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  695.                  ElseIf $VendorRare == True Then
  696.                     $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  697.                  Else
  698.                     $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  699.                  EndIf
  700.                 ContinueLoop
  701.             endif
  702.             $tt_title = PixelSearch($gX, $gY, $gX+425, $gY+70, 0x6969FF, 1) ; Magic
  703.             if not @error then
  704.                 if _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Magic ilvl 59
  705.                     If(getOption("i59m") == 1) Then
  706.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  707.                     ElseIf(getOption("i59m") == 2) Then
  708.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  709.                     Else
  710.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  711.                     EndIf
  712.                     ContinueLoop
  713.                 endif
  714.                 if _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Magic ilvl 60, goes to salvage
  715.                     If(getOption("i60m") == 1) Then
  716.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  717.                     ElseIf(getOption("i60m") == 2) Then
  718.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  719.                     Else
  720.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  721.                     EndIf
  722.                     ContinueLoop
  723.                 endif
  724.                 if _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Magic ilvl 61, goes to salvage
  725.                     If(getOption("i61m") == 1) Then
  726.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  727.                     ElseIf(getOption("i61m") == 2) Then
  728.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  729.                     Else
  730.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  731.                     EndIf
  732.                     ContinueLoop
  733.                 endif
  734.                 if _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Magic ilvl 62, goes to salvage
  735.                     If(getOption("i62m") == 1) Then
  736.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  737.                     ElseIf(getOption("i62m") == 2) Then
  738.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  739.                     Else
  740.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  741.                     EndIf
  742.                     ContinueLoop
  743.                 endif
  744.                 if _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX+125, Round(1080*$y_ratio),$gX,$gY,20) Then ; Magic ilvl 63, goes to stash
  745.                     If(getOption("i63m") == 1) Then
  746.                        $str_Salvage = $str_Salvage & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  747.                     ElseIf(getOption("i63m") == 2) Then
  748.                        $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  749.                     Else
  750.                        $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  751.                     EndIf
  752.                     ContinueLoop
  753.                 endif
  754.                 ; Below ilvl 59
  755.                  if $StashMagic == True Then
  756.                     $str_Stash = $str_Stash & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  757.                  ElseIf $VendorMagic == True Then
  758.                     $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  759.                  Else
  760.                     $str_Ignore = $str_Ignore & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  761.                  EndIf
  762.                 ContinueLoop
  763.             endif
  764.             ; Probably white/gray trash bugged pick, add to vendor string
  765.             $str_Vendor = $str_Vendor & "|" & 1435+(48*$x) & "," & 609+(45*$y)
  766.         Else
  767.             $int_emptygrid += 1
  768.             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.
  769.                 $int_emptygrid = 0
  770.                 exitloop
  771.             else
  772.             ContinueLoop
  773.             endif
  774.          EndIf
  775.       Next
  776.   Next
  777.   Send("c")
  778.   Sleep(500)
  779.   ;ConsoleWrite("Stash gear : "  & $str_Stash & @crlf)
  780.   ;ConsoleWrite("Stash misc : "  & $str_StashMisc & @crlf)
  781.   ;ConsoleWrite("Stash gems : "  & $str_StashGems & @crlf)
  782.   ;ConsoleWrite("Salvage : "  & $str_Salvage & @crlf)
  783.   ;ConsoleWrite("Vendor : "  & $str_Vendor & @crlf)
  784.   ;ConsoleWrite("Ignored Square : "  & $str_Ignore & @crlf)
  785.   if $str_Stash <> "" or $str_StashGems <> "" or $str_StashMisc <> "" then Call ("StashLoot_new")
  786.   if $str_Salvage <> "" then Call ("SalvageLoot_new")
  787.   if $str_Vendor <> "" then Call ("VendorLoot_new")
  788. EndFunc
  789.  
  790. Func StashLoot_new()
  791.     $arr_split = ""
  792.     $pos_split = ""
  793.     GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  794.     MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  795.     Moving(1600)
  796.     $int_TownPosition = 1
  797.  
  798.     ;Gems Page 1
  799.     if $str_StashGems <> "" Then
  800.     MouseClick("left", 500 * $x_ratio, 200 * $y_ratio, 1, 3)
  801.     $str_StashGems = StringMid($str_StashGems,2)
  802.     $arr_split = StringSplit($str_StashGems,"|")
  803.     For $i = 1 to $arr_split[0]
  804.         Sleep(Random(300, 350))
  805.         $pos_split = StringSplit($arr_split[$i], ",", 2)
  806.         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  807.     Next
  808.     EndIf
  809.  
  810.     ;Tomes/Crafting Materials/Plans/Etc Page 2
  811.     if $str_StashMisc <> "" Then
  812.     MouseClick("left", 500 * $x_ratio, 360 * $y_ratio, 1, 3)
  813.     $str_StashMisc = StringMid($str_StashMisc,2)
  814.     $arr_split = StringSplit($str_StashMisc,"|")
  815.     For $i = 1 to $arr_split[0]
  816.         Sleep(Random(300, 350))
  817.         $pos_split = StringSplit($arr_split[$i], ",", 2)
  818.         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  819.     Next
  820. EndIf
  821.  
  822.     ;Gears Page 2
  823.     if $str_Stash <> "" then
  824.     $str_Stash = StringMid($str_Stash,2)
  825.     $arr_split = StringSplit($str_Stash,"|")
  826.     For $i = 1 to $arr_split[0]
  827.         Sleep(Random(80,100))
  828.         RandTab() ;choose a random tab
  829.         Sleep(Random(300, 350))
  830.         $pos_split = StringSplit($arr_split[$i], ",", 2)
  831.         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  832.     Next
  833.     EndIf
  834.  
  835.     Sleep(Random(100, 150))
  836.     Send("{SPACE}")
  837. EndFunc
  838.  
  839. Func SalvageLoot_new()
  840.     $arr_split = ""
  841.     $pos_split = ""
  842.     GUICtrlSetData($lblStatus, "Status: Salvaging loots")
  843.     if $int_TownPosition = 0 then ; Starting from TP
  844.         MouseClick("middle", 1582 * $x_ratio, 527 * $y_ratio)
  845.         Moving(2000)
  846.         MouseClick("left", 1661 * $x_ratio, 409 * $y_ratio)
  847.         Moving(2500)
  848.     Else ; Starting from Stash
  849.         MouseClick("middle", 1484 * $x_ratio, 583 * $y_ratio)
  850.         Moving(2000)
  851.         MouseClick("left", 1773 * $x_ratio, 484 * $y_ratio)
  852.         Moving(2500)
  853.     EndIf
  854.     $int_TownPosition = 2
  855.     MouseClick("left", 263 * $x_ratio, 287 * $y_ratio)
  856.     $str_Salvage = StringMid($str_Salvage,2)
  857.     $arr_split = StringSplit($str_Salvage,"|")
  858.     For $i = 1 to $arr_split[0]
  859.         Sleep(Random(300, 400))
  860.         $pos_split = StringSplit($arr_split[$i], ",")
  861.         MouseClick("left", $pos_split[1], $pos_split[2], 1, 3)
  862.         if $pos_split[0] == 3 then
  863.             Send("{ENTER}")
  864.             Sleep(1000)
  865.         endif
  866.     Next
  867.     Sleep(Random(300, 400))
  868.     Send("{SPACE}")
  869. EndFunc
  870.  
  871. Func VendorLoot_new()
  872.     $arr_split = ""
  873.     $pos_split = ""
  874.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  875.     if $int_TownPosition = 0 Then ; Starting from TP
  876.         MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  877.     Elseif $int_TownPosition = 1 Then ; Starting from Stash
  878.         MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  879.     Else ; Starting from Blacksmith
  880.         MouseClick("middle", 738 * $x_ratio, 64 * $y_ratio)
  881.     EndIf
  882.     Moving(3000)
  883.     MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  884.     Moving(3000)
  885.     $str_Vendor = StringMid($str_Vendor,2)
  886.     $arr_split = StringSplit($str_Vendor,"|")
  887.     For $i = 1 to $arr_split[0]
  888.         Sleep(Random(100, 300))
  889.         $pos_split = StringSplit($arr_split[$i], ",", 2)
  890.         MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
  891.         if PixelGetColor(819*$x_ratio,375*$y_ratio) == 0x370C00 then Send("{ENTER}")
  892.     Next
  893.     Sleep(Random(500, 800))
  894.     Send("{SPACE}")
  895. EndFunc
  896.  
  897. Func StashLoot()
  898.     GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  899.     MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  900.     Moving(1600)
  901.  
  902.     ;Tomes
  903.     While $StashTomes == True
  904.         Sleep(Random(100, 300))
  905.         If _ImageSearchArea($pngLoc & "TomeIcon.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 140) Then
  906.             GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  907.             MouseClick("left", 500 * $x_ratio, 360 * $y_ratio, 1, 4)
  908.             MouseClick("right", $gX, $gY, 1, 4)
  909.             Sleep(80)
  910.             MouseClick("left", 500 * $x_ratio, 200 * $y_ratio, 1, 4)
  911.         Else
  912.             ExitLoop
  913.         EndIf
  914.     WEnd
  915.  
  916.     If $StashLegendary == True Then
  917.         StashItems(0xFF7F00, 0)
  918.         StashItems(0x8F5C25, 1)
  919.     EndIf
  920.  
  921.     If $StashRare == True Then
  922.         StashItems(0x4A3C0B, 1)
  923.     EndIf
  924.  
  925.     If $StashMagic == True Then
  926.         StashItems(0x182037, 1)
  927.     EndIf
  928.  
  929.     ;Gems (DOESN'T STASH BOTTOM ROW!)
  930.     If $StashGems == True Then
  931.         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  932.         MouseClick("left", 500 * $x_ratio, 200 * $y_ratio, 1, 4)
  933.         Sleep(Random(20, 100))
  934.         For $i = 0 To 7
  935.             If _ImageSearchArea($pngLoc & $gems[$i], 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 820 * $y_ratio, $gX, $gY, 140) Then
  936.                 MouseClick("right", $gX, $gY, 1, 3)
  937.             EndIf
  938.         Next
  939.     EndIf
  940.     Sleep(Random(1000, 1500))
  941.     Send("{SPACE}")
  942. EndFunc   ;==>StashLoot
  943.  
  944. Func VendorLoot()
  945.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  946.     If Not $StashLoot == True Then ;Move from TP towards vendor
  947.         Sleep(Random(300, 500))
  948.         MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  949.     Else ;Move from Stash towards vendor
  950.         Sleep(Random(300, 500))
  951.         MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  952.     EndIf
  953.     Moving(3000)
  954.     MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  955.     Moving(3000)
  956.  
  957.     ;All
  958.     If $vendorAll == True Then
  959.         For $c = 1 To $vendorCols
  960.             For $r = 1 To $vendorRows
  961.                 RandClick("right", (((($c - 1) * 50) + 32 + 1400) * $x_ratio), (((($r - 1) * 51) + 32 + 580) * $y_ratio), 2, 2, 1, 2.5)
  962.             Next
  963.         Next
  964.     EndIf
  965.  
  966.     ;Rares
  967.     If $VendorRare == True Then
  968.         VendItems(0x4A3C0B, 1)
  969.     EndIf
  970.  
  971.     ;Magic
  972.     If $VendorMagic == True Then
  973.         VendItems(0x182037, 1)
  974.     EndIf
  975.  
  976.     Sleep(200)
  977.     RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  978.     Sleep(300)
  979.     RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  980.     Sleep(200)
  981.     GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  982.     Send("{ESCAPE}")
  983. EndFunc   ;==>VendorLoot
  984.  
  985. Func StashItems($color, $tolerance)
  986.     $c = 0
  987.     While $c <= 20
  988.         Sleep(Random(20, 100))
  989.         $StashPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  990.         If Not @error Then
  991.             RandTab()
  992.             Sleep(Random(80,100))
  993.             MouseClick("right", $StashPixel[0] + 4, $StashPixel[1], 1, 4)
  994.             $c += 1
  995.         Else
  996.             ExitLoop
  997.         EndIf
  998.     WEnd
  999. EndFunc   ;==>StashItems
  1000.  
  1001. Func VendItems($color, $tolerance)
  1002.     $c = 0
  1003.     While $c <= 20
  1004.         Sleep(Random(20, 100))
  1005.         $VendPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  1006.         If Not @error Then
  1007.             MouseClick("right", $VendPixel[0], $VendPixel[1], 1, 4)
  1008.             $c += 1
  1009.         Else
  1010.             ExitLoop
  1011.         EndIf
  1012.     WEnd
  1013. EndFunc   ;==>VendItems
  1014.  
  1015. Func DoUpdate()
  1016.     $ini = InetGet($VersionsInfo, @ScriptDir & "\version.ini") ;download version.ini
  1017.     If $ini = 0 Then ;was the download of version.ini successful?
  1018.         MsgBox(16, "Fatal Error", "The server seems to be offline. No update will be done.")
  1019.     Else
  1020.         $newVersion = IniRead(@ScriptDir & "\version.ini", "Version", "Version", "") ;reads the new version out of version.ini
  1021.         If $newVersion = $oldVersion Then ;compare old and new
  1022.             ;MsgBox (0,"No update","There is no update available!")
  1023.             FileDelete(@ScriptDir & "\version.ini")
  1024.         Else
  1025.             $msg = MsgBox(68, "Update", "A new version is available: " & $newVersion & "! Current version: " & $oldVersion & @CRLF & "Do you want to download the new version?")
  1026.             If $msg = 7 Then ;No was pressed
  1027.                 FileDelete(@ScriptDir & "\version.ini")
  1028.             ElseIf $msg = 6 Then ;OK was pressed
  1029.                 $downloadLink = IniRead(@ScriptDir & "\version.ini", "Version", "download", "NotFound")
  1030.                 $dlhandle = InetGet($downloadLink, @ScriptDir & "\Update_" & $newVersion & ".zip", 1, 1)
  1031.                 ProgressOn("Update", "Downloading Updates", "", -1, -1, 16) ;creates a progressbar
  1032.  
  1033.                 $size = InetGetSize($downloadLink, 1) ;get the size of the update
  1034.                 While Not InetGetInfo($dlhandle, 2)
  1035.                     $Percent = Round((InetGetInfo($dlhandle, 0) / $size) * 100)
  1036.                     ProgressSet($Percent, $Percent & "%") ;update progressbar
  1037.                     Sleep(1)
  1038.                 WEnd
  1039.                 ProgressSet(100, "Done", "Complete") ;show complete progressbar
  1040.                 Sleep(500)
  1041.                 ProgressOff() ;close progress window
  1042.                 IniWrite("updater.ini", "version", "version", $newVersion)
  1043.                 InetClose($dlhandle)
  1044.                 $iniMsg = IniRead(@ScriptDir & "\version.ini", "Version", "message", "Exiting...")
  1045.                 MsgBox(64, "Success", "Download Complete!" & @CRLF & "Please restart the bot by extracting the Au3 from Update_" & $newVersion & ".zip" & @CRLF & $iniMsg)
  1046.                 FileDelete(@ScriptDir & "\version.ini")
  1047.                 Exit
  1048.             EndIf
  1049.         EndIf
  1050.     EndIf
  1051.     WinSetTitle($title, "", $title & $ver & " - Waiting")
  1052. EndFunc   ;==>DoUpdate
  1053. Func ReadINI()
  1054.     $pngLoc = IniRead($ini, "Custom Loot", "PNG Location", $pngLoc)
  1055.     $totalItems = IniRead($ini, "Custom Loot", "Total Items", $totalItems)
  1056.     $skillCaltrops = IniRead($ini, "Skills", "Caltrops", $skillCaltrops)
  1057.     $skillSmokeScreen = IniRead($ini, "Skills", "SmokeScreen", $skillSmokeScreen)
  1058.     $skillPreparation = IniRead($ini, "Skills", "Preparation", $skillPreparation)
  1059.     $skillCompanion = IniRead($ini, "Skills", "Companion", $skillCompanion)
  1060.     $movementSpeed = IniRead($ini, "Additional", "Movement Speed", $movementSpeed)
  1061.     $walktime = IniRead($ini, "Additional", "Walk Time", $walktime)
  1062.     $loadtime = IniRead($ini, "Additional", "Load Time", $loadtime)
  1063.     $tptime = IniRead($ini, "Additional", "Teleport Time", $tptime)
  1064.     $LootSets = IniRead($ini, "Looting", "Sets", $LootSets)
  1065.     $LootLegendaries = IniRead($ini, "Looting", "Legendaries", $LootLegendaries)
  1066.     $LootRares = IniRead($ini, "Looting", "Rares", $LootRares)
  1067.     $LootMagic = IniRead($ini, "Looting", "Magic", $LootMagic)
  1068.     $LootGems = IniRead($ini, "Looting", "Gems", $LootGems)
  1069.     $LootTomes = IniRead($ini, "Looting", "Tomes", $LootTomes)
  1070.     $LootCustom = IniRead($ini, "Looting", "Custom", $LootCustom)
  1071.     $mLoot = IniRead($ini, "ManageLoot", "Every", $mLoot)
  1072.     $Identify = IniRead($ini, "ManageLoot", "Identify", $Identify)
  1073.     $StashLoot = IniRead($ini, "Stashing", "Loot", $StashLoot)
  1074.     $StashLegendary = IniRead($ini, "Stashing", "Legendaries", $StashLegendary)
  1075.     $StashRare = IniRead($ini, "Stashing", "Rares", $StashRare)
  1076.     $StashMagic = IniRead($ini, "Stashing", "Magic", $StashMagic)
  1077.     $StashTomes = IniRead($ini, "Stashing", "Tomes", $StashTomes)
  1078.     $StashGems = IniRead($ini, "Stashing", "Gems", $StashGems)
  1079.     $VendorLoot = IniRead($ini, "Vendoring", "Loot", $VendorLoot)
  1080.     $VendorRare = IniRead($ini, "Vendoring", "Rares", $VendorRare)
  1081.     $VendorMagic = IniRead($ini, "Vendoring", "Magic", $VendorMagic)
  1082.     $vendorAll = IniRead($ini, "Vendoring", "All", $vendorAll)
  1083.     $vendorRows = IniRead($ini, "Vendoring", "All-Rows", $vendorRows)
  1084.     $vendorCols = IniRead($ini, "Vendoring", "All-Cols", $vendorCols)
  1085.     $Timer = IniRead($ini, "Variability", "Timer", $Timer)
  1086.     $mLootOff = IniRead($ini, "Variability", "Manage Off By", $mLootOff)
  1087.     $attackTime = IniRead($ini, "Variability", "Attack Time", $attackTime)
  1088.     $attackMulti = IniRead($ini, "Variability", "Attack Multiple", $attackMulti)
  1089.     $i59Rare = IniRead($ini, "AnalyzeLoot", "i59Rare", $i59Rare)
  1090.     $i60Rare = IniRead($ini, "AnalyzeLoot", "i60Rare", $i60Rare)
  1091.     $i61Rare = IniRead($ini, "AnalyzeLoot", "i61Rare", $i61Rare)
  1092.     $i62Rare = IniRead($ini, "AnalyzeLoot", "i62Rare", $i62Rare)
  1093.     $i63Rare = IniRead($ini, "AnalyzeLoot", "i63Rare", $i63Rare)
  1094.     $i59Magic = IniRead($ini, "AnalyzeLoot", "i59Magic", $i59Magic)
  1095.     $i60Magic = IniRead($ini, "AnalyzeLoot", "i60Magic", $i60Magic)
  1096.     $i61Magic = IniRead($ini, "AnalyzeLoot", "i61Magic", $i61Magic)
  1097.     $i62Magic = IniRead($ini, "AnalyzeLoot", "i62Magic", $i62Magic)
  1098.     $i63Magic = IniRead($ini, "AnalyzeLoot", "i63Magic", $i63Magic)
  1099. EndFunc   ;==>ReadINI
  1100. Func CreateINI()
  1101.     IniWrite($ini, "Custom Loot", "PNG Location", $pngLoc)
  1102.     IniWrite($ini, "Custom Loot", "Total Items", $totalItems)
  1103.     IniWrite($ini, "Skills", "Caltrops", $skillCaltrops)
  1104.     IniWrite($ini, "Skills", "SmokeScreen", $skillSmokeScreen)
  1105.     IniWrite($ini, "Skills", "Preparation", $skillPreparation)
  1106.     IniWrite($ini, "Skills", "Companion", $skillCompanion)
  1107.     IniWrite($ini, "Additional", "Movement Speed", $movementSpeed)
  1108.     IniWrite($ini, "Additional", "Walk Time", $walktime)
  1109.     IniWrite($ini, "Additional", "Load Time", $loadtime)
  1110.     IniWrite($ini, "Additional", "Teleport Time", $tptime)
  1111.     IniWrite($ini, "Looting", "Sets", $LootSets)
  1112.     IniWrite($ini, "Looting", "Legendaries", $LootLegendaries)
  1113.     IniWrite($ini, "Looting", "Rares", $LootRares)
  1114.     IniWrite($ini, "Looting", "Magic", $LootMagic)
  1115.     IniWrite($ini, "Looting", "Gems", $LootGems)
  1116.     IniWrite($ini, "Looting", "Tomes", $LootTomes)
  1117.     IniWrite($ini, "Looting", "Custom", $LootCustom)
  1118.     IniWrite($ini, "ManageLoot", "Every", $mLoot)
  1119.     IniWrite($ini, "ManageLoot", "Identify", $Identify)
  1120.     IniWrite($ini, "Stashing", "Loot", $StashLoot)
  1121.     IniWrite($ini, "Stashing", "Legendaries", $StashLegendary)
  1122.     IniWrite($ini, "Stashing", "Rares", $StashRare)
  1123.     IniWrite($ini, "Stashing", "Magic", $StashMagic)
  1124.     IniWrite($ini, "Stashing", "Tomes", $StashTomes)
  1125.     IniWrite($ini, "Stashing", "Gems", $StashGems)
  1126.     IniWrite($ini, "Vendoring", "Loot", $VendorLoot)
  1127.     IniWrite($ini, "Vendoring", "Rares", $VendorRare)
  1128.     IniWrite($ini, "Vendoring", "Magic", $VendorMagic)
  1129.     IniWrite($ini, "Vendoring", "All", $vendorAll)
  1130.     IniWrite($ini, "Vendoring", "All-Rows", $vendorRows)
  1131.     IniWrite($ini, "Vendoring", "All-Cols", $vendorCols)
  1132.     IniWrite($ini, "Variability", "Timer", $Timer)
  1133.     IniWrite($ini, "Variability", "Manage Off By", $mLootOff)
  1134.     IniWrite($ini, "Variability", "Attack Time", $attackTime)
  1135.     IniWrite($ini, "Variability", "Attack Multiple", $attackMulti)
  1136.     IniWrite($ini, "AnalyzeLoot", "i59Rare", $i59Rare)
  1137.     IniWrite($ini, "AnalyzeLoot", "i60Rare", $i60Rare)
  1138.     IniWrite($ini, "AnalyzeLoot", "i61Rare", $i61Rare)
  1139.     IniWrite($ini, "AnalyzeLoot", "i62Rare", $i62Rare)
  1140.     IniWrite($ini, "AnalyzeLoot", "i63Rare", $i63Rare)
  1141.     IniWrite($ini, "AnalyzeLoot", "i59Magic", $i59Magic)
  1142.     IniWrite($ini, "AnalyzeLoot", "i60Magic", $i60Magic)
  1143.     IniWrite($ini, "AnalyzeLoot", "i61Magic", $i61Magic)
  1144.     IniWrite($ini, "AnalyzeLoot", "i62Magic", $i62Magic)
  1145.     IniWrite($ini, "AnalyzeLoot", "i63Magic", $i63Magic)
  1146. EndFunc   ;==>CreateINI
  1147.  
  1148. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  1149.     If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  1150.     $findImage = "*TRANSBLACK " & $findImage
  1151.     If @AutoItX64 Then
  1152.         $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1153.     Else
  1154.         $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1155.     EndIf
  1156.     If $result = "0" Then
  1157.         Return 0
  1158.     EndIf
  1159.  
  1160.     ; Otherwise get the x,y location of the match and the size of the image to
  1161.     ; compute the centre of search
  1162.     $array = StringSplit($result[0], "|")
  1163.     If (UBound($array) >= 4) Then
  1164.         $x = Int(Number($array[2]))
  1165.         $y = Int(Number($array[3]))
  1166.         If $resultPosition = 1 Then
  1167.             $x = $x + Int(Number($array[4]) / 2)
  1168.             $y = $y + Int(Number($array[5]) / 2)
  1169.         EndIf
  1170.         Return 1
  1171.     EndIf
  1172. EndFunc   ;==>_ImageSearchArea
  1173.  
  1174. Func LeaveGame()
  1175.     Call("RandSleep")
  1176.     GUICtrlSetData($lblStatus, "Status: Leaving Game")
  1177.     Send("{Escape}")
  1178.     Sleep(200)
  1179.     RandClick("left", Round(956 * $x_ratio), Round(579 * $y_ratio), 120, 20) ;Random Click on the leave button
  1180.     Call("CalcTime")
  1181.     Sleep($loadtime)
  1182. EndFunc   ;==>LeaveGame
  1183.  
  1184. Func TownPortal()
  1185.     GUICtrlSetData($lblStatus, "Status: Returning to Town")
  1186.     Send("t")
  1187.     Sleep(Random($tptime, $tptime + 500))
  1188. EndFunc   ;==>TownPortal
  1189.  
  1190. Func Moving($time)
  1191.     Sleep($time / $movementSpeed)
  1192. EndFunc   ;==>Moving
  1193.  
  1194. Func RandClick($clickType, $xPos, $yPos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
  1195.     If $xOff < 1 Then $xOff = 1
  1196.     If $yOff < 1 Then $yOff = 1
  1197.     $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1198.     $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1199.     MouseClick($clickType, $randX, $randY, $clicks, $speed)
  1200. EndFunc   ;==>RandClick
  1201.  
  1202. Func RandMove($xPos, $yPos, $xOff = 10, $yOff = 10, $speed = 1)
  1203.     $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1204.     $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1205.     MouseMove($randX, $randY, $speed)
  1206. EndFunc   ;==>RandMove
  1207.  
  1208. Func RandSleep($min = 5, $max = 45, $chance = 3)
  1209.     $randNum = Round(Random(1, 100))
  1210.     If $Timer == True And $randNum <= $chance Then
  1211.         $sleepTime = Random($min * 1000, $max * 1000)
  1212.         GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime / 1000) & " secs")
  1213.  
  1214.         For $c = 0 To 10
  1215.             Sleep($sleepTime / 10)
  1216.         Next
  1217.     EndIf
  1218. EndFunc   ;==>RandSleep
  1219.  
  1220. ;Hotkey Functions
  1221.  
  1222. Func getOption($option) ;Gets the correct INI settings corrisponding to the vend/stash/salvage of items.
  1223.    
  1224.    if($option == "i59r") Then
  1225.       If($i59Rare = "salvage") Then
  1226.          Return 1
  1227.       ElseIf($i59Rare = "vend") Then
  1228.          Return 2
  1229.       Else
  1230.          Return 0
  1231.       EndIf
  1232.    ElseIf($option == "i60r") Then
  1233.       If($i60Rare = "salvage") Then
  1234.          Return 1
  1235.       ElseIf($i60Rare = "vend") Then
  1236.          Return 2
  1237.       Else
  1238.          Return 0
  1239.       EndIf
  1240.    ElseIf($option == "i61r") Then
  1241.       If($i61Rare = "salvage") Then
  1242.          Return 1
  1243.       ElseIf($i61Rare = "vend") Then
  1244.          Return 2
  1245.       Else
  1246.          Return 0
  1247.       EndIf
  1248.    ElseIf($option == "i62r") Then
  1249.       If($i62Rare = "salvage") Then
  1250.          Return 1
  1251.       ElseIf($i62Rare = "vend") Then
  1252.          Return 2
  1253.       Else
  1254.          Return 0
  1255.       EndIf
  1256.    ElseIf($option == "i63r") Then
  1257.       If($i63Rare = "salvage") Then
  1258.          Return 1
  1259.       ElseIf($i63Rare = "vend") Then
  1260.          Return 2
  1261.       Else
  1262.          Return 0
  1263.       EndIf
  1264.    ElseIf($option == "i59m") Then
  1265.       If($i59Magic = "salvage") Then
  1266.          Return 1
  1267.       ElseIf($i59Magic = "vend") Then
  1268.          Return 2
  1269.       Else
  1270.          Return 0
  1271.       EndIf
  1272.    ElseIf($option == "i60m") Then
  1273.       If($i60Magic = "salvage") Then
  1274.          Return 1
  1275.       ElseIf($i60Magic = "vend") Then
  1276.          Return 2
  1277.       Else
  1278.          Return 0
  1279.       EndIf
  1280.    ElseIf($option == "i61m") Then
  1281.       If($i61Magic = "salvage") Then
  1282.          Return 1
  1283.       ElseIf($i61Magic = "vend") Then
  1284.          Return 2
  1285.       Else
  1286.          Return 0
  1287.       EndIf
  1288.    ElseIf($option == "i62m") Then
  1289.       If($i62Magic = "salvage") Then
  1290.          Return 1
  1291.       ElseIf($i62Magic = "vend") Then
  1292.          Return 2
  1293.       Else
  1294.          Return 0
  1295.       EndIf
  1296.    ElseIf($option == "i63m") Then
  1297.       If($i63Magic = "salvage") Then
  1298.          Return 1
  1299.       ElseIf($i63Magic = "vend") Then
  1300.          Return 2
  1301.       Else
  1302.          Return 0
  1303.       EndIf
  1304.    Else
  1305.       Return 0
  1306.    EndIf
  1307.    
  1308. EndFunc
  1309.  
  1310. Func RandTab() ;tabs through stash randomly before stashing item
  1311.    
  1312.    $k = Random(0,10)
  1313.    if($k > 6) Then
  1314.       MouseClick("left", 500 * $x_ratio, 360 * $y_ratio, 1, 4) ;2nd tab
  1315.    Else
  1316.       MouseClick("left", 500 * $x_ratio, 200 * $y_ratio, 1, 4) ;1st tab
  1317.    EndIf
  1318.    
  1319. EndFunc
  1320.  
  1321. Func Begin()
  1322.     $Go = Not $Go
  1323.     If Not $Go Then WinSetTitle($title, "", $title & $ver & " - Halted")
  1324. EndFunc   ;==>Begin
  1325.  
  1326. Func TogglePause()
  1327.     $Paused = Not $Paused
  1328.     While $Paused
  1329.         Sleep(100)
  1330.         WinSetTitle($title, "", $title & $ver & " - Paused")
  1331.         ToolTip('[PAUSED] - Deaths: ' & $deathCount & ' | Cellars: ' & $cellarCount, 0, 0)
  1332.     WEnd
  1333.     WinSetTitle($title, "", $title & $ver & " - Running")
  1334.     ToolTip("")
  1335. EndFunc   ;==>TogglePause
  1336.  
  1337. Func ShowLoot()
  1338.     GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  1339.     GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  1340. EndFunc   ;==>ShowLoot
  1341.  
  1342. Func Stop() ;to allow the script to stop
  1343.     Exit
  1344. EndFunc   ;==>Stop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement