Code:
Global $Paused
HotKeySet("y","Leave") ;Press Y to start the script
HotKeySet("x","Pause")
HotKeySet("z","Quit")
;Stop/Start runs
HotKeySet("c","stopRun")
HotKeySet("v","startRun")
$go = True
$Leave = False
$rand = 0
$timer = TimerInit()
$totalTime = 0
$default_resolutionX = 1920 ;DON'T CHANGE THIS
$default_resolutionY = 1080 ;DON'T CHANGE THIS
;Use these settings to change the script resolution.
$resX = 1920
$resY = 1080
;don't change the ratio lines.
$x_ratio = $resX / $default_resolutionX
$y_ratio = $resY / $default_resolutionY
;Custom Set Vars
;Move Speed, completely untested
$ms = 10 ;default of 10
;4.1 Seconds to load game, increase if you have a slower pc, decrease if you have a faster pc
$pcLoadTime = 5000 ;default of 4100
;Try to not pickup items (using mouse move instead of click)
$DontPickupItems = True ;default of true - uses mouseMove instead of MouseClick to pickup gold, possible avoiding handing in the quest
;What hotkey to hit to use it as a buff. Cannot be a movement buff. Might also be an aoe ability key
$buffKey = 4 ;default of 4, for aura for monk - CANNOT be a click-to-cast ability.
$buffkeytwo = 1 ;make invincable for monk - CANNOT be a click-to-cast ability
;What mousekey to use to do the attacks
$mouseAttack = "left" ;default of left for melee, right for ranged
;2.3 Seconds to Load back into the game Menu
$pcExitTime = 3000 ;default of 2300
;Try to Collect X amount of times
$collectAttempts = 1 ;default of 1 will repeat the pattern if you are having pickup issues
;collection length, 1 = short, 2 = long 0= very small - This is based on your pickup range. 0 should be greater then 10, 1 is 5, 2 less then 5
$colLength = 0 ;default 0
;Time that it takes to attack shadows
$attackTime = 8500 ;default of 6000
;number of runs
$numOfRuns = 0
;attempt runs. will stop after this many runs. set to a small number to test, anything over 5000 will run over night.
$attempts = 50000
;Enterance Load TimerDiff don't really need to mess with this. If you are being attacked by shadows too early, this might be something you want to decrease
$entLoads = 2000
;Try not to edit below these lines
go()
Func go()
While $go
if($Leave) then
if($Leave) then
resumeGame()
goToEnterance()
EndIF
Sleep(time($entLoads,3)) ;Load time
if($Leave) then
endEvent()
fight()
EndIF
if($Leave) then
$ca = $collectAttempts
while($ca > 0)
$ca = $ca-1
goldCollect()
WEnd
EndIF
if($Leave) then
endGame()
doTimer()
EndIF
EndIF
WEnd
if($go = False) Then
stopRuns()
EndIf
EndFunc
Func stopRuns()
endTimer()
While($go = False)
;do nothing
Sleep(1000)
WEND
if($go = true) Then
go()
EndIf
EndFunc
Func endTimer()
$a = $totalTime/$numOfRuns
$b = $totalTime/1000
ConsoleWrite(" == END. Total Time: " & $b/60 & " == Average: " & $a/1000 & " == Over Total Runs: " & $numOfRuns)
EndFunc
;----------Beginning of the mouse macro functions
Func resumeGame()
MouseClick("left",rx(213),ry(411),1) ;Click on Resume Game
Sleep(time($pcLoadTime,3)) ;PC Load Time from Menu to Game
EndFunc
Func goToEnterance() ;Goes to the bottom enterance based on movespeed
Mouseclick("left",rx(xyRand(1530)),ry(369),1)
Sleep(20)
Mouseclick("left",rx(xyRand(1530)),ry(369),1)
Sleep(ms(500))
Mouseclick("left",rx(xyRand(1533)),ry(xyRand(477)),1)
Sleep(20)
Mouseclick("left",rx(xyRand(1533)),ry(xyRand(477)),1)
Sleep(ms(1000))
Mouseclick("left",rx(xyRand(1533)),ry(xyRand(477)),1)
Sleep(20)
Mouseclick("left",rx(xyRand(1533)),ry(xyRand(477)),1)
Sleep(ms(1800))
MouseClick("left",rx(xyRand(968)),ry(xyRand(388)),1) ;Click on enterance
EndFunc
Func endEvent()
Send("{ESC}")
Mouseclick("left",rx(xyRand(928)),ry(359),1) ;Click on Yes to End Event
Sleep(time(2000,3))
EndFunc
Func fight()
Mouseclick("left",rx(xyRand(1062)),ry(xyRand(722)),1)
Sleep(20)
Mouseclick("left",rx(xyRand(1062)),ry(xyRand(722)),1)
Sleep(time(4000,3))
Send($buffkey)
Sleep(20)
MouseMove(rx(960),ry(540))
Sleep(20)
Send($buffkeytwo)
Sleep(time(200,2))
MouseDown($mouseAttack)
Opt("SendKeyDownDelay", time($attackTime,3)) ;6.3 second delay with random added
Send("{LSHIFT}")
Opt("SendKeyDownDelay", 5)
Sleep(20)
MouseUp($mouseAttack)
EndFunc
Func goldCollect()
if($DontPickupItems) Then
justGold()
Return false
EndIf
Mouseclick("left",rx(xyRand(1150)),ry(xyRand(620)),1)
Sleep(time(20,2))
Mouseclick("left",rx(xyRand(1150)),ry(xyRand(620)),1)
Sleep(time(400,2))
Mouseclick("left",rx(xyRand(750)),ry(xyRand(520)),1)
Sleep(time(20,2))
Mouseclick("left",rx(xyRand(750)),ry(xyRand(420)),1)
if($colLength = 1) Then
Sleep(time(430,2))
Mouseclick("left",rx(xyRand(750)),ry(xyRand(420),1)
Sleep(time(430,2))
Mouseclick("left",rx(xyRand(750)),ry(xyRand(620),1)
Sleep(time(430,2))
Mouseclick("left",rx(xyRand(1150)),ry(xyRand(670),1)
Sleep(time(300,2))
EndIf
if($colLength = 2) Then
Mouseclick("left",rx(xyRand(1050)),ry(xyRand(420)),1)
Sleep(time(400,2))
Mouseclick("left",rx(xyRand(750)),ry(xyRand(420)),1)
Sleep(time(300,2))
Mouseclick("left",rx(xyRand(750)),ry(xyRand(620)),1)
Sleep(time(300,2))
Mouseclick("left",rx(xyRand(1050)),ry(xyRand(620)),1)
EndIf
Sleep(time(200,2))
EndFunc
Func justGold()
MouseMove(rx(xyRand(1125)),ry(xyRand(550)))
MouseDown("left")
Sleep(time(400,2))
MouseMove(rx(xyRand(750)),ry(xyRand(520)))
if($colLength = 1) Then
Sleep(time(400,2))
MouseMove(rx(xyRand(750)),ry(xyRand(420))
Sleep(time(400,2))
MouseMove(rx(xyRand(750)),ry(xyRand(620))
Sleep(time(400,2))
MouseMove(rx(xyRand(1150)),ry(xyRand(670))
Sleep(time(500,2))
EndIf
if($colLength = 2) Then
MouseMove(rx(xyRand(1050)),ry(xyRand(380)))
Sleep(time(400,2))
MouseMove(rx(xyRand(750)),ry(xyRand(420)))
Sleep(time(300,2))
MouseMove(rx(xyRand(750)),ry(xyRand(620)))
Sleep(time(300,2))
MouseMove(rx(xyRand(1050)),ry(xyRand(620)))
EndIf
Sleep(time(200,2))
MouseUp("left")
EndFunc
Func endGame()
Send("{ESC}")
Sleep(xyRand(20))
MouseClick("left",rx(xyRand(995)),ry(xyRand(580)),1); end
Sleep(xyRand(20))
Sleep(time($pcExitTime,3))
EndFunc
; Number Changing Functions
Func ms($time)
if($ms = 10) Then
Return $time
ElseIf($ms > 15) Then
if($ms > 24) Then
$i = $time-250
Return $i
Else
$i = $time-100
Return $i
EndIf
ElseIf($ms < 10) Then
$i = $time+100
Return $i
EndIf
EndFunc
Func rand($big)
$rand = Random(-20,80,1) ;Average Random Time Dilation
if($rand > 70) then ;To add a little bit more variation and the number is large and accuracy is not required
if($big = 1) then
$rand = Random(60,120,1)
EndIf
EndIf
if($big = 2) Then;If the number needs small variation
$rand = Random(-20,20,1)
EndIf
if($big = 3) then
$rand = Random(0,400,1)
EndIf
Return $rand
EndFunc
Func time($i,$big)
$temp = $i + rand($big)
Return $temp
EndFunc
Func xyRand($i)
$ran = Random(-2,4,1)
$i = $i+$ran
Return $i
EndFunc
;Pause/Stop Script
Func Pause()
$Leave = False
EndFunc
Func Quit() ;to allow the script to stop
endTimer()
Exit
EndFunc
Func Leave()
$Leave = True
EndFunc
Func stopRun()
$go = False
EndFunc
Func starRun()
$go = True
EndFunc
Func rX($i)
$rx = $i * $x_ratio
return int($rx)
EndFunc
Func rY($i)
$ry = $i * $y_ratio
return int($ry)
EndFunc
Func doTimer()
$numOfRuns = $numOfRuns +1
ConsoleWrite($numOfRuns)
ConsoleWrite(";")
$dif = TimerDiff($timer)
$totalTime = $totalTime + $dif
$dif2 = StringLeft($dif, StringInStr($dif, ".") -1)
$Count = int($dif/1000)
$timer = TimerInit()
ConsoleWrite($Count & "." & $dif2)
ConsoleWrite(" - ")
if($numOfRuns > $attempts) Then
$go = False
EndIf
EndFunc