View difference between Paste ID: x3PbRjdi and hV4L3dXR
SHOW: | | - or go back to the newest paste.
1-
;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.
1+
#include <ImageSearch.au3> ;comment this if you are not using the new looting system
2-
;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
2+
Global $Paused
3-
;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkoth-dh-gold-script-autoit-script-1920x1080.html
3+
4-
;;;;;
4+
5-
;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
5+
HotKeySet("=","Leave")  ;script started by pressing =
6-
;Suggested build: http://us.battle.net/d3/en/calculator/demon-hunter#aRYXVT!aYW!YaaabY
6+
HotKeySet("-", "Pause") ;script paused by pressing -
7-
;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
7+
8-
;Official supported resolution: 1920x1080
8+
9-
;;;;;
9+
;ImageSearch Looting Variables
10-
;Original by mackus101 @ ownedcore
10+
$ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
11-
;ImageSearch contributions by rvbfreak, goofinator, and asuRob
11+
$directory = "C:\Users\junqi\Documents\D3" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
12-
;Refactoring and additional functions by Shimizoki
12+
$totalItems = 19 ; This needs to match the number of pngs you are loading
13
Global $pick[$totalItems], $size = WinGetClientSize("[TITLE:Diablo III; CLASS:D3 Main Window Class]"), $go = True, $Leave = False, $Dead = False, $Logout = False, $Window = False, $i = 0, $currentArrayItem = 0, $gX = 0, $gY = 0
14-
;=========== DO NOT TOUCH ===========;
14+
If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
15-
#RequireAdmin
15+
$pick[0] = "legendaryA.png|20"
16-
#include <GUIConstantsEx.au3>
16+
$pick[1] = "legendaryE.png|20"
17-
#include <StaticConstants.au3>
17+
$pick[2] = "legendaryI.png|10"
18-
#include <WindowsConstants.au3>
18+
$pick[3] = "legendaryO.png|20"
19
$pick[4] = "legendaryU.png|20"
20
$pick[5] = "legendaryY.png|20"
21-
Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "1.9.3", $ini = "DH.ini", $hFont = 0, $title, $Paused, $Go = False, $i = 0, $gX = 0, $gY = 0, $LegendaryCount = 0, $SetCount = 0, $RareCount = 0, $MagicCount = 0, $GemCount = 0, $TomeCount = 0, $deathCount = 0, $cellarCount = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000, $lblRun, $lblLocation, $lblStatus, $lblLast, $lblRuntime, $lblGear, $lblItems
21+
$pick[6] = "setA.png|30"
22-
For $i = 0 To Random(0, 7, 1)
22+
$pick[7] = "setE.png|30"
23-
	$title &= Chr(Random(97, 122, 1))
23+
$pick[8] = "setU.png|30"
24
$pick[9] = "setO.png|30"
25-
For $i = 0 To Random(5, 10, 1)
25+
$pick[10] = "setI.png|30"
26-
	$title &= Chr(Random(65, 90, 1))
26+
$pick[11] = "rareA.png|20"
27
$pick[12] = "rareE.png|20"
28-
$title &= " "
28+
$pick[13] = "rareI.png|20"
29-
Global $gems[8] = ["Ru1.png", "Ru2.png", "Em1.png", "Em2.png", "To1.png", "To2.png", "Am1.png", "Am2.png"]
29+
$pick[14] = "rareO.png|20"
30-
If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
30+
$pick[15] = "rareU.png|20" 
31-
If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
31+
$pick[16] = "ros.png|40"
32-
If $size = 0 Then
32+
$pick[17] = "uare.png|40"
33-
	MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
33+
$pick[18] = "tome.png|40"
34-
	Exit
34+
35
$LootRares = True ; set this to false if you don't want the bot to pick up rares (old looting method only)
36-
;====================================;
36+
$Timer = False ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
37
$walktime = 3000 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
38-
;============= SETTINGS: DONT CHANGE HERE, CHANGE DH.INI =============;
38+
$loadtime = 5000 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
39-
HotKeySet("=", "Begin") ;script toggled on/off by pressing =
39+
$tptime = 6900 ; time in ms the script waits for teleport before exiting the game
40-
HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
40+
41
$y_ratio = $size[1] / 1080
42
$yellow = 0xFFF000 ; yellow color code (repair icon)
43-
;Change to match your abilities (1-4 by default)z
43+
$red = 0xD90000 ; red color code (repair icon)
44-
$skillCaltrops = "1"
44+
45-
$skillSmokeScreen = "2"
45+
Call("RestartRun")
46-
$skillPreparation = "3"
46+
47-
$skillCompanion = "4"
47+
   While $go
48
	  if($Leave) Then
49-
$movementSpeed = 25 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0% (25% is the movement cap but SS + Displacement avg = 32%)
49+
		 $i = 0
50
		 Call("CheckExit")
51-
;Custom Loot
51+
		 Sleep(850) ;had to add this since the icon doesn't show up RIGHT away in game
52-
$pngLoc = "@ScriptDir" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
52+
		 Call("CheckDead")
53-
$totalItems = 1 ;Number of items in the pick array
53+
		 Call("CheckRepair")
54-
Global $pick[$totalItems] ;DONT CHANGE THIS
54+
		 If $Window Then
55
			MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
56-
;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
56+
57-
$pick[0] = "mythic.png|40" ;png|Tolerance
57+
			$Window = False
58-
;$pick[1] = "item2.png|0"
58+
59-
;$pick[2] = "item3.png|0"
59+
		 ElseIf $Dead or $Logout Then
60
			ExitLoop
61-
;Looting
61+
		 EndIf
62-
$LootSets = "True" ;True if you want to pick up Sets
62+
		 MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
63-
$LootLegendaries = "True";True if you want to pick up Legendaries
63+
		 Sleep(900)
64-
$LootRares = "True" ;True if you want to pick up Rares
64+
		 Send("2")
65-
$LootMagic = "True" ;True if you want to pick up Magic
65+
		 Sleep(300)
66-
$LootGems = "True" ;True if you want to pick up Gems
66+
		 MouseClick("middle", 1, Round(370*$y_ratio)) ;waits ~1 second then [waypoint 2]
67-
$LootTomes = "True" ;True if you want to pick up Tome of Secrets
67+
		 Sleep(1400)
68-
$LootCustom = "False" ;True if you want to pick up Custom Items (The items in the $pick array above)
68+
		 MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard [waypoint 3]
69
		 Sleep(40)
70-
;Manage Loot
70+
		 Send("2")
71-
$Identify = "True" ;True to enable identifying items before stashing/vendoring
71+
		 Sleep(20)
72-
$mLoot = 5 ;Nuber of successful runs until Stash and Vendor
72+
		 Send("3")
73-
$mLootOff = 2 ;Stash and Vendor after mLoot +- X number of runs (Variability)
73+
		 Sleep(600)
74
		 Send("1")
75-
;Stashing
75+
		 Sleep(300)
76-
$StashLoot = "True" ;True if you want to store Items in the stash
76+
		 MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
77-
;---
77+
		 Sleep(790)
78-
$StashLegendary = "True";True if you want to store Legendary items in the stash
78+
		 Call("CheckDead")
79-
$StashRare = "True" ;True if you want to store Rare items in the stash
79+
		 If $Window Then
80-
$StashMagic = "False" ;True if you want to store Magic items in the stash
80+
			MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
81-
$StashTomes = "True" ;True if you want to store Tomes items in the stash
81+
82-
$StashGems = "True" ;True if you want to store Gems items in the stash
82+
			$Window = False
83
			ExitLoop
84-
;Vendoring ==NEW SETTINGS==
84+
		 ElseIf $Dead or $Logout Then
85-
$VendorLoot = "True" ;True if you want to vendor anything
85+
86-
;---
86+
		 EndIf
87-
$VendorRare = "True" ;True if you want to vendor Rares
87+
		 $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x600 box from the top left - where it should always be)
88-
$VendorMagic = "True" ;True if you want to vendor Magic
88+
			   If Not @error Then
89-
$vendorAll = "False" ;True if you want to right click all items when talking to vendor
89+
				  MouseClick("left",Round(300*$x_ratio),Round(100*$y_ratio)) ;Entrance to cellar
90-
$vendorRows = 5 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
90+
				  Sleep(300)
91-
$vendorCols = 10 ;# of columns to vendor, starting from left
91+
				  Send("2")
92
				  Sleep(350) ; second cast in case the cooldown timer isn't quite right (rarely happens)
93-
;Variability ==NEW SETTINGS==
93+
				  Send("2")
94-
$Timer = "True" ;True and the bot will add random sleep intervals
94+
				  Sleep($walktime)
95-
;---
95+
				  MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
96-
$attackTime = 3900 ;Time (in ms) the script will shoot sarkoth with the right button
96+
				  Sleep(2500)
97-
$attackMulti = "True" ;True if you want to shoot both left and right in addition to the middle (False for Lightning Ball)
97+
				  MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
98-
$walktime = 2800 ;Time (in ms) the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
98+
				  Sleep(10)
99-
$loadtime = 3400 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
99+
				  Send("{SHIFTDOWN}")
100-
$tptime = 6900 ;Time (in ms) the script waits for teleport before exiting the game
100+
				  MouseDown("right") ;attack middle
101-
;====================================;
101+
				  Sleep(1200)
102
				  Send("4")
103
				  Sleep(3000)
104
				  MouseUp("right")
105-
If FileExists($ini) Then
105+
				  MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
106-
	Call("ReadINI")
106+
				  MouseMove(Round(240*$x_ratio),Round(75*$y_ratio),1) ;attack left
107-
	Call("CreateINI")
107+
				  Sleep(40)
108
				  MouseDown("right")
109-
	Call("CreateINI")
109+
				  Sleep(2800)
110
				  MouseUp("right")
111
				  MouseMove(Round(590*$x_ratio),Round(50*$y_ratio),1) ;attack right
112-
If $pngLoc == "@ScriptDir" Then $pngLoc = @ScriptDir & "\pics\"
112+
				  MouseDown("right")
113-
If $totalItems < 1 Then $LootCustom = "False"
113+
				  Sleep(1800)
114-
$mLootIn = $mLoot
114+
				  MouseUp("right")
115-
$movementSpeed = 1 + ($movementSpeed / 100)
115+
				  MouseDown("left")
116-
$VersionsInfo = "http://dl.dropbox.com/u/9955791/version.ini"
116+
				  MouseMove(Round(Random(240,260)*$x_ratio),Round(75*$y_ratio),1) ;attack left
117-
$oldVersion = IniRead("updater.ini", "Version", "Version", $ver)
117+
				  Sleep(1200)
118-
$newVersion = "0.0"
118+
				  MouseMove(Round(Random(560,600)*$x_ratio),Round(50*$y_ratio),1) ;attack right
119
				  Sleep(1200)
120-
If Not FileExists($pngLoc & "MainMenu.png") Then
120+
				  MouseUP("left")
121-
	MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
121+
				  Sleep(10)
122-
	Exit
122+
				  MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
123
				  Sleep(10)
124
				  Send("{SHIFTUP}")
125-
Call("SetupGUI")
125+
				  Sleep(400)
126-
Call("DoUpdate")
126+
				  MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
127
				  Sleep(2100)
128-
While 1
128+
				  MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
129-
	Call("RestartRun")
129+
				  Sleep(1100)
130-
WEnd
130+
				  MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
131
				  Sleep(1100)
132
				  Send("4")
133-
	If ($Go) Then
133+
				  MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
134-
		$i = 0
134+
				  Send("{ALTDOWN}")
135-
		WinSetTitle($title, "", $title & $ver & " - Running")
135+
				  Call("CheckLoot")
136-
		MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
136+
				  Send("{ALTUP}")
137-
		;Checks if the player is Dead/Logout/Window, then if in Main Menu, etc.
137+
				  SLeep(10)
138-
		If CheckDead() Then
138+
				  Send("t")
139-
			Return
139+
				  Sleep($tptime)
140-
		ElseIf CheckFor("ExitGame", "", Round(860 * $x_ratio), Round(400 * $y_ratio), Round(1040 * $x_ratio), Round(450 * $y_ratio), 0.5, 140) Then
140+
				  Call("RandomSleep")
141-
			GUICtrlSetData($lblStatus, "Status: Exit window up")
141+
				  Call("CheckDead")
142-
			MouseClick("left", Round(1064 * $x_ratio), Round(632 * $y_ratio))
142+
				  If Not $Logout And Not $Dead And Not $Window Then
143-
			Sleep(100)
143+
					 Sleep(300)
144-
			Send("{SPACE}")
144+
					 Send("{ESCAPE}") ;menu
145-
			Return
145+
					 Sleep(200)
146-
		ElseIf CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio)) Then
146+
					 MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
147-
			GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till vendor: " & $mLootIn)
147+
					 Sleep($loadtime)
148-
			GUICtrlSetData($lblLocation, "Location: Main Menu")
148+
					 Call("CheckDead")
149-
			GUICtrlSetData($lblStatus, "Status: Starting Game")
149+
					 If Not $Logout Then
150-
			RandClick("left", Round(230 * $x_ratio), Round(416 * $y_ratio), 120, 20, 1, 6) ;Random Click on the resume button
150+
						MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
151
						Sleep($loadtime)
152-
			$rt = TimerInit()
152+
					 EndIf
153-
			$run += 1
153+
				  Else
154-
		ElseIf CheckFor("OldRuins", "Area") Or CheckFor("NewTristram", "Area") Or CheckFor("DankCellar", "Area") Then
154+
					 MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
155-
			Call("TownPortal")
155+
					 Sleep($loadtime)
156-
			Call("LeaveGame")
156+
					 $Window = False ; reset the flag so it doesn't think a window is always up
157-
			Return
157+
				  EndIf
158-
		ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
158+
			   Else
159-
			MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio))
159+
				  Sleep(10)
160-
			$rand = Random(40000, 80000)
160+
				  MouseClick("middle",Round(1100*$x_ratio),Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
161-
			GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
161+
				  Sleep(200)
162-
			Sleep($rand)
162+
				  Send("1")
163-
			Send("{SPACE}")
163+
				  Sleep(620)
164-
			Return
164+
				  Send("2")
165-
		ElseIf CheckFor("Disconnect", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
165+
				  Sleep(40)
166-
			GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
166+
				  Send("t")
167-
			MouseClick("left", Round(960 * $x_ratio), Round(632 * $y_ratio))
167+
				  Sleep($tptime)
168-
			Sleep(100)
168+
				  Call("RandomSleep")
169-
			Send("{SPACE}")
169+
				  Call("CheckDead")
170-
			Return
170+
				  If Not $Logout And Not $Dead And Not $Window Then
171-
		Else
171+
					 Sleep(300)
172-
			GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
172+
					 Send("{ESCAPE}") ;menu
173-
			Return
173+
					 Sleep(200)
174-
		EndIf
174+
					 MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
175-
		;Make sure we are in the right area before beginning run
175+
					 Sleep($loadtime)
176-
		If CheckFor("OldRuins", "Area") Then
176+
					 Call("CheckDead")
177-
			Sleep(200)
177+
					 If Not $Logout Then
178-
			GUICtrlSetData($lblLocation, "Location: Old Ruins")
178+
						MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
179-
			Call("CheckRepair")
179+
						Sleep($loadtime)
180-
			;Start Run
180+
					 EndIf
181-
			RandClick("middle", Round(500 * $x_ratio), Round(250 * $y_ratio), 2, 2) ;starts the run [waypoint 1]
181+
				  Else
182-
			Moving(900)
182+
					 MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
183-
			Send($skillSmokeScreen)
183+
					 Sleep($loadtime)
184-
			Moving(600)
184+
					 $Window = False ; reset the flag so it doesn't think a window is always up
185-
			RandClick("middle", Round(3 * $y_ratio), Round(370 * $y_ratio), 2, 2) ;waits ~1 second then [waypoint 2]
185+
				  EndIf
186-
			Moving(1850)
186+
187-
			RandClick("middle", Round(400 * $x_ratio), Round(600 * $y_ratio), 2, 2) ;middle of courtyard [waypoint 3]
187+
	  EndIf
188-
			Moving(100)
188+
   WEnd
189-
			Send($skillSmokeScreen)
189+
   Call("RestartRun")
190-
			Moving(100)
190+
EndFunc
191-
			Send($skillPreparation)
191+
192-
			Moving(750)
192+
193-
			Send($skillCaltrops)
193+
Call("CheckWindow")
194-
			Moving(100)
194+
$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"
195-
			RandMove(Round(300 * $x_ratio), Round(70 * $y_ratio), 1, 1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
195+
If Not @error Then
196-
			Sleep(350)
196+
   If Not $Window Then
197-
			If CheckDead() Then
197+
	  $Dead = True
198-
				Return
198+
	  Sleep(100)
199
	  Send("{Escape}")
200
	  Sleep(10)
201-
			;Checks if Dank Cellar is Open
201+
	  MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
202-
			$Pixel2 = PixelSearch(0, 0, Round(600 * $x_ratio), Round(600 * $y_ratio), 0x334FB7, 3)
202+
	  Sleep(11000)
203-
			If Not @error Then
203+
	  Sleep($loadtime)
204-
				GUICtrlSetData($lblStatus, "Status: Cellar - Found")
204+
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
205-
				$cellarCount += 1
205+
	  Sleep($loadtime)
206-
				MouseClick("left", Round(300 * $x_ratio), Round(70 * $y_ratio), 1) ;Entrance to cellar
206+
   Else
207-
				Sleep(800 * $movementSpeed)
207+
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
208-
				Send($skillSmokeScreen)
208+
	  Sleep($loadtime)
209-
				Moving($walktime)
209+
	  $Dead = False
210-
			Else ;ABORT RUN
210+
   EndIf
211-
				GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
211+
212-
				Sleep(10)
212+
   $Dead = False
213-
				RandClick("middle", Round(1100 * $x_ratio), Round(600 * $y_ratio)) ;moves between caltrops for safety before teleporting back to town
213+
214-
				Moving(250)
214+
$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
215-
				Send($skillCaltrops)
215+
If Not @error Then
216-
				Sleep(620)
216+
   Sleep(11000)
217-
				Send($skillSmokeScreen)
217+
   Sleep($loadtime)
218-
				Sleep(40)
218+
   If Not $Window Then
219-
				Call("TownPortal")
219+
	  $Dead = True
220-
				If Not CheckDead() Then
220+
	  $Logout = True
221-
					Call("LeaveGame")
221+
	  Sleep($loadtime)
222-
				EndIf
222+
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
223-
				Return
223+
	  Sleep($loadtime)
224
   Else
225-
		Else
225+
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
226-
			Call("TownPortal")
226+
	  Sleep($loadtime)
227-
			If Not CheckDead() Then
227+
	  $Logout = False
228-
				Call("LeaveGame")
228+
   EndIf
229
Else
230-
			Return
230+
   $Logout = False
231-
		EndIf
231+
232
EndFunc
233-
		;Checks that the player is in the Dank Cellar
233+
234-
		If CheckFor("DankCellar", "Area") Then
234+
Func CheckWindow()
235-
			GUICtrlSetData($lblLocation, "Location: Dank Cellar")
235+
$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
236-
			RandClick("middle", Round(110 * $x_ratio), Round(1000 * $y_ratio), 1, 1) ;moves to doorway leading to rare inside cellar
236+
If Not @error Then
237-
			Sleep(Random(2200, 2800))
237+
   Sleep(200)
238-
			RandMove(Round(460 * $x_ratio), Round(80 * $y_ratio), 1, 1) ;hovers over the rare Sarkoth
238+
   Send("{SPACE}") ;close any open windows
239-
			Sleep(10)
239+
   $Window = True
240-
			Send("{SHIFTDOWN}")
240+
241-
			GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
241+
   $Window = False
242-
			MouseDown("right") ;ATTACK
242+
243-
			Sleep(1100)
243+
EndFunc
244-
			Send($skillCompanion)
244+
245-
			Sleep($attackTime)
245+
Func CheckExit()
246-
			MouseUp("right")
246+
$ExitButton = PixelSearch(Round(1190*$x_ratio), Round(400*$y_ratio), Round(1200*$x_ratio), Round(440*$y_ratio), 0x14100E) ; checks for the grey border of the exit prompt
247-
			RandClick("left", Round(460 * $x_ratio), Round(80 * $y_ratio), 1, 1)
247+
If Not @error Then
248-
			RandMove(Round(240 * $x_ratio), Round(75 * $y_ratio), 1, 1) ;attack left
248+
   Send("{ESCAPE}")
249-
			Sleep(40)
249+
   Sleep(100)
250-
			MouseDown("right")
250+
   Send("{SPACE}") ;close any open windows
251-
			If $attackMulti == True Then Sleep($attackTime / 2)
251+
   Sleep(200)
252-
			MouseUp("right")
252+
   MouseMove(1,1) ; reset cursor position before checking for button
253-
			MouseMove(Round(590 * $x_ratio), Round(50 * $y_ratio), 1) ;attack right
253+
   $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
254-
			MouseDown("right")
254+
   If $Resume == "400900" Or $Resume == "380900" Then
255-
			If $attackMulti == True Then Sleep($attackTime / 2)
255+
	  Sleep(200)
256-
			MouseUp("right")
256+
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
257-
			MouseDown("left")
257+
	  Sleep($loadtime)
258-
			MouseMove(Round(Random(240, 260) * $x_ratio), Round(75 * $y_ratio), 1) ;attack left
258+
   EndIf
259-
			If $attackMulti == True Then Sleep($attackTime / 2.5)
259+
260-
			MouseMove(Round(Random(560, 600) * $x_ratio), Round(50 * $y_ratio), 1) ;attack right
260+
EndFunc
261-
			If $attackMulti == True Then Sleep($attackTime / 2.5)
261+
262-
			MouseUp("left")
262+
263-
			Sleep(400)
263+
$RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
264-
			MouseClick("right", Round(630 * $x_ratio), Round(18 * $y_ratio), 1, 8) ;break the table & chair
264+
   If Not @error Then
265-
			Sleep(200)
265+
	  Call("DoRepair")
266-
			Send("{SHIFTUP}")
266+
   EndIf
267-
			Moving(200)
267+
$RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
268-
			RandClick("middle", Round(530 * $x_ratio), Round(190 * $y_ratio)) ;location of sarkoth after death
268+
   If Not @error Then
269-
			Moving(2700)
269+
	  Call("DoRepair")
270-
			GUICtrlSetData($lblStatus, "Status: Looting")
270+
   EndIf
271-
			Send($skillCompanion)
271+
EndFunc
272-
			Call("Loot")
272+
273-
			RandSleep(0, 6, 30)
273+
274-
			Send($skillCompanion)
274+
Sleep(100)
275-
			Call("TownPortal")
275+
Send("t")
276-
		Else
276+
Sleep($tptime)
277-
			Send($skillCaltrops)
277+
MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
278-
			Sleep(400)
278+
Sleep(1500)
279-
			Send($skillSmokeScreen)
279+
MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
280-
			Sleep(40)
280+
Sleep(1500)
281-
			Call("TownPortal")
281+
MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
282-
			If Not CheckDead() Then
282+
Sleep(1200)
283-
				Call("LeaveGame")
283+
MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
284
Sleep(400)
285-
			Return
285+
MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
286-
		EndIf
286+
Sleep(200)
287-
		;After successful run
287+
Call("CheckDead")
288-
		If Not CheckDead() Then
288+
If Not $Dead and Not $Logout Then
289-
			Sleep(600)
289+
   Send("{ESCAPE}") ;closes repair tab
290-
			If $mLootIn = 1 And CheckFor("NewTristram", "Area") Then ;If its time to manage loot and we are in town
290+
   Sleep(100)
291-
				If $Identify == True Then Call("Identify")
291+
   Send("{ESCAPE}") ;menu
292-
				If $StashLoot == True Then
292+
   Sleep(10)
293-
					Call("StashLoot")
293+
   MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
294-
				EndIf
294+
   Sleep($loadtime)
295-
				If $VendorLoot == True Then
295+
   MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
296-
					Call("VendorLoot")
296+
   Sleep($loadtime)
297-
				EndIf
297+
298-
				$mLootIn = Round(Random($mLoot - $mLootOff, $mLoot + $mLootOff)) ;Reset Counter
298+
EndFunc
299-
			ElseIf Not CheckFor("NewTristram", "Area") Then
299+
300-
				GUICtrlSetData($lblStatus, "Status: Skipping vendor, not in New Tristram")
300+
Func CheckLoot()
301-
				Sleep(3000)
301+
Sleep(Random(500,2000))
302-
			ElseIf $mLootIn <= 0 Then
302+
If Not $ImgLoot Then
303-
				$mLootIn = 1
303+
   $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
304-
			Else
304+
   If Not @error Then
305-
				$mLootIn -= 1
305+
	  MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
306
	  Sleep(Random(1000,1200))
307-
			If Not CheckDead() Then
307+
	  MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
308-
				Call("LeaveGame")
308+
	  $i+= 1
309
	  If $i <= 6 Then
310-
			Return
310+
		 Call("CheckLoot")
311-
		Else
311+
		 SLeep(10)
312-
			Return
312+
	  EndIf
313-
		EndIf
313+
   EndIf
314-
	EndIf
314+
   $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
315-
EndFunc   ;==>RestartRun
315+
   If Not @error Then
316
	  MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
317-
;Helper Functions
317+
	  Sleep(Random(1000,1200))
318
	  MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
319-
Func SetupGUI()
319+
	  $i+= 1
320-
	$frmBot = GUICreate($title & $ver & " - Updating", 280, 121, Round(1540 * $x_ratio), Round(920 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
320+
	  If $i <= 6 Then
321-
	GUISetBkColor(0xC0C0C0)
321+
		 Call("CheckLoot")
322-
	$lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
322+
		 SLeep(10)
323-
	GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
323+
	  EndIf
324-
	GUICtrlSetColor(-1, 0xFF0000)
324+
   EndIf
325-
	$lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
325+
   If $LootRares Then
326-
	$lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
326+
	  $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
327-
	$lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
327+
	  If Not @error Then
328-
	$lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
328+
		 MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
329-
	$lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
329+
		 Sleep(Random(1000,1200))
330-
	$lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
330+
		 MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
331-
	GUISetState(@SW_SHOW)
331+
		 $i+= 1
332-
EndFunc   ;==>SetupGUI
332+
		 If $i <= 6 Then
333
		 Call("CheckLoot")
334
		 EndIf
335-
	$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
335+
	  EndIf
336-
	If Not @error Then
336+
   EndIf
337-
		GUICtrlSetData($lblStatus, "Status: Logging out")
337+
338-
		Sleep(11000)
338+
   Call("pickItems")
339-
		Sleep($loadtime)
339+
340-
		Return 1
340+
EndFunc
341-
	EndIf
341+
342
Func pickItems()
343-
	$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
343+
$currentArrayItem = 0
344-
	If Not @error Then
344+
For $gI = 0 to ($totalItems - 1)
345-
		GUICtrlSetData($lblStatus, "Status: Open Window")
345+
   $array = StringSplit($pick[$gI],"|")
346-
		Sleep(200)
346+
   $file = $array[1]
347-
		Send("{SPACE}") ;close any open windows
347+
   $accuracy = $array[2]
348-
		Return 1
348+
   $urlString = $directory & $file
349-
	EndIf
349+
   $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
350
   While $i <= 12 ; max: 13 gems and pieces of gear to loot
351-
	$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"
351+
	  If $Target And ($gX > 15) And ($gY > 15) Then
352-
	If Not @error Then
352+
		 ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
353-
		GUICtrlSetData($lblStatus, "Status: Dead")
353+
		 MouseClick("left", $gX, $gY, 1, 0)
354-
		$deathCount += 1
354+
		 Sleep(Random(1200,1400))
355-
		Call("LeaveGame")
355+
		 MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
356-
		Sleep(11000)
356+
		 Sleep(5)
357-
		Sleep($loadtime)
357+
		 $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
358-
		Return 1
358+
		 $i+= 1
359-
	Else
359+
	  Else
360-
		Return 0
360+
		 ExitLoop
361-
	EndIf
361+
	  EndIf
362-
EndFunc   ;==>CheckDead
362+
   WEnd
363
Next
364
EndFunc
365-
	$RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
365+
366-
	If Not @error Then
366+
Func RandomSleep()
367-
		Call("DoRepair")
367+
   If $Timer And Random(1,20) = 20 Then
368-
	EndIf
368+
	  Sleep(Random(30000,60000)
369-
	$RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
369+
   EndIf
370-
	If Not @error Then
370+
EndFunc
371-
		Call("DoRepair")
371+
372-
	EndIf
372+
Func Pause()
373-
EndFunc   ;==>CheckRepair
373+
   $Leave = False
374
EndFunc
375
376-
	Sleep(Random(75, 150))
376+
377-
	Call("TownPortal")
377+
    Exit
378-
	If CheckDead() Then
378+
EndFunc 
379-
		Return
379+
 
380-
	EndIf
380+
Func Leave()
381-
	If CheckFor("NewTristram", "Area") Then
381+
   $Leave = True
382-
		RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
382+
EndFunc