i have give it a try, the farm bot can only stealing but no plant revive oder take the weed. maybe it need another images for it. the worldmap farming do nothing. i will give a try and edit it
;===========================================================================================================
;@Author Ewvyx I wrote this so please don't slap your name on it.
;This script searches through the wilds of Erandel and fights Managogs for Daru Pearls
;It is designed for a 1920x1080 display
;Works best if you start in the top left most corner of the wilds map (less wait time for your character to move to the first found managog)
#RequireAdmin
#include <ImageSearch.au3>
;===========================================================================================================
;Global Variables (DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING)
;X Coords Input on 1920x1080 : 1518x198
;Y Coords Input on 1920x1080 : 1553x198
$Version = "1.1.0a"
Global $Paused
Global $gX = 0
Global $gY = 0
Global $c1X = 0
Global $c1Y = 0
Global $c2X = 0
Global $c2Y = 0
Global $success = False ;boolean for various checks
Global $managogFound = False ;flag for when a managog is found by _ImageSearch
Global $tolFail = 0 ;tolerance failures for _ImageSearch
Global $troopRecruitY = 0 ;Y coordinate of specified troop portrait in recruit troops window
Global $searchCoordsFound = False
$bmpLocation = @ScriptDir & "\Pics"
$managogsDir = "Managogs"
$buttonsDir = "Buttons"
;===========================================================================================================
;User Defined Variables
Global $mapX = 15 ;change this to the x coordinate of the map that your character is in. map starts at 15, goes to 585
Global $mapY = 8 ;change this to the x coordinate of the map that your character is in. map starts at 8, goes to 591
$collectTreasure = True ;set to True if you want to attack treasure caches as well, False if do not
$troops = "warlock" ;set this to the troops you are using i.e. "templar" or "warlock"
$defaultCheckRate = .1 ;smaller the number, the faster the image checks are. increase if managogs aren't being found.
;===========================================================================================================
;HotKeys
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("q","RunScript")
HotKeySet("x","ChangeCoords")
;===========================================================================================================
;~Functions
Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause
Func Terminate()
Exit 0
EndFunc ;==>Terminate
Func CheckFor($directory,$img,$tolerance=50,$startX=0,$startY=0,$endX=@DesktopWidth,$endY=@DesktopHeight,$seconds=$defaultCheckRate)
$c = 0
MouseMove(0,(@DesktopHeight/2),0)
$string = $bmpLocation & "\" & $directory & "\" & $img & ".bmp"
If $img = "city" Then
$updateString = "Wilds View"
Else
$updateString = $img
EndIf
ToolTip("Checking for " & $updateString,0,0)
$tolerance = 50
If $directory = $managogsDir Then
$tolerance = 100
EndIf
If $img = "treasure" Then
$tolerance = 35
ElseIf $img = "attackingsword" Then
$tolerance = 70
EndIf
If $tolFail > 0 Then
$tolerance += $tolFail
EndIf
Do
$c += 1
Sleep(100)
If $c > ($seconds * 10) Then
Return False
EndIf
Until _ImageSearchArea($string,1,$startX,$startY,$endX,$endY,$gX,$gY,$tolerance)
;Until _ImageSearchArea($string,1,216,180,1723,1002,$gX,$gY,$tolerance)
Sleep(500)
Return True
EndFunc
Func ClickImage($directory,$img,$tolerance=50,$startX=0,$startY=0,$endX=@DesktopWidth,$endY=@DesktopHeight,$seconds=$defaultCheckRate)
If CheckFor($directory,$img,$tolerance,$startX,$startY,$endX,$endY,$seconds) Then
MouseClick("left",$gX,$gY,1,0)
Return True
Else
Return False
EndIf
EndFunc
Func HoverOverImage($directory,$img,$tolerance=50,$startX=0,$startY=0,$endX=@DesktopWidth,$endY=@DesktopHeight,$seconds=$defaultCheckRate)
If CheckFor($directory,$img,$startX,$startY,$endX,$endY,$seconds,$tolerance) Then
MouseMove($gX,$gY,0)
Sleep(2000)
Return True
Else
Return False
EndIf
EndFunc
Func ClickOffsetOfImage($direction,$offset,$directory,$img,$clicks=1,$tolerance=50,$startX=0,$startY=0,$endX=@DesktopWidth,$endY=@DesktopHeight,$seconds=$defaultCheckRate)
If CheckFor($directory,$img,$startX,$startY,$endX,$endY,$seconds,$tolerance) Then
If $direction = "right" Then
$gX += $offset
ElseIf $direction = "left" Then
$gX -= $offset
ElseIf $direction = "up" Then
$gY -= $offset
ElseIf $direction = "down" Then
$gY += $offset
EndIf
MouseClick("left",$gX,$gY,$clicks,0)
Return True
Else
Return False
EndIf
EndFunc
Func ChangeCoords()
;Changes map coordinates square by square. Moves left to right then moves down one square and goes left to right again.
$wait = 2000 ;sleep (milliseconds) at the end of this function
If $mapX < 585 Then
$mapX += 30
Else
$wait = 2000
$mapX = 15
If $mapY < 591 Then
$mapY += 17
EndIf
EndIf
MouseClick("left",1181,21,2,0)
Send($mapX)
MouseClick("left",1208,20,2,0)
Send($mapY)
MouseCLick("left",1242,19,2,0)
Sleep($wait)
EndFunc
Func FindXCoordsFor($directory,$img)
If CheckFor($directory,$img) Then
Return $gX
Else
Return 0
EndIf
EndFunc
Func FindYCoordsFor($directory,$img)
If CheckFor($directory,$img) Then
Return $gY
Else
Return 0
EndIf
EndFunc
Func SearchForAttackSword()
;Searches for the sword icon. Used to make sure SearchForManagogs() actually found something.
If CheckFor($managogsDir,"attackingsword") Or CheckFor($managogsDir,"attackingsword2") Or CheckFor($managogsDir,"attackingsword3") Then
Return True
Else
Return False
EndIf
EndFunc
Func SearchForManagogs()
;Iterates through each managog bitmap until it finds one. Returns false if it doesn't.
If ClickImage($managogsDir,"bear(black)") Or ClickImage($managogsDir,"bear(black)2") Then
Return True
ElseIf ClickImage($managogsDir,"bear(brown)") Then
Return True
ElseIf ClickImage($managogsDir,"goblin3") Or ClickImage($managogsDir,"goblin2") Or ClickImage($managogsDir,"goblin") Then
Return True
ElseIf ClickImage($managogsDir,"goblin(purple)") Then
Return True
ElseIf ClickImage($managogsDir,"griffon") Then
Return True
ElseIf ClickImage($managogsDir,"paladin") Or ClickImage($managogsDir,"paladin2") Then
Return True
ElseIf ClickImage($managogsDir,"tauren(club)") Or ClickImage($managogsDir,"tauren(club)2") Then
Return True
ElseIf ClickImage($managogsDir,"tauren(shield)") Then
Return True
ElseIf $collectTreasure Then
If ClickImage($managogsDir,"treasure") Then
Return True
EndIf
Else
Return False
EndIf
EndFunc
Func WaitForAttack()
;Waits for your character to get to the managog. If the attack button does not appear after 1 min, it will search for and click on the managog again.
If ClickImage($buttonsDir,"attack",0,0,@DesktopWidth,@DesktopHeight,1,50) Then
$success = True
Sleep(2000)
Else
$success = False
EndIf
EndFunc
Func CheckAFKMode()
;Ensures AFK mode is on for faster farming.
ClickImage($buttonsDir,"afkmode")
EndFunc
Func CheckWildsView()
;Returns True if the city button is in view, false if not.
If CheckFor($buttonsDir,"city") Then
Return True
Else
Return False
EndIf
EndFunc
Func CheckLowTroops()
;Ensures troop count doesn't drop too low.
If ClickImage($buttonsDir,"recruittroops") Then
Return True
Else
Return False
EndIf
EndFunc
Func RecruitTroops()
;Recruits more troops
$troopPortrait = ""
If $troops = "templar" Then
$troopPortrait = "templarportrait"
ElseIf $troops = "warlock" Then
$troopPortrait = "warlockportrait"
EndIf
Do
ClickImage($buttonsDir,"scrollarrow(down)")
Until CheckFor($buttonsDir,$troopPortrait)
$troopRecruitY = $gY
ClickImage($buttonsDir,"recruit",0,$troopRecruitY,@DesktopWidth,@DesktopHeight,0.5,50)
ClickImage($buttonsDir,"ok")
ClickImage($buttonsDir,"x")
EndFunc
Func RunScript()
;Main script activated by hotkey
While 1
If CheckWildsView() Then
Do
If ClickImage($buttonsDir,"attack") Then
Sleep(500)
ElseIf CheckLowTroops() Then
RecruitTroops()
ElseIf SearchForAttackSword() Then
Do
WaitForAttack()
Until SearchForAttackSword() = False Or ClickImage($buttonsDir,"attack") = True
ElseIf $managogFound = False And SearchForManagogs() Then
ToolTip("Managog found!",0,0)
Sleep(1000)
$managogFound = True
Do
WaitForAttack()
Until SearchForAttackSword() = False Or ClickImage($buttonsDir,"attack") = True
ElseIf $managogFound = True And $success = False Then
$managogFound = False
ChangeCoords()
ElseIf $managogFound = False Then
ChangeCoords()
EndIf
Until $success = True
If $success = True Then
$managogFound = False
CheckAFKMode()
EndIf
Else
$success = False
$managogFound = False
CheckAFKMode()
EndIf
WEnd
EndFunc
;===========================================================================================================
;Main
While 1
ToolTip("Press 'q' to begin...",0,0)
Sleep(100)
WEnd
Until _ImageSearchArea($string,1,$startX,$startY,$endX,$endY,$gX,$gY,$tolerance) ;Until _ImageSearchArea($string,1,216,180,1723,1002,$gX,$gY,$tolerance)
;Until _ImageSearchArea($string,1,$startX,$startY,$endX,$endY,$gX,$gY,$tolerance) Until _ImageSearchArea($string,1,216,180,1723,1002,$gX,$gY,$tolerance)