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

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 65.32 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;=========== DO NOT TOUCH ===========;
  2. #RequireAdmin
  3. #include <GUIConstantsEx.au3>
  4. #include <StaticConstants.au3>
  5. #include <WindowsConstants.au3>
  6. #include <ScreenCapture.au3>
  7. #include <GoldRead.au3>
  8. Opt('MouseCoordMode', 2)
  9. Opt('PixelCoordMode', 2)
  10.  
  11.  
  12. ;GUI Predeclare to prevent firing the Case statements
  13. Global $lbllink,$mFile,$mOptions,$lblRun,$lblLocation,$lblStatus,$lblLast,$lblRuntime,$lblGold,$lblCellars,$lblStats,$mAutoUpdate,$SettingsGUI,$Settings,$tsSettings,$grpgameAutoStart,$lblgameDiabloIIILoc,$txtgameDiabloIIILoc,$lblgamePassword,$txtgamePassword,$cbgameAutoStart,$btngameDiabloIIILoc,$tsLooting,$grpLoot,$etlootCustom,$cblootSet,$cblootLegendary,$cblootRare,$cblootMagic,$cblootCustom,$tsStash,$grpStashing,$cbstashSet,$cbStashLegendary,$cbstashRare,$cbstashMagic,$cbStashTomes,$cbStashGems, $tsVendoring,$grpVendoring,$cbvendorRare,$cbvendorMagic,$cbvendorLegendary,$cbvendorSet,$cmbvendorRows,$lblVendorRow,$cbvendorAll, $lblVendorCol,$cmbVendorColumns,$tsSkills,$grpSkills,$txtSkill1,$txtSkill2,$txtSkill3,$txtSkill4,$lblskill1,$lblSkill2,$lblSkill3, $lblSkill4,$cbCellarDetectScreenShots, $btnSave,$grpAdd,$txtAddMove, $txtAddDPS, $lblAddDPS,$cbAddGoldOnly, $lbltimingGameLoad, $lbltimingCellarClick, $lbltimingWormHole, $lbltimingMiddleDoor, $lbltimingAbort, $lbltimingTP, $lbltimingLoot, $lbltimingLootRun, $txttimingGameLoad, $txttimingWormHole, $txttimingTP, $txttimingCellarClick, $txttimingMiddleDoor, $txttimingLootRun, $txttimingLoot, $txttimingAbort,$txtRareStashilvl, $txtRareSalvageilvl, $txtRareVendorilvl, $txtMagicStashilvl, $txtMagicSalvageilvl, $txtMagicVendorilvl,$lblitems,$lblgear,$lblStartingG,$CurrentItems
  14.  
  15. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $Kill = ProcessList("AutoIt3_x64.exe"),$mLootIn = 0, $x_ratio, $y_ratio, $AddDPS = 0,$attackTime = 0, $hFont = 0, $title, $Paused, $Go = 0, $i = 0, $gX = 0, $gY = 0, $GemCount = 0, $LegendaryCount = 0, $SetCount = 0, $RareCount = 0, $deathCount = 0, $MagicCount = 0, $repairCount = 0, $closedcellarCount = 0, $cellarCount = 0, $countMissedCellar = 0, $MissedCellarCountPercent = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000, $StartingGold = 0,$AccumulatedGold = 0,$GPH = 0, $OpenCellarAvg = 0, $OpenCellarSec = 0,$ClosedCellarAvg, $ClosedCellarSec = 0,$CellCoord = 0, $c = 0, $RunsPerHour = 0,$closedCellarCountPercent = 0, $repairCountPercent = 0, $deathsCountPercent = 0, $cellarCountPercent = 0, $settingsINI = "Settings.ini", $StashSelectedTab = 0,$Items = 0
  16. Global $gems[4] = ["Em1.png", "Ru1.png", "To1.png", "Am1.png"]
  17. Global $AnalyzedLoot[10][6]
  18. Global $StashTabs[3][2] = [[281,127], [281,199], [285,271]]
  19.  
  20.  
  21. For $i = 1 To $Kill[0][0]
  22.         $CurrentPID = @AutoItPID
  23.         If $CurrentPID < $Kill[$i][1] or $CurrentPID > $Kill[$i][1] Then
  24.         ProcessClose($Kill[$i][1])
  25.         EndIf
  26.  Next
  27.  
  28. DirCreate("shots")
  29. DirCreate("shots\Start")
  30. DirCreate("shots\Cellar")
  31.  
  32. $pngLoc = @ScriptDir & "\pics\" & @DesktopWidth & "x" & @DesktopHeight& "\"
  33.  
  34. If Not FileExists($pngLoc & "MainMenu.png") Then
  35.         MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your desktop resolution is 800x600")
  36.         Exit
  37. EndIf
  38.  
  39. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  40. If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
  41.  
  42. ;GUI Title Bar
  43. For $i = 0 To Random(0, 7, 1)
  44.         $title &= Chr(Random(97, 122, 1))
  45. Next
  46. For $i = 0 To Random(5, 10, 1)
  47.         $title &= Chr(Random(65, 90, 1))
  48. Next
  49. $title &= " "
  50.  
  51.  
  52. ;==================================================
  53.  
  54. $totalItems = 1 ;Number of items in the pick array
  55. ;$currentArrayItem = 0x
  56. Global $pick[$totalItems]       ;DONT CHANGE THIS
  57.  
  58. ;Cellar Detection
  59. Global $cellarCoordx[6] = [166,137,240,245,121,174]
  60. Global $cellarCoordy[6]=  [146,145,156,144,135,129]
  61. $cellarCheckSleep = 180
  62. $Screenshot = 1
  63.  
  64. ;AutoStart
  65. $gameDiabloIIILoc = "C:\" ;Location of Diablo 3 executable
  66. $gameAutoStart = 0 ; Set this to 1 to start game from desktop or reco from closed game
  67. $gameStartTime = 9000  ;Change depending on computer/internet speed
  68. $gamePassword = "Your Password" ;Symbols go in brackets "Password1{!}"
  69. $gameExecutable = "Diablo III.exe"
  70.  
  71. ;Change to match your abilities (1-4 by default)z
  72. $Skill1 = "1"
  73. $Skill2 = "2"
  74. $Skill3 = "3"
  75. $Skill4 = "4"
  76. ;==================================================
  77.  
  78. ;Looting
  79. $LootSet = 1 ;1 if you want to pick up Set
  80. $LootLegendary = 1;1 if you want to pick up Legendaries
  81. $LootRare = 1 ;1 if you want to pick up Rares
  82. $LootMagic = 1 ;1 if you want to pick up Magic
  83. $LootCustom = 0 ;1 if you want to pick up Custom Items
  84. $LootGoldOnly = 0 ; 1 if you want to not loot anything but gold
  85. ;==================================================
  86.  
  87. ;Stashing
  88. $StashLegendary = 1 ;1 if you want to store Legendary items in the stash
  89. $StashSet = 1 ;1 if you want to store Set items in the stash
  90. $StashRare = 1 ;1 if you want to store Rare items in the stash
  91. $StashMagic = 0 ;1 if you want to store Magic items in the stash
  92. $StashTomes = 1 ;1 if you want to store Tomes items in the stash
  93. $StashGems = 1 ;1 if you want to store Gems items in the stash
  94. $StashLoot = $StashMagic  + $StashRare + $StashLegendary + $Stashset + $StashGems + $StashTomes
  95. ;==================================================
  96.  
  97. ;Vendoring
  98. $VendorSet = 0
  99. $VendorLegendary = 0
  100. $VendorRare = 0 ;1 if you want to vendor Rares
  101. $VendorMagic = 1 ;1 if you want to vendor Magic
  102. $vendorRows = 6 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
  103. $vendorColumns = 10 ;# of columns to vendor, starting from left
  104. $VendorAll = 1 ;Vendors everything but identified items
  105. $VendorLoot = $VendorMagic + $VendorRare + $VendorLegendary + $VendorSet +  $VendorAll
  106. ;==================================================
  107.  
  108. ;Additional
  109. $AddDPS = 0 ;Time (in s) the script will shoot sarkoth with the right button
  110.  
  111. ;==================================================
  112.  
  113. ;Timing
  114.  
  115. $timingCellarClick = 750 ;time (in ms) it takes to run into the cellar
  116.  
  117. $timingAbort = 300 ;time (in ms) to wait to cast abort skills, decrease if you have high attack speed
  118. $timingGameLoad = 5000 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  119. $timingTP = 6000;Time (in ms) the script waits for teleport before exiting the game
  120. $timingLoot = 800;Time (in ms) the script waits before each loot attempt
  121. $timingLootRun = 600;Time (in ms) the script runs towards sarkoth dead body
  122. ;==================================================
  123.  
  124.  
  125. ;Anal Loot!!
  126. $AnalLoot = 1
  127. $RareSalvageiLvl = 61 ;and below to Salvage #
  128. $MagicSalvageiLvl = 62 ;and below to Salvage #
  129. $RareStashiLvl = 62 ;and above to Stash #
  130. $MagicStashiLvl = 63 ;and above to Stash #
  131. $RareVendoriLvl = 60 ;and below to Vendor #
  132. $MagicVendoriLvl = 60 ;and below to Vendor #
  133. $AnalSpeed = 50
  134. ;==================================================
  135. ;New Loot Coords
  136. $slot1x = 530  ; first slot x coordinate
  137. $slot1y = 338 ;first slot y coordinate
  138.  
  139.  
  140. $offset = 27 ; offset for each slot
  141.  
  142.  
  143.     $slotLineX = 520 ;First slot line x coordinate
  144.         $slotLineY = 324 ;First slot line y coordinate
  145.         $slotLineOffSet = 26.75 ;offset for each line
  146.  
  147. $CellMiddleTopX = 530
  148. $CellMiddleTopY = 339
  149. $CellMiddleBotX = 531
  150. $CellMiddleBotY =341
  151. $CellMiddleO = 26.75
  152. ;==================================================
  153.  
  154. ;====DONT CHANGE=====;
  155. $AnalSalvage = 0 ;determines whether not theres items to salvage
  156. $AnalRareIdentify = 0  ;determines whether not theres a rare to identify, don't change
  157. $AnalVendor = 0
  158. $slotError = 0;Used if line doesn't exisit
  159. ;==================================================
  160.  
  161.  
  162. HotKeySet("=", "Begin") ;script toggled on/off by pressing =
  163. HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
  164. HotKeySet("x", "Stop") ;script stopped by pressing x
  165.  
  166. Call("ReadINI")
  167.  
  168.  If $AddDPS = 0 then
  169.         MsgBox(16, "First Run", "Edit your settings.")
  170.          EndIf
  171.          
  172.  
  173. If $gameAutoStart = 1 Then
  174.    Call("GameAutostart")
  175. Else
  176.    $size = WinGetClientSize("[CLASS:D3 Main Window Class]")
  177.    If $size = 0 Then
  178.         MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  179.         Exit
  180.    EndIf
  181.    $x_ratio = $size[0] / 800
  182.    $y_ratio =  $size[1] / 600
  183. EndIf
  184.    
  185. MainGUI()
  186. Func MainGUI()
  187.  
  188. $frmBot = GUICreate($title &  " -waiting to start", 255, 157, Round(10 * $x_ratio), Round(375 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  189. GUISetBkColor(0xC0C0C0)
  190. $mFile = GUICtrlCreateMenu("File")
  191. $mStart = GUICtrlCreateMenuItem("Start", $mFile)
  192. $mOptions = GUICtrlCreateMenu("Options")
  193. $mSettings = GUICtrlCreateMenuItem("Settings", $mOptions)
  194.  
  195. $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs Per Hour: 0", 2, 0, 260, 24)
  196. GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  197. GUICtrlSetColor(-1, 0xFF0000)
  198.  
  199. $lblStatus = GUICtrlCreateLabel("Status: ", 2, 20, 260, 17)
  200. $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 2, 35, 260, 17)
  201. $lblLast = GUICtrlCreateLabel("Open Cellar Avg: 0s - Closed Cellar Avg: 0s", 2, 50, 260, 17)
  202. $lblCellars = GUICtrlCreateLabel("Cellars Open: 0 (0%) - Cellars Closed: 0 (0%)", 2, 65, 260, 17)
  203. $lblGold = GUICtrlCreateLabel("0 Per Hour - Accumulated Gold: 0", 2, 80, 260, 17)
  204. $lblStartingG=GUICtrlCreateLabel("Staring Gold: 0", 2, 95, 260, 17)
  205. $lblGear= GUICtrlCreateLabel("Legendary: 0 Set: 0 Rare: 0 Magics: 0",2, 110,260,17)
  206.  
  207. GUISetState()
  208.  
  209. While 1
  210.  
  211. $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array
  212.         Switch $aMsg[1] ; check which GUI sent the message
  213.                 Case $frmBot
  214.                         Switch $aMsg[0]
  215.                                 Case $mStart
  216.                                         Call("Begin")
  217.                                 Case $mSettings
  218.                                         GUICtrlSetState($mSettings, $GUI_DISABLE)
  219.                                         SettingsGUI()
  220.  
  221.                                  EndSwitch
  222.                 Case $SettingsGUI
  223.                    Switch $aMsg[0] ; Now check for the messages for $hGUI2
  224.                         Case $cbStashSet
  225.                         If IsChecked($cbStashSet) Then GUICtrlSetState($cbvendorSet,$GUI_UNCHECKED)
  226.                 Case $cbStashLegendary
  227.                         If IsChecked($cbStashLegendary) Then GUICtrlSetState($cbvendorLegendary,$GUI_UNCHECKED)
  228.                 Case $cbStashRare
  229.                         If IsChecked($cbStashRare) Then GUICtrlSetState($cbvendorRare,$GUI_UNCHECKED)
  230.                 Case $cbStashMagic
  231.                         If IsChecked($cbStashMagic) Then GUICtrlSetState($cbvendorMagic,$GUI_UNCHECKED)
  232.                 Case $cbvendorSet
  233.                         If IsChecked($cbvendorSet) Then GUICtrlSetState($cbStashSet,$GUI_UNCHECKED)
  234.                 Case $cbvendorLegendary
  235.                         If IsChecked($cbvendorLegendary) Then GUICtrlSetState($cbStashLegendary,$GUI_UNCHECKED)
  236.                 Case $cbVendorRare
  237.                         If IsChecked($cbvendorRare) Then GUICtrlSetState($cbStashRare,$GUI_UNCHECKED)
  238.                 Case $cbVendorMagic
  239.                         If IsChecked($cbvendorMagic) Then GUICtrlSetState($cbStashMagic,$GUI_UNCHECKED)
  240.                 Case $cbgameAutoStart
  241.                         If IsChecked($cbgameAutoStart) And FileExists(GUICtrlRead($txtgameDiabloIIILoc) & "Diablo III.exe") = 0 Then
  242.                                 GUICtrlSetState($cbgameAutoStart,$GUI_UNCHECKED)
  243.                                 EndIF
  244.                 Case $txtSkill1
  245.                         SkillAlphaNum($txtSkill1,$Skill1,0)
  246.                 Case $txtSkill2
  247.                         SkillAlphaNum($txtSkill2,$Skill2,0)
  248.                 Case $txtSkill3
  249.                         SkillAlphaNum($txtSkill3,$Skill3,0)
  250.                 Case $txtSkill4
  251.                         SkillAlphaNum($txtSkill4,$Skill4,0)
  252.                          
  253.                        
  254.                 Case $btngameDiabloIIILoc
  255.                         $GUIfileSelect = FileSelectFolder ("Diablo III Executable Location","")
  256.                         If Not @Error And FileExists($GUIfileSelect & "\Diablo III.exe") = 0 Then
  257.                                 $GUIwrongLocation = MsgBox ( "6", "Wrong Location", "Select the folder with the Diablo III.exe!")
  258.                                 If $GUIwrongLocation = 2 Or 11 Then
  259.                                         GUISetCheck(0,$cbgameAutoStart)
  260.                                         GUIUpdate($txtgameDiabloIIILoc,$GUIfileSelect)
  261.                                 EndIf
  262.                         ElseIf FileExists($GUIfileSelect & "\Diablo III.exe") = 1 Then
  263.                         GUIUpdate($txtgameDiabloIIILoc,$GUIfileSelect & "\")
  264.                         GUISetCheck(1,$cbgameAutoStart)
  265.                         Endif
  266.  
  267.                         Case $btnSave
  268.                         Call("SaveINI")
  269.                         GUIDelete($SettingsGUI)
  270.                         GUICtrlSetState($mSettings, $GUI_ENABLE)
  271.         EndSwitch
  272.         EndSwitch
  273.         Call("RestartRun")
  274. WEnd
  275.  
  276. EndFunc   ;==>MainGUI
  277.  
  278. Func SettingsGUI()
  279.  
  280. $SettingsGUI = GUICreate($title , 443, 195, Round(10 * $x_ratio), Round(375 * $y_ratio), -1,$WS_EX_TOPMOST, 0)
  281. GUISetIcon(@ScriptDir & "\Setting-icon.ico")
  282. $Settings = GUICtrlCreateTab(0, 8, 441, 185)
  283. GUICtrlSetResizing($Settings, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
  284. $tsSettings = GUICtrlCreateTabItem("Auto Start")
  285. $grpgameAutoStart = GUICtrlCreateGroup("", 4, 33, 273, 121)
  286. $lblgameDiabloIIILoc = GUICtrlCreateLabel("Diablo III Location:", 12, 83, 93, 17)
  287. $txtgameDiabloIIILoc = GUICtrlCreateInput($gameDiabloIIILoc, 116, 81, 105, 21)
  288. $lblgamePassword = GUICtrlCreateLabel("Password:", 12, 116, 53, 17)
  289. $txtgamePassword = GUICtrlCreateInput($gamePassword, 116, 113, 105, 21)
  290. $cbgameAutoStart = GUICtrlCreateCheckbox("Auto Start", 12, 49, 73, 17)
  291. $btngameDiabloIIILoc = GUICtrlCreateButton("Browse", 224, 79, 49, 23, 0)
  292. GUICtrlSetState($txtgameDiabloIIILoc, $GUI_DISABLE)
  293.  
  294. GUICtrlCreateGroup("", -99, -99, 1, 1)
  295. $tsLooting = GUICtrlCreateTabItem("Looting")
  296. $grpLoot = GUICtrlCreateGroup("", 4, 33, 273, 121)
  297. $etlootCustom = GUICtrlCreateEdit("",148, 73, 121, 65)
  298. $cblootSet = GUICtrlCreateCheckbox("Set Items", 12, 49, 81, 17)
  299. $cblootLegendary = GUICtrlCreateCheckbox("Legendary Items", 12, 73, 113, 17)
  300. $cblootRare = GUICtrlCreateCheckbox("Rare Items", 12, 97, 81, 17)
  301. $cblootMagic = GUICtrlCreateCheckbox("Magic Items", 12, 121, 81, 17)
  302. $cblootCustom = GUICtrlCreateCheckbox("Custom Loot", 149, 49, 81, 17)
  303.  
  304. GUICtrlCreateGroup("", -99, -99, 1, 1)
  305. $tsstash = GUICtrlCreateTabItem("Stashing")
  306. $grpStashing = GUICtrlCreateGroup("", 4, 33, 273, 121)
  307. ;~ $cbstashSet = GUICtrlCreateCheckbox("Set Items", 12, 49, 97, 17)
  308. ;~ $cbstashLegendary = GUICtrlCreateCheckbox("Legendary Items", 12, 73, 97, 17)
  309. ;~ $cbstashRare = GUICtrlCreateCheckbox("Rare Items", 12, 97, 97, 17)
  310. ;~ $cbstashMagic = GUICtrlCreateCheckbox("Magic Items", 12, 121, 96, 17)
  311. $cbStashGems = GUICtrlCreateCheckbox("Gems", 12, 49, 97, 17)
  312. $cbStashTomes = GUICtrlCreateCheckbox("Tomes", 12, 73, 97, 17)
  313.  
  314.  
  315. GUICtrlCreateGroup("", -99, -99, 1, 1)
  316. $tsAnalLoot = GUICtrlCreateTabItem("Anal Loot")
  317. $grpAnalLoot = GUICtrlCreateGroup("", 4, 33, 273, 121)
  318. $lblRareStashiLvl = GUICtrlCreateLabel("Rare Stash:", 12, 52, 60, 17)
  319. $lblRareSalvageiLvl = GUICtrlCreateLabel("Rare Salvage:", 12, 76, 72, 17)
  320. $lblRareVendoriLvl = GUICtrlCreateLabel("Rare Vendor:", 12, 100, 67, 17)
  321. $lblMagicStashiLvl = GUICtrlCreateLabel("Magic Stash:", 136, 52, 66, 17)
  322. $lblMagicSalvageiLvl = GUICtrlCreateLabel("Magic Salvage:", 136, 76, 78, 17)
  323. $lblMagicVendoriLvl = GUICtrlCreateLabel("Magic Vendor:", 136, 100, 73, 17)
  324. $txtRareStashiLvl = GUICtrlCreateInput($RareStashiLvl, 88, 49, 33, 21)
  325. $txtRareVendoriLvl = GUICtrlCreateInput($RareVendoriLvl, 88, 97, 33, 21)
  326. $txtRareSalvageiLvl = GUICtrlCreateInput($RareSalvageiLvl, 88, 73, 33, 21)
  327. $txtMagicStashiLvl = GUICtrlCreateInput($MagicStashiLvl, 216, 49, 33, 21)
  328. $txtMagicSalvageiLvl = GUICtrlCreateInput($MagicSalvageiLvl, 216, 73, 33, 21)
  329. $txtMagicVendoriLvl = GUICtrlCreateInput($MagicVendoriLvl, 216, 97, 33, 21)
  330.  
  331. GUICtrlCreateGroup("", -99, -99, 1, 1)
  332. $tsSkills = GUICtrlCreateTabItem("Skills")
  333. $grpSkills = GUICtrlCreateGroup("", 4, 33, 273, 121)
  334. $txtSkill1 = GUICtrlCreateInput($Skill1, 184, 49, 41, 21)
  335. $txtSkill2 = GUICtrlCreateInput($Skill2, 184, 73, 41, 21)
  336. $txtSkill3 = GUICtrlCreateInput($Skill3, 184, 97, 41, 21)
  337. $txtSkill4 = GUICtrlCreateInput($Skill4, 184, 121, 41, 21)
  338. $lblskill1 = GUICtrlCreateLabel("Vault(Rattling Roll):", 12, 52, 139, 17)
  339. $lblSkill2 = GUICtrlCreateLabel("Preperation(Battlescars):", 12, 76, 124, 17)
  340. $lblSkill3 = GUICtrlCreateLabel("Companion(Ferret):", 12, 100, 103, 17)
  341. $lblSkill4 = GUICtrlCreateLabel("Spike Trap(Scatter):", 12, 124, 160, 17)
  342.  
  343. GUICtrlCreateGroup("", -99, -99, 1, 1)
  344. $tsTiming = GUICtrlCreateTabItem("Timing")
  345. $grpTiming = GUICtrlCreateGroup("", 4, 33, 273, 121)
  346. $lbltimingGameLoad = GUICtrlCreateLabel("Game Load:", 12, 52, 62, 17)
  347. $lbltimingTP = GUICtrlCreateLabel("Town Portal:", 12, 76, 64, 17)
  348.  
  349. $lbltimingCellarClick = GUICtrlCreateLabel("Cellar Click:", 12, 124, 59, 17)
  350. $lbltimingAbort = GUICtrlCreateLabel("Abort:", 139, 52, 32, 17)
  351. $lbltimingMiddleDoor = GUICtrlCreateLabel("Middle Door:", 139, 76, 64, 17)
  352. $lbltimingLootRun = GUICtrlCreateLabel("Loot Run:", 139, 100, 51, 17)
  353. $lbltimingLoot = GUICtrlCreateLabel("Loot:", 139, 124, 28, 17)
  354. $txttimingGameLoad = GUICtrlCreateInput("2000", 80, 49, 41, 21)
  355. $txttimingTP = GUICtrlCreateInput("5000", 80, 73, 41, 21)
  356.  
  357. $txttimingCellarClick = GUICtrlCreateInput("750", 80, 121, 41, 21)
  358. $txttimingAbort = GUICtrlCreateInput("255", 206, 49, 41, 21)
  359.  
  360. $txttimingLootRun = GUICtrlCreateInput("300", 206, 97, 41, 21)
  361. $txttimingLoot = GUICtrlCreateInput("800", 206, 121, 41, 21)
  362.  
  363. GUICtrlCreateGroup("", -99, -99, 1, 1)
  364. $tsCellarDetect = GUICtrlCreateTabItem("Cellar Detect")
  365. $grpCellarDetect = GUICtrlCreateGroup("", 4, 33, 273, 121)
  366. $lblCellarDetectX = GUICtrlCreateLabel("X Coordinates:", 12, 52, 73, 17)
  367. $lblCellarDetectY = GUICtrlCreateLabel("Y Coordinates:", 12, 76, 73, 17)
  368. $lblCellarDetectTime = GUICtrlCreateLabel("Check Time:", 12, 100, 64, 17)
  369. $cbCellarDetectScreenShots = GUICtrlCreateCheckbox("Screen Shots", 12, 124, 97, 17)
  370. $txtCellarDetectXCoords = GUICtrlCreateInput("166,137,240,245,121", 96, 49, 169, 21)
  371. GUICtrlSetState($txtCellarDetectXCoords, $GUI_DISABLE)
  372. $txtCellarDetectYCoords = GUICtrlCreateInput("146,145,156,144,135", 96, 73, 169, 21)
  373. GUICtrlSetState($txtCellarDetectYCoords, $GUI_DISABLE)
  374. $txtCellarDetectTime = GUICtrlCreateInput("155", 96, 97, 41, 21)
  375. GUICtrlCreateGroup("", -99, -99, 1, 1)
  376.  
  377. GUICtrlCreateTabItem("")
  378. $btnSave = GUICtrlCreateButton("Save", 352, 160, 75, 25, 0)
  379. $grpAdd = GUICtrlCreateGroup("Additional", 280, 33, 153, 121)
  380. $cbAddGoldOnly = GUICtrlCreateCheckbox("Gold Only", 288, 97, 97, 17)
  381. $txtAddDPS = GUICtrlCreateInput($AddDPS, 376, 49, 49, 21)
  382. $lblAddDPS = GUICtrlCreateLabel("DPS:", 288, 52, 29, 17)
  383.  
  384. GUICtrlCreateGroup("", -99, -99, 1, 1)
  385. GUISetState()
  386.  
  387.  
  388. getCustomKeys()
  389. UpdateGUI()
  390. EndFunc ;===SettingsGUI
  391.  
  392. Func ReadINI()
  393.     getCustomkeys()
  394.         $gameAutoStart = IniRead($settingsINI, "Auto Start", "Auto Start", $gameAutoStart)
  395.         $gameDiabloIIILoc = IniRead($settingsINI, "Auto Start", "Game Location", $gameDiabloIIILoc)
  396.         $gamePassword = IniRead($settingsINI, "Auto Start", "Password", $gamePassword)
  397.         $Skill1 = IniRead($settingsINI, "Skills", "Skill1", $Skill1)
  398.         $Skill2 = IniRead($settingsINI, "Skills", "Skill2", $Skill2)
  399.         $Skill3 = IniRead($settingsINI, "Skills", "Skill3", $Skill3)
  400.         $Skill4 = IniRead($settingsINI, "Skills", "Skill4", $Skill4)
  401.  
  402.         $AddDPS = IniRead($settingsINI, "Additional", "DPS", $AddDPS )
  403.         $LootSet = IniRead($settingsINI, "Looting", "Set", $LootSet)
  404.         $LootLegendary = IniRead($settingsINI, "Looting", "Legendary", $LootLegendary)
  405.         $LootRare = IniRead($settingsINI, "Looting", "Rare", $LootRare)
  406.         $LootMagic = IniRead($settingsINI, "Looting", "Magic", $LootMagic)
  407.         $LootCustom = IniRead($settingsINI, "Looting", "Custom", $LootCustom)
  408.         $LootGoldOnly = IniRead($settingsINI, "Looting", "Gold Only", $LootGoldOnly)
  409.         $StashSet = IniRead($settingsINI, "Stashing", "Set", $StashSet)
  410.         $StashLegendary = IniRead($settingsINI, "Stashing", "Legendary", $StashLegendary)
  411.         $StashRare = IniRead($settingsINI, "Stashing", "Rare", $StashRare)
  412.         $StashMagic = IniRead($settingsINI, "Stashing", "Magic", $StashMagic)
  413.         $StashGems = IniRead($settingsINI, "Stashing", "Gems", $StashGems)
  414.         $StashTomes = IniRead($settingsINI, "Stashing", "Tomes", $StashTomes)
  415.         $VendorSet = IniRead($settingsINI, "Vendoring", "Set", $VendorSet)
  416.         $VendorLegendary = IniRead($settingsINI, "Vendoring", "Legendary", $VendorLegendary)
  417.         $VendorRare = IniRead($settingsINI, "Vendoring", "Rare", $VendorRare)
  418.         $VendorMagic = IniRead($settingsINI, "Vendoring", "Magic", $VendorMagic)
  419.         $VendorAll  = IniRead($settingsINI, "Vendoring", "All Items", $VendorAll)
  420.         $vendorRows = IniRead($settingsINI, "Vendoring", "All-Rows", $vendorRows)
  421.         $vendorColumns = IniRead($settingsINI, "Vendoring", "All-Columns", $vendorColumns)
  422.        
  423.         $timingGameLoad = IniRead($SettingsINI, "Timing", "Game Load", $timingGameLoad)
  424.  
  425.     $timingTP = Iniread($SettingsINI, "Timing", "Town Portal", $timingTP)
  426.    
  427.         $timingCellarClick = Iniread($SettingsINI, "Timing", "Cellar Click", $timingCellarClick)
  428.  
  429.     $timingLootRun = Iniread($SettingsINI, "Timing", "Loot Run", $timingLootRun)
  430.     $timingLoot = Iniread($SettingsINI, "Timing", "Loot", $timingLoot)
  431.     $timingAbort = Iniread($SettingsINI, "Timing", "Abort", $timingAbort)
  432.         $ScreenShot = InIread($SettingsINI, "Cellar Detect", "Screen Shot", $ScreenShot)
  433.         $RareStashilvl=IniRead($settingsINI, "Anal Loot", "Stash Rare", $RareStashiLvl)
  434.     $RareSalvageilvl=IniRead($settingsINI, "Anal Loot", "Salvage Rare", $RareSalvageilvl)
  435.     $RareVendoriLvl=IniRead($settingsINI, "Anal Loot", "Vendor Rare", $RareVendoriLvl)
  436.     $MagicStashilvl=IniRead($settingsINI, "Anal Loot", "Stash Magic", $MagicStashilvl)
  437.     $MagicSalvageilvl=IniRead($settingsINI, "Anal Loot", "Salvage Magic", $MagicSalvageilvl)
  438.     $MagicVendorilvl=IniRead($settingsINI, "Anal Loot", "Vendor Magic", $MagicVendorilvl)
  439. EndFunc   ;==>ReadINI
  440.  
  441. Func UpdateGUI()
  442. ;GUI Update
  443.  
  444. ;Loot
  445. GUISetCheck($gameAutoStart,$cbgameAutoStart)
  446. GUISetCheck($LootSet,$cbLootSet)
  447. GUISetCheck($LootLegendary,$cbLootLegendary)
  448. GUISetCheck($LootRare,$cbLootRare)
  449. GUISetCheck($LootMagic,$cbLootMagic)
  450. GUISetCheck($LootCustom,$cbLootCustom)
  451. GUISetCheck($LootGoldOnly,$cbAddGoldOnly)
  452. ;=============================================
  453.  
  454. ;Stash
  455. GUISetCheck($StashSet,$cbStashSet)
  456. GUISetCheck($StashLegendary,$cbStashLegendary)
  457. GUISetCheck($StashRare,$cbStashRare)
  458. GUISetCheck($StashMagic,$cbStashMagic)
  459. GUISetCheck($StashGems,$cbStashGems)
  460. GUISetCheck($StashTomes,$cbStashTomes)
  461. ;=============================================
  462.  
  463. ;Vendor
  464. If Not IsChecked($cbStashSet) Then GUISetCheck($VendorSet,$cbvendorSet)
  465. If Not IsChecked($cbStashLegendary) Then GUISetCheck($VendorLegendary,$cbvendorLegendary)
  466. If Not IsChecked($cbStashRare) Then GUISetCheck($VendorRare,$cbVendorRare)
  467. If Not IsChecked($cbStashMagic) Then GUISetCheck($VendorMagic,$cbVendorMagic)
  468. GUISetCheck($VendorAll,$cbVendorAll)
  469. ;=============================================
  470.  
  471. ;Cellar Detect
  472. GUISetCheck($ScreenShot,$cbCellarDetectScreenShots)
  473. ;=============================================
  474.  
  475.  
  476. ;Misc
  477. ;Skills
  478. SkillAlphaNum($txtSkill1,$Skill1,1)
  479. SkillAlphaNum($txtSkill2,$Skill2,1)
  480. SkillAlphaNum($txtSkill3,$Skill3,1)
  481. SkillAlphaNum($txtSkill4,$Skill4,1)
  482.  
  483. ;AutoStart
  484. GUIUpdate($txtgamePassword,$gamePassword)
  485. GUIUpdate($txtgameDiabloIIILoc,$gameDiabloIIILoc)
  486.  
  487. ;Vendoring
  488. GUIUpdate($cmbVendorColumns,$vendorColumns)
  489. GUIUpdate($cmbvendorRows,$vendorRows)
  490.  
  491. ;Timing
  492. GUIUpdate($txttimingGameLoad, $timingGameLoad)
  493.  
  494.  
  495.  
  496. GUIUpdate($txttimingTP, $timingTP)
  497. GUIUpdate($txttimingCellarClick, $timingCellarClick)
  498.  
  499.  
  500.  
  501.  
  502. GUIUpdate($txttimingLootRun, $timingLootRun)
  503. GUIUpdate($txttimingLoot, $timingLoot)
  504. GUIUpdate($txttimingAbort, $timingAbort)
  505.  
  506. ;anal loot
  507. GUIUpdate($txtRareStashiLvl,$RareStashiLvl)
  508. GUIUpdate($txtRareSalvageiLvl,$RareSalvageiLvl)
  509. GUIUpdate($txtRareVendoriLvl,$RareVendoriLvl)
  510. GUIUpdate($txtMagicStashiLvl,$MagicStashiLvl)
  511. GUIUpdate($txtMagicSalvageiLvl,$MagicSalvageiLvl)
  512. GUIUpdate($txtMagicVendoriLvl,$MagicVendoriLvl)
  513. ;=============================================
  514.  
  515. ;Additional
  516. GUIUpdate($txtAddDPS, $AddDPS)
  517. ;=============================================
  518. EndFunc
  519.  
  520. Func SaveINI()
  521.         FileDelete($settingsINI)
  522.         IniWrite($settingsINI, "Auto Start", "Auto Start", ConvertFlag($cbgameAutoStart))
  523.         IniWrite($settingsINI, "Auto Start", "Game Location", GUICtrlRead($txtgameDiabloIIILoc))
  524.         IniWrite($settingsINI, "Auto Start", "Password", GUICtrlRead($txtgamePassword))
  525.         IniWrite($settingsINI, "Auto Start", "Task Manager Executable Name", $gameExecutable)
  526.         IniWrite($settingsINI, "Skills", "Skill1", GUICtrlRead($txtSkill1))
  527.         IniWrite($settingsINI, "Skills", "Skill2", GUICtrlRead($txtSkill2))
  528.         IniWrite($settingsINI, "Skills", "Skill3", GUICtrlRead($txtSkill3))
  529.         IniWrite($settingsINI, "Skills", "Skill4", GUICtrlRead($txtSkill4))
  530.         IniWrite($settingsINI, "Additional", "DPS", GUICtrlRead($txtAddDPS))
  531.  
  532.  
  533.  
  534.         IniWrite($settingsINI, "Looting", "Set", ConvertFlag($cbLootSet))
  535.         IniWrite($settingsINI, "Looting", "Legendary", ConvertFlag($cbLootLegendary))
  536.         IniWrite($settingsINI, "Looting", "Rare", ConvertFlag($cbLootRare))
  537.         IniWrite($settingsINI, "Looting", "Magic", ConvertFlag($cbLootMagic))
  538.         IniWrite($settingsINI, "Looting", "Custom", ConvertFlag($cbLootCustom))
  539.         IniWrite($settingsINI, "Looting", "Gold Only", ConvertFlag($cbAddGoldOnly))
  540.         IniWrite($settingsINI, "Stashing", "Set", ConvertFlag($cbStashSet))
  541.         IniWrite($settingsINI, "Stashing", "Legendary", ConvertFlag($cbStashLegendary))
  542.         IniWrite($settingsINI, "Stashing", "Rare", ConvertFlag($cbStashRare))
  543.         IniWrite($settingsINI, "Stashing", "Magic", ConvertFlag($cbStashMagic))
  544.     IniWrite($settingsINI, "Stashing", "Gems",  ConvertFlag($cbStashGems))
  545.         IniWrite($settingsINI, "Stashing", "Tomes",  ConvertFlag($cbStashTomes))
  546.         IniWrite($settingsINI, "Vendoring", "Set", ConvertFlag($cbVendorSet))
  547.         IniWrite($settingsINI, "Vendoring", "Legendary", ConvertFlag($cbVendorLegendary))
  548.         IniWrite($settingsINI, "Vendoring", "Rare", ConvertFlag($cbVendorRare))
  549.         IniWrite($settingsINI, "Vendoring", "Magic", ConvertFlag($cbVendorMagic))
  550.         IniWrite($settingsINI, "Vendoring", "All Items", ConvertFlag($cbVendorAll))
  551.         IniWrite($settingsINI, "Vendoring", "All-Rows", GUICtrlRead($cmbvendorRows))
  552.         IniWrite($settingsINI, "Vendoring", "All-Columns", GUICtrlRead($cmbVendorColumns))
  553.  
  554.         IniWrite($settingsINI, "Timing", "Game Load", GUICtrlRead($txttimingGameLoad))
  555.  
  556.  
  557.  
  558.         IniWrite($settingsINI, "Timing", "Town Portal", GUICtrlRead($txttimingTP))
  559.         IniWrite($settingsINI, "Timing", "Cellar Click", GUICtrlRead($txttimingCellarClick))
  560.  
  561.  
  562.         IniWrite($settingsINI, "Timing", "Loot Run", GUICtrlRead($txttimingLootRun))
  563.         IniWrite($settingsINI, "Timing", "Loot", GUICtrlRead($txttimingLoot))
  564.         IniWrite($settingsINI, "Timing", "Abort", GUICtrlRead($txttimingAbort))
  565.         IniWrite($SettingsINI, "Cellar Detect", "Screen Shot", ConvertFlag($cbCellarDetectScreenShots))
  566.     IniWrite($settingsINI, "Anal Loot", "Stash Rare", GUICtrlRead($txtRareStashilvl))
  567.     IniWrite($settingsINI, "Anal Loot", "Salvage Rare", GUICtrlRead($txtRareSalvageilvl))
  568.     IniWrite($settingsINI, "Anal Loot", "Vendor Rare", GUICtrlRead($txtRareVendoriLvl))
  569.     IniWrite($settingsINI, "Anal Loot", "Stash Magic", GUICtrlRead($txtMagicStashilvl))
  570.     IniWrite($settingsINI, "Anal Loot", "Salvage Magic", GUICtrlRead($txtMagicSalvageilvl))
  571.     IniWrite($settingsINI, "Anal Loot", "Vendor Magic", GUICtrlRead($txtMagicVendorilvl))
  572.      saveCustomKeys()
  573.         Call("ReadINI")
  574.         $StashLoot = $StashMagic  + $StashRare + $StashLegendary + $Stashset + $StashGems + $StashTomes
  575.     $VendorLoot = $VendorMagic + $VendorRare + $VendorLegendary + $VendorSet +  $VendorAll
  576. EndFunc   ;==>SaveINI
  577.  
  578.  
  579.  
  580. Func GUISetCheck($Flag,$CheckBox)
  581.         If $Flag = 0 Then
  582.                 GUICtrlSetState($CheckBox, $GUI_UNCHECKED)
  583.         ElseIf $Flag = 1 Then
  584.                 GUICtrlSetState($CheckBox, $GUI_CHECKED)
  585.         EndIf
  586. EndFunc
  587.  
  588. Func ConvertFlag($CheckBox)
  589.         If GUICtrlRead($Checkbox) = 4 Or GUICtrlRead($Checkbox) = 68 Then
  590.                 Return 0
  591.         Else
  592.                 Return 1
  593.         EndIf
  594. EndFunc
  595.  
  596. Func GUIUpdate($CheckBox,$Value)
  597.         GUICtrlSetData($CheckBox, $Value)
  598. EndFunc
  599.  
  600. Func saveCustomKeys()
  601.         $string = GUICtrlRead($etlootCustom)
  602.         If Not $string = "" Then
  603.                 $temp = StringReplace($string, @CRLF, " ")
  604.                 $temp = StringStripWS($temp, 7)
  605.                 $arr = StringSplit($temp, " ")
  606.  
  607.                 For $a = 1 To $arr[0]
  608.                         $tempLoc = StringSplit($arr[$a],"|")
  609.                         If FileExists($pngLoc & $tempLoc[1] & ".png") Then
  610.                         IniWrite($settingsINI, "Custom Items", "Key" & $a , $arr[$a])
  611.                         EndIf
  612.                 Next
  613.                 Return 1
  614.          Else
  615.    If $totalItems < 1 Then
  616.                 $LootCustom = "0"
  617.                 GUICtrlSetState($cblootCustom, $GUI_UNCHECKED)
  618.                 EndIf
  619.                 Return @error
  620.         EndIf
  621. EndFunc
  622.  
  623. Func getCustomKeys()
  624.         $string = ""
  625.         $var = IniReadSection($settingsINI, "Custom Items")
  626.         If Not @error Then
  627.                 $totalItems = $var[0][0]
  628.                 If $totalItems > 0 Then
  629.                         ReDim $pick[$totalItems]
  630.                 EndIf
  631.                 For $a = 1 To $totalItems
  632.                         $pick[$a-1] = $var[$a][1]
  633.                         $string &= $pick[$a-1] & @CRLF
  634.                 Next
  635.         Else
  636.                 $totalItems = 0
  637.          EndIf
  638.      If $totalItems < 1 Then
  639.                 $LootCustom = "0"
  640.                 GUICtrlSetState($cblootCustom, $GUI_UNCHECKED)
  641.          EndIf
  642.         GUICtrlSetData($etlootCustom, $string)
  643. EndFunc
  644.  
  645. Func IsChecked($control)
  646.  Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
  647. EndFunc
  648.  
  649. Func SkillAlphaNum($txtSkill,$Skill,$UpdateFlag)
  650. If $UpdateFlag = 0 Then $temp = GUICtrlRead($txtSkill)
  651. If $UpdateFlag = 1 Then $temp = $Skill
  652. $temp = StringStripWS($temp, 8)
  653. If StringLen($temp) = 1 Then
  654.         If StringRegExp($temp,"[a-zA-Z0-9]") Then
  655.                 GUICtrlSetData($txtSkill, $temp)
  656.                         Else
  657.                 GUICtrlSetData($txtSkill,"1")
  658.         EndIf
  659. Else
  660.         $temp = StringTrimRight($temp, StringLen($temp)-1)
  661.         GUICtrlSetData($txtSkill, $temp)
  662.         SkillAlphaNum($txtSkill,$Skill,$UpdateFlag)
  663.         EndIf
  664. EndFunc
  665.  
  666. Func RestartRun()
  667.         If ($Go) Then
  668.                 $i = 0
  669.                 WinSetTitle($title, "", $title &  " - Running")
  670.                
  671.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(300, 600) * $y_ratio), 1) ;Moves mouse out of the way
  672.                 ;Checks if the player is Dead/Logout/Window, then if in Main Menu, etc.
  673.                 If CheckDead() Then
  674.                         Return
  675.                 ElseIf CheckFor("ExitGame", "", Round(370 * $x_ratio), Round(232 * $y_ratio), Round(431 * $x_ratio), Round(243 * $y_ratio), 0.5, 140) Then
  676.                         GUICtrlSetData($lblStatus, "Status: Exit window up")
  677.                         MouseClick("left", Round(461 * $x_ratio), Round(351 * $y_ratio))
  678.                         Sleep(Random(100, 105))
  679.                         Send("{SPACE}")
  680.                         Return
  681.                 ElseIf CheckFor("MainMenu", "", Round(86 * $x_ratio),Round(225 * $y_ratio) ,Round(174 * $x_ratio),Round(240  * $y_ratio)) Then
  682.                         GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs Per Hour: " &  Round($RunsPerHour))
  683.                         GUICtrlSetData($lblLocation, "Location: Main Menu")
  684.                         GUICtrlSetData($lblStatus, "Status: Starting Game")
  685.                         WinActivate("Diablo III")
  686.                         RandClick("left", Round(128* $x_ratio), Round(232 * $y_ratio), 10, 20, 1, 1) ;Random Click on the resume button
  687.                         Sleep($timingGameLoad)
  688.                  ElseIf CheckFor("Road", "Area")  Then
  689.                         Call("TownPortal")
  690.                         Call("LeaveGame")
  691.                         Return
  692.                 ElseIf CheckFor("OldRuins", "Area") Or CheckFor("NewTristram", "Area") Or CheckFor("DankCellar", "Area") Then
  693.                         Call("TownPortal")
  694.                         Call("LeaveGame")
  695.                         Return
  696.             ElseIf CheckFor("Disconnect", "", Round(338 * $x_ratio), Round(230* $y_ratio), Round(461 * $x_ratio), Round(242 * $y_ratio), 1, 140) Then
  697.                         GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
  698.                         MouseClick("left", Round(401 * $x_ratio), Round(351 * $y_ratio),1)
  699.                         Sleep(Random(100, 105))
  700.  
  701.                         Send("{SPACE}")
  702.                        
  703.                         Return
  704.                 ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  705.                         MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio),1)
  706.                         $rand = Random(40000, 80000)
  707.                         GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
  708.                         Sleep($rand)
  709.                         Send("{SPACE}")
  710.                         Return
  711.                                  
  712.            ElseIf CheckFor("connection", "", Round(338 * $x_ratio), Round(230* $y_ratio), Round(461 * $x_ratio), Round(242 * $y_ratio), 1, 140) Then
  713.                         GUICtrlSetData($lblStatus, "Status: Lost Connection window up")
  714.                         MouseClick("left", Round(401 * $x_ratio), Round(351 * $y_ratio),1)
  715.                         Sleep(Random(100, 105))
  716.                         Send("{SPACE}")
  717.                
  718.                         Return
  719.                        
  720. else
  721.     GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  722.                        
  723.                         Return
  724.                  EndIf
  725.                  
  726.                 ;Make sure we are in the right area before beginning run
  727.                 If CheckFor("OldRuins", "Area") Then
  728.                         $rt = TimerInit()
  729.                         $run += 1
  730.                         ;Call("StartScreenShot")
  731.                         GUICtrlSetData($lblLocation, "Location: Old Ruins")
  732.                         If $StartingGold = 0 Then Call("GoldPerHour")
  733.                         ;Start Run
  734.                 MouseMove(Round(262* $x_ratio ), Round(220* $y_ratio )) ;vault to stairs
  735.                         Send($skill1)
  736.                         sleep(random(500,520))
  737.                         MouseMove(Round(0* $x_ratio ), Round(224* $y_ratio )) ;vault1
  738.                         Send($Skill1)
  739.                         sleep(random(500,520))
  740.                         MouseMove( Round(0 * $x_ratio), Round(224* $y_ratio )) ;vault2
  741.                         Send($Skill1)
  742.                         sleep(random(500,520))
  743.                         MouseMove( Round(0 * $x_ratio), Round(224* $y_ratio )) ;vault3
  744.                         Send($Skill1)
  745.                         sleep(random(50,75))
  746.                         MouseMove( Round(55 * $x_ratio), Round(224* $y_ratio )) ;vault4
  747.                         Send($Skill4) ;scatter to vaulting area
  748.                         sleep(random(500,520))
  749.                         Send($skill2) ;preperation to heal/regen disc
  750.                         sleep(random(250,270))
  751.                         Send($skill1) ;vault5
  752.                         sleep(random(500,520))
  753.                        
  754.                        
  755.  
  756.  
  757.  
  758.  
  759.  
  760.                         If FindCellar() = 1 Then
  761.                                 If CheckDead() Then
  762.                                   Return
  763.                            EndIf
  764.  
  765.                         GUICtrlSetData($lblStatus, "Status: Cellar - Found")  
  766.                         MouseClick("left",Round($cellarCoordx[$CellCoord] * $x_ratio),Round($cellarCoordy[$CellCoord] * $y_ratio),1)
  767.                         sleep($timingCellarClick)
  768.                         Else ;ABORT RUN
  769.                             ;FileMove(@ScriptDir & "\shots\Start\OpenStartShot"& $run & ".bmp", @ScriptDir & "\shots\Start\ClosedStartShot"& $run & ".bmp")
  770.                                 GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  771.                                 Sleep(Random(300, 320))
  772.                                 MouseMove(Round(396 * $x_ratio),Round(526 * $y_ratio))
  773.                                 Send("{SHIFTDOWN}")
  774.                              MouseDown("right") ;ATTACK
  775.                             Sleep(Random(100, 120))
  776.                             MouseUp("right")
  777.                             Send("{SHIFTUP}")
  778.                             Sleep(Random(50, 78))
  779.                                 send($Skill1)
  780.                                 Sleep(Random(300, 312))
  781.                                 send($Skill4)
  782.                                 Sleep(Random(200, 215))
  783.                                 randMove(Round(396 * $x_ratio),Round(526 * $y_ratio))
  784.                                 Sleep(Random(50, 61))
  785.                             send($Skill4)
  786.                                 Sleep(Random(100, 115))
  787.                             randclick("middle", Round(437* $x_ratio),Round(349 * $y_ratio) , 1, 1)
  788.                             Sleep(Random(200, 215))
  789.                             randMove(Round(362 * $x_ratio),Round(196 * $y_ratio))
  790.                             send($Skill4)
  791.                                 Sleep(Random(300, 350))
  792.  
  793.  
  794.  
  795.  
  796.                                 Call("TownPortal")
  797.                                 If Not CheckDead() Then
  798.                                    Call("ClosedCellar")
  799.                                         Call("LeaveGame")
  800.                                 EndIf
  801.                                 Return
  802.                         EndIf
  803.                 Else
  804.                         Call("TownPortal")
  805.                         If Not CheckDead() Then
  806.                            Call("ClosedCellar")
  807.                                 Call("LeaveGame")
  808.                         EndIf
  809.                         Return
  810.                 EndIf
  811.  
  812.                 ;Checks that the player is in the Dank Cellar
  813.                 If CheckFor("DankCellar", "Area") Then
  814.                         GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  815.                         Sleep(Random(500, 550))
  816.                         MouseMove(round(0 * $x_ratio),Round(500 * $y_ratio)) ;moves cursor to doorway leading to rare inside cellar
  817.                         Sleep(Random(50, 60))
  818.                         send($skill1);vaults to doorway leading to rare inside cellar
  819.                         sleep(random(500,520))
  820.  
  821.                         randclick("middle", Round(200 * $x_ratio),Round(228 * $y_ratio) , 1, 1) ;moves to doorway inside doorway
  822. Sleep(Random(375, 383))
  823. MouseMove(Round(213* $x_ratio),Round(147 * $y_ratio)) ;hovers over the rare Sarkoth
  824. Send($Skill4); bombs
  825. Sleep(Random(150, 200))
  826. Send($Skill3) ;cast ferret for looting
  827. Sleep(Random(100, 110))
  828. Send("{SHIFTDOWN}")
  829. MouseDown("right") ;cast cluster arrow 1x
  830. Sleep(Random(600, 650));cast cluster arrow
  831. MouseUp("right");end cluster arrow should shoot 2x
  832. MouseDown("left") ;cast hungering arrow till mobs are dead
  833. sleep($attackTime/2)
  834. mousemove(Round(109* $x_ratio),Round(157 * $y_ratio))
  835. sleep($attackTime/2)
  836.                         mousemove(Round(109* $x_ratio),Round(157 * $y_ratio))
  837.  
  838.                         sleep($attackTime/2)
  839.                         MouseUp("left") ;stop cast hungering arrow
  840.  
  841.                         Sleep(Random(150, 156))
  842.                         Send("{SHIFTUP}")
  843.                         Sleep(Random(100, 110))
  844.                         send($Skill1) ;vault to loot
  845.                         Sleep(Random(400, 510))
  846.  
  847.                         sleep($timingLootRun)
  848.  
  849.                         If $LootGoldOnly = 0 then
  850.                         GUICtrlSetData($lblStatus, "Status: Looting")
  851.                                 Call("Loot")
  852.                         EndIf                  
  853.                         Sleep(Random(100, 110))
  854.  
  855.  
  856.                         Call("TownPortal")
  857.                  Else
  858.                         $countMissedCellar += 1
  859.                            Call("CellarScreenShot")
  860.                     MouseMove(Round(396 * $x_ratio),Round(526 * $y_ratio))
  861.  
  862.  
  863.                         Send("{SHIFTDOWN}")
  864.                         MouseDown("right") ;ATTACK
  865.                         Sleep(Random(100, 120))
  866.                         MouseUp("right")
  867.                         Send("{SHIFTUP}")
  868.                         Sleep(Random(50, 78))
  869.                         send($Skill1)
  870.                         Sleep(Random(300, 312))
  871.                         send($Skill4)
  872.                         Sleep(Random(200, 215))
  873.                         randMove(Round(396 * $x_ratio),Round(526 * $y_ratio))
  874.                         Sleep(Random(50, 61))
  875.                         send($Skill4)
  876.                         Sleep(Random(100, 115))
  877.  
  878.  
  879.  
  880.  
  881.  
  882.                         Call("TownPortal")
  883.                         If Not CheckDead() Then
  884.                             Call("ClosedCellar")
  885.                                 Call("LeaveGame")
  886.                         EndIf
  887.                         Return
  888.                 EndIf
  889.                 ;After successful run
  890.                 If Not CheckDead() Then
  891.                         Sleep(Random(300, 305))
  892.                         If $mLootIn = 1 And CheckFor("NewTristram", "Area") Then ;If its time to manage loot and we are in town
  893.                                 If $LootGoldOnly = 0 Then
  894.                                   If $StashLoot >= 1 Then
  895.                                         Call("StashLoot")
  896.                                   EndIF
  897.                                 EndIF          
  898.  
  899.  
  900.                         ElseIf Not CheckFor("NewTristram", "Area") Then
  901.                         GUICtrlSetData($lblStatus, "Status: Skipping vendor, not in New Tristram")
  902.                                 Sleep(Random(3000, 3005))
  903.                         ElseIf $mLootIn = 1 Then
  904.                                 $mLootIn = 0
  905.                         EndIf
  906.        
  907.  
  908.                         If Not CheckDead() Then
  909.                             Call("OpenCellar")
  910.                                 Call("LeaveGame")
  911.                         EndIf
  912.                         Return
  913.                 Else
  914.                         Return
  915.                  EndIf
  916.           Else
  917.                  Return 0
  918.          EndIf
  919. EndFunc   ;==>RestartRun
  920.  
  921. Func CheckDead()
  922.         $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
  923.         If Not @error Then
  924.         GUICtrlSetData($lblStatus, "Status: Logging out")
  925.                 Sleep(11000)
  926.                 Sleep($timingGameLoad)
  927.                 Return 1
  928.         EndIf
  929.  
  930.         $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
  931.         If Not @error Then
  932. GUICtrlSetData($lblStatus, "Status: Open Window")
  933.         Sleep(200)
  934.                 Send("{SPACE}") ;close any open windows
  935.                 Return 1
  936.         EndIf  
  937.  
  938.  
  939.  
  940.         $YouHaveDied = PixelSearch(Round(285* $x_ratio), Round(491* $y_ratio), Round(308* $x_ratio), Round(508* $y_ratio), 0x2C0100,2) ; checks for white text "YOU HAVE DIED"
  941.         If Not @error Then
  942.                 GUICtrlSetData($lblStatus, "Status: Dead")
  943.                 $deathCount += 1
  944.                 Call("LeaveGame")
  945.                 Sleep(Random(11000, 11005)
  946.                
  947.                 Sleep($timingGameLoad)
  948.                 Return 1
  949.         Else
  950.                 Return 0
  951.         EndIf
  952. EndFunc   ;==>CheckDead
  953.  
  954.  
  955. Func CheckRepair()
  956.         $RepairArea = PixelSearch(Round(552 * $x_ratio),Round(6* $y_ratio),Round(589 * $x_ratio),Round(51 * $y_ratio), $yellow)
  957.         If Not @error Then
  958.                 Call("DoRepair")
  959.         EndIf
  960.         $RepairAreaRed = PixelSearch(Round(552 * $x_ratio),Round(6 * $y_ratio),Round(589 * $x_ratio),Round(51 * $y_ratio), $red)
  961.         If Not @error Then
  962.                 Call("DoRepair")
  963.         EndIf
  964. EndFunc   ;==>CheckRepair
  965.  
  966. Func DoRepair()
  967. Sleep(Random(2500, 2550))
  968.  
  969. $repairCount += 1
  970.         If CheckDead() Then
  971.                 Return
  972.         EndIf
  973.         If CheckFor("NewTristram", "Area") Then
  974.         RandClick1("middle", Round(755 * $x_ratio),Round(29 * $y_ratio), 1, 1) ;step1
  975.                 Sleep(Random(3500, 3550))
  976.  
  977.  
  978.  
  979.                 RandClick1("left", Round(405 * $x_ratio),Round(123 * $y_ratio), 1, 1) ;vendor
  980.                 Sleep(Random(2100,2110))
  981.  
  982.             RandClick("left", Round(282 * $x_ratio),Round(267 * $y_ratio), 1, 1) ;button to open up repair menu
  983.                 Sleep(Random(400, 412))
  984.                 RandClick("left", Round(142 * $x_ratio),Round(295 * $y_ratio), 1, 1) ;button to pay for repairs
  985.                 Sleep(Random(200, 212))
  986.                 Send("{Escape}")
  987.         EndIf
  988. EndFunc   ;==>DoRepair
  989.  
  990.  
  991. Func ClosedCellar()
  992.            $closedcellarCount += 1
  993.            $srt = TimerDiff($rt)
  994.            $ClosedCellarSec = $ClosedCellarSec + Round($srt / 1000, 2)
  995.            $ClosedCellarAvg = $ClosedCellarSec / $closedcellarCount
  996.         EndFunc
  997.        
  998. Func OpenCellar()
  999.            $cellarCount += 1
  1000.            $srt = TimerDiff($rt)
  1001.            $OpenCellarSec = $OpenCellarSec + Round($srt / 1000, 2)
  1002.            $OpenCellarAvg = $OpenCellarSec / $cellarCount
  1003.    EndFunc
  1004.  
  1005. Func CalcTime()
  1006.         $trt = TimerDiff($t)
  1007.         $total = Round((($trt / 1000) / 60) / 60, 4)
  1008.         ;Total runtime calculation.
  1009.         $hours = Floor((($trt / 1000) / 60) / 60)
  1010.         $minutes = (($trt / 1000) / 60)
  1011.         ;trim minutes if runtime is more then 1 hour.
  1012.         If $minutes > 60 Then
  1013.                 While $minutes > 60
  1014.                         $minutes -= 60
  1015.                 WEnd
  1016.          EndIf
  1017.          $RunsPerHour = $Run / ($trt / 1000) * 3600
  1018.          $repairCountPercent = $repairCount / $run
  1019.      $deathsCountPercent = $deathCount / $run
  1020.      $cellarCountPercent = $cellarCount /  $run
  1021.      $closedCellarCountPercent = ($run - $cellarCount) / $run
  1022.          $MissedCellarCountPercent = $countMissedCellar / $run
  1023.          GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, " & Ceiling($minutes) & " minutes")
  1024.          GUICtrlSetData($lblLast, "Open Cellar Avg: " & Round($OpenCellarAvg,1) & "s - Closed Cellar Avg: " & Round($ClosedCellarAvg,1) & "s")
  1025.          GUICtrlSetData($lblCellars, "Cellars Open: " & $cellarCount & " (" & Round($cellarCountPercent * 100) & "%)" &  " - Cellars Closed: " & $run - $cellarCount & " (" & Round($closedCellarCountPercent * 100,.00) & "%)")
  1026.          GUICtrlSetData($lblStats, "Deaths: " & $deathCount &  " (" & Round($deathsCountPercent * 100) & "%" & ")" &  " - Missed Cellars: " & $countMissedCellar & " (" & Round($MissedCellarCountPercent * 100) & "%)")
  1027. EndFunc   ;==>CalcTime
  1028.  
  1029. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 6, $tolerance = 140)
  1030.         If $type = "Area" Then
  1031.                 $startX = 650 * $x_ratio
  1032.                 $startY = 0 * $y_ratio
  1033.                 $endX = 800 * $x_ratio
  1034.                 $endY = 50 * $y_ratio
  1035.                 $seconds = 2.5
  1036.         EndIf
  1037.         $c = 0
  1038.         $string = $pngLoc & $img & ".png"
  1039.         Do
  1040.                 $c += 1
  1041.                 Sleep(Random(100, 105))
  1042.                
  1043.                 If $c > ($seconds * 10) Then ;Make sure we never get stuck here for infinity.
  1044.                         If $type = "Area" Then
  1045.                                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  1046.                         EndIf
  1047.                         Return 0
  1048.                 EndIf
  1049.          Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  1050.         Return 1
  1051. EndFunc   ;==>CheckFor
  1052.  
  1053.  
  1054. Func Loot()
  1055.         Sleep($timingLoot)
  1056.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(300, 600) * $y_ratio), 3) ;Moves mouse out of the way
  1057.         If $LootSet == 1 Then
  1058.                 $SetCount += LootGear(0x02CE01)        
  1059.         EndIf
  1060.        
  1061.         If $LootLegendary == 1 Then
  1062.                 $LegendaryCount += LootGear(0xBF642F, 0)
  1063.         EndIf
  1064.        
  1065.         If $LootRare == 1 Then
  1066.                 $RareCount += LootGear(0xBBBB00)
  1067.         EndIf
  1068.        
  1069.         If $LootCustom == 1 Then
  1070.                 Call("LootCustom")
  1071.         EndIf
  1072.        
  1073.         If $LootMagic == 1 Then
  1074.                 $MagicCount += LootGear(0x6969FF)
  1075.         EndIf
  1076.         call("Showloot")
  1077. EndFunc   ;==>Loot
  1078.  
  1079.  Func LootCustom()
  1080.         $count = 0
  1081.         $gX = 0
  1082.         $gY = 0
  1083.         For $i = 0 To ($totalItems - 1)
  1084.                 $array = StringSplit($pick[$i], "|")
  1085.                 $file = $array[1]
  1086.                 $accuracy = $array[2]
  1087.                 $urlString = $pngLoc & $file & ".png"
  1088.                 While _ImageSearchArea($urlString, 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, $accuracy)
  1089.                         $count += 1
  1090.                         MouseClick("left", $gX, $gY, 1, 3)
  1091.                         Sleep(Random(50, 55))
  1092.  
  1093.                         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(300, 600) * $y_ratio), 3) ;Moves mouse out of the way
  1094.                         Sleep($timingLoot)
  1095.                         If $count >= 15 Then
  1096.                         ExitLoop
  1097.                 EndIf
  1098.                 WEnd
  1099.         Next
  1100. EndFunc   ;==>LootCustom
  1101.  
  1102. Func LootGear($color, $tolerance = 3)
  1103.         $count = 0
  1104.         $Loot = PixelSearch(Round(0 * $x_ratio), Round(75*$y_ratio), Round(800 * $x_ratio), Round(400 * $y_ratio), $color, $tolerance)
  1105.         If Not @error Then
  1106.                 While Not @error
  1107.                         $count += 1
  1108.                         MouseClick('left', $Loot[0], $Loot[1], 1, 3)
  1109.                         Sleep(Random(50, 55))
  1110.  
  1111.                         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(300, 600) * $y_ratio), 1) ;Moves mouse out of the way
  1112.                         sleep($timingLoot)
  1113.                         If $count >= 15 Then
  1114.                         ExitLoop
  1115.                 EndIf
  1116.                         $Loot = PixelSearch(Round(0 * $x_ratio), Round(75*$y_ratio), Round(800 * $x_ratio), Round(400 * $y_ratio), $color, $tolerance)
  1117.                 WEnd
  1118.         EndIf
  1119.         Return $count
  1120.  
  1121.  EndFunc   ;==>LootGear
  1122.  
  1123.  Func CheckFullInventory()
  1124.  
  1125.  If Not _ImageSearchArea($pngLoc &  "FullInventory.png", 1, Round(518* $x_ratio),Round(329 * $y_ratio), Round(788 * $y_ratio),Round(484 * $x_ratio), $gX, $gY, 140) Then
  1126.           $mLootIn = 1
  1127.           If $StashLoot = 0 And $VendorLoot = 0 Then
  1128.                  $LootGoldOnly = 1
  1129.          EndIf
  1130.          Return 0
  1131.  
  1132.    Else
  1133.    $mLootIn = 0
  1134.                  Return 1
  1135. EndIf
  1136. Return
  1137.   EndFunc
  1138.  
  1139.  
  1140. Func StashLoot()
  1141.    MouseClick("left", 442* $x_ratio,121* $y_ratio)
  1142.    Sleep(Random(1600, 1620))
  1143.  
  1144. GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  1145.    If $StashSelectedTab > 0 Then MouseClick("left", Round($StashTabs[$StashSelectedTab][0] * $x_ratio) ,Round($StashTabs[$StashSelectedTab][1] * $x_ratio), 1, 4)
  1146.  
  1147. If $AnalLoot = 1 And $StashLoot > 0 Then
  1148.          MouseMove(Round($StashTabs[$StashSelectedTab][0] * $x_ratio) ,Round($StashTabs[$StashSelectedTab][1] * $x_ratio), 2)
  1149.          AnalLoot()
  1150.          Send("{SPACE}")
  1151.    If $AnalSalvage = 1 Then
  1152.           If $AnalRareIdentify = 1 Then
  1153.            DoIdentify()
  1154.           EndIf
  1155.            DoSalvage()
  1156.         EndIf
  1157.         If $AnalVendor = 1 Then
  1158.             If $AnalRareIdentify = 1 Then
  1159.            DoIdentify()
  1160.           EndIf
  1161.    VendorLoot()
  1162.    EndIf
  1163. EndIF
  1164. $AnalSalvage = 0
  1165. $AnalRareIdentify = 0  
  1166. $AnalVendor = 0
  1167.  EndFunc   ;==>StashLoot
  1168.  
  1169.  
  1170.  Func CheckFullStash()
  1171. If _ImageSearchArea($pngLoc &  "FullStash.png", 1, Round(320 * $x_ratio),Round(72 * $y_ratio), Round(376 * $y_ratio),Round(88 * $x_ratio), $gX, $gY, 140) Then
  1172.    If $StashSelectedTab < 2 Then
  1173.           $StashSelectedTab += 1
  1174.    ElseIf $StashSelectedTab = 2 Then
  1175.           $StashLoot = 0
  1176.           Return 0
  1177.    EndIf
  1178. Do
  1179. Sleep(Random(100, 105))
  1180.    Until Not _ImageSearchArea($pngLoc &  "FullStash.png", 1, Round(320 * $x_ratio),Round(72 * $y_ratio), Round(376 * $y_ratio),Round(88 * $x_ratio), $gX, $gY, 140)
  1181.  
  1182. MouseClick("left", Round($StashTabs[$StashSelectedTab][0] * $x_ratio) ,Round($StashTabs[$StashSelectedTab][1] * $x_ratio), 1, 4)
  1183. EndIf
  1184.  Return 1
  1185.    EndFunc
  1186.  
  1187.  Func AnalScan()
  1188.     GUICtrlSetData($lblStatus, "Status: Unhighlighting new items")
  1189.     For $i = 0 To 9
  1190.       For $j = 0 To 5
  1191.       MouseMove(Round(($slot1x + ($i * $offset)*$x_ratio)),Round(($slot1y + ($j * $offset)) * $y_ratio), 1)
  1192.       Next
  1193.    Next
  1194. EndFunc
  1195.  
  1196.  Func AnalLoot()
  1197. DebugLog(@CRLF & "iLvl Analyzing " & @CRLF & _
  1198.         "****************************************************")
  1199.         GUICtrlSetData($lblStatus, "Status: Stashing And Analyzing Loot")
  1200.         AnalScan()
  1201.         ArrayClear($AnalyzedLoot)
  1202.         $rt = TimerInit()
  1203.  
  1204.         For $i = 0 To 9
  1205.                            For $j = 0 To 5
  1206.           $SlotPixelLine = PixelSearch(Round($slotLineX + $i * $slotLineOffSet * $x_ratio), Round($slotLineY  + $j * $slotLineOffSet * $y_ratio), Round($slotLineX + $i * $slotLineOffSet * $x_ratio), Round($slotLineY + $j * $slotLineOffSet + 27 * $y_ratio), 0x37241A, 9)
  1207.           $MiddleOfCell = PixelSearch(Round($CellMiddleTopX + $i * $CellMiddleO * $x_ratio), Round($CellMiddleTopY  + $j * $CellMiddleO * $y_ratio), Round($CellMiddleBotX+ $i * $CellMiddleO * $x_ratio), Round($CellMiddleBotY + $j * $CellMiddleO * $y_ratio), 0x130C08,1)
  1208.    If Not IsArray($MiddleOfCell) Then
  1209.           If IsArray($SlotPixelLine) Or $slotError >= 1 Or $j = 0 Then
  1210.                  $slotError  = 0
  1211.           MouseMove(Round($slot1x + $i * $offset * $x_ratio), Round($slot1y + $j * $offset * $y_ratio),1)
  1212.       Sleep($AnalSpeed)
  1213.           $ItemInfo = StringSplit(GetItemInfo(), ",")
  1214.  
  1215.           If StringRegExp($ItemInfo[1],"Magic")  Then
  1216.           DebugLog("Magic Item Found iLvl=" &$ItemInfo[2]&" @ Cell " & $i & "," & $j)
  1217.            
  1218.                  If $ItemInfo[2] < 0 Then
  1219.                         $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Vendor,Magic," & $ItemInfo[2]
  1220.                         $AnalVendor = 1
  1221.                   Else
  1222.                         If $ItemInfo[2] >= $MagicStashiLvl Then
  1223.                            GUICtrlSetData($lblStatus, "Status: " & $ItemInfo[2] & " Stashing Magic @ " & $i & "," & $j)
  1224.                            $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Stashed,Magic," & $ItemInfo[2]
  1225.                            MouseClick("Right", Round($slot1x + $i * $offset * $x_ratio), Round($slot1y + $j * $offset * $y_ratio), 1)
  1226.  
  1227.  
  1228.                         Elseif $ItemInfo[2] <= $MagicSalvageiLvl And $ItemInfo[2] > $MagicVendoriLvl Then
  1229.                            GUICtrlSetData($lblStatus, "Status: " & $ItemInfo[2] & " Salvaging Magic @ " & $i & "," & $j)
  1230.                            $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Salvage,Magic," & $ItemInfo[2]
  1231.                            $AnalSalvage = 1
  1232.                            
  1233.                         Elseif $ItemInfo[2] <= $MagicVendoriLvl Then
  1234.                            GUICtrlSetData($lblStatus, "Status: " & $ItemInfo[2] & " Vendoring Magic @ " & $i & "," & $j)
  1235.                            $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Vendor,Magic," & $ItemInfo[2]
  1236.                            $AnalVendor = 1
  1237.  
  1238.                         EndIf
  1239.                  EndIf
  1240.           ElseIf StringRegExp($ItemInfo[1],"Rare") Then
  1241.  
  1242.                 DebugLog("Rare Item Found iLvl=" &$ItemInfo[2]&" @ Cell " & $i & "," & $j)
  1243.            
  1244.                  If $ItemInfo[2] < 0 Then
  1245.                         $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Vendor,Rare," & $ItemInfo[2]
  1246.                         $AnalRareIdentify = 1
  1247.                         $AnalVendor = 1
  1248.                        
  1249.                   Else
  1250.                         If $ItemInfo[2] >= $RareStashiLvl Then
  1251.                            GUICtrlSetData($lblStatus, "Status: " & $ItemInfo[2] & " Stashing Rare @ " & $i & "," & $j)
  1252.                            $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Stashed,Rare," & $ItemInfo[2]
  1253.                            MouseClick("Right", Round($slot1x + $i * $offset * $x_ratio), Round($slot1y + $j * $offset * $y_ratio), 1)
  1254.  
  1255.  
  1256.  
  1257.                         Elseif $ItemInfo[2] <= $RareSalvageiLvl And $ItemInfo[2] > $RareVendoriLvl Then
  1258.                            GUICtrlSetData($lblStatus, "Status: " & $ItemInfo[2] & " Salvaging Rare @ " & $i & "," & $j)
  1259.                            $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Salvage,Rare," & $ItemInfo[2]
  1260.                            $AnalRareIdentify = 1
  1261.                            $AnalSalvage = 1
  1262.                            
  1263.                         ElseIf $ItemInfo[2] <= $RareVendoriLvl Then
  1264.                            GUICtrlSetData($lblStatus, "Status: " & $ItemInfo[2] & " Vendoring Rare @ " & $i & "," & $j)
  1265.                            $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Vendor,Rare," & $ItemInfo[2]
  1266.                            $AnalRareIdentify = 1
  1267.                            $AnalVendor = 1
  1268.  
  1269.                         EndIf
  1270.                  EndIf
  1271.           ElseIf StringRegExp($ItemInfo[1],"Set") Or StringRegExp($ItemInfo[1],"Legendary") Then
  1272.  
  1273.                  DebugLog($ItemInfo[1] & " Item Found iLvl=" &$ItemInfo[2]&" @ Cell " & $i & "," & $j)
  1274.                  GUICtrlSetData($lblStatus, "Status: " & $ItemInfo[2] & " Stashing " & $ItemInfo[1] & " @ " & $i & "," & $j)
  1275.                  $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Stashed,Set/Legendary," & $ItemInfo[2]
  1276.                  MouseClick("Right", Round($slot1x + $i * $offset * $x_ratio), Round($slot1y + $j * $offset * $y_ratio), 1)
  1277.  
  1278.  
  1279.  ElseIf StringRegExp($ItemInfo[1],"Crafting") Or StringRegExp($ItemInfo[1],"Tomes") Or StringRegExp($ItemInfo[1],"Gem") Or StringRegExp($ItemInfo[1],"Tome") _
  1280.           Or StringRegExp($ItemInfo[1],"RareRing") Or StringRegExp($ItemInfo[1], "RareAmmy") Or StringRegExp($ItemInfo[1], "BlackSmithPlan") Then
  1281.          
  1282.          DebugLog($ItemInfo[1] & " @ Cell " & $i & "," & $j)
  1283.      GUICtrlSetData($lblStatus, "Status: Stashing " & $ItemInfo[1] & " @ " & $i & "," & $j)
  1284.      $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Stashed," &$ItemInfo[1]& ",0"
  1285.          MouseClick("Right", Round($slot1x + $i * $offset * $x_ratio), Round($slot1y + $j * $offset * $y_ratio), 1)
  1286.          
  1287.           ElseIf $ItemInfo[1] = 0 Then
  1288.                  
  1289.                  DebugLog("Unknown Item Found iLvl=0 @ Cell " & $i & "," & $j)
  1290.                  GUICtrlSetData($lblStatus, "Status:  Vendoring Unknown @ " & $i & "," & $j)
  1291.              $AnalyzedLoot[$i][$j] = Round($slot1x + $i * $offset * $x_ratio) & "," & Round($slot1y + $j * $offset * $y_ratio) & ",Vendor,Unknown,0"
  1292.                  $AnalVendor = 1
  1293.                  
  1294.   Else
  1295.           $slotError += 1
  1296.     EndIF        
  1297.    EndIf       
  1298.  EndIf
  1299.           If CheckFullStash() = 0 Then ExitLoop
  1300.           Next
  1301.    Next
  1302.    $srt = TimerDiff($rt)
  1303.    $AnalTime = Round($srt / 1000, 2)
  1304.       DebugLog(@CRLF & "iLvl Analyzing took " & $AnalTime & " Seconds" & @CRLF & _
  1305.         "****************************************************")
  1306.    ToolTip("")
  1307.  EndFunc   ;==>AnalLoot
  1308.  
  1309. Func DoIdentify()
  1310.    DebugLog("Identifying Rare Items" & @CRLF & _
  1311.         "****************************************************")
  1312.    Send("c")
  1313.    $arr = 0
  1314.                 For $i = 0 To 9
  1315.                            For $j = 0 To 5
  1316.                                   If StringRegExp($AnalyzedLoot[$i][$j],"Rare") Then
  1317.                                   $arr = StringSplit($AnalyzedLoot[$i][$j], ",")
  1318.                                   DebugLog("Rare to Identify "  & $i & "," & $j)
  1319.                                   GUICtrlSetData($lblStatus, "Status: " & $arr[5] & " Identify " & $arr[4] & " @ Cell " & $i & "," & $j)
  1320.                                   MouseClick("Right",$arr[1],$arr[2],2)
  1321.                   Sleep(Random(2900, 3000))
  1322.                                   ToolTip("")
  1323.                                   EndIF
  1324.           Next 
  1325.    Next
  1326.    Send("c")
  1327.    $AnalRareIdentify = 0
  1328.    EndFunc
  1329.    
  1330. Func DoSalvage()
  1331.         DebugLog("Salvaging Items")
  1332.         MouseClick("Left",Round(799 * $x_ratio),Round(290 * $y_ratio),1)
  1333.  
  1334.         Sleep(Random(1600, 1620))
  1335.         MouseClick("Left",Round(562 * $x_ratio),Round(211 * $y_ratio),1)
  1336.         Sleep(Random(1000, 1010))
  1337.  
  1338.         MouseClick("Left",Round(286 * $x_ratio),Round(268 * $y_ratio),1)
  1339.         Sleep(Random(300, 305))
  1340.  
  1341.         MouseClick("Left",Round(151 * $x_ratio),Round(159 * $y_ratio),1)
  1342.          If Not _ImageSearchArea("CurrentInventory.png", 1, Round(625 * $x_ratio), Round(93 * $y_ratio), Round(772 * $x_ratio), Round(300 * $y_ratio), $gX, $gY, 9) Then
  1343.                         TogglePause()
  1344.                         GUICtrlSetData($lblStatus, "Status: Frozen to prevent vendor of worn item, sorry....")
  1345.                  EndIf
  1346.         $arr = 0
  1347.                 For $i = 0 To 9
  1348.                            For $j = 0 To 5
  1349.                                   If StringRegExp($AnalyzedLoot[$i][$j],"Salvage") Then
  1350.                                   $arr = StringSplit($AnalyzedLoot[$i][$j], ",")
  1351.                                   DebugLog("Item to Salvage " & $arr[4] & " " & $i & "," & $j)
  1352.                                   GUICtrlSetData($lblStatus, "Status: " & $arr[5] & " Salvaging " & $arr[4] & " @ Cell " & $i & "," & $j)
  1353.                                   MouseClick("Left",$arr[1],$arr[2],1)
  1354.                                   If $arr[4] == "Rare" Then
  1355.                                         Send("{Enter}")
  1356.                                   EndIf
  1357.                                   sleep(150)
  1358.                                   EndIF
  1359.           Next 
  1360.    Next
  1361.    ToolTip("")
  1362.    Send("{Space}")
  1363.    EndFunc
  1364.  
  1365.  
  1366. Func VendorLoot()
  1367.            If $AnalSalvage = 1 Then
  1368.                 MouseClick("left",Round(517 * $x_ratio), Round(15 * $y_ratio), 6) ;NPC Merchant to the right of cain's home
  1369.                 Sleep(Random(2200, 2210))
  1370.                
  1371.  
  1372.                 MouseClick("left",Round(279 * $x_ratio), Round(218 * $y_ratio), 6) ;NPC Merchant to the right of cain's home
  1373.                 Sleep(Random(500, 550))
  1374.                
  1375.  
  1376.                 Else
  1377. Sleep(Random(500, 550))
  1378.                 RandClick1("middle", Round(755 * $x_ratio),Round(29 * $y_ratio), 1, 1) ;step1
  1379.  
  1380.                 Sleep(Random(3500, 3550))
  1381.  
  1382.  
  1383.  
  1384.  
  1385.                 RandClick1("left", Round(405 * $x_ratio),Round(123 * $y_ratio), 1, 1) ;vendor
  1386.                 Sleep(Random(2800, 2850))
  1387.                 EndIf
  1388.  
  1389.                 Sleep(Random(300, 310))
  1390.  
  1391.                 $arr = 0
  1392.                 If Not _ImageSearchArea("CurrentInventory.png", 1, Round(625 * $x_ratio), Round(93 * $y_ratio), Round(772 * $x_ratio), Round(300 * $y_ratio), $gX, $gY, 9) Then
  1393.                   TogglePause()  
  1394.                   GUICtrlSetData($lblStatus, "Status: Frozen to prevent salvage of worn item, sorry....")
  1395.                  EndIf
  1396.            
  1397.  
  1398.                 For $i = 0 To 9
  1399.                            For $j = 0 To 5
  1400.                                   If StringRegExp($AnalyzedLoot[$i][$j],"Vendor") Then
  1401.                                   $arr = StringSplit($AnalyzedLoot[$i][$j], ",")
  1402.                                   DebugLog("Item To Vendor  " & $arr[4] & " " & $i & "," & $j)
  1403.                                   GUICtrlSetData($lblStatus, "Status: " & $arr[5] & " Vendoring " & $arr[4] & " @ Cell " & $i & "," & $j)
  1404.  
  1405.                                   MouseClick("Right",$arr[1],$arr[2],1)
  1406.                                   EndIF
  1407.           Next 
  1408.    Next
  1409.     ToolTip("")
  1410.         Sleep(Random(200, 205))
  1411.         RandClick("left", Round(282 * $x_ratio),Round(267 * $y_ratio), 1) ;button to open up repair menu
  1412.     Sleep(Random(400, 405))
  1413.  
  1414.     RandClick("left", Round(142 * $x_ratio),Round(295 * $y_ratio), 1) ;button to pay for repairs
  1415.     Sleep(Random(200, 205))
  1416.  
  1417.         Send("{ESCAPE}")
  1418.  EndFunc   ;==>VendorLoot
  1419.  
  1420.  
  1421.  
  1422. Func GetItemInfo()
  1423.    $gX = 0
  1424.    $gY = 0
  1425.    $Type = 0
  1426.    $CheckRing = 0
  1427.    $mousePos = MouseGetPos()
  1428.    Local $Rings[2] = ["RareRing","RareAmmy"]
  1429.    Local $MiscItems[4] = ["Crafting","Tomes","Gem","BlackSmithPlan"]
  1430.    Local $ItemQuality[8] = ["Magic","MagicRed","Rare","RareRed","Legendary","LegendaryRed","Set","SetRed"]
  1431.  
  1432.  
  1433.    For $i = 0 to Ubound($ItemQuality) -1
  1434.           If _ImageSearchArea($pngLoc & $ItemQuality[$i] & ".png",1, Round($mousePos[0] - 300 * $x_ratio), 0, Round($mousePos[0] + 70 * $x_ratio),900,$gX,$gY, 100) Then
  1435.           $Type = $ItemQuality[$i]
  1436.                  If StringRegExp($Type,"Rare") Or StringRegExp($Type,"Legendary") Or StringRegExp($Type,"Set") Then
  1437.                  $CheckRing = 1
  1438.           EndIf
  1439.           ExitLoop
  1440.    Else
  1441.           $Type = 0
  1442.           EndIf
  1443.    Next
  1444.  
  1445.    If $CheckRing = 1 Then
  1446.    For $i = 0 to Ubound($Rings) -1
  1447.           If _ImageSearchArea($pngLoc & $Rings[$i] & ".png",1, Round($mousePos[0] - 300 * $x_ratio), 0, Round($mousePos[0] + 70 * $x_ratio), $size[1],$gX,$gY, 100) Then
  1448.                  Return $Rings[$i] & "," & $RareStashiLvl
  1449.                  ExitLoop
  1450.           EndIf
  1451.    Next
  1452.    
  1453.    ElseIf $Type = 0 Then
  1454.    For $i = 0 to Ubound($MiscItems) -1
  1455.          If _ImageSearchArea($pngLoc & $MiscItems[$i] & ".png",1, Round($mousePos[0] - 300 * $x_ratio), 0, Round($mousePos[0] + 70 * $x_ratio), $size[1],$gX,$gY, 100) And $CheckRing = 1 Then
  1456.                   Return $MiscItems[$i] & "," & $RareStashiLvl
  1457.                   Exitloop       
  1458.                 EndIf
  1459.    Next
  1460.    EndIf
  1461.  
  1462.         If _ImageSearchArea($pngLoc & "ItemLevel800x600.png",1, Round($mousePos[0] - 300 * $x_ratio), 0, Round($mousePos[0] + 70 * $x_ratio), $size[1],$gX,$gY, 90) Then
  1463.         $capture = _TesseractScreenCapture(0, "", 1, 11, Round($gX - 5 * $x_ratio), Round($gY - 10 * $y_ratio), Round($gX + 40 * $x_ratio), Round($gY + 10 * $y_ratio), 0)
  1464.         $Fixed = StringRegExpReplace($capture,"Q","9")
  1465.         $iLvl = StringRegExpReplace($Fixed,"[a-zA-Z|:;~.,»<?_=+|-]","")
  1466.         $StringLength = StringLen($iLvl)
  1467.         If $StringLength > 2 Then
  1468.            $StringLength -= 3
  1469.            $iLvl = StringMid($iLvl, $StringLength, 2)
  1470.     EndIF
  1471.         Return $Type & "," & $iLvl
  1472.     Else
  1473.         Return 0
  1474.         EndIf
  1475.  EndFunc
  1476.  
  1477.  
  1478. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  1479.         If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  1480.         $findImage = "*TRANSBLACK " & $findImage
  1481.         If @AutoItX64 Then
  1482.                 $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1483.         Else
  1484.                 $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1485.         EndIf
  1486.         If $result = "0" Then
  1487.                 Return 0
  1488.         EndIf
  1489.  
  1490.         ; Otherwise get the x,y location of the match and the size of the image to
  1491.         ; compute the centre of search
  1492.         $array = StringSplit($result[0], "|")
  1493.         If (UBound($array) >= 4) Then
  1494.                 $x = Int(Number($array[2]))
  1495.                 $y = Int(Number($array[3]))
  1496.                 If $resultPosition = 1 Then
  1497.                         $x = $x + Int(Number($array[4]) / 2)
  1498.                         $y = $y + Int(Number($array[5]) / 2)
  1499.                 EndIf
  1500.                 Return 1
  1501.         EndIf
  1502.  EndFunc   ;==>_ImageSearchArea
  1503.  
  1504. Func FindCellar()
  1505.    $CellCoord = 0
  1506.    $gY = 0
  1507.    $gX = 0
  1508.  
  1509.    ;A precheck to the cellar search
  1510.    _ImageSearchArea($pngLoc & "Cellar.png", 1,Round(670 * $x_ratio),Round(90 * $y_ratio) ,Round(691 * $x_ratio),Round(110 * $y_ratio), $gX, $gY, 160)
  1511.    sleep($cellarCheckSleep)
  1512.    If $gX > 0 Or $gY > 0 then
  1513.           Do
  1514.                  MouseMove(Round($cellarCoordx[$CellCoord] * $x_ratio), Round($cellarCoordy[$CellCoord] * $y_ratio),1) ;moves cursor over to the cellar
  1515.                  sleep($cellarCheckSleep)
  1516.  
  1517.                  $Pixel2 = PixelSearch(Round($cellarCoordx[$CellCoord] * $x_ratio - 65),Round($cellarCoordy[$CellCoord] * $y_ratio - 50),Round($cellarCoordx[$CellCoord] * $x_ratio + 50),Round($cellarCoordy[$CellCoord] * $x_ratio + 65), 0x375BC6, 3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
  1518.  
  1519.  
  1520.  
  1521.                  If Not @Error Then
  1522.                         ;Msgbox("4096","found it","Found it")
  1523.                         Return 1
  1524.                  EndIf
  1525.                  $CellCoord += 1
  1526.           Until $CellCoord >= Ubound($cellarCoordx)
  1527.    Else
  1528.           Return 0
  1529.    EndIf
  1530.    $countMissedCellar += 1
  1531.    Call("CellarScreenShot")
  1532.    Return 0
  1533. EndFunc
  1534.  
  1535. Func CellarScreenShot()
  1536.    If $ScreenShot = 1 Then
  1537.                            _ScreenCapture_SetBMPFormat(0)
  1538.                            _ScreenCapture_Capture(@ScriptDir & "\shots\Cellar\CellarShot"& $run & "c" & $CellCoord & ".bmp")
  1539.                         EndIf
  1540.                  EndFunc
  1541.                  
  1542.  Func GoldPerHour()
  1543. Send("i")
  1544. Sleep(Random(750, 800))
  1545. If $CurrentItems = 0 Then
  1546.    Call("ScreenShotInventory")
  1547. EndIf
  1548. CheckFullInventory()
  1549. $CurrentGoldCaptured = _TesseractGoldCapture(0, "", 1,  6,544*$x_ratio, 281*$y_ratio, 607*$x_ratio, 292*$y_ratio, 0)
  1550. Sleep(Random(190, 200))
  1551. Send("i")
  1552.  
  1553. $CurrentGoldInteger = ""
  1554.  
  1555.  
  1556. For $i = 1 to stringlen($CurrentGoldCaptured)
  1557. $chr = asc(StringMid($CurrentGoldCaptured, $i, 1))
  1558. if $chr >= 48 And $chr <= 57 Then $CurrentGoldInteger = $CurrentGoldInteger & chr($chr)
  1559. Next
  1560.  
  1561.  
  1562. $trt = TimerDiff($t)
  1563. $SecondsRan = $trt / 1000
  1564.  
  1565. If $StartingGold <= 0 Then $StartingGold = $CurrentGoldInteger
  1566. If $StartingGold > 0 Then $AccumulatedGold = $CurrentGoldInteger - $StartingGold
  1567. $GPH = $AccumulatedGold / $SecondsRan * 60 * 60
  1568.  
  1569. $GPH=(Round($GPH,0))
  1570.  
  1571. If $GPH >= 0 and $AccumulatedGold >=0 then
  1572.   GUICtrlSetData($lblStartingG,"Staring Gold: " & $StartingGold)
  1573.   GUICtrlSetData($lblGold,$GPH & " Per Hour - Accumulated Gold: " & $AccumulatedGold)
  1574.  
  1575. EndIf
  1576.  
  1577. EndFunc ;==>GoldPerHour
  1578.  
  1579. Func LeaveGame()
  1580.    GUICtrlSetData($lblStatus, "Status: Leaving Game")
  1581.         Send("{SPACE}")
  1582.         sleep(200)
  1583.         Send("{Escape}")
  1584.         RandClick("left", Round(398 * $x_ratio),Round(322 * $y_ratio), 10, 2) ;Random Click on the leave button
  1585.         Call("CalcTime")
  1586.         Sleep($timingGameLoad)
  1587. EndFunc   ;==>LeaveGame
  1588.  
  1589.  
  1590. Func TownPortal()
  1591. GUICtrlSetData($lblStatus, "Status: Returning to Town")
  1592.         Sleep(Random(200, 205))
  1593. Send($Skill3)
  1594. Sleep(Random(50, 65))
  1595.         Send("t")
  1596.         Call("GoldPerHour")
  1597.         Sleep($timingTP)
  1598.         Call("CheckRepair")
  1599. EndFunc   ;==>TownPortal
  1600.  
  1601. Func RandClick($clickType, $xPos, $yPos, $xOff = 5, $yOff = 5, $clicks = 1, $speed = 1)
  1602.         If $xOff < 1 Then $xOff = 1
  1603.         If $yOff < 1 Then $yOff = 1
  1604.         $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1605.         $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1606.         MouseClick($clickType, $randX, $randY, $clicks, $speed)
  1607. EndFunc   ;==>RandClick
  1608.  
  1609.  Func RandClick1($clickType, $xPos, $yPos, $xOff = 3, $yOff = 2, $clicks = 1, $speed = 1)
  1610.         If $xOff < 1 Then $xOff = 1
  1611.         If $yOff < 1 Then $yOff = 1
  1612.         $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1613.         $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1614.         MouseClick($clickType, $randX, $randY, $clicks, $speed)
  1615. EndFunc   ;==>RandClick
  1616.  
  1617. Func RandMove($xPos, $yPos, $xOff = 10, $yOff = 10, $speed = 1)
  1618.         $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1619.         $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1620.         MouseMove($randX, $randY, $speed)
  1621. EndFunc   ;==>RandMove
  1622.  
  1623. Func StopLog()
  1624. If $run > 0 Then
  1625. $repairCountPercent = $repairCount / $run
  1626. $deathsCountPercent = $deathCount / $run
  1627. $cellarCountPercent = $cellarCount /  $run
  1628. $closedCellarCountPercent = ($run - $cellarCount) / $run
  1629. $trt = TimerDiff($t)
  1630. ;Total runtime calculation.
  1631. $hours = Floor((($trt / 1000) / 60) / 60)
  1632. $minutes = (($trt / 1000) / 60)
  1633. If $minutes > 60 Then
  1634.         While $minutes > 60
  1635.                 $minutes -= 60
  1636.         WEnd
  1637.  EndIf
  1638.  
  1639. _FileWriteLog("Dank Cellar Log.txt",  @CRLF & "************************************************" & @CRLF & _
  1640. "Dank Celler" & @CRLF & @CRLF & "Stats:" & @CRLF &  _
  1641. "Total Runtime: " & $hours & " hours, " & Ceiling($minutes) & " minutes" & @CRLF & _
  1642. GUICtrlRead($lblLast) & @CRLF & _
  1643. "Total Cellars Found: " & $cellarCount & " (" & Round($cellarCountPercent * 100,.00) & "%" & ")" & @CRLF & _
  1644. "Total Cellars Not Found: " & $run - $cellarCount & " (" & Round($closedCellarCountPercent * 100,.00) & "%" & ")" & @CRLF & _
  1645. "Total Deaths: " & $deathCount &  " (" & Round($deathsCountPercent * 100,.00) & "%" & ")" & @CRLF & _
  1646. "Total Repairs: " & $repairCount &  " (" & Round($repairCountPercent * 100,.00) & "%" & ")" & @CRLF & @CRLF & "Loot:" & @CRLF & _
  1647. "Magics: " & $MagicCount & " Rares: " & $RareCount & " Legendary's: " & $LegendaryCount & " Set Items: " & $setCount & @CRLF & _
  1648. "Gems: " & $GemCount & @CRLF & _
  1649. GUICtrlRead($lblGold) & $StartingGold &  @CRLF & _
  1650. "************************************************")
  1651. EndIf
  1652. EndFunc
  1653.  
  1654. Func Begin()
  1655.            If $AddDPS = 0 then
  1656.         MsgBox(16, "First Run", "Edit your settings.")
  1657.          Else
  1658.           $AddDPS = $AddDPS * 3.25
  1659.           $attackTime = (170000 / $AddDPS) * 1000
  1660.           WinActivate("Diablo III")
  1661.         $Go = Not $Go
  1662.         GUICtrlSetState($mFile, $GUI_DISABLE)
  1663.         GUICtrlSetState($mOptions, $GUI_DISABLE)
  1664.            EndIf
  1665.         If Not $Go Then WinSetTitle($title, "", $title  & " - Halted")
  1666. EndFunc   ;==>Begin
  1667.  
  1668. Func TogglePause()
  1669.         $Paused = Not $Paused
  1670.         While $Paused
  1671.                 Sleep(100)
  1672.                 WinSetTitle($title, "", $title & " - Paused")
  1673.                 ToolTip('[PAUSED] - Deaths: ' & $deathCount & ' | Cellars: ' & $cellarCount, 0, 0)
  1674.         WEnd
  1675.         WinSetTitle($title, "", $title  & " - Running")
  1676.         ToolTip("")
  1677.  EndFunc   ;==>TogglePause
  1678.  
  1679.  Func GameAutostart()
  1680. If ProcessExists($gameExecutable) = 0 Then
  1681.                 GUICtrlSetData($lblStatus, "Status: Starting Game Client")
  1682.                 Run($gameDiabloIIILoc & $gameExecutable & " -launch")
  1683.             sleep($gameStartTime)
  1684.                 WinActivate("Diablo III")
  1685.             Sleep(Random(500, 505))
  1686.  
  1687.             Send($gamePassword)
  1688.             Sleep(Random(500, 505))
  1689.  
  1690.             Send("{ENTER}")
  1691.             Sleep($gameStartTime)
  1692.                 $size = WinGetClientSize("[CLASS:D3 Main Window Class]")
  1693.                 $x_ratio = $size[0] / 800
  1694.             $y_ratio = $size[1] / 600
  1695.                 Call("Begin")
  1696.          Else
  1697.                 $size = WinGetClientSize("[CLASS:D3 Main Window Class]")
  1698.                 $x_ratio = $size[0] / 800
  1699.             $y_ratio = $size[1] / 600
  1700.                
  1701.                 Call("Begin")
  1702.          EndIf
  1703.   EndFunc
  1704.  
  1705.   Func ArrayClear(ByRef $aArray)
  1706.     Local $iCols = UBound($aArray, 2)
  1707.     Local $iDim = UBound($aArray, 0)
  1708.     Local $iRows = UBound($aArray, 1)
  1709.  
  1710.     If $iDim > 1 Then
  1711.         Local $ClearArray2D[$iRows][$iCols]
  1712.         $AnalyzedLoot = $ClearArray2D
  1713.     EndIf
  1714.  EndFunc   ;==>_ArrayClear
  1715.  
  1716.  
  1717.  Func DebugLog($DebugLine)
  1718.         _FileWriteLog( "Debug.txt", $DebugLine )
  1719. EndFunc
  1720.  
  1721.  
  1722.  Func ScreenShotInventory()
  1723.  
  1724.  
  1725.     _ScreenCapture_Capture("CurrentInventory.png",625 * $x_ratio,93 * $y_ratio,772 * $x_ratio,300 * $y_ratio)
  1726.    $CurrentItems = 1
  1727. EndFunc
  1728.  
  1729. Func Stop() ;to allow the script to stop
  1730.         Call("StopLog")
  1731.         Exit
  1732.  EndFunc   ;==>Stop
  1733.  
  1734. func ShowLoot()
  1735.         GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount& " - Magic: " & $MagicCount )
  1736. EndFunc   ;==>ShowLoot