If anyone can send me a file with a metallurgy bot that would be very appreciated:bandit:
Dim $x,$y
Dim $c=08, $d, $e, $f, $g, $r, $i
Dim $loc[8]
Dim $s, $t, $scale[4]
$i=0
Do
$loc[$i]=0
$i+=1
Until $i=8
$Winpos=WinGetPos("Mabinogi")
OnAutoItExitRegister("OnExit")
Sleep(3000)
WinActivate("Mabinogi")
Sleep(1000)
Send("{F11}")
;Will run while the sieve is not broken and the map is working.
While Containerfunc()=1
Sleep(13000)
;Rotate the screen a few times.
$e=0
While $e<4
$e+=1
;Will run as long as silver is somewhere on the screen and the sieve is not broken.
While Active()=1
$e=0
Sleep(300)
Send("{ALTUP}")
Sleep(200)
$r=Random(0,20,1)
MouseMove($x,$y+20+$r,0)
Sleep(150)
MouseClick("Left")
Sleep(200)
Send("{ALTUP}")
Sleep(7000)
CollectOres()
Send("{ALTUP}")
Sleep(100)
Send("{F11}")
Sleep(5000)
WEnd
MouseMove((($Winpos[0]+$Winpos[2])/2)-100,($Winpos[1]+$Winpos[3])/2,2)
Sleep(200)
MouseDown("Right")
Sleep(200)
MouseMove((($Winpos[0]+$Winpos[2])/2)+100,($Winpos[1]+$Winpos[3])/2,2)
Sleep(200)
MouseUp("Right")
Sleep(200)
Wend
WEnd
Exit 1
;Moves to new site/Checks sieve
Func Containerfunc()
If SuperiorActive()=0 Then
Sleep(100)
If SuperiorActive()=0 Then Exit 3
EndIf
Return 1
EndFunc
Func SuperiorActive()
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,50)=1 Then Rechecksieve()
If $c<15 Then $c+=1
If $c=15 Then $c=1
MouseMove(1777,187,0)
Sleep(500)
$i=0
Do
$loc[$i]=0
$i+=1
Until $i=8
$i=0
Do
$i+=1
If Imagesearch2(".\Map"&$i&".png",1,$x,$y,50)=1 Then $loc[$i-1]=1
Until $i=8
If $c<9 Then
If $loc[$c-1]=1 Then
ImageSearch2(".\Map"&$c&".png",1,$x,$y,50)
MouseMove($x,$y)
Sleep(150)
MouseClick("Left")
Sleep(200)
Return 1
EndIf
Else
$d=16-$c
If $loc[$d-1]=1 Then
ImageSearch2(".\Map"&$d&".png",1,$x,$y,50)
MouseMove($x,$y)
Sleep(150)
MouseClick("Left")
Sleep(200)
Return 1
EndIf
EndIf
$i=0
Do
If $loc[$i]=1 Then
ImageSearch2(".\Map"&$i+1&".png",1,$x,$y,50)
MouseMove($x,$y)
Sleep(150)
MouseClick("Left")
Sleep(200)
$c=$i
Return 1
EndIf
$i+=1
Until $i=8
Return 0
EndFunc
;Func to combine sieve + Imagesearch Checks
Func Active()
MouseMove(1601,267,0)
Send("{AltDown}")
Sleep(300)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,50)=1 Then
Send("{ALTUP}")
Rechecksieve()
Send("{ALTDOWN}")
EndIf
$i=0
Do
If ImageSearchScales(".\Gold.png",1,$x,$y,$i*25,$i*50,60)=1 Then Return 1
If ImageSearchScales(".\Silver.png",1,$x,$y,$i*25,$i*50,60)=1 Then Return 1
$i+=1
Until $i=30
If ImageSearch2(".\Gold.png",1,$x,$y,60)=1 Then Return 1
If ImageSearch2(".\Silver.png",1,$x,$y,60)=1 Then Return 1
Return 0
EndFunc
Func Rechecksieve()
Sleep(100)
Send("{TAB}")
Sleep(1500)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,10)=0 Then
Send("{F11}")
Return
EndIf
Sleep(100)
Send("{TAB}")
Sleep(1500)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,10)=0 Then
Send("{F11}")
Return
EndIf
Sleep(100)
Send("{TAB}")
Sleep(1500)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,10)=0 Then
Send("{F11}")
Return
EndIf
Exit 1
EndFunc
Func CollectOres()
Sleep(100)
Send("{AltDown}")
$f=0
Do
$f+=1
Sleep(200)
$g=ImageSearch1(".\orefrag.png",1,$x,$y,100)
If $f=47 Then Return
Until $g=1
$f=0
While $f<5
$f+=1
MouseMove((($Winpos[0]+$Winpos[2])/2),(($Winpos[1]+$Winpos[3])/2)-150,2)
Sleep(200)
While ImageSearch1(".\orefrag.png",1,$x,$y,100)=1
Sleep(200)
MouseMove($x,$y)
Sleep(200)
If ImageSearch1(".\orefrag1.bmp",1,$x,$y,30)=1 Then
Sleep(200)
MouseClick("left")
Sleep(1500)
EndIf
MouseMove((($Winpos[0]+$Winpos[2])/2),(($Winpos[1]+$Winpos[3])/2)-150,2)
Sleep(100)
WEnd
WEnd
Send("{AltUp}")
EndFunc
Func ImageSearch2($findImage,$resultPosition,ByRef $x, ByRef $y, $tolerance)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$result = DllCall(".\ImageSearchDLL.dll","str","ImageSearch","int",$Winpos[0],"int",$Winpos[1]+60,"int",$Winpos[2],"int",$Winpos[3]-200,"str",$findImage)
; If error exit
if $result[0]="0" then Return 0
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
Func ImageSearch1($findImage,$resultPosition,ByRef $x, ByRef $y, $tolerance)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$result = DllCall(".\ImageSearchDLL.dll","str","ImageSearch","int",(($Winpos[0]+$Winpos[2])/2)-150,"int",(($Winpos[1]+$Winpos[3])/2)-150,"int",(($Winpos[0]+$Winpos[2])/2)+250,"int",(($Winpos[1]+$Winpos[3])/2)+150,"str",$findImage)
; If error exit
if $result[0]="0" then return 0
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
Func ImageSearchScales($findImage,$resultPosition,ByRef $x, ByRef $y, $s ,$t , $tolerance)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$scale[0]=(($Winpos[0]+$Winpos[2])/2)-$s
If $scale[0]<$Winpos[0] Then $scale[0]=$Winpos[0]
$scale[1]=(($Winpos[1]+$Winpos[3])/2)-$t
If $scale[1]<$Winpos[1] Then $scale[1]=$Winpos[1]
$scale[2]=(($Winpos[0]+$Winpos[2])/2)+$s+50
If $scale[2]<$Winpos[2] Then $scale[2]=$Winpos[2]
$scale[3]=(($Winpos[1]+$Winpos[3])/2)+$t
If $scale[3]<$Winpos[3] Then $scale[3]=$Winpos[3]
$result = DllCall(".\ImageSearchDLL.dll","str","ImageSearch","int",$scale[0],"int",$scale[1],"int",$scale[2],"int",$scale[3],"str",$findImage)
; If error exit
if $result[0]="0" then Return 0
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
Func OnExit()
Send("{ALTUP}")
EndFunc
#cs
While $c<17
If $c<9 Then
ImageSearch2(".\Map"&$c&".png",1,$x,$y,50)
Else
$d=16-$c
ImageSearch2(".\Map"&$d&".png",1,$x,$y,50)
EndIf
MouseMove($x,$y)
Sleep(100)
$c+=1
WEnd
Exit
#ce
Dim $x,$y
Dim $c=08, $d, $e, $f, $g, $r, $i
Dim $loc[8]
Dim $s, $t, $scale[4]
$i=0
Do
$loc[$i]=0
$i+=1
Until $i=8
$Winpos=WinGetPos("Mabinogi")
OnAutoItExitRegister("OnExit")
Sleep(3000)
WinActivate("Mabinogi")
Sleep(1000)
Send("{F11}")
;Will run while the sieve is not broken and the map is working.
While Containerfunc()=1
Sleep(13000)
;Rotate the screen a few times.
$e=0
While $e<4
$e+=1
;Will run as long as silver is somewhere on the screen and the sieve is not broken.
While Active()=1
$e=0
Sleep(300)
Send("{ALTUP}")
Sleep(200)
$r=Random(0,20,1)
MouseMove($x,$y+20+$r,0)
Sleep(150)
MouseClick("Left")
Sleep(200)
Send("{ALTUP}")
Sleep(7000)
CollectOres()
Send("{ALTUP}")
Sleep(100)
Send("{F11}")
Sleep(5000)
WEnd
MouseMove((($Winpos[0]+$Winpos[2])/2)-100,($Winpos[1]+$Winpos[3])/2,2)
Sleep(200)
MouseDown("Right")
Sleep(200)
MouseMove((($Winpos[0]+$Winpos[2])/2)+100,($Winpos[1]+$Winpos[3])/2,2)
Sleep(200)
MouseUp("Right")
Sleep(200)
Wend
WEnd
Exit 1
;Moves to new site/Checks sieve
Func Containerfunc()
If SuperiorActive()=0 Then
Sleep(100)
If SuperiorActive()=0 Then Exit 3
EndIf
Return 1
EndFunc
Func SuperiorActive()
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,50)=1 Then Rechecksieve()
If $c<15 Then $c+=1
If $c=15 Then $c=1
MouseMove(1777,187,0)
Sleep(500)
$i=0
Do
$loc[$i]=0
$i+=1
Until $i=8
$i=0
Do
$i+=1
If Imagesearch2(".\Map"&$i&".png",1,$x,$y,50)=1 Then $loc[$i-1]=1
Until $i=8
If $c<9 Then
If $loc[$c-1]=1 Then
ImageSearch2(".\Map"&$c&".png",1,$x,$y,50)
MouseMove($x,$y)
Sleep(150)
MouseClick("Left")
Sleep(200)
Return 1
EndIf
Else
$d=16-$c
If $loc[$d-1]=1 Then
ImageSearch2(".\Map"&$d&".png",1,$x,$y,50)
MouseMove($x,$y)
Sleep(150)
MouseClick("Left")
Sleep(200)
Return 1
EndIf
EndIf
$i=0
Do
If $loc[$i]=1 Then
ImageSearch2(".\Map"&$i+1&".png",1,$x,$y,50)
MouseMove($x,$y)
Sleep(150)
MouseClick("Left")
Sleep(200)
$c=$i
Return 1
EndIf
$i+=1
Until $i=8
Return 0
EndFunc
;Func to combine sieve + Imagesearch Checks
Func Active()
MouseMove(1601,267,0)
Send("{AltDown}")
Sleep(300)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,50)=1 Then
Send("{ALTUP}")
Rechecksieve()
Send("{ALTDOWN}")
EndIf
$i=0
Do
If ImageSearchScales(".\Gold.png",1,$x,$y,$i*25,$i*50,60)=1 Then Return 1
If ImageSearchScales(".\Silver.png",1,$x,$y,$i*25,$i*50,60)=1 Then Return 1
$i+=1
Until $i=30
If ImageSearch2(".\Gold.png",1,$x,$y,60)=1 Then Return 1
If ImageSearch2(".\Silver.png",1,$x,$y,60)=1 Then Return 1
Return 0
EndFunc
Func Rechecksieve()
Sleep(100)
Send("{TAB}")
Sleep(1500)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,10)=0 Then
Send("{F11}")
Return
EndIf
Sleep(100)
Send("{TAB}")
Sleep(1500)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,10)=0 Then
Send("{F11}")
Return
EndIf
Sleep(100)
Send("{TAB}")
Sleep(1500)
If Imagesearch2(".\BrokenSieve.png",1,$x,$y,10)=0 Then
Send("{F11}")
Return
EndIf
Exit 1
EndFunc
Func CollectOres()
Sleep(100)
Send("{AltDown}")
$f=0
Do
$f+=1
Sleep(200)
$g=ImageSearch1(".\orefrag.png",1,$x,$y,100)
If $f=47 Then Return
Until $g=1
$f=0
While $f<5
$f+=1
MouseMove((($Winpos[0]+$Winpos[2])/2),(($Winpos[1]+$Winpos[3])/2)-150,2)
Sleep(200)
While ImageSearch1(".\orefrag.png",1,$x,$y,100)=1
Sleep(200)
MouseMove($x,$y)
Sleep(200)
If ImageSearch1(".\orefrag1.bmp",1,$x,$y,30)=1 Then
Sleep(200)
MouseClick("left")
Sleep(1500)
EndIf
MouseMove((($Winpos[0]+$Winpos[2])/2),(($Winpos[1]+$Winpos[3])/2)-150,2)
Sleep(100)
WEnd
WEnd
Send("{AltUp}")
EndFunc
Func ImageSearch2($findImage,$resultPosition,ByRef $x, ByRef $y, $tolerance)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$result = DllCall(".\ImageSearchDLL.dll","str","ImageSearch","int",$Winpos[0],"int",$Winpos[1]+60,"int",$Winpos[2],"int",$Winpos[3]-200,"str",$findImage)
; If error exit
if $result[0]="0" then Return 0
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
Func ImageSearch1($findImage,$resultPosition,ByRef $x, ByRef $y, $tolerance)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$result = DllCall(".\ImageSearchDLL.dll","str","ImageSearch","int",(($Winpos[0]+$Winpos[2])/2)-150,"int",(($Winpos[1]+$Winpos[3])/2)-150,"int",(($Winpos[0]+$Winpos[2])/2)+250,"int",(($Winpos[1]+$Winpos[3])/2)+150,"str",$findImage)
; If error exit
if $result[0]="0" then return 0
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
Func ImageSearchScales($findImage,$resultPosition,ByRef $x, ByRef $y, $s ,$t , $tolerance)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$scale[0]=(($Winpos[0]+$Winpos[2])/2)-$s
If $scale[0]<$Winpos[0] Then $scale[0]=$Winpos[0]
$scale[1]=(($Winpos[1]+$Winpos[3])/2)-$t
If $scale[1]<$Winpos[1] Then $scale[1]=$Winpos[1]
$scale[2]=(($Winpos[0]+$Winpos[2])/2)+$s+50
If $scale[2]<$Winpos[2] Then $scale[2]=$Winpos[2]
$scale[3]=(($Winpos[1]+$Winpos[3])/2)+$t
If $scale[3]<$Winpos[3] Then $scale[3]=$Winpos[3]
$result = DllCall(".\ImageSearchDLL.dll","str","ImageSearch","int",$scale[0],"int",$scale[1],"int",$scale[2],"int",$scale[3],"str",$findImage)
; If error exit
if $result[0]="0" then Return 0
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
Func OnExit()
Send("{ALTUP}")
EndFunc
#cs
While $c<17
If $c<9 Then
ImageSearch2(".\Map"&$c&".png",1,$x,$y,50)
Else
$d=16-$c
ImageSearch2(".\Map"&$d&".png",1,$x,$y,50)
EndIf
MouseMove($x,$y)
Sleep(100)
$c+=1
WEnd
Exit
#ce
Also requires the skill on F11.Quote:
Thanks for the code tags, okay pretty much, since it's your own pictures it will run with any mod set, but it does use the 1-8 map edit from tiara and the names over metallurgy site, you can always edit your own in the data folder.
You need;
Autoit
ImagesearchDLL.dll
Screenshot|Named
"alt" text of "*ore fragment"|orefrag.png
hover over text of "*ore fragment"|orefrag1.png
"alt" text of "silver" and "gold"|Silver.png,Gold.png
a shot of a broken sieve equipped|BrokenSieve.png
the 8 map points on the tiara map edit|Map1.png to Map8.png
It still needs some work, if the metallurgy sites are regularly spaced it can wander a long way before returning to search for a Map marker which results in undesired behavior eg. sticking on the sea, a fix for that has been implemented however it is still beta and often results in the bot looping locations 6-8 due to imagesearch fails.
The code is quite foul because I learnt about commenting up for legibility after it was half written :-)
I'm cleaning it up as I go.
Quote:
Well from what I see here spoonfeeding too much is frowned upon :P
That module would really improve almost all my bots, from this to a pet gathering mod that feeds mp pots to a pet and constantly gathers herbs/wool etc and also gave stamina to me...I really have no knowledge of constructing pake functions. I started looking into it but I haven't got time to spare to learn a new skill right now.
I do know autoit can access specified memory modules by handle(if i remember right)
The items on the map are reliable for me, the only problem is that the program has no way to tell where the character is, for an example, Once i set this script running at location one, and there was an unbroken line of metal deposits all the way to location 8, then when it had gathered everything at 8 it tried to move to location 2...and got confused and ran at the sea for a while xD now it works better but I do need to just add a feature to check whether it's going in the 1->8 direction or 8->1 hence the looping 6-8 problem.
I assume a module could be written to find where the character is?