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

Users > Spoiled > AutoFlax

This macro will plant a number of beds in a number of rows and then either weed&harvest or just harvest the seeds. The opened "Plant" menu has to be pinned in the top left corner and the flax you want to plant the first on the list.

It is by far the most useful for seed harvesting and for best efficiency, using 4 beds in 10 rows = 40 beds should be ideal. The maximum number of beds for harvesting flax should be somewhere between 30 and 40, but don't hold me to it. Client-side lag spikes will solidly mess this macro and its window organization up, so be prepared to babysit it a little if worse comes to worst. Usually, if you're harvesting seeds and the macro skips a beat you can simply pause, add one on the side, and rearrange the windows later to fit. The positioning has 1 pixel tolerance and only one window may be assigned to one bed or the macro will get stuck in the loop.

The macro is meant to be used at 1280x1024 resolution. You will have to adjust the pixel shiftings for other resolutions.
You also need the pictures that are attached to this page in the same directory as the macro. Controls:

If you're Sadeh or need a version to debug with, try the DebuggingVersion.


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 - 75
topy := cy - 70		;65
bottomy := cy + 85	;80
displaceloopy := cy + 52	;redefined during use

;				Window-positioning coordinates
neighbourx := cx + 20
neighboury := cy + 10		
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 seed harvest runs to be done
FlaxBeds := 10
FlaxBedCheck := 0
TurnCornerCheck := false
TurnCounter := 0
return

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

PlantFlax:
	MouseClick, left, 60, 40
return

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

PinDragWindow:

	if (TurnCornerCheck = true)
		MouseMove, %neighbourx2%, %neighboury2%
	else
		MouseMove, %neighbourx%, %neighboury%
	sleep 100
	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 150

	ImageSearch, px1, py1, %searchx1%, %searchy1%, %searchx2%, %searchy2%, *5 pinlooseflax2.bmp
	if ErrorLevel = 0
		MouseClick, left, %px1%, %py1%
	else 
		Send fuckpin
	sleep 75

	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												;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
	ImageSearch, px3, py3, %searchx1%, %searchy1%, %searchx2%, %searchy2%, *2 tlcorner.bmp
	if ErrorLevel = 0
		MouseClickDrag, left, % (px3 + 1), % (py3 + 1), %gridx%, %gridy%, 
	sleep 75
	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
		}
		MouseClick, left, 6, %cy%
		loop 2 {				
			Send {WheelUp}
			sleep 175
		}

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
}

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
	}
	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


	}
	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
		}
		MouseClick, left, 6, %cy%
		loop 2 {				
			Send {WheelUp}
			sleep 175
		}
	}
	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 5{
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 + 10
	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 + 10
	loop, %FlaxBeds%
	{
		Gosub, PlantFlax
		MouseClick, left, %cx%, %topy%
		MouseClick, left, %cx%, %topy%
		Gosub, CheckFlaxrun
		Gosub, PinDragWindow
	}
	neighboury := cy - 10
	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 + 10
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %topy%
			MouseClick, left, %cx%, %topy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
		neighboury := cy - 10
		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 + 10
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %topy%
			MouseClick, left, %cx%, %topy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
		neighboury := cy - 10
		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 BALLS
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 + 10
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %topy%
			MouseClick, left, %cx%, %topy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
		neighboury := cy - 10
		loop, %FlaxBeds%
		{
			Gosub, PlantFlax
			MouseClick, left, %cx%, %bottomy%
			MouseClick, left, %cx%, %bottomy%
			Gosub, CheckFlaxrun
			Gosub, PinDragWindow
		}
	}
	displaceloopy := cy + 52
	GoSub, SeedHarvest
	sleep 2000
}
return
}


NameCreatorDateSizeDescription
flaxpictures.rarSpoiledJuly 31, 2006 2:22 pm3786Unpack to the same directory as the macro for it to work.

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:20 pm by Spoiled (diff)
Search: