You can try
1. Lower the similarity, for example
Pattern("target.png"):similar(0.6)
2. Prepare images with different background.
I'm using similarity but sometimes it takes time to recognize the image. Do you think it is something to do with the transparency of the target image?
hmm is there's any way to recognize by text on the certain image?
function Target_Quest()
img1=Pattern("Target_killcontinue.png",0.50)
img2=Pattern("target_questdone.png",0.50)
img3=Pattern("targetQuest.png",0.50)
img4=Pattern("FirstTargetIcon.png",0.50)
imageTable2 = {img1,img2,img3,img4}
is_firstrun2 =true
ctr=0
target_btncomplete = Pattern("target_btncomplete.png",0.65)
target_btngo = Pattern("target_btngo.png",0.65)
Xbutton = Pattern("Xbutton.png",0.65)
target_btngo2 = Pattern("target_btngo2.png",0.65)
navigating = Pattern("navigating.png",0.65)
while loop2 do
tquest_region:highlight()
ImageResult2=existsMultiMax(tquest_region,imageTable2)
if imageTable2[ImageResult2]==img2 then
tquest_region:existsClick("target_questdone.png",1)
tquest_region:highlightOff()
usePreviousSnap(false)
waitClick(target_btncomplete,5)
wait(2)
existsClick(target_btngo,3)
wait(3)
existsClick(Xbutton,4)
elseif imageTable2[ImageResult2]== img3 then
tquest_region:highlightOff()
toast("Daily/Target Quest is Complete...")
loop2=false
return
elseif imageTable2[ImageResult2]== img4 then
tquest_region:existsClick("FirstTargetIcon.png",1)
tquest_region:highlightOff()
usePreviousSnap(false)
waitClick(target_btngo2,3)
elseif imageTable2[ImageResult2]== img1 and Is_firstrun2 == true then
tquest_region:existsClick("Target_killcontinue.png",1)
usePreviousSnap(false)
waitClick(navigating,1)
dquest_region:highlightOff()
Is_firstrun2=false
ctr=0
else
usePreviousSnap(false)
dquest_region:highlightOff()
ctr=ctr+1
end
if exists(Pattern("redrev.png"))then
dquest_region:highlightOff()
Is_firstrun2=true
click("redrev.png")
wait(2)
Xbutton = exists("Xbutton.png")
if (Xbutton) then
click(Xbutton)
end
existsClick(navigating,3)
Is_firstrun2=true
end
if ctr > 15 then
existsClick("Target_killcontinue.png" ,4)
wait(1)
existsClick(navigating,3)
Is_firstrun=true
ctr=0
Xbutton = exists("Xbutton.png")
if (Xbutton) then
click(Xbutton)
end
end
end
end
function existsMultiMax(region, target)
local oldROI = Settings:getROI();
local maxScore = 0
local maxIndex = 0
if (region ~= nil) then
Settings:setROI(region)
end
for i, t in ipairs(target) do
if (i == 1) then
usePreviousSnap(false)
else
usePreviousSnap(true)
end
if (exists(t, 0)) then -- check once
local score = getLastMatch():getScore()
if (score > maxScore) then
maxScore = score
maxIndex = i
end
end
end
if (oldROI ~= nil) then
Settings:setROI(oldROI)
else
Settings:setROI()
end
usePreviousSnap(true)
if (maxScore == 0) then
return -1
end
return maxIndex
end