Code:
Global $Paused
HotKeySet("=","Leave") ;script started by pressing =
HotKeySet("-", "Pause") ;script paused by pressing -
HotKeySet("x", "Stop") ;script stopped by pressing x
$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
$loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
$tptime = 6900 ; time in ms the script waits for teleport before exiting the game
$yellow = "FFEB00" ; yellow color code it detects @ pixel 1520x40, tweak this if it's not detecting correctly
$go = True
$Leave = False
$NeedRepair = False
$Dead = False
$default_resolutionX = 1920
$default_resolutionY = 1080
$x_ratio = @Desktopwidth / $default_resolutionX
$y_ratio = @Desktopheight / $default_resolutionY
While $go
if($Leave) Then
Call("CheckDead")
Call("CheckProfile")
Call("CheckMenu")
Call("CheckLogout")
Call("CheckRepair")
If $NeedRepair Then
Send("t")
Sleep($tptime)
MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
Sleep(1500)
MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
Sleep(1500)
MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
Sleep(1200)
MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
Sleep(400)
MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
Sleep(100)
Call("CheckDead")
Call("CheckProfile")
Call("CheckMenu")
If Not $Dead Then
Send("{ESCAPE}") ;closes repair tab
Sleep(100)
Send("{ESCAPE}") ;menu
Sleep(10)
MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
Sleep($loadtime)
MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
Sleep($loadtime)
EndIf
Else
$i = 0
Call("CheckRepair")
MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
Sleep(1200)
MouseClick("middle", 1, Round(370*$y_ratio)) ;waits 1 second then [waypoint 2]
Sleep(100)
Send("2")
Sleep(1700)
MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard [waypoint 3]
Sleep(40)
Send("2")
Sleep(20)
Send("3")
Sleep(600)
Send("1")
Sleep(300)
MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
Sleep(700)
Call("CheckDead")
Call("CheckProfile")
Call("CheckMenu")
$Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
If Not @error Then
Send("4")
Sleep(140)
MouseClick("left",Round(300*$x_ratio),Round(100*$y_ratio)) ;Entrance to cellar
Sleep(220)
Send("2")
Sleep($walktime)
MouseClick("middle",Round(80*$x_ratio),Round(940*$y_ratio)) ;moves to doorway leading to rare inside cellar
Sleep(2500)
MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
Sleep(10)
Send("{SHIFTDOWN}")
MouseDown("right") ;attack middle
Sleep(4200)
MouseUp("right")
MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
MouseMove(Round(250*$x_ratio),Round(110*$y_ratio),1) ;attack left
Sleep(40)
MouseDown("right")
Sleep(1600)
MouseUp("right")
MouseMove(Round(590*$x_ratio),Round(50*$y_ratio),1) ;attack right
MouseDown("right")
Sleep(1200)
MouseUp("right")
MouseDown("left")
MouseMove(Round(Random(250,280)*$x_ratio),Round(110*$y_ratio),1) ;attack left
Sleep(1200)
MouseMove(Round(Random(560,600)*$x_ratio),Round(50*$y_ratio),1) ;attack right
Sleep(1200)
MouseUP("left")
Sleep(10)
MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
Sleep(10)
Send("{SHIFTUP}")
Call("CheckDead")
Call("CheckProfile")
Call("CheckMenu")
Sleep(400)
MouseClick("middle",Round(440*$x_ratio),Round(80*$y_ratio)) ;location of sarkoth after death
Sleep(2000)
MouseClick("middle",Round(680*$x_ratio),Round(570*$y_ratio)) ;move to left top corner for gold
Sleep(1200)
MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
Sleep(1600)
Call("CheckLoot")
Send("t")
Sleep($tptime)
Call("CheckDead")
Call("CheckProfile")
Call("CheckMenu")
If Not $Dead Then
Send("{ESCAPE}") ;menu
Sleep(10)
MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
Sleep($loadtime)
MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
Sleep($loadtime)
EndIf
Else
Sleep(10)
MouseClick("middle",Round(1100*$x_ratio),Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
Sleep(200)
Send("1")
Sleep(620)
Send("2")
Sleep(40)
Send("t")
Sleep($tptime)
Call("CheckDead")
Call("CheckProfile")
Call("CheckMenu")
If Not $Dead Then
Send("{ESCAPE}") ;menu
Sleep(10)
MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
Sleep($loadtime)
MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
Sleep($loadtime)
EndIf
EndIf
EndIf
EndIf
WEnd
Func CheckDead()
$Pixeltest = PixelGetColor(Round(740*$x_ratio), Round(850*$y_ratio))
If Hex($Pixeltest, 6) == "0C0404" OR Hex($Pixeltest, 6) == "310000" Then
$Dead = True
Sleep(100)
Send("{Escape}")
Sleep(10)
MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
Sleep(10500)
Sleep($loadtime)
MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
Sleep($loadtime)
Else
$Dead = False
EndIf
EndFunc
Func CheckProfile()
$Pixeltest2 = PixelGetColor(Round(1580*$x_ratio), Round(100*$y_ratio))
If Hex($Pixeltest2, 6) == "653B23" Then
Sleep(20)
Send("{Escape}") ;close the open window
Sleep(20)
MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
Sleep($loadtime)
EndIf
EndFunc
Func CheckMenu()
$Pixeltest2 = PixelGetColor(Round(1158*$x_ratio), Round(218*$y_ratio))
If Hex($Pixeltest2, 6) == "FFD394" Then
Sleep(20)
Send("{Escape}") ;close the open window
Sleep(20)
MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
Sleep($loadtime)
EndIf
EndFunc
Func CheckLogout()
$Pixeltest3 = PixelGetColor(Round(960*$x_ratio), Round(290*$y_ratio))
If Hex($Pixeltest3, 6) == "400400" Then
Sleep(9000)
Sleep($loadtime)
MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
Sleep($loadtime)
EndIf
EndFunc
Func CheckRepair()
$Repair = PixelGetColor(Round(1515*$x_ratio), Round(40*$y_ratio)) ;Searches the exact location of armor indicator
If Hex($Repair, 6) == $yellow Then ;Checks if the pixel is yellow and starts the repair loop
$NeedRepair = True
Else
$NeedRepair = False
EndIf
EndFunc
Func CheckLoot()
Sleep(Random(1200,3200))
$Pixel4 = PixelSearch(Round(270*$x_ratio), 0, Round(1490*$x_ratio), Round(900*$y_ratio), 0xBF642F, 1) ;Searches for Legendary Gear
If Not @error Then
MouseClick ('left', $Pixel4[0], $Pixel4[1])
Sleep(Random(800,1200))
$i+= 1
If $i < 4 Then
Call("CheckLoot")
EndIf
EndIf
$Pixel5 = PixelSearch(Round(270*$x_ratio), 0, Round(1490*$x_ratio), Round(900*$y_ratio), 0x00FF00) ;Searches For Set Gear
If Not @error Then
MouseClick ('left', $Pixel5[0], $Pixel5[1])
Sleep(Random(800,1200))
$i+= 1
If $i < 4 Then
Call("CheckLoot")
EndIf
EndIf
EndFunc
Func Pause()
$Leave = False
EndFunc
Func Stop() ;to allow the script to stop
Exit
EndFunc
Func Leave()
$Leave = True
EndFunc
This is notAres's code, modified by myself. All credit goes to him (and those before him and etc.). All functions working properly (repair, death, loot, etc.). Fixed Ferrets getting stuck on chest. I should note that I disabled looting Rare/Magic items (I'd rather my inventory not be full of them when a Legendary/Set piece drops). It does work for looting up to 4 Legendary/Set items (I've tested it multiple times).