Search: Home | Atlas | Guides | Tests | Research | Techs | Skills | Index | Recent Changes | Preferences | Login

Users > Spoiled > AutoFlax > DebuggingVersion

The only difference between this version and the real one is that you can adjust the sleep timers to see what's going on and set the zoom. Increase "DelayFactor" A or B to 4 or 5 to slow down mouse movement and troubleshoot. DelayFactorA changes the planting routine delays, B is for the seed harvesting. "ZoomNumber" is the number of times the mousewheel is turned to zoom out. If you're below 1280x1024, between 6-8 should be good, but it might be easier to adjust the pixel shiftings directly.

The macro should be doing these clicks, step by step:
1. Click on the plant window in the top left corner.
2. Click north or south of your position to move. This should not be on the flax bed and if a window opens up here, you need to zoom out more.
3. Click on the flax bed you just planted to bring up the menu.
4. Pin it by looking for the pin.
5. Look for the top left corner of the window and drag it away.

If you want to get deeper into the troubleshooting talk to me or use the AutoHotkey help.


SendMode Input
SetDefaultMouseSpeed, 0

WinActivate, eGenesis Client
WinGetPos,,, winWidth, winHeight, A
;				Flax-planting coordinates
cx := (winWidth / 2) - 5
cy := (winHeight / 2) + 5
rightx := cx + 80	;75
leftx := cx - 70
topy := cy - 70		;65
bottomy := cy + 85	;80
displaceloopy := cy + 52	;redefined during use

;				Window-positioning coordinates
neighbourx := cx - 20
neighboury := cy + 70		
neighbourx2 := (cx - (neighbourx - cx))
neighboury2 := (cy - (neighboury - cy))
;gridx := 4			(reference only)
;gridy := 23 + 829 (852)	(reference only)
BedNumber := 0
BedRun := 1
Bedx := 4
Bedy := 23
GoClear := false
GoHarvest := false
;HarvestRun := 0		(reference)
RunLimit := 4			;Times of HarvestRuns to be done(check with lag)
FlaxBeds := 10
FlaxBedCheck := 0
TurnCornerCheck := false
TurnCounter := 0
DelayFactorA := 1		;Debugging
DelayFactorB := 1		;Debugging
ZoomNumber := 5			;Number of Mousewheel turns to zoom out with. 5 standard.
return

;	---	---	---	Subroutines	---	---	---

PlantFlax:
	MouseClick, left, 60, 40
return

CheckFlaxrun:
	FlaxBedCheck++
	TurnCounter++
	TurnCornerCheck := false
	if (TurnCounter = BedNumber)
	{
		MouseClick, left, % (rightx + 18), %displaceloopy%
		TurnCounter := 0	
		TurnCornerCheck := true
		FlaxBedCheck := 0
		return
	}
	if (FlaxBedCheck = FlaxBeds)
	{
		MouseClick, left, % (rightx + 18), %displaceloopy%
		FlaxBedCheck := 0
		TurnCornerCheck := true
	}
return

PinDragWindow:

	if (TurnCornerCheck = true)
	{
		neighboury2 := cy - 10
		neighbourx2 := leftx	
		MouseMove, %neighbourx2%, %neighboury2%
	}
	else{
		MouseMove, %neighbourx%, %neighboury%
	}
	sleep (300 * %DelayFactorA%)
	gridx := 12 + ((BedRun - 1) * 4)
	gridy := 852 - ((BedRun - 1) * 3)
	Bedx%BedRun% := gridx
	Bedy%BedRun% := gridy
	if (TurnCornerCheck = true) {
		MouseClick, left, %neighbourx2%, %neighboury2%
		searchx1 := neighbourx2 - 5
		searchx2 := neighbourx2 + 340  ;280
		searchy1 := neighboury2 - 100  ;75
		searchy2 := neighboury2 + 50	;20
	}
	else {
		MouseClick, left, %neighbourx%, %neighboury%
		searchx1 := neighbourx - 5
		searchx2 := neighbourx + 340  ;280
		searchy1 := neighboury - 100  ;75
		searchy2 := neighboury + 50	;20
	}
	sleep (250 * %DelayFactorA%)

	ImageSearch, px1, py1, %searchx1%, %searchy1%, %searchx2%, %searchy2%, *5 pinlooseflax2.bmp
	if ErrorLevel = 0
		MouseClick, left, %px1%, %py1%
	sleep (100 * %DelayFactorA%)

	ImageSearch, px2, py2, %searchx1%, %searchy1%, %searchx2%, %searchy2%, *2 tlcorner.bmp
	MouseMove, %px2%, %py2%
	if ErrorLevel = 0
		MouseClickDrag, left, % (px2 + 1), % (py2 + 1), %gridx%, %gridy%, 1
	sleep (75 * %DelayFactorA%)							;Check for STUPID CLICKS
	ImageSearch, px3, py3, %searchx1%, %searchy1%, %searchx2%, %searchy2%, *2 tlcorner.bmp
	if ErrorLevel = 0
		MouseClickDrag, left, % (px3 + 1), % (py3 + 1), %gridx%, %gridy%, 
	sleep (75 * %DelayFactorA%)
	ImageSearch, px3, py3, %searchx1%, %searchy1%, %searchx2%, %searchy2%, *2 tlcorner.bmp
	if ErrorLevel = 0
		MouseClickDrag, left, % (px3 + 1), % (py3 + 1), %gridx%, %gridy%, 
	sleep (75 * %DelayFactorA%)
	ImageSearch, px3, py3, %searchx1%, %searchy1%, %searchx2%, %searchy2%, *2 tlcorner.bmp
	if ErrorLevel = 0
		MouseClickDrag, left, % (px3 + 1), % (py3 + 1), %gridx%, %gridy%, 

	BedRun++
	if (BedRun = (BedNumber + 1))
		BedRun := 1
return

SeedHarvest:
BedRun := 1
searchx2 := Bedx1 + 280
searchy2 := Bedy1 + 120

		loop 2 {					;Scroll out, click to the left to move some.
			Send {WheelDown}
			sleep (175 * %DelayFactorB%)
		}
		MouseClick, left, 6, %cy%
		loop 2 {				
			Send {WheelUp}
			sleep (175 * %DelayFactorB%)
		}

loop{						;Delay until the SeedHarvest can begin
	MouseGetPos, mosx, mosy
	MouseClick, left, %Bedx1%, %Bedy1%
	MouseMove %mosx%, %mosy%
	sleep (200
	ImageSearch,,, %Bedx1%, %Bedy1%, %searchx2%, %searchy2%, *2 HarvestFlaxSeeds3.bmp
	if ErrorLevel = 0 
		break			;Break out to start harvest
	else 
		sleep (1000 * %DelayFactorB%)
}

HarvestRun := 0
if (BedNumber = FlaxBeds * 10)			;Get to the left in case of 10 rows
	MouseClick, left, 6, %cy%
BlockInput, MouseMove
loop 						;Harvest the Seeds X times
{
	gridx := Bedx%BedRun%
	gridy := Bedy%BedRun%
	clickx := gridx + 25
	clicky := gridy + 63
	closex := gridx + 150
	closey := gridy + 20
	searchx2 := Bedx%BedRun% + 280
	searchy2 := Bedy%BedRun% + 120

	loop{					;Wait for Weed option to appear, refreshing
		MouseClick, left, %gridx%, %gridy%
		sleep (150
		ImageSearch,,, % Bedx%BedRun%, % Bedy%BedRun%, %searchx2%, %searchy2%, *2 HarvestFlaxSeeds3.bmp
		if ErrorLevel = 0
			break
		else
			sleep (1250 * %DelayFactorB%)
	}
	MouseClick, left, %clickx% , %clicky%	;Click on HarvestSeeds
	loop{					;Wait for flaxbed to stop displaying weed action
		MouseClick, left, %gridx%, %gridy%
		sleep (100
		ImageSearch,,, % Bedx%BedRun%, % Bedy%BedRun%, %searchx2%, %searchy2%, *2 HarvestFlaxSeeds3.bmp
		if ErrorLevel = 1
			break
		else 
			sleep (150 * %DelayFactorB%)


	}
	if (HarvestRun = (RunLimit - 1)) {
		MouseClick, left, %clickx%, % (clicky + 16)	;Click on RIP OUT BEDS for last run
		MouseClick, left, %closex%, %closey%		;Close the window after
	}
	BedRun++
	if (BedRun = (BedNumber + 1))				;Start the loop again
	{
		BedRun := 1
		HarvestRun++
		loop 2 {					;Scroll out, click to the left to move some.
			Send {WheelDown}
			sleep (175 * %DelayFactorB%)
		}
		MouseClick, left, 6, %cy%
		loop 2 {				
			Send {WheelUp}
			sleep (175 * %DelayFactorB%)
		}
	}
	if (HarvestRun = RunLimit)
		break
}
BedRun := 1
BlockInput, MouseMoveOff
return

FlaxHarvest:
BedRun := 1					;Delay Weeding to until the 12th bed is ready to avoid lag problems
searchx2 := Bedx15 + 280
searchy2 := Bedy15 + 150
loop{
	MouseGetPos, mosx, mosy
	MouseClick, left, %Bedx15%, %Bedy15%
	MouseMove %mosx%, %mosy%
	sleep 200
	ImageSearch,,, %Bedx15%, %Bedy15%, %searchx2%, %searchy2%, WeedShrunkFlax.bmp
	if ErrorLevel = 0 
		break			;Break out to start weeding loop
	else 
		sleep 750
}


BlockInput, MouseMove
loop 						;Weeding loop
{
	gridx := Bedx%BedRun%
	gridy := Bedy%BedRun%
	clickx := gridx + 25
	clicky := gridy + 63
	searchx2 := Bedx%BedRun% + 280
	searchy2 := Bedy%BedRun% + 120

	loop{					;Wait for Weed option to appear, refreshing
		MouseClick, left, %gridx%, %gridy%
		sleep 100
		ImageSearch,,, % Bedx%BedRun%, % Bedy%BedRun%, %searchx2%, %searchy2%, WeedShrunkFlax.bmp
		if ErrorLevel = 0
			break
		else
			sleep 100

		ImageSearch,,, % Bedx%BedRun%, % Bedy%BedRun%, %searchx2%, %searchy2%, HarvestFlax.bmp	;Check for Harvest
		if ErrorLevel = 0 
		{
			GoHarvest := true
			break
		}
	}
	if (GoHarvest = true)
	break

	MouseClick, left, %clickx% , %clicky%	;Click on Weed/Water
	loop{					;Wait for flaxbed to stop displaying weed action
		MouseClick, left, %gridx%, %gridy%
		sleep 100
		ImageSearch,,, % Bedx%BedRun%, % Bedy%BedRun%, %searchx2%, %searchy2%, WeedShrunkFlax.bmp
		if ErrorLevel = 1
			break
		else 
			sleep 100
	}

	BedRun++
	if (BedRun = (BedNumber + 1))
		BedRun := 1
}

						;Commence the Flax Harvesting
BedRun := 1
loop{
	loop{
		gridx := Bedx%BedRun%
		gridy := Bedy%BedRun%
		clickx := gridx + 25
		clicky := gridy + 63
		closex := gridx + 150
		closey := gridy + 20
		searchx2 := Bedx%BedRun% + 280
		searchy2 := Bedy%BedRun% + 120
	
		MouseClick, left, %gridx%, %gridy%
		sleep 100
		ImageSearch,,, % Bedx%BedRun%, % Bedy%BedRun%, %searchx2%, %searchy2%, HarvestFlax.bmp
		if ErrorLevel = 0
			break
		else 
			sleep 100
	}

	MouseClick, left, %clickx% , %clicky%
	sleep 100
	MouseClick, left, %closex% , %closey%
	
	BedRun++
	if (BedRun = (BedNumber + 1))
		break
}	
BlockInput, MouseMoveOff
BedRun := 1
GoClear := false
GoHarvest := false
return

;---	---	---	---	---	---	---	---	---

^+r::Reload

^+p::
Pause
BlockInput, MouseMoveOff
return

#IfWinActive, eGenesis Client

NumPad5::					;Zoom out camera
loop %ZoomNumber%{
Send {WheelDown}
sleep 150
}
return

^NumPad5::GoSub, SeedHarvest			;Automatizing SEED HARVESTING

!NumPad5::GoSub, FlaxHarvest			;Automatizing the FLAX GROWING AND HARVESTING

^NumPad8::					;Going North
IfWinExist eGenesis Client
{
	WinActivate
	
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, How many flax beds in a row?(northwards)
	Gui, Add, Edit, Number vFlaxBeds, %FlaxBeds%
	Gui, Add, Button, default gflaxCommitN, OK
	Gui, Show
	return
	

	flaxCommitN:
	Gui, Submit
	Gui, Destroy
	WinActivate, eGenesis Client
	
	BedNumber := FlaxBeds
	loop, %FlaxBeds%
	{
		Gosub, PlantFlax
		MouseClick, left, %cx%, %topy%
		Gosub, PinDragWindow
		Gosub, CheckFlaxrun
	}

return
}

^NumPad2::					;Going South
IfWinExist eGenesis Client
{
	WinActivate
	
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, How many flax beds in a row?(southwards)
	Gui, Add, Edit, Number vFlaxBeds, %FlaxBeds%
	Gui, Add, Button, default gflaxCommitS, OK
	Gui, Show
	return
	

	flaxCommitS:
	Gui, Submit
	Gui, Destroy
	WinActivate, eGenesis Client
	
	BedNumber := FlaxBeds
	
	neighboury := cy + 70
	loop, %FlaxBeds%
	{
		Gosub, PlantFlax
		MouseClick, left, %cx%, %topy%
		Gosub, CheckFlaxrun
		Gosub, PinDragWindow
	}
return
}

^NumPad9::					;Going N-S once
IfWinExist eGenesis Client
{
	WinActivate
	
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, How many flax beds in a row?(North x1, then south x1(2 rows total)) Harvesting flax after
	Gui, Add, Edit, Number vFlaxBeds, %FlaxBeds%
	Gui, Add, Button, default gflaxCommitNS, OK
	Gui, Show
	return
	

	flaxCommitNS:
	Gui, Submit
	Gui, Destroy
	WinActivate, eGenesis Client	

	BedNumber := FlaxBeds * 2

	neighboury := cy + 70
	loop, %FlaxBeds%
	{
		Gosub, PlantFlax
		MouseClick, left, %cx%, %topy%
		MouseClick, left, %cx%, %topy%
		Gosub, CheckFlaxrun
		Gosub, PinDragWindow
	}
	neighboury := cy - 70
	loop, %FlaxBeds%
	{
		Gosub, PlantFlax
		MouseClick, left, %cx%, %bottomy%
		MouseClick, left, %cx%, %bottomy%
		Gosub, CheckFlaxrun
		Gosub, PinDragWindow
	}
	GoSub, FlaxHarvest
return
}

^NumPad3::					;Going N-S twice
IfWinExist eGenesis Client
{
	WinActivate
	
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, How many flax beds in a row?(Going N-S-N-S(4 rows total)) Harvesting flax after.
	Gui, Add, Edit, Number vFlaxBeds, %FlaxBeds%
	Gui, Add, Button, default gflaxCommitNSNS, OK
	Gui, Show
	return
	

	flaxCommitNSNS:
	Gui, Submit
	Gui, Destroy
	WinActivate, eGenesis Client
	
	BedNumber := FlaxBeds * 4
	loop, 2
	{
		neighboury := cy + 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %topy%
			MouseClick, left, %cx%, %topy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
		neighboury := cy - 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %bottomy%
			MouseClick, left, %cx%, %bottomy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
	}
	GoSub, FlaxHarvest
return
}

^NumPad6::					;Going N-S 8 times
IfWinExist eGenesis Client
{
	WinActivate
	
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, How many flax beds in a row?(Going N-S-N-S... for a total of 8 rows) Harvesting seeds after.
	Gui, Add, Edit, Number vFlaxBeds, %FlaxBeds%
	Gui, Add, Button, default gflaxCommitNS5, OK
	Gui, Show
	return
	

	flaxCommitNS5:
	Gui, Submit
	Gui, Destroy
	WinActivate, eGenesis Client
	
	BedNumber := FlaxBeds * 8
	displaceloopy := cy + 30
	loop, 4
	{
		neighboury := cy + 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %topy%
			MouseClick, left, %cx%, %topy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
		neighboury := cy - 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %bottomy%
			MouseClick, left, %cx%, %bottomy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
	}
	displaceloopy := cy + 52
	GoSub, SeedHarvest
return
}

^NumPad4::					;Going N-S 8 times UNATTENDED HOLY SHIT
IfWinExist eGenesis Client
{
	WinActivate
	
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, How many flax beds in a row?(Going N-S-N-S... for a total of 8 rows) Harvesting seeds after AND LOOPING UNTIL RELOAD.
	Gui, Add, Edit, Number vFlaxBeds, %FlaxBeds%
	Gui, Add, Button, default gflaxCommitNS4, OK
	Gui, Show
	return
	

	flaxCommitNS4:
	Gui, Submit
	Gui, Destroy
	WinActivate, eGenesis Client
	
loop{
	BedNumber := FlaxBeds * 8
	displaceloopy := cy + 30
	loop, 4
	{
		neighboury := cy + 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %topy%
			MouseClick, left, %cx%, %topy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
		neighboury := cy - 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %bottomy%
			MouseClick, left, %cx%, %bottomy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
	}
	displaceloopy := cy + 52
	GoSub, SeedHarvest
	sleep 3000
}
return
}

^NumPad1::					;Going N-S 10 times UNATTENDED HOLY SHIT
IfWinExist eGenesis Client
{
	WinActivate
	
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, How many flax beds in a row?(Going N-S-N-S... for a total of 10 rows) Harvesting seeds after AND LOOPING UNTIL RELOAD.
	Gui, Add, Edit, Number vFlaxBeds, %FlaxBeds%
	Gui, Add, Button, default gflaxCommitNS1, OK
	Gui, Show
	return
	

	flaxCommitNS1:
	Gui, Submit
	Gui, Destroy
	WinActivate, eGenesis Client
	
loop{
	BedNumber := FlaxBeds * 10
	displaceloopy := cy + 30
	loop, 5
	{
		neighboury := cy + 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %topy%
			MouseClick, left, %cx%, %topy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
		neighboury := cy - 70
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %bottomy%
			MouseClick, left, %cx%, %bottomy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
	}
	displaceloopy := cy + 52
	GoSub, SeedHarvest
	sleep 3000
}
return
}


Home | Atlas | Guides | Tests | Research | Techs | Skills | Index | Recent Changes | Preferences | Login
You must log in to edit pages. | View other revisions
Last edited July 31, 2006 3:32 pm by Spoiled (diff)
Search: