The Wiki for Tale 4 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

User:Cegaiel/Macros/Barley/Code

From A Tale in the Desert
Jump to navigationJump to search
;Barley Macro written for http://www.autohotkey.com, 1280x1024 resolution, pin plant window in the upper left corner of the screen. 

;Have 10 Raw Barley, 60 Grain Fertilizer and 60 jugs of water, in inventory, for "Water + 6 fertilizer" mode
;Have 10 Raw Barley, 30 Grain Fertilizer and 60 jugs of water, in inventory, for "Water + 3 fertilizer" mode
;Have 10 Raw Barley, 0 Grain Fertilizer and 60 jugs of water, in inventory, for "Water only" mode


; Barley - 1280x1024 resolution

; Ctrl+Alt+W to Start script
; Ctrl+R to Reload script
; Ctrl+P to Pause script


; Author: Cegaiel
; Based on Daniels barley macro
; Date: 6/3/2010
; Updated: 9/17/2010 for T5 (No adjustments were required, however I somehow deleted the "interval = 1200" line
; on the T4 version which caused the script to fail miserably when I tried it on T5. That line is now added and works fine now
; Updated: 10/16/2010 - I attempted to revamp the script to automatically start without Ctrl+Alt+W, but some reason this made it misclick very badly.
; Restored back to previous version, which includes the 9/17/2010 update



^r::reload
^p::Pause
^!w::


IfWinExist eGenesis Client
{
	WinActivate, eGenesis Client

	WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
	SetDefaultMouseSpeed, 0
	interval = 1200
	


;Check to see if we are in the correct resolution, or else exit script
if (Xmax = 1288) && (Ymax = 1002)
{
nothing = 0
} else {
Msgbox, You are not in 1280x1024 resolution`n`nExiting...
EXIT
}



	Gui, +AlwaysOnTop +ToolWindow
	Gui, Font, bold
	Gui, Add, Text,, Adjust Camera/Zoom Level?
	Gui, Font, normal
	Gui, Add, Text,, Choose Yes if this is the first time running.`nChoose No if you already performed this step and locked screen.
	Gui, Add, DropDownList, vAdjust Choose2, Yes|No


	Gui, Font, bold
	Gui, Add, Text,, `nChoose method/fertilizer qty:
	Gui, Font, normal
	;Gui, Add, Text,, 
	Gui, Add, DropDownList, vMethod Choose3, Water + 3 fertilizer|Water + 6 fertilizer|Water only



	Gui, Add, Button, Default gStart, GO
	Gui, Show
	return



Start:
	Gui, Submit
	Gui, Destroy
	Sleep 250

if (Adjust = "Yes")
{

;Now Zoom in all the way with F8
	WinActivate, eGenesis Client
	Sleep 1000
	Send {F5}{F8}{F8}
	MouseMove, 0,0
	Sleep 5000
	MouseMove, 0, 0
	Sleep 5000

	Xcenter := Xmax//2 - 3
	Ycenter := Ymax//2 + 16
	MouseMove, Xcenter, Ycenter, 0


	; Zoom out a little
	Loop, 8
	{
		click, WD
		sleep 250
	}

Sleep 2000

Msgbox, Screen adjusted, Lock screen (Alt+L) NOW so you wont have to repeat this step on next plantings.`n`nDon't forget to make sure you have your Plant menu in top left corner before continuing!`n`nClick OK when you are ready to continue...

}

Plant:

	WinActivate, eGenesis Client

	Loop, 100
	{
		mousex := Xmax//2 - 3
		mousey := Ymax//2 + 16
		incx = 70
		incy = 70
		rows = 0
		Loop, 2 ; columns of barley
		{
			bug = 0
			Loop, 4 ; rows of barley
			{
				if (Mod(rows, 2) = 0) ; plant left to right
				{
					MouseMove, 30, 45
					sleep 100
					click, Left ; Plant
					sleep 100
					MouseMove, mousex + incx, mousey
					sleep 100
					click, Left
					sleep interval
				}
				else ; plant right to left
				{
					MouseMove, 30, 45
					sleep 100
					click, Left ; Plant
					sleep 100
					MouseMove, mousex - incx, mousey
					sleep 100	
					click, Left
					sleep interval
				}
			}
			MouseMove, 30, 45
			sleep 100
			click, Left ; Plant
			sleep 100
			MouseMove, mousex, mousey + incy
			sleep 100
			click, Left
			sleep interval	
			rows++
		}



	
		; Begin watering and fertalizing
		water = 0
		count = 0
		Loop, 6
		{
			mousex = 640
			mousey = 375
			intx = 0
			inty = 0
			Loop, 2
			{





				Loop, 5
				{

					Gosub, Calc

					if (count = 0) ; water and fert twice
					{
						Click, %x%, %y%
						Sleep 250

						;Water
						click, %WaterX%, %WaterY%
						Sleep 250
						click, %WaterX%, %WaterY%

					
					if !(Method = "Water only")
					{
						Sleep 250
						;Fert
						click, %FertX%, %FertY%
						Sleep 250
						click, %FertX%, %FertY%
					}

						Sleep 250
						SendInput {ESC}
						sleep 350
						intx += 70	

						Gosub, Calc


					}
					else if (count = 3) and (Method = "Water + 3 fertilizer") ; water and fert once
					{
						click, %x%, %y%
						Sleep 250
						click, %waterX%, %waterY%
						Sleep 250
						click, %FertX%, %FertY%

						Sleep 250
						SendInput {ESC}
						sleep 350
						intx += 70

						Gosub, Calc


					}
					else if (count = 5) ; harvest
					{
						click, %x%, %y%
						Sleep 250
						click, %harvestX%, %harvestY%

						Sleep 250
						SendInput {ESC}
						sleep 500
						intx += 70
						Gosub, Calc

					}
					else ; water and fert once
					{
						click, %x%, %y%
						Sleep 250

						;Water
						click, %waterX%, %waterY%

					if (Method = "Water + 6 fertilizer") 
					{
						;Fert
						Sleep 250
						click, %FertX%, %FertY%
					}

						Sleep 250
						SendInput {ESC}
						sleep 350
						intx += 70	
						Gosub, Calc
					}
				}
				mousex = 640
				intx = 0
				inty += 90
				Gosub, Calc
			}
			count++



			if (count = 5)
			{
			sleep 25000 ;Last cycle, let is sit for 25s, usually get more barley
			} else if (count = 6) {
			Sleep 0
			} else{
			sleep 6000
			}



		}

	Msgbox, Done! Click OK`n`nPress Press F2 if you want to plant again...`n`nFirst gather water and stand on a good spot, if you will continue.
	KeyWait, F2, D
	Gosub, Plant


		;EXIT


	}
}


Calc:
;Bed 1 Location
x := mousex + intx
y := mousey + inty

waterX := mousex + intx + 189
waterY := mousey + inty + 23

FertX := mousex + intx + 189
FertY := mousey + inty + 46

HarvestX := mousex + intx + 106
HarvestY := mousey + inty + 86
return