Here's an update to the code.
Since I don't have access to the weapon anymore I can not test it, so this is just code from another script.
The main changes are that it's now faster to capture the score and calculate each farm. It uses the score capture inside the code without having to call another script and most importantly it goes into a few statements to verify if you died and failed to collect the runes. If the runes are out of reach from their search code location - by the grace in this case - it will kill the script after a couple tries until the player manually collects them. At least that's how it worked on the other script, so I left the tooltips there to help in case someone wants to change it. I'm not sure how needed this is in this script, since the runes seem to always be by the grace, but just in case they don't, this will save you from losing them.
This post
viewtopic.php?f=74&t=107303&p=477189#p477189 shows how to call another script, provided below, to restart Elden Ring and the script in case the game crashes. Make sure to check lines 94/95 and lines 62/74 on the reload script for their names so that they match. Please note that the names are different from what was used in the other farm code posts. Also, I haven't tested the timings for these changes or pretty much anything in this script as well so might be unwanted errors coming up with the files provided, their file names or so.
If you don't want any of these and feel comfortable with the shorter timings from the previous script, you can just remove the code you don't want
or change the {* up} part from the previous code to improve on that.
Here's the new code:
Code: Select all
#NoEnv
#Warn
#SingleInstance Force
Process, priority, , high
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 2
#MaxThreadsperHotkey 2
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
WinGetPos, WinX, WinY, WinW, WinH, ELDEN RING™
if (WinX !=0)
Winmove, ELDEN RING™, , 0, 0
SetBatchLines, -1
WinActivate ELDEN RING™
#IfWinActive, ELDEN RING™
;#UseHook Off
xposList:= [[1750, 1771], [1761, 1782], [1772, 1793], [1783, 1805], [1794, 1816]
,[1806, 1827] , [1817, 1840], [1830, 1850], [1843, 1865]]
score := 0
score0 := 0
score0reload := 0
F6::reload
F8::ExitApp
F9::Pause
F7::Gosub main
main:
previousscore := score
loop {
Sleep 50
Send, {r up}{e up}{f up}{g up}{w up}{a up}{d up}{o up}
Sleep 50
Send, {g down}
Sleep 30
Send, {g up}
loop, 300 {
ImageSearch, , , 1802, 100, 1816, 119, *25 *transblack Compass.png
If (ErrorLevel = 0) {
break
}
If (A_Index = 300) {
Sleep, 100
Gosub main
break
}
}
Send, {f down}
Sleep 30
Send, {f up}
Sleep 30
loop,100 {
Imagesearch, , , 85, 150, 105, 970, *25 *transblack GraceList.png
If (ErrorLevel = 0)
break
If (A_Index = 100) {
Sleep 30
Send, {f up}
Sleep 30
Send, {f down}
Sleep 30
Send, {f up}
Sleep 30
break
}
}
Send, {e down}
Sleep 30
Send, {e up}
Sleep 30
Loop, 100 {
Imagesearch, , , 1151, 582, 1162, 592, *115 *Transblack TravelCancel.png
If (ErrorLevel = 0) {
Send, {e down}
Sleep 30
Send, {e up}
break
}
}
Send, {e down}
Sleep 1000
loop, 1000 {
Imagesearch, , , 148, 1018, 382, 1034, *55 *Transblack Next.png
If (ErrorLevel = 1) {
If (A_Index = 1) {
Send, {e up}
Sleep 145
Send, {e down}
Sleep 1000
}
break
}
If (A_Index =1000) and (ErrorLevel = 0) {
run, MohgwinFarmTSch
Process, WaitClose, MohgwinFarmTSch
ExitApp
}
}
Sleep 500
loop, 400 {
ImageSearch, , , 1685, 1026, 1705, 1045, *55 *transblack RuneIcon.png
If (ErrorLevel = 0) {
Sleep, 2000
score =
For each, xpos in xposList {
Loop, 11 {
digit := A_Index - 1
image :="Digit" digit ".png"
ImageSearch,,, xpos.1, 1025, xpos.2, 1047, *115 *transblack %image%
err := ErrorLevel
If (digit = 10)
digit:= 0
} Until !err
score .= err ? "_" : digit
}
sessiontotal := score - previousscore
Tooltip, score = %score%`nsession total = %sessiontotal%, 900, 900
SetTimer, RemoveToolTip, -2000
If (score0 = 0) {
Tooltip, score0reload = %score0reload%`nscore0 = %score0%, 400, 100, 2
SetTimer, RemoveToolTip2, -4000
break
}
If (score0 = 1) {
Tooltip, ErrorLevel = %ErrorLevel%`nscore0 = %score0%, 400, 100
SetTimer, RemoveToolTip, -4000
If (score < 150000) {
Tooltip, ErrorLevel = %ErrorLevel%`nscore0 = %score0%`nscore0reload = %score0reload%`nscore < 150000`n"break", 600, 300, 2
SetTimer, RemoveToolTip2, -4000
break
}
If (score > 150000) {
If (score < 290000) {
Tooltip, ErrorLevel = %ErrorLevel%`nscore0 = %score0%`nscore0reload = %score0reload%`nscore > 150000`n"ExitApp", 700, 400, 2
SetTimer, RemoveToolTip2, -4000
Exitapp
}
Else {
score0 := 0
score0reload := 0
break
}
}
If (score = 0) {
Score0+= 1
Tooltip, ErrorLevel = %ErrorLevel%`nscore0 = %score0%`nscore0reload = %score0reload%`nscore = 0`n"Break", 800, 500, 2
SetTimer, RemoveToolTip2, -4000
break
}
}
}
If (ErrorLevel = 1) {
If (A_Index = 1) {
Send, {e down}
Sleep 50
Send, {e up}
Sleep 350
}
If (A_Index = 400) {
If (score0 = 2) {
Tooltip, ErrorLevel = %ErrorLevel%`nscore0 = %score0%`nscore0reload = %score0reload%`n"exitApp", 900, 600, 2
SetTimer, RemoveToolTip2, -4000
ExitApp
}
If (score0reload > 0) {
Tooltip, ErrorLevel = %ErrorLevel%`nscore0 = %score0%`nscore0reload = %score0reload%`n"Continue", 1000, 700, 2
SetTimer, RemoveToolTip2, -4000
continue
}
{
score0 += 1
Tooltip, ErrorLevel = %ErrorLevel%`nscore0 = %score0%`nscore0reload = %score0reload%`n"A_Index = 400", 1100, 800, 2
SetTimer, RemoveToolTip2, -4000
}
}
}
}
Sleep 60
Send, {e up}
Sleep 450
ImageSearch, , , 862, 908, 927, 920, *55 *transblack YRetrieve.png
If (ErrorLevel = 0) {
Send, {e down}
Sleep 50
Send, {e up}
Sleep 550
If (score0 > 0) {
score0reload := 0
score0 := 0
}
}
;; W A W ==> we zig zag into position
;BlockInput, MouseMove
Send, {e up}
Sleep 300
Send, {w down}
Sleep 30
Send, {space down}
Sleep 1760
Send, {a down}
Sleep 1000
Send, {a up}
Sleep 1400
Send, {a down}
Sleep 400
Send, {space up}{a up}{d down}
Sleep 140
Send, {d up}{w up}
Sleep 50 ; you may need to adjust this for the Pixelsearch to work
Loop {
PixelSearch, PixelX, PixelY, 820, 400, 821, 600, 0x6EB0CF, 35, fast
If (ErrorLevel = 1){
SoundBeep, 500
Send, {w down}{d down}
Sleep 30
Send, {d up}{w up}
break
}
If (ErrorLevel = 0) {
SoundBeep, 1000
ToolTip, %PixelX% %PixelY%,PixelX, PixelY
SetTimer, RemoveToolTip, -3000
break
}
}
;; TAB ==> we activate the weapon skill and wait some time to collect runes
Send, {TAB down}
Sleep 30
Send, {TAB up}
;BlockInput, MouseMoveOff
Sleep 6500
}
return
RemoveToolTip:
ToolTip
return
and here's the reload code:
Code: Select all
#NoEnv
; #Warn
SendLevel 1
SendMode Input
SetWorkingDir %A_ScriptDir%
;Process, close, ELDEN RING™
SetTitleMatchMode, 2
#MaxThreadsperHotkey 2
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
Process, close, eldenring.exe
Sleep, 400
run, start_protected_game.exe, C:\Program Files (x86)\Steam\steamapps\common\ELDEN RING\Game
loop {
ImageSearch, , , 689, 414, 704, 431, *25 *Transblack EldenRingStart.png
if (ErrorLevel = 0) {
Send, {enter down}
sleep, 50
Send, {enter up}
break
}
}
loop {
ImageSearch, , , 846, 601, 873, 611, *25 *Transblack EldenRingOK.png
if (ErrorLevel = 0) {
MouseMove, 962, 661
Send, {LButton down}
sleep, 50
Send, {LButton up}
break
}
}
loop {
ImageSearch, , , 891, 742, 915, 753, *25 *Transblack EldenRingInformation.png
if (ErrorLevel = 0) {
MouseMove, 950, 749
sleep, 50
Send, {LButton down}
sleep, 50
Send, {LButton up}
break
}
}
loop {
ImageSearch, , , 689, 414, 704, 431, *25 *Transblack EldenRingStart.png
if (ErrorLevel = 0) {
MouseMove, 966, 808
sleep, 50
Send, {LButton down}
sleep, 50
Send, {LButton up}
break
}
}
sleep, 5000
loop, 1000 {
Imagesearch, , , 148, 1018, 382, 1034, *115 *Transblack Next.png
If (ErrorLevel = 1)
break
If (A_Index = 10000) and (ErrorLevel = 0) {
run, MohgwinFarmClose
Return
}
}
Sleep 1000
loop, 400 {
If (A_Index = 1) {
tooltip, RuneIcon.png search started, 1100, 800, 18
SetTimer, RemoveToolTip18, -1000
}
ImageSearch, , ,1685, 1026, 1705, 1045, *55 *transblack RuneIcon.png
If (ErrorLevel = 0){
run, MohgwinFarm20.ahk
Sleep, 2000
Send, {F7 down}
Sleep, 50
Send, {F7 up}
tooltip, MohgwinFarmClose exited, 1000, 800, 17
SetTimer, RemoveToolTip17, -1000
Sleep, 1000
break
}
}
RemoveToolTip17:
ToolTip,,,,17
return
RemoveToolTip18:
ToolTip,,,,18
return
ExitApp
Their names are MohgwinFarm20.ahk and MohgwinFarmClose.ahk if that makes it easier for you or I missed something, and the elevated task is named MohgwinFarmTSch. Special thanks to Mikeyww for providing the score code.