Advertisement
stealthingyew

ChanDH

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