Advertisement
onedoesnotsimply

onedoesnotsimply notares update

Jul 9th, 2012
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 39.36 KB | None | 0 0
  1. ;onedoesnot simply update.  stash items all tabs (credit BlackSack) gph calculation (credit stealthingyew ?)
  2. ;notAres' DH Gold Script 1.9.3 - 6/18/2012 - New INI option: Identify. Added VendItems() and StashItems() to simplify code and added 2 colors of legendaries to stash (highlighted/not highlighted). Trimmed down all "Area" CheckFor() calls. Fixed CheckFor("ExitGame"). Moves mouse out of the way while looting. Added deaths/cellars to PAUSED tooltip.
  3. ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
  4. ;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkoth-dh-gold-script-autoit-script-1920x1080.html
  5. ;;;;;
  6. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  7. ;Suggested build: http://us.battle.net/d3/en/calculator/demon-hunter#aRYXVT!aYW!YaaabY
  8. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  9. ;Official supported resolution: 1920x1080
  10. ;;;;;
  11. ;Original by mackus101 @ ownedcore
  12. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  13. ;Refactoring and additional functions by Shimizoki
  14.  
  15. ;=========== DO NOT TOUCH ===========;
  16. #RequireAdmin
  17. #include <GUIConstantsEx.au3>
  18. #include <StaticConstants.au3>
  19. #include <WindowsConstants.au3>
  20. #include <tesseract.au3>
  21. #include <currency.au3>
  22.  Global $numitem, $numgem, $numtomb, $numgold, $numpot, $lblGold, $numsold, $numstashed, $monold = 0, $mon = 0, $monstart = 0, $SprintStart, $lootany
  23. Opt('MouseCoordMode', 2)
  24. Opt('PixelCoordMode', 2)
  25. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "1.9.3", $ini = "DH.ini", $hFont = 0, $title, $Paused, $Go = False, $i = 0, $gX = 0, $gY = 0, $LegendaryCount = 0,$RepairCount=0, $SetCount = 0, $RareCount = 0, $MagicCount = 0,$deathLabel, $GemCount = 0, $TomeCount = 0, $deathCount = 0, $cellarCount = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000, $lblRun, $lblLocation, $lblStatus, $lblLast, $lblRuntime, $lblGear, $lblItems,$lblGold, $lblFailed, $StartingGold = 0,$AccumulatedGold = 0,$GPH = 0, $StartingG, $AccumulatedG, $TotalGold, $CurrentGoldCaptured , $CurrentGoldInteger
  26. For $i = 0 To Random(0, 7, 1)
  27.     $title &= Chr(Random(97, 122, 1))
  28. Next
  29. For $i = 0 To Random(5, 10, 1)
  30.     $title &= Chr(Random(65, 90, 1))
  31. Next
  32. $title &= " "
  33. Global $gems[8] = ["Ru1.png", "Ru2.png", "Em1.png", "Em2.png", "To1.png", "To2.png", "Am1.png", "Am2.png"]
  34. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  35. If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
  36. If $size = 0 Then
  37.     MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  38.     Exit
  39. EndIf
  40. ;====================================;
  41.  
  42. ;============= SETTINGS: DONT CHANGE HERE, CHANGE DH.INI =============;
  43. HotKeySet("=", "Begin") ;script toggled on/off by pressing =
  44. HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
  45. HotKeySet("x", "Stop") ;script stopped by pressing x
  46.  
  47. ;Change to match your abilities (1-4 by default)z
  48. $skillCaltrops = "1"
  49. $skillSmokeScreen = "2"
  50. $skillPreparation = "3"
  51. $skillCompanion = "4"
  52.  
  53. $movementSpeed = 25 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0% (25% is the movement cap but SS + Displacement avg = 32%)
  54.  
  55. ;Custom Loot
  56. $pngLoc = "@ScriptDir" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  57. $totalItems = 2 ;Number of items in the pick array
  58. Global $pick[$totalItems] ;DONT CHANGE THIS
  59.  
  60. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  61. $pick[0] = "prosp.png|40"
  62. $pick[1] = "design.png|40"
  63. ;$pick[2] = "ofdeath2.png|40"   ;png|Tolerance
  64. ;$pick[3] = "archon.png|40"
  65.  
  66. ;Looting
  67. $LootSets = "True" ;True if you want to pick up Sets
  68. $LootLegendaries = "True";True if you want to pick up Legendaries
  69. $LootRares = "True" ;True if you want to pick up Rares
  70. $LootMagic = "False" ;True if you want to pick up Magic
  71. $LootGems = "False" ;True if you want to pick up Gems
  72. $LootTomes = "False" ;True if you want to pick up Tome of Secrets
  73. $LootCustom = "True" ;True if you want to pick up Custom Items (The items in the $pick array above)
  74.  
  75. ;Manage Loot
  76. $Identify = "True" ;True to enable identifying items before stashing/vendoring
  77. $mLoot = 30 ;Nuber of successful runs until Stash and Vendor
  78. $mLootOff = 5 ;Stash and Vendor after mLoot +- X number of runs (Variability)
  79.  
  80. ;Stashing
  81. $StashLoot = "True" ;True if you want to store Items in the stash
  82. ;---
  83. $StashLegendary = "True";True if you want to store Legendary items in the stash
  84. $StashRare = "True" ;True if you want to store Rare items in the stash
  85. $StashMagic = "False" ;True if you want to store Magic items in the stash
  86. $StashTomes = "False" ;True if you want to store Tomes items in the stash
  87. $StashGems = "False" ;True if you want to store Gems items in the stash
  88.  
  89. ;Vendoring ==NEW SETTINGS==
  90. $VendorLoot = "True" ;True if you want to vendor anything
  91. ;---
  92. $VendorRare = "False" ;True if you want to vendor Rares
  93. $VendorMagic = "False" ;True if you want to vendor Magic
  94. $vendorAll = "False" ;True if you want to right click all items when talking to vendor
  95. $vendorRows = 5 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
  96. $vendorCols = 10 ;# of columns to vendor, starting from left
  97.  
  98. ;Variability ==NEW SETTINGS==
  99. $Timer = "False" ;True and the bot will add random sleep intervals
  100. ;---
  101. $attackTime = 6400 ;Time (in ms) the script will shoot sarkoth with the right button
  102. $attackMulti = "False" ;True if you want to shoot both left and right in addition to the middle (False for Lightning Ball)
  103. $walktime = 2600 ;Time (in ms) the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  104. $loadtime = 3400 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  105. $tptime = 6000 ;Time (in ms) the script waits for teleport before exiting the game
  106. ;====================================;
  107.  
  108. $GemTab = 1 ;Tab to put gems and tombs in
  109. $ItemTab = 2 ;Tab to put any items in
  110. $NextItemTab = 3 ;Next Tab to put any items in when first one is full
  111. $FinalItemTab = 1 ;Next, Next Tab to put any items in when Next one is full
  112.  
  113. $x_ratio = $size[0] / 1920
  114. $y_ratio = $size[1] / 1080
  115. If FileExists($ini) Then
  116.     Call("ReadINI")
  117.     Call("CreateINI")
  118. Else
  119.     Call("CreateINI")
  120. EndIf
  121.  
  122. If $pngLoc == "@ScriptDir" Then $pngLoc = @ScriptDir & "\pics\"
  123. If $totalItems < 1 Then $LootCustom = "False"
  124. $mLootIn = $mLoot
  125. $movementSpeed = 1 + ($movementSpeed / 100)
  126. $VersionsInfo = "http://dl.dropbox.com/u/9955791/version.ini"
  127. $oldVersion = IniRead("updater.ini", "Version", "Version", $ver)
  128. $newVersion = "0.0"
  129.  
  130. If Not FileExists($pngLoc & "MainMenu.png") Then
  131.     MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  132.     Exit
  133. EndIf
  134.  
  135. Call("SetupGUI")
  136. Call("DoUpdate")
  137.  
  138. While 1
  139.     Call("RestartRun")
  140. WEnd
  141.  
  142. Func RestartRun()
  143.     If ($Go) Then
  144.         $i = 0
  145.         WinSetTitle($title, "", $title & $ver & " - Running")
  146.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  147.         ;Checks if the player is Dead/Logout/Window, then if in Main Menu, etc.
  148.         If CheckDead() Then
  149.             Return
  150.         ElseIf CheckFor("ExitGame", "", Round(860 * $x_ratio), Round(400 * $y_ratio), Round(1040 * $x_ratio), Round(450 * $y_ratio), 0.5, 140) Then
  151.             GUICtrlSetData($lblStatus, "Status: Exit window up")
  152.             MouseClick("left", Round(1064 * $x_ratio), Round(632 * $y_ratio))
  153.             Sleep(100)
  154.             Send("{SPACE}")
  155.             Return
  156.         ElseIf CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio)) Then
  157.             GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till vendor: " & $mLootIn)
  158.             GUICtrlSetData($lblLocation, "Location: Main Menu")
  159.             GUICtrlSetData($lblStatus, "Status: Starting Game")
  160.             RandClick("left", Round(230 * $x_ratio), Round(416 * $y_ratio), 120, 20, 1, 6) ;Random Click on the resume button
  161.             Sleep($loadtime)
  162.             $rt = TimerInit()
  163.             $run += 1
  164.         ElseIf CheckFor("OldRuins", "Area") Or CheckFor("NewTristram", "Area") Or CheckFor("DankCellar", "Area") Then
  165.             Call("TownPortal")
  166.             Call("LeaveGame")
  167.             Return
  168.         ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  169.             MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio))
  170.             $rand = Random(40000, 80000)
  171.             GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
  172.             Sleep($rand)
  173.             Send("{SPACE}")
  174.             Return
  175.         ElseIf CheckFor("Disconnect", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  176.             GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
  177.             MouseClick("left", Round(960 * $x_ratio), Round(632 * $y_ratio))
  178.             Sleep(100)
  179.             Send("{SPACE}")
  180.             Return
  181.         Else
  182.             GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  183.             Return
  184.         EndIf
  185.         ;Make sure we are in the right area before beginning run
  186.         If CheckFor("OldRuins", "Area") Then
  187.             Sleep(200)
  188.             GUICtrlSetData($lblLocation, "Location: Old Ruins")
  189.             Call("CheckRepair")
  190.             If $StartingGold = 0 Then Call("GoldPerHour")
  191.             ;Start Run
  192.             RandClick("middle", Round(500 * $x_ratio), Round(250 * $y_ratio), 2, 2) ;starts the run [waypoint 1]
  193.             Moving(900)
  194.             Send($skillSmokeScreen)
  195.             Moving(600)
  196.             RandClick("middle", Round(3 * $y_ratio), Round(370 * $y_ratio), 2, 2) ;waits ~1 second then [waypoint 2]
  197.             Moving(1850)
  198.             RandClick("middle", Round(400 * $x_ratio), Round(600 * $y_ratio), 2, 2) ;middle of courtyard [waypoint 3]
  199.             Moving(100)
  200.             Send($skillSmokeScreen)
  201.             Moving(100)
  202.             Send($skillPreparation)
  203.             Moving(750)
  204.             Send($skillCaltrops)
  205.             Moving(100)
  206.             RandMove(Round(300 * $x_ratio), Round(70 * $y_ratio), 1, 1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  207.             Sleep(350)
  208.             If CheckDead() Then
  209.                 Return
  210.             EndIf
  211.  
  212.             ;Checks if Dank Cellar is Open
  213.             $Pixel2 = PixelSearch(0, 0, Round(600 * $x_ratio), Round(600 * $y_ratio), 0x334FB7, 3)
  214.             If Not @error Then
  215.                 GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  216.                 $cellarCount += 1
  217.                 MouseClick("left", Round(300 * $x_ratio), Round(70 * $y_ratio), 1) ;Entrance to cellar
  218.                 Sleep(800 * $movementSpeed)
  219.                 Send($skillSmokeScreen)
  220.                 Moving($walktime)
  221.             Else ;ABORT RUN
  222.                 GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  223.                 Sleep(10)
  224.                 RandClick("middle", Round(1100 * $x_ratio), Round(600 * $y_ratio)) ;moves between caltrops for safety before teleporting back to town
  225.                 Moving(250)
  226.                 Send($skillCaltrops)
  227.                 Sleep(620)
  228.                 Send($skillSmokeScreen)
  229.                 Sleep(40)
  230.                 Call("TownPortal")
  231.                 If Not CheckDead() Then
  232.                     Call("LeaveGame")
  233.                 EndIf
  234.                 Return
  235.             EndIf
  236.         Else
  237.             Call("TownPortal")
  238.             If Not CheckDead() Then
  239.                 Call("LeaveGame")
  240.             EndIf
  241.             Return
  242.         EndIf
  243.  
  244.         ;Checks that the player is in the Dank Cellar
  245.         If CheckFor("DankCellar", "Area") Then
  246.             GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  247.             RandClick("middle", Round(110 * $x_ratio), Round(1000 * $y_ratio), 1, 1) ;moves to doorway leading to rare inside cellar
  248.             Sleep(Random(2200, 2800))
  249.             RandMove(Round(460 * $x_ratio), Round(80 * $y_ratio), 1, 1) ;hovers over the rare Sarkoth
  250.             Sleep(10)
  251.             Send("{SHIFTDOWN}")
  252.             GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  253.             MouseDown("right") ;ATTACK
  254.             Sleep(1100)
  255.             Send($skillCompanion)
  256.             Sleep($attackTime)
  257.             MouseUp("right")
  258.             RandClick("left", Round(460 * $x_ratio), Round(80 * $y_ratio), 1, 1)
  259.             RandMove(Round(240 * $x_ratio), Round(75 * $y_ratio), 1, 1) ;attack left
  260.             Sleep(40)
  261.             MouseDown("right")
  262.             If $attackMulti == True Then Sleep($attackTime / 2)
  263.             MouseUp("right")
  264.             MouseMove(Round(590 * $x_ratio), Round(50 * $y_ratio), 1) ;attack right
  265.             MouseDown("right")
  266.             If $attackMulti == True Then Sleep($attackTime / 2)
  267.             MouseUp("right")
  268.             MouseDown("left")
  269.             MouseMove(Round(Random(240, 260) * $x_ratio), Round(75 * $y_ratio), 1) ;attack left
  270.             If $attackMulti == True Then Sleep($attackTime / 2.5)
  271.             MouseMove(Round(Random(560, 600) * $x_ratio), Round(50 * $y_ratio), 1) ;attack right
  272.             If $attackMulti == True Then Sleep($attackTime / 2.5)
  273.             MouseUp("left")
  274.             Sleep(400)
  275.             MouseClick("right", Round(630 * $x_ratio), Round(18 * $y_ratio), 1, 8) ;break the table & chair
  276.             Sleep(200)
  277.             Send("{SHIFTUP}")
  278.             Moving(200)
  279.             RandClick("middle", Round(530 * $x_ratio), Round(190 * $y_ratio)) ;location of sarkoth after death
  280.             Moving(2700)
  281.             GUICtrlSetData($lblStatus, "Status: Looting")
  282.             Send($skillCompanion)
  283.             Call("Loot")
  284.             RandSleep(0, 6, 30)
  285.             Send($skillCompanion)
  286.             Call("TownPortal")
  287.         Else
  288.             Send($skillCaltrops)
  289.             Sleep(400)
  290.             Send($skillSmokeScreen)
  291.             Sleep(40)
  292.             Call("TownPortal")
  293.             If Not CheckDead() Then
  294.                 Call("LeaveGame")
  295.             EndIf
  296.             Return
  297.         EndIf
  298.         ;After successful run
  299.         If Not CheckDead() Then
  300.             Sleep(600)
  301.             If $mLootIn = 1 And CheckFor("NewTristram", "Area") Then ;If its time to manage loot and we are in town
  302.                 If $Identify == True Then Call("Identify")
  303.                 If $StashLoot == True Then
  304.                     Call("StashLoot")
  305.                 EndIf
  306.                 If $VendorLoot == True Then
  307.                     Call("VendorLoot")
  308.                 EndIf
  309.                 $mLootIn = Round(Random($mLoot - $mLootOff, $mLoot + $mLootOff)) ;Reset Counter
  310.             ElseIf Not CheckFor("NewTristram", "Area") Then
  311.                 GUICtrlSetData($lblStatus, "Status: Skipping vendor, not in New Tristram")
  312.                 Sleep(3000)
  313.             ElseIf $mLootIn <= 0 Then
  314.                 $mLootIn = 1
  315.             Else
  316.                 $mLootIn -= 1
  317.             EndIf
  318.             If Not CheckDead() Then
  319.                 Call("LeaveGame")
  320.             EndIf
  321.             Return
  322.         Else
  323.             Return
  324.         EndIf
  325.     EndIf
  326. EndFunc   ;==>RestartRun
  327.  
  328. ;Helper Functions
  329.  
  330. Func SetupGUI()
  331.     $frmBot = GUICreate($title & $ver & " - Updating", 340, 120, Round(1532* $x_ratio), Round(927 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  332.     GUISetBkColor(0xC0C0C0)
  333.     $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  334.     GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  335.     GUICtrlSetColor(-1, 0xFF0000)
  336.     $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  337.     $deathLabel = GUICtrlCreateLabel("Deaths: 0", 190, 20, 240, 17)
  338.     $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  339.     $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  340.     $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  341.     $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  342.     $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  343.     $StartingG = GUICtrlCreateLabel("Starting Gold: 0 ", 190, 50, 240, 17)
  344.     $AccumulatedG=GUICtrlCreateLabel("Accumulated Gold: 0 ", 190, 65, 240, 17)
  345.     $lblGold=GUICtrlCreateLabel("Gold Per Hour: 0 ", 190, 80, 240, 17)
  346.     $TotalGold=GUICtrlCreateLabel("Total Gold: 0 ", 190, 95, 240, 17)
  347.     GUISetState(@SW_SHOW)
  348. EndFunc   ;==>SetupGUI
  349.  
  350. Func CheckDead()
  351.     $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
  352.     If Not @error Then
  353.         GUICtrlSetData($lblStatus, "Status: Logging out")
  354.         Sleep(11000)
  355.         Sleep($loadtime)
  356.         Return 1
  357.     EndIf
  358.  
  359.     $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
  360.     If Not @error Then
  361.         GUICtrlSetData($lblStatus, "Status: Open Window")
  362.         Sleep(200)
  363.         Send("{SPACE}") ;close any open windows
  364.         Return 1
  365.     EndIf
  366.  
  367.     $YouHaveDied = PixelSearch(Round(620 * $x_ratio), Round(325 * $y_ratio), Round(625 * $x_ratio), Round(330 * $y_ratio), 0xFFFFFF) ; checks for white text "YOU HAVE DIED"
  368.     If Not @error Then
  369.         GUICtrlSetData($lblStatus, "Status: Dead")
  370.         $deathCount += 1
  371.         Call("LeaveGame")
  372.         Sleep(11000)
  373.         Sleep($loadtime)
  374.         Return 1
  375.     Else
  376.         Return 0
  377.     EndIf
  378. EndFunc   ;==>CheckDead
  379.  
  380. Func CheckRepair()
  381.     $RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
  382.     If Not @error Then
  383.         Call("DoRepair")
  384.     EndIf
  385.     $RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
  386.     If Not @error Then
  387.         Call("DoRepair")
  388.     EndIf
  389. EndFunc   ;==>CheckRepair
  390.  
  391. Func DoRepair()
  392.     Sleep(Random(75, 150))
  393.     Call("TownPortal")
  394.     If CheckDead() Then
  395.         Return
  396.     EndIf
  397.     If CheckFor("NewTristram", "Area") Then
  398.         RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
  399.         Moving(1875)
  400.         RandClick("left", Round(1316 * $x_ratio), Round(206 * $y_ratio), 1, 1) ;moves to get merchant in screen
  401.         Moving(1875)
  402.         RandClick("left", Round(845 * $x_ratio), Round(225 * $y_ratio), 1, 1) ;NPC Merchant to the right of cain's home
  403.         Sleep(1200)
  404.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  405.         Sleep(400)
  406.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  407.         Sleep(200)
  408.         Send("{Escape}")
  409.         If Not CheckDead() Then
  410.             Call("LeaveGame")
  411.         EndIf
  412.     EndIf
  413. EndFunc   ;==>DoRepair
  414.  
  415. Func CalcTime()
  416.     $srt = TimerDiff($rt)
  417.     GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  418.     $trt = TimerDiff($t)
  419.     $total = Round((($trt / 1000) / 60) / 60, 4)
  420.  
  421.     ;Total runtime calculation.
  422.     $hours = Floor((($trt / 1000) / 60) / 60)
  423.     $minutes = (($trt / 1000) / 60)
  424.     ;trim minutes if runtime is more then 1 hour.
  425.     If $minutes > 60 Then
  426.         While $minutes > 60
  427.             $minutes -= 60
  428.         WEnd
  429.     EndIf
  430.     GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, " & Ceiling($minutes) & " minutes")
  431. EndFunc   ;==>CalcTime
  432.  
  433. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 6, $tolerance = 140)
  434.     If $type = "Area" Then
  435.         $startX = 1500 * $x_ratio
  436.         $startY = 0 * $y_ratio
  437.         $endX = 1920 * $x_ratio
  438.         $endY = 90 * $y_ratio
  439.         $seconds = 2.5
  440.     EndIf
  441.     $c = 0
  442.     $string = $pngLoc & $img & ".png"
  443.     Do
  444.         $c += 1
  445.         Sleep(100)
  446.         If $c > ($seconds * 10) Then ;Make sure we never get stuck here for infinity.
  447.             If $type = "Area" Then
  448.                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  449.             EndIf
  450.             Return False
  451.         EndIf
  452.     Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  453.     Return True
  454. EndFunc   ;==>CheckFor
  455.  
  456. Func Loot()
  457.     Sleep(Random(500, 1200))
  458.     MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  459.     If $LootSets == True Then
  460.         $SetCount += LootGear(0x02CE01)
  461.     EndIf
  462.     If $LootLegendaries == True Then
  463.         $LegendaryCount += LootGear(0xBF642F, 0)
  464.     EndIf
  465.     If $LootRares == True Then
  466.         $RareCount += LootGear(0xBBBB00)
  467.     EndIf
  468.     If $LootGems == True Then
  469.         Call("LootGems")
  470.     EndIf
  471.     If $LootTomes == True Then
  472.         Call("LootTomes")
  473.     EndIf
  474.     If $LootCustom == True Then
  475.         Call("LootCustom")
  476.     EndIf
  477.     If $LootMagic == True Then
  478.         $MagicCount += LootGear(0x6969FF)
  479.     EndIf
  480.     Call("ShowLoot")
  481. EndFunc   ;==>Loot
  482.  
  483. Func LootGear($color, $tolerance = 2)
  484.     $count = 0
  485.     $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  486.     If Not @error Then
  487.         While Not @error
  488.             $count += 1
  489.             MouseClick('left', $Loot[0], $Loot[1], 1, 3)
  490.             Sleep(50)
  491.             MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  492.             Sleep(1000)
  493.             ;Run at max 10 times per quality
  494.             If $count >= 10 Then
  495.                 ExitLoop
  496.             EndIf
  497.             $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  498.         WEnd
  499.     EndIf
  500.     Return $count
  501. EndFunc   ;==>LootGear
  502.  
  503. Func LootCustom()
  504.     $count = 0
  505.     $gX = 0
  506.     $gY = 0
  507.     For $i = 0 To ($totalItems - 1)
  508.         $array = StringSplit($pick[$i], "|")
  509.         $file = $array[1]
  510.         $accuracy = $array[2]
  511.         $urlString = $pngLoc & $file
  512.         While _ImageSearchArea($pngLoc & $file, 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, $accuracy)
  513.             $count += 1
  514.             MouseClick("left", $gX, $gY, 1, 3)
  515.             Sleep(50)
  516.             MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  517.             Sleep(1000)
  518.             If $count >= 10 Then
  519.                 ExitLoop
  520.             EndIf
  521.         WEnd
  522.     Next
  523. EndFunc   ;==>LootCustom
  524.  
  525. Func LootGems()
  526.     $count = 0
  527.     $gX = 0
  528.     $gY = 0
  529.     While _ImageSearchArea($pngLoc & "square.png", 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, 90)
  530.         $count += 1
  531.         MouseClick("left", $gX, $gY - 3, 1, 3)
  532.         Sleep(50)
  533.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  534.         $GemCount += 1
  535.         Sleep(1000)
  536.         If $count >= 10 Then
  537.             ExitLoop
  538.         EndIf
  539.     WEnd
  540. EndFunc   ;==>LootGems
  541.  
  542. Func LootTomes()
  543.     $count = 0
  544.     $gX = 0
  545.     $gY = 0
  546.     While _ImageSearchArea($pngLoc & "tome.png", 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, 90)
  547.         $count += 1
  548.         MouseClick("left", $gX, $gY - 3, 1, 3)
  549.         Sleep(50)
  550.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  551.         $TomeCount += 1
  552.         Sleep(1000)
  553.         If $count >= 10 Then
  554.             ExitLoop
  555.         EndIf
  556.     WEnd
  557. EndFunc   ;==>LootTomes
  558.  
  559. Func Identify()
  560.     Send("c")
  561.     Sleep(1300)
  562.     While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 120)
  563.         GUICtrlSetData($lblStatus, "Status: Identifying")
  564.         MouseClick("right", $gX, $gY, 1, 4)
  565.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  566.         Sleep(Random(3000, 3500))
  567.     WEnd
  568.     Send("c")
  569.     Sleep(200)
  570. EndFunc   ;==>Identify
  571.  
  572. Func ClickTab($Tabno)
  573.  
  574.         If $Tabno = 1 Then RandClick("left", Round(517 * $x_ratio), Round(229 * $y_ratio), 3, 4)
  575.  
  576.         If $Tabno = 2 Then RandClick("left", Round(517 * $x_ratio), Round(361 * $y_ratio), 3, 4)
  577.  
  578.         If $Tabno = 3 Then RandClick("left", Round(517 * $x_ratio), Round(486 * $y_ratio), 3, 4)
  579.  
  580.         Sleep(Random(100, 200))
  581.  
  582. EndFunc   ;==>ClickTab
  583.  
  584. Func UseNextTab()
  585.  
  586.  if $ItemTab = $NextItemTab Then
  587.  
  588.           Call("AddLog", "Second Stash full Using Last tab")
  589.           $ItemTab = $FinalItemTab
  590.    elseif $ItemTab =$FinalItemTab Then
  591.           Call("AddLog", "Stash full, disabling stashing and magic looting")
  592.           $StashLegendary = False
  593.           $StashRare = False
  594.           $StashMagic = False
  595.           $LootMagic = False
  596.    else
  597.    Call("AddLog", "Stash full Using next tab")
  598.           $ItemTab = $NextItemTab
  599.  
  600.    EndIf
  601.    
  602. EndFunc   ;==>UseNextTab
  603.  
  604.      
  605. Func AddLog($logtxt)
  606.  
  607.         Local $file = FileOpen("log.txt", 1)
  608.  
  609.         $msg = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ': ' & $logtxt & @CRLF
  610.  
  611.         FileWrite($file, $msg)
  612.  
  613.         FileClose($file)
  614.  
  615.         ConsoleWrite($msg)
  616.  
  617. EndFunc   ;==>AddLog
  618.  
  619.  
  620. Func StashLoot()
  621.  
  622.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  623.  
  624.         MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  625.  
  626.         Sleep(Random(800, 1000))
  627.  
  628.         ClickTab($GemTab)
  629.  
  630.         ;Tomes
  631.         If $StashTomes Then
  632.  
  633.                 GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  634.  
  635.                 ClickImage("TomeIcon.png", 140, 1)
  636.  
  637.         EndIf
  638.  
  639.         ;Gems (DOESN'T STASH BOTTOM ROW!)
  640.  
  641.         If $StashGems Then
  642.  
  643.                 GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  644.  
  645.                 For $i = 0 To 7
  646.  
  647.                         ClickImage($gems[$i], 150, 1)
  648.                 Next
  649.  
  650.         EndIf
  651.  
  652.         $numstashed = 0;
  653.  
  654.         ClickTab($ItemTab)
  655.  
  656.         If $StashLegendary Then
  657.  
  658.                 ClickItems(0xFF7F00, 2, True, 5)
  659.  
  660.                 ClickItems(0x8F5C25, 2, True, 5)
  661.  
  662.         EndIf
  663.  
  664.         If $StashRare Then
  665.  
  666.                 ClickItems(0x4A3C0B, 1, True, 20)
  667.  
  668.         EndIf
  669.  
  670.         If $StashMagic Then
  671.  
  672.                 ClickItems(0x182037, 1, True, 30)
  673.  
  674.         EndIf
  675.  
  676.  
  677.         Call("AddLog", "Stashed Items: " & $numstashed)
  678.  
  679.         Sleep(Random(300, 400))
  680.  
  681.         Send("{SPACE}")
  682.  
  683. EndFunc   ;==>StashLoot
  684.  
  685. Func ClickItems($color, $tolerance, $checkfull = False, $max = 30)
  686.  
  687.         $c = 0
  688.  
  689.         While $c < $max
  690.  
  691.                 RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  692.                 Sleep(Random(60, 120))
  693.  
  694.                 $StashPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  695.  
  696.                 If Not @error Then
  697.  
  698.                         MouseClick("right", $StashPixel[0], $StashPixel[1], 1, 4)
  699.  
  700.                         $c += 1
  701.  
  702.                         If $checkfull Then
  703.  
  704.                                 $numstashed += 1
  705.  
  706.                         Else
  707.  
  708.                                 $numsold += 1
  709.  
  710.                         EndIf
  711.  
  712.                 Else
  713.  
  714.                         ExitLoop
  715.  
  716.                 EndIf
  717.  
  718.         WEnd
  719.  
  720.         Sleep(Random(60, 120))
  721.         If $checkfull Then
  722.                 If $c = $max Then Call("UseNextTab")
  723.                 ClickTab($ItemTab)
  724.         EndIf
  725. EndFunc   ;==>ClickItems
  726.  
  727.  
  728. Func ClickImage($image, $tolerance, $max = 20)
  729.  
  730.         For $c = 1 To $max
  731.  
  732.                 RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
  733.  
  734.                 Sleep(Random(100, 300))
  735.  
  736.                 If _ImageSearchArea($pngLoc & $image, 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, $tolerance) Then
  737.  
  738.                         MouseClick("right", $gX, $gY, 1, 4)
  739.  
  740.                         Sleep(120)
  741.  
  742.                 Else
  743.  
  744.                         ExitLoop
  745.  
  746.                 EndIf
  747.  
  748.         Next
  749.  
  750. EndFunc   ;==>ClickImage
  751.  
  752. Func VendorLoot()
  753.     GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  754.     If Not $StashLoot == True Then ;Move from TP towards vendor
  755.         Sleep(Random(300, 500))
  756.         MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  757.     Else ;Move from Stash towards vendor
  758.         Sleep(Random(300, 500))
  759.         MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  760.     EndIf
  761.     Moving(2600)
  762.     MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  763.     Moving(2600)
  764.  
  765.     ;All
  766.     If $vendorAll == True Then
  767.         For $c = 1 To $vendorCols
  768.             For $r = 1 To $vendorRows
  769.                 RandClick("right", (((($c - 1) * 50) + 32 + 1400) * $x_ratio), (((($r - 1) * 51) + 32 + 580) * $y_ratio), 2, 2, 1, 2.5)
  770.             Next
  771.         Next
  772.     EndIf
  773.  
  774.     ;Rares
  775.     If $VendorRare == True Then
  776.         VendItems(0x4A3C0B, 1)
  777.     EndIf
  778.  
  779.     ;Magic
  780.     If $VendorMagic == True Then
  781.         VendItems(0x182037, 1)
  782.     EndIf
  783.  
  784.     Sleep(200)
  785.     RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  786.     Sleep(300)
  787.     RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  788.     Sleep(200)
  789.     GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  790.     Send("{ESCAPE}")
  791. EndFunc   ;==>VendorLoot
  792.  
  793. Func VendItems($color, $tolerance)
  794.     $c = 0
  795.     While $c <= 20
  796.         Sleep(Random(20, 100))
  797.         $VendPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
  798.         If Not @error Then
  799.             MouseClick("right", $VendPixel[0], $VendPixel[1], 1, 4)
  800.             $c += 1
  801.         Else
  802.             ExitLoop
  803.         EndIf
  804.     WEnd
  805. EndFunc   ;==>VendItems
  806.  
  807. Func StopLog()
  808. $repairCountPercent = $repairCount / $run
  809. $deathsCountPercent = $deathCount / $run
  810. $cellarCountPercent = $cellarCount /  $run
  811. $closedCellarCountPercent = ($run - $cellarCount) / $run
  812. $trt = TimerDiff($t)
  813. ;Total runtime calculation.
  814. $hours = Floor((($trt / 1000) / 60) / 60)
  815. $minutes = (($trt / 1000) / 60)
  816. If $minutes > 60 Then
  817.         While $minutes > 60
  818.             $minutes -= 60
  819.         WEnd
  820. EndIf
  821. _FileWriteLog("Dank Cellar Log.txt",  @CRLF & "************************************************" & @CRLF & _
  822. "Dank Celler" & @CRLF & @CRLF & "Stats:" & @CRLF &  _
  823. "Total Runtime: " & $hours & " hours, " & Ceiling($minutes) & " minutes" & @CRLF & _
  824. "Total Cellars Found: " & $cellarCount & " (" & Round($cellarCountPercent * 100,.00) & "%" & ")" & @CRLF & _
  825. "Total Cellars Not Found: " & $run - $cellarCount & " (" & Round($closedCellarCountPercent * 100,.00) & "%" & ")" & @CRLF & _
  826. "Total Deaths: " & $deathCount &  " (" & Round($deathsCountPercent * 100,.00) & "%" & ")" & @CRLF & _
  827. "Total Repairs: " & $repairCount &  " (" & Round($repairCountPercent * 100,.00) & "%" & ")" & @CRLF & @CRLF & "Loot:" & @CRLF & _
  828. "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount & @CRLF & _
  829. "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount & @CRLF & _
  830. "Starting Gold: " & $StartingGold & " Gold Per Hour: " & (Round($GPH)) & " Gold Earned: " & $AccumulatedGold & @CRLF & _
  831. "Total Gold: " & $CurrentGoldInteger & @CRLF & _
  832. "************************************************")
  833. EndFunc
  834.  
  835. Func GoldPerHour()
  836. Send("i")
  837. Sleep(800)
  838. $CurrentGoldCaptured = _TesseractScreenCapture(0, "", 1,  2,1454,508,1920-1571,1080-525, 0)
  839. Send("i")
  840.  
  841. $CurrentGoldInteger = ""
  842.  
  843.  
  844. For $i = 1 to stringlen($CurrentGoldCaptured)
  845. $chr = asc(StringMid($CurrentGoldCaptured, $i, 1))
  846. if $chr >= 48 And $chr <= 57 Then $CurrentGoldInteger = $CurrentGoldInteger & chr($chr)
  847. Next
  848.  
  849.  
  850. $trt = TimerDiff($t)
  851. $SecondsRan = $trt / 1000
  852.  
  853. If $StartingGold <= 0 Then $StartingGold = $CurrentGoldInteger
  854. If $StartingGold > 0 Then $AccumulatedGold = $CurrentGoldInteger - $StartingGold
  855. $GPH = $AccumulatedGold / $SecondsRan * 60 * 60
  856.  
  857. $GPH=(Round($GPH,0))
  858.  
  859. If $GPH >= 0 and $AccumulatedGold >=0 then
  860.    GUICtrlSetData($StartingG, "Starting Gold: " & _StringAddThousandsSep($StartingGold))
  861.    GUICtrlSetData($AccumulatedG, "Gold Earned: "& _StringAddThousandsSep($AccumulatedGold))
  862.    GUICtrlSetData($lblGold, "Gold Per Hour: " & _StringAddThousandsSep($GPH))
  863.    GUICtrlSetData($TotalGold, "Total Gold: " & _StringAddThousandsSep($CurrentGoldInteger))
  864. EndIf
  865.  
  866. EndFunc ;==>GoldPerHour
  867.  
  868. Func DoUpdate()
  869.     $ini = InetGet($VersionsInfo, @ScriptDir & "\version.ini") ;download version.ini
  870.     If $ini = 0 Then ;was the download of version.ini successful?
  871.         MsgBox(16, "Fatal Error", "The server seems to be offline. No update will be done.")
  872.     Else
  873.         $newVersion = IniRead(@ScriptDir & "\version.ini", "Version", "Version", "") ;reads the new version out of version.ini
  874.         If $newVersion = $oldVersion Then ;compare old and new
  875.             ;MsgBox (0,"No update","There is no update available!")
  876.             FileDelete(@ScriptDir & "\version.ini")
  877.         Else
  878.             $msg = MsgBox(68, "Update", "A new version is available: " & $newVersion & "! Current version: " & $oldVersion & @CRLF & "Do you want to download the new version?")
  879.             If $msg = 7 Then ;No was pressed
  880.                 FileDelete(@ScriptDir & "\version.ini")
  881.             ElseIf $msg = 6 Then ;OK was pressed
  882.                 $downloadLink = IniRead(@ScriptDir & "\version.ini", "Version", "download", "NotFound")
  883.                 $dlhandle = InetGet($downloadLink, @ScriptDir & "\Update_" & $newVersion & ".zip", 1, 1)
  884.                 ProgressOn("Update", "Downloading Updates", "", -1, -1, 16) ;creates a progressbar
  885.  
  886.                 $size = InetGetSize($downloadLink, 1) ;get the size of the update
  887.                 While Not InetGetInfo($dlhandle, 2)
  888.                     $Percent = Round((InetGetInfo($dlhandle, 0) / $size) * 100)
  889.                     ProgressSet($Percent, $Percent & "%") ;update progressbar
  890.                     Sleep(1)
  891.                 WEnd
  892.                 ProgressSet(100, "Done", "Complete") ;show complete progressbar
  893.                 Sleep(500)
  894.                 ProgressOff() ;close progress window
  895.                 IniWrite("updater.ini", "version", "version", $newVersion)
  896.                 InetClose($dlhandle)
  897.                 $iniMsg = IniRead(@ScriptDir & "\version.ini", "Version", "message", "Exiting...")
  898.                 MsgBox(64, "Success", "Download Complete!" & @CRLF & "Please restart the bot by extracting the Au3 from Update_" & $newVersion & ".zip" & @CRLF & $iniMsg)
  899.                 FileDelete(@ScriptDir & "\version.ini")
  900.                 Exit
  901.             EndIf
  902.         EndIf
  903.     EndIf
  904.     WinSetTitle($title, "", $title & $ver & " - Waiting")
  905. EndFunc   ;==>DoUpdate
  906. Func ReadINI()
  907.     $pngLoc = IniRead($ini, "Custom Loot", "PNG Location", $pngLoc)
  908.     $totalItems = IniRead($ini, "Custom Loot", "Total Items", $totalItems)
  909.     $skillCaltrops = IniRead($ini, "Skills", "Caltrops", $skillCaltrops)
  910.     $skillSmokeScreen = IniRead($ini, "Skills", "SmokeScreen", $skillSmokeScreen)
  911.     $skillPreparation = IniRead($ini, "Skills", "Preparation", $skillPreparation)
  912.     $skillCompanion = IniRead($ini, "Skills", "Companion", $skillCompanion)
  913.     $movementSpeed = IniRead($ini, "Additional", "Movement Speed", $movementSpeed)
  914.     $walktime = IniRead($ini, "Additional", "Walk Time", $walktime)
  915.     $loadtime = IniRead($ini, "Additional", "Load Time", $loadtime)
  916.     $tptime = IniRead($ini, "Additional", "Teleport Time", $tptime)
  917.     $LootSets = IniRead($ini, "Looting", "Sets", $LootSets)
  918.     $LootLegendaries = IniRead($ini, "Looting", "Legendaries", $LootLegendaries)
  919.     $LootRares = IniRead($ini, "Looting", "Rares", $LootRares)
  920.     $LootMagic = IniRead($ini, "Looting", "Magic", $LootMagic)
  921.     $LootGems = IniRead($ini, "Looting", "Gems", $LootGems)
  922.     $LootTomes = IniRead($ini, "Looting", "Tomes", $LootTomes)
  923.     $LootCustom = IniRead($ini, "Looting", "Custom", $LootCustom)
  924.     $mLoot = IniRead($ini, "ManageLoot", "Every", $mLoot)
  925.     $Identify = IniRead($ini, "ManageLoot", "Identify", $Identify)
  926.     $StashLoot = IniRead($ini, "Stashing", "Loot", $StashLoot)
  927.     $StashLegendary = IniRead($ini, "Stashing", "Legendaries", $StashLegendary)
  928.     $StashRare = IniRead($ini, "Stashing", "Rares", $StashRare)
  929.     $StashMagic = IniRead($ini, "Stashing", "Magic", $StashMagic)
  930.     $StashTomes = IniRead($ini, "Stashing", "Tomes", $StashTomes)
  931.     $StashGems = IniRead($ini, "Stashing", "Gems", $StashGems)
  932.     $VendorLoot = IniRead($ini, "Vendoring", "Loot", $VendorLoot)
  933.     $VendorRare = IniRead($ini, "Vendoring", "Rares", $VendorRare)
  934.     $VendorMagic = IniRead($ini, "Vendoring", "Magic", $VendorMagic)
  935.     $vendorAll = IniRead($ini, "Vendoring", "All", $vendorAll)
  936.     $vendorRows = IniRead($ini, "Vendoring", "All-Rows", $vendorRows)
  937.     $vendorCols = IniRead($ini, "Vendoring", "All-Cols", $vendorCols)
  938.     $Timer = IniRead($ini, "Variability", "Timer", $Timer)
  939.     $mLootOff = IniRead($ini, "Variability", "Manage Off By", $mLootOff)
  940.     $attackTime = IniRead($ini, "Variability", "Attack Time", $attackTime)
  941.     $attackMulti = IniRead($ini, "Variability", "Attack Multiple", $attackMulti)
  942. EndFunc   ;==>ReadINI
  943. Func CreateINI()
  944.     IniWrite($ini, "Custom Loot", "PNG Location", $pngLoc)
  945.     IniWrite($ini, "Custom Loot", "Total Items", $totalItems)
  946.     IniWrite($ini, "Skills", "Caltrops", $skillCaltrops)
  947.     IniWrite($ini, "Skills", "SmokeScreen", $skillSmokeScreen)
  948.     IniWrite($ini, "Skills", "Preparation", $skillPreparation)
  949.     IniWrite($ini, "Skills", "Companion", $skillCompanion)
  950.     IniWrite($ini, "Additional", "Movement Speed", $movementSpeed)
  951.     IniWrite($ini, "Additional", "Walk Time", $walktime)
  952.     IniWrite($ini, "Additional", "Load Time", $loadtime)
  953.     IniWrite($ini, "Additional", "Teleport Time", $tptime)
  954.     IniWrite($ini, "Looting", "Sets", $LootSets)
  955.     IniWrite($ini, "Looting", "Legendaries", $LootLegendaries)
  956.     IniWrite($ini, "Looting", "Rares", $LootRares)
  957.     IniWrite($ini, "Looting", "Magic", $LootMagic)
  958.     IniWrite($ini, "Looting", "Gems", $LootGems)
  959.     IniWrite($ini, "Looting", "Tomes", $LootTomes)
  960.     IniWrite($ini, "Looting", "Custom", $LootCustom)
  961.     IniWrite($ini, "ManageLoot", "Every", $mLoot)
  962.     IniWrite($ini, "ManageLoot", "Identify", $Identify)
  963.     IniWrite($ini, "Stashing", "Loot", $StashLoot)
  964.     IniWrite($ini, "Stashing", "Legendaries", $StashLegendary)
  965.     IniWrite($ini, "Stashing", "Rares", $StashRare)
  966.     IniWrite($ini, "Stashing", "Magic", $StashMagic)
  967.     IniWrite($ini, "Stashing", "Tomes", $StashTomes)
  968.     IniWrite($ini, "Stashing", "Gems", $StashGems)
  969.     IniWrite($ini, "Vendoring", "Loot", $VendorLoot)
  970.     IniWrite($ini, "Vendoring", "Rares", $VendorRare)
  971.     IniWrite($ini, "Vendoring", "Magic", $VendorMagic)
  972.     IniWrite($ini, "Vendoring", "All", $vendorAll)
  973.     IniWrite($ini, "Vendoring", "All-Rows", $vendorRows)
  974.     IniWrite($ini, "Vendoring", "All-Cols", $vendorCols)
  975.     IniWrite($ini, "Variability", "Timer", $Timer)
  976.     IniWrite($ini, "Variability", "Manage Off By", $mLootOff)
  977.     IniWrite($ini, "Variability", "Attack Time", $attackTime)
  978.     IniWrite($ini, "Variability", "Attack Multiple", $attackMulti)
  979. EndFunc   ;==>CreateINI
  980.  
  981. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  982.     If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  983.     $findImage = "*TRANSBLACK " & $findImage
  984.     If @AutoItX64 Then
  985.         $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  986.     Else
  987.         $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  988.     EndIf
  989.     If $result = "0" Then
  990.         Return 0
  991.     EndIf
  992.  
  993.     ; Otherwise get the x,y location of the match and the size of the image to
  994.     ; compute the centre of search
  995.     $array = StringSplit($result[0], "|")
  996.     If (UBound($array) >= 4) Then
  997.         $x = Int(Number($array[2]))
  998.         $y = Int(Number($array[3]))
  999.         If $resultPosition = 1 Then
  1000.             $x = $x + Int(Number($array[4]) / 2)
  1001.             $y = $y + Int(Number($array[5]) / 2)
  1002.         EndIf
  1003.         Return 1
  1004.     EndIf
  1005. EndFunc   ;==>_ImageSearchArea
  1006.  
  1007. Func LeaveGame()
  1008.  Call("GoldPerHour")
  1009.     Call("RandSleep")
  1010.     GUICtrlSetData($lblStatus, "Status: Leaving Game")
  1011.     Send("{Escape}")
  1012.     Sleep(200)
  1013.     RandClick("left", Round(956 * $x_ratio), Round(579 * $y_ratio), 120, 20) ;Random Click on the leave button
  1014.     Call("CalcTime")
  1015.     Sleep($loadtime)
  1016. EndFunc   ;==>LeaveGame
  1017.  
  1018. Func TownPortal()
  1019.     GUICtrlSetData($lblStatus, "Status: Returning to Town")
  1020.     Send("t")
  1021.     Sleep(Random($tptime, $tptime + 500))
  1022. EndFunc   ;==>TownPortal
  1023.  
  1024. Func Moving($time)
  1025.     Sleep($time / $movementSpeed)
  1026. EndFunc   ;==>Moving
  1027.  
  1028. Func RandClick($clickType, $xPos, $yPos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
  1029.     If $xOff < 1 Then $xOff = 1
  1030.     If $yOff < 1 Then $yOff = 1
  1031.     $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1032.     $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1033.     MouseClick($clickType, $randX, $randY, $clicks, $speed)
  1034. EndFunc   ;==>RandClick
  1035.  
  1036. Func RandMove($xPos, $yPos, $xOff = 10, $yOff = 10, $speed = 1)
  1037.     $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  1038.     $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  1039.     MouseMove($randX, $randY, $speed)
  1040. EndFunc   ;==>RandMove
  1041.  
  1042. Func RandSleep($min = 5, $max = 45, $chance = 3)
  1043.     $randNum = Round(Random(1, 100))
  1044.     If $Timer == True And $randNum <= $chance Then
  1045.         $sleepTime = Random($min * 1000, $max * 1000)
  1046.         GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime / 1000) & " secs")
  1047.  
  1048.         For $c = 0 To 10
  1049.             Sleep($sleepTime / 10)
  1050.         Next
  1051.     EndIf
  1052. EndFunc   ;==>RandSleep
  1053.  
  1054. ;Hotkey Functions
  1055.  
  1056. Func Begin()
  1057.     $Go = Not $Go
  1058.     If Not $Go Then WinSetTitle($title, "", $title & $ver & " - Halted")
  1059. EndFunc   ;==>Begin
  1060.  
  1061. Func TogglePause()
  1062.     $Paused = Not $Paused
  1063.     While $Paused
  1064.         Sleep(100)
  1065.         WinSetTitle($title, "", $title & $ver & " - Paused")
  1066.         ToolTip('[PAUSED] - Deaths: ' & $deathCount & ' | Cellars: ' & $cellarCount, 0, 0)
  1067.     WEnd
  1068.     WinSetTitle($title, "", $title & $ver & " - Running")
  1069.     ToolTip("")
  1070. EndFunc   ;==>TogglePause
  1071.  
  1072. Func ShowLoot()
  1073.     GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  1074.     GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  1075. EndFunc   ;==>ShowLoot
  1076.  
  1077. Func Stop() ;to allow the script to stop
  1078.     Exit
  1079. EndFunc   ;==>Stop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement