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:Wopper87

From A Tale in the Desert
Revision as of 15:08, 29 December 2008 by Wopper87 (talk | contribs)
Jump to navigationJump to search

hey iggy i took your script and beefed it up alittle(just made it to 20 instead).

  • one thing i cant fix is that the first two rows of boxes (menus) overlap each other. no big deal since it still works but would like it cleaned up alittle.
  • i made the space between the flax alittle bigger since i was getting a few exploit warnings once in a while.
  • i also moved the boxes out from left side ever so slightly since when it would break down the box the left three would get left there (pointer crashing into wall, mine said 8 was the far left)

improvements?

  • instead of the constant loop can you make it a if/else at each box so it waits at the first box when it gets the result, then it moves to the next box?


file

 
SetDefaultMouseSpeed, 3

;Global Constants

;Location of the Flax: ? planting button (assumes far top left of screen, atm.)
plantButtonX:=50
plantButtonY:=44

;Flax Bed Size:
flaxBed:=419

;Flax Popup Box Size
flaxBoxX:=174
flaxBoxY:=100

;Grid Layout
;XY|Xx     |Xx     |Xx     |Xx
;Yy|AA(UL) |BB(UM) |CC(UR) |DD(new)
;Yy|EE(ML) |FF(MM) |GG(MR) |HH(new)
;Yy|II(LL) |JJ(LM) |Kk(LR) |LL(new)
;Yy|MM(new)|NN(new)|OO(new)|PP(new)
;Yy|QQ(new)|RR(new)|SS(new)|TT(new)
;all positions are based off of ULxy
AAx:=10
AAy:=600

BBx:=AAx + flaxBoxX
BBy:=AAy

CCx:=BBx + flaxBoxX
CCy:=AAy

DDx:=CCx + flaxBoxX
DDy:=CCy

EEx:=AAx
EEy:=AAy + flaxBoxY

FFx:=EEx + flaxBoxX
FFy:=EEy

GGx:=FFx + flaxBoxX
GGy:=FFy

HHx:=GGx + flaxBoxX
HHy:=EEy

IIx:=AAx
IIy:=EEy + flaxBoxY

JJx:=IIx + flaxBoxX
JJy:=IIy

KKx:=JJx + flaxBoxX
KKy:=JJy

LLx:=KKx + flaxBoxX
LLy:=IIy

MMx:=AAx
MMy:=IIy + flaxBoxY

NNx:=MMx + flaxBoxX
NNy:=MMy

OOx:=NNx + flaxBoxX
OOy:=NNy

PPx:=OOx + flaxBoxX
PPy:=MMy

QQx:=AAx 
QQy:=IIy + flaxBoxX

RRx:=QQx + flaxBoxY
RRy:=QQy 

SSx:=RRx + flaxBoxX
SSy:=RRy

TTx:=SSx + flaxBoxX
TTy:=QQy 

^!+p::Pause ;Pause Script Ctrl+Alt+Shift+P

;Move the popup menu box to the specified topleft corner by posX,posy
;(assumes the menu was just opend and the mouse hasn't moved)
moveMenu(posX, posY)
{
	Click up
	MouseGetPos , MX, MY
	MXv:=MX+50
	MYv:=MY-35
	MouseMove , MX+50, MY-35
	Click down 
	MXv:=posX+50
	MYv:=posY+15
	MouseMove , posX+50, posY+15
	Click up
	return
}

refreshMenu(TCx,TCy)
{
	;Relative location to click
	Rx:=TCx+95
	Ry:=TCy+30
	click %Rx% , %Ry%
	return
}

;UnPin menu with topleft corner at TCx,TCy
unPinMenu(TCx,TCy)
{
	;offset pin from top left corner
	pinLocX:=TCx+150
	pinLocY:=TCy+17
	
	msgbox , 0 , unpinning menu, "Unpinning Menu at %TCx% _ %TCy% pin at %pinLocX% _ %pinLocY%"
	
	Click %pinLocX% , %pinLocY%
	
	return 1
}

;Process the top left corner of the flax menu at TCx,TCy
processFlax(TCx,TCy)
{
	;Action item Relative Location
	actionX:=TCx+50
	actionY:=TCy+50
	
	;Search Area Adjustment
	SATCx:=TCx+174
	SATCy:=TCy+100
	
	refreshMenu(TCx,TCy)
	sleep 250
	
	;Msgbox , 0 , Searchbox, "Search area is %TCx% _ %TCy% by %SATCx% _ %SATCy%"
	
	ImageSearch, Px, Py, TCx, TCy, SATCx, SATCy, *50 Find_Weed_this.png
	if (ErrorLevel < 1) {
		Click %actionX% , %actionY% ;Click Weed This
		return 1		; found the "weed this"
	}
	ImageSearch, Px, Py, TCx, TCy, SATCx, SATCy, *50 Find_Weed_and.png
	if (ErrorLevel < 1) {
		Click %actionX% , %actionY% ;Click Weed and Water This
		return 1		; found the "weed and"
	}
	ImageSearch, Px, Py, TCx, TCy, SATCx, SATCy, *50 Find_Harvest_this.png
	if (ErrorLevel < 1) {
		Click %actionX% , %actionY% ;Click Harvest This
		;unPinMenu(TCx,TCy)
		pinLocX:=TCx+150
		pinLocY:=TCy+17
		Click %pinLocX% , %pinLocY%
		return 0 ; found the "Harvest this", menu removed
	}
	ImageSearch, Px, Py, TCx, TCy, SATCx, SATCy, *50 Find_Harvest_seeds.png
	if (ErrorLevel < 1) {
		;ripOutFlax(TCx,TCy)
		Click %actionX% , %actionY% ;Click Harvest seeds
		utilX:=TCx+35
		utilY:=TCy+82
		Click %utilX%, %utilY% ;click Utilities
		;adjust for new popup menu
		MouseGetPos , MX, MY
		ROFx:=MX+50 ;Rip Out Flax button X
		ROFy:=MY-8  ;Rip Out Flax button Y
		clickItem(ROFx,ROFy) ; click Rip out Flax
		;unPinMenu(TCx,TCy)
		pinLocX:=TCx+150
		pinLocY:=TCy+17
		Click %pinLocX% , %pinLocY%
		return 0 ; found the "harvest seeds", menu removed
	}
	return 1 ; no clicks here
}

;Process the top left corner of the flax menu at TCx,TCy
processFlaxSeeds(TCx,TCy,seedCount)
{
	;Action item Relative Location
	actionX:=TCx+50
	actionY:=TCy+50
	
	;Search Area Adjustment
	SATCx:=TCx+174
	SATCy:=TCy+100
	
	refreshMenu(TCx,TCy)
	sleep 250
	
	ImageSearch, Px, Py, TCx, TCy, SATCx, SATCy, *50 Find_Harvest_seeds.png
	if (ErrorLevel < 1) {
		;ripOutFlax(TCx,TCy)
		Click %actionX% , %actionY% ;Click Harvest seeds
		if (seedCount >= 5) {
			utilX:=TCx+35
			utilY:=TCy+82
			Click %utilX%, %utilY% ;click Utilities
			;adjust for new popup menu
			MouseGetPos , MX, MY
			ROFx:=MX+50 ;Rip Out Flax button X
			ROFy:=MY-8  ;Rip Out Flax button Y
			clickItem(ROFx,ROFy) ; click Rip out Flax
			pinLocX:=TCx+150
			pinLocY:=TCy+17
			Click %pinLocX% , %pinLocY%
			return 99
		}
		return 1 ; found the "harvest seeds", menu removed
	}
	return 0 ; no clicks here	
}
	
;Rip out the flax bed of the box with top left corner at TCx,TCy
ripOutFlax(TCx,TCy)
{
	;Utilities menu relative location
	utilX:=TCx+35
	utilY:=TCy+82
	
	Click %utilX%, %utilY% ;click Utilities
	
	;adjust for new popup menu
	MouseGetPos , MX, MY
	ROFx:=MX+50 ;Rip Out Flax button X
	ROFy:=MY-8  ;Rip Out Flax button Y
	
	clickItem(ROFx,ROFy) ; click Rip out Flax
	
	return
}

;Pin menu assuming that it was just brought up
pinMenu()
{
	mouseGetPos , MX , MY
	;Pin icon relative location
	pinX:=MX+155
	pinY:=MY-33
	
	click %pinX% , %pinY% ;Click the pin button
	
	MouseMove , MX, MY, 0 ;put back the mouse
	
	return	
}

;Plant the flax seed
plantSeed()
{
	pBX:=50
	pBY:=44
	;click on the flax seed button
	Click %pbX% , %pbY%
	return
}

;Move avatar to location specified AvX, AvY
moveAvatar(AvX, AvY)
{
	Click %AvX%, %AvY%
	sleep 500
	return
}

;Bring up the Flax bed's popup menu provided the avatars current location AvX,AvY
flaxMenu(AvX,AvY)
{
	;MouseGetPos , MX, MY
	;Use above and to the right of the avatar to bring up menu
	flaxMenuX:= AvX+50
	flaxMenuY:= AvY-50
	
	click %flaxMenuX% , %flaxMenuY%
	
	pinMenu()
	
	;MouseMove , MX, MY
	
	return
}
	

;;Click the resource at X,Y then return the pointer
clickItem(X, Y)
{
	oldMouseDelay:= A_MouseDelay
	setMouseDelay , 1
  Click up
  MouseGetPos , MX, MY
  Click , %X%, %Y%
  MouseMove , MX, MY
	setMouseDelay , A_MouseDelay
  return
}

^!f::
WinWait, eGenesis Client, 
IfWinNotActive, eGenesis Client, , WinActivate, eGenesis Client, 
WinWaitActive, eGenesis Client,
WinGetActiveStats, win_Title, win_Width, win_Height, win_Xpos, win_Ypos
InputBox, flaxNum, Flax some, How many Flax passes do you want?
;some local constants

;msgBox " AA= %AAx%,%AAy% _ BB= %BBx%,%BBy% _ CC= %CCx%,%CCy% _ DD= %DDx%,%DDy% _ EE= %EEx%,%EEy% _ FF= %FFx%,%FFy% _ GG= %GGx%,%GGy% _ HH= %HHx%,%HHy% _ II= %IIx%,%IIy% _ JJ= %JJx%,%JJy% _ KK= %KKx%,%KKy% _ LL= %LLx%,%LLy% _ MM= %MMx%,%MMy% _ NN= %NNx%,%NNy% _ OO= %OOx%,%OOy% _ PP= %PPx%,%PPy% _ QQ= %QQx%,%QQy% _ RR= %RRx%,%RRy% _ SS= %SSx%,%SSy% _ TT= %TTx%,%TTy%"

;middle of the window where the avatar is located
avatarX:=win_Width/2 
avatarY:=win_Height/2 + 28 ;add a little for title-bar adjustment

moveDist:=flaxBed + 5 ;Move one plot plus a little

;standard movement values
moveLeft:= avatarX - moveDist
moveRight:= avatarX + moveDist
moveUp:= avatarY - moveDist
moveDown:= avatarY + moveDist

loop {
	;Left Rigth Flipper
	moveTT:=1 ;0 for left, 1 for right
	
	TrayTip Flaxing in progress, You have %flaxNum% more Passes to go,15,1
	if (flaxNum<=0) {	
		TrayTip, Flaxing Done, Flaxing Done, enjoy your flax, 15, 1
		soundPlay *64,1
		exit
	}
	flaxNum:=flaxNum-1
	
if (A_Index==1) {
		moveAvatar(avatarX,moveUp)
		moveAvatar(moveRight,avatarY)
	} else {
		moveAvatar(avatarX,moveUp)
		moveAvatar(avatarX,moveUp)
		moveAvatar(moveRight,avatarY)
		moveAvatar(moveRight,AvatarY)
	}
	
	;Set all grid boxes to non moved values ( 0 )
	AA:=0
	BB:=0
	CC:=0
	DD:=0
	EE:=0
	FF:=0
	GG:=0
	HH:=0
	II:=0
	JJ:=0
	KK:=0
	LL:=0
	MM:=0
	NN:=0
	OO:=0
	PP:=0
	QQ:=0
	RR:=0
	SS:=0
	TT:=0

	gridXCounter:=4
	gridYCounter:=5
	loop {
		if (gridYCounter > 0) {
			gridYCounter:=gridYCounter-1
			if (moveTT==1) {
				moveTT:=0
			} else {
				moveTT:=1
			}
			gridXCounter:=4
			loop {
				if (gridXCounter > 0)	{
					gridXCounter:=gridXCounter-1
					plantSeed()
					flaxMenu(avatarX, avatarY)
					if (gridYCounter==0) {
						if (AA==0) {
							moveMenu(AAx,AAy)
							AA:=1
						} else if (BB==0) {
							moveMenu(BBx,BBy)
							BB:=1
						} else if (CC==0) {
							moveMenu(CCx,CCy)
							CC:=1
						} else if (DD==0) {
							moveMenu(DDx,DDy)
							DD:=1
						}
					}
					if (gridYCounter==1) {
						if (EE==0) {
							moveMenu(EEx,EEy)
							EE:=1
						} else if (FF==0) {
							moveMenu(FFx,FFy)
							FF:=1
						} else if (GG==0) {
							moveMenu(GGx,GGy)
							GG:=1
						} else if (HH==0) {
							moveMenu(HHx,HHy)
							HH:=1
						}
					}
					if (gridYCounter==2) {
						if (II==0) {
							moveMenu(IIx,IIy)
							II:=1
						} else if (JJ==0) {
							moveMenu(JJx,JJy)
							JJ:=1
						} else if (KK==0) {
							moveMenu(KKx,KKy)
							KK:=1
						} else if (LL==0) {
							moveMenu(LLx,LLy)
							LL:=1
						}
					}
					if (gridYCounter==3) {
						if (MM==0) {
							moveMenu(MMx,MMy)
							MM:=1
						} else if (NN==0) {
							moveMenu(NNx,NNy)
							NN:=1
						} else if (OO==0) {
							moveMenu(OOx,OOy)
							OO:=1
						} else if (PP==0) {
							moveMenu(PPx,PPy)
							PP:=1
						}
					}
					if (gridYCounter==4) {
						if (QQ==0) {
							moveMenu(QQx,QQy)
							QQ:=1
						} else if (RR==0) {
							moveMenu(RRx,RRy)
							RR:=1
						} else if (SS==0) {
							moveMenu(SSx,SSy)
							SS:=1
						} else if (TT==0) {
							moveMenu(TTx,TTy)
							TT:=1
						}
					}
					if (moveTT==0 && gridXCounter > 0)
					{
						moveAvatar(moveLeft,avatarY)
					} else if (moveTT==1 && gridXCounter > 0) {
						moveAvatar(moveRight,avatarY)
					}
				} else {
					break
				}	
			}
		} else {
			break
		}
		if (gridYCounter>0) 
				moveAvatar(avatarX, moveDown)		
	}
Pause=1000
	;start harvest loops
	loop {
		if (AA==0 && BB==0 && CC==0 && DD==0 && EE==0 && FF==0 && GG==0 && HH==0 && II==0 && JJ==0 && KK==0 && LL==0 && MM==0 && NN==0 && OO==0 && PP==0 && QQ==0 && RR==0 && SS==0 && TT==0)
			break
		if QQ
			QQ:=processFlax(QQx,QQy)
		if RR
			RR:=processFlax(RRx,RRy)
		if SS
			SS:=processFlax(SSx,SSy)
		if TT
			TT:=processFlax(TTx,TTy)
		if MM
			MM:=processFlax(MMx,MMy)
		if NN
			NN:=processFlax(NNx,NNy)
		if OO
			OO:=processFlax(OOx,OOy)
		if PP
			PP:=processFlax(PPx,PPy)
		if II
			II:=processFlax(IIx,IIy)
		if JJ
			JJ:=processFlax(JJx,JJy)
		if KK
			KK:=processFlax(KKx,KKy)
		if LL
			LL:=processFlax(LLx,LLy)
		if EE
			EE:=processFlax(EEx,EEy)
		if FF
			FF:=processFlax(FFx,FFy)
		if GG
			GG:=processFlax(GGx,GGy)
		if HH
			HH:=processFlax(HHx,HHy)
		if AA
			AA:=processFlax(AAx,AAy)
		if BB
			BB:=processFlax(BBx,BBy)
		if CC
			CC:=processFlax(CCx,CCy)
		if DD
			DD:=processFlax(DDx,DDy)

	}
	SoundPlay *-1, 1
}
SoundPlay *64,1



^!e::
WinWait, eGenesis Client, 
IfWinNotActive, eGenesis Client, , WinActivate, eGenesis Client, 
WinWaitActive, eGenesis Client,
WinGetActiveStats, win_Title, win_Width, win_Height, win_Xpos, win_Ypos
InputBox, flaxNum, Flax some, How many Seed passes do you want?
;some local constants

;msgBox " AA= %AAx%,%AAy% _ BB= %BBx%,%BBy% _ CC= %CCx%,%CCy% _ DD= %DDx%,%DDy% _ EE= %EEx%,%EEy% _ FF= %FFx%,%FFy% _ GG= %GGx%,%GGy% _ HH= %HHx%,%HHy% _ II= %IIx%,%IIy% _ JJ= %JJx%,%JJy% _ KK= %KKx%,%KKy% _ LL= %LLx%,%LLy% _ MM= %MMx%,%MMy% _ NN= %NNx%,%NNy% _ OO= %OOx%,%OOy% _ PP= %PPx%,%PPy% _ QQ= %QQx%,%QQy% _ RR= %RRx%,%RRy% _ SS= %SSx%,%SSy% _ TT= %TTx%,%TTy%"

;middle of the window where the avatar is located
avatarX:=win_Width/2 
avatarY:=win_Height/2 + 28 ;add a little for title-bar adjustment

moveDist:=flaxBed + 5 ;Move one plot plus a little

;standard movement values
moveLeft:= avatarX - moveDist
moveRight:= avatarX + moveDist
moveUp:= avatarY - moveDist
moveDown:= avatarY + moveDist

loop {
	;Left Rigth Flipper
	moveTT:=1 ;0 for left, 1 for right
	
	TrayTip Flaxing in progress, You have %flaxNum% more Passes to go,15,1
	if (flaxNum<=0)	{
		TrayTip, Flaxing Done, Flaxing Done, enjoy your flax, 15, 1
		soundPlay *64,1
		exit
	}
	flaxNum:=flaxNum-1
	
	if (A_Index==1) {
		moveAvatar(avatarX,moveUp)
		moveAvatar(moveRight,avatarY)
	} else {
		moveAvatar(avatarX,moveUp+50)
		moveAvatar(avatarX,moveUp)
		moveAvatar(moveRight-50,avatarY)
		moveAvatar(moveRight,AvatarY)
	}
	;Set all grid boxes to non moved values ( 0 )
	AA:=0
	BB:=0
	CC:=0
	DD:=0
	EE:=0
	FF:=0
	GG:=0
	HH:=0
	II:=0
	JJ:=0
	KK:=0
	LL:=0
	MM:=0
	NN:=0
	OO:=0
	PP:=0
	QQ:=0
	RR:=0
	SS:=0
	TT:=0
	
	gridXCounter:=4
	gridYCounter:=5
	loop {
		if (gridYCounter > 0) {
			gridYCounter:=gridYCounter-1
			if (moveTT==1) {
				moveTT:=0
			} else {
				moveTT:=1
			}
			gridXCounter:=4
			loop {
				if (gridXCounter > 0)	{
					gridXCounter:=gridXCounter-1
					plantSeed()
					flaxMenu(avatarX, avatarY)
					if (gridYCounter==0) {
						if (AA==0) {
							moveMenu(AAx,AAy)
							AA:=1
						} else if (BB==0) {
							moveMenu(BBx,BBy)
							BB:=1
						} else if (CC==0) {
							moveMenu(CCx,CCy)
							CC:=1
						} else if (DD==0) {
							moveMenu(DDx,DDy)
							DD:=1
						}
					}
					if (gridYCounter==1) {
						if (EE==0) {
							moveMenu(EEx,EEy)
							EE:=1
						} else if (FF==0) {
							moveMenu(FFx,FFy)
							FF:=1
						} else if (GG==0) {
							moveMenu(GGx,GGy)
							GG:=1
						} else if (HH==0) {
							moveMenu(HHx,HHy)
							HH:=1
						}
					}
					if (gridYCounter==2) {
						if (II==0) {
							moveMenu(IIx,IIy)
							II:=1
						} else if (JJ==0) {
							moveMenu(JJx,JJy)
							JJ:=1
						} else if (KK==0) {
							moveMenu(KKx,KKy)
							KK:=1
						} else if (LL==0) {
							moveMenu(LLx,LLy)
							LL:=1
						}
					}
					if (gridYCounter==3) {
						if (MM==0) {
							moveMenu(MMx,MMy)
							MM:=1
						} else if (NN==0) {
							moveMenu(NNx,NNy)
							NN:=1
						} else if (OO==0) {
							moveMenu(OOx,OOy)
							OO:=1
						} else if (PP==0) {
							moveMenu(PPx,PPy)
							PP:=1
						}
					}
					if (gridYCounter==4) {
						if (QQ==0) {
							moveMenu(QQx,QQy)
							QQ:=1
						} else if (RR==0) {
							moveMenu(RRx,RRy)
							RR:=1
						} else if (SS==0) {
							moveMenu(SSx,SSy)
							SS:=1
						} else if (TT==0) {
							moveMenu(TTx,TTy)
							TT:=1
						}
					}
					if (moveTT==0 && gridXCounter > 0)
					{
						moveAvatar(moveLeft,avatarY)
					} else if (moveTT==1 && gridXCounter > 0) {
						moveAvatar(moveRight,avatarY)
					}
				} else {
					break
				}	
			}
		} else {
			break
		}
		if (gridYCounter>0) 
				moveAvatar(avatarX, moveDown)		
	}
	
	;start gather loops
	loop {
		if (AA>6 && BB>6 && CC>6 && DD>6 && EE>6 && FF>6 && GG>6 && HH>6 && II>6 && JJ>6 && KK>6 && LL>6 && MM>6 && NN>6 && OO>6 && PP>6 && QQ>6 && RR>6 && SS>6 && TT>6)
			break




		if QQ<6
			QQ+=processFlaxSeeds(QQx,QQy,QQ)
		if RR<6
			RR+=processFlaxSeeds(RRx,RRy,RR)
		if SS<6
			SS+=processFlaxSeeds(SSx,SSy,SS)
		if TT<6
			TT+=processFlaxSeeds(TTx,TTy,TT)
		if MM<6
			MM+=processFlaxSeeds(MMx,MMy,MM)
		if NN<6
			NN+=processFlaxSeeds(NNx,NNy,NN)
		if OO<6
			OO+=processFlaxSeeds(OOx,OOy,OO)
		if PP<6
			PP+=processFlaxSeeds(PPx,PPy,PP)
		if II<6
			II+=processFlaxSeeds(IIx,IIy,II)
		if JJ<6
			JJ+=processFlaxSeeds(JJx,JJy,JJ)
		if KK<6
			KK+=processFlaxSeeds(KKx,KKy,KK)
		if LL<6
			LL+=processFlaxSeeds(LLx,LLy,LL)
		if EE<6
			EE+=processFlaxSeeds(EEx,EEy,EE)
		if FF<6
			FF+=processFlaxSeeds(FFx,FFy,FF)
		if GG<6
			GG+=processFlaxSeeds(GGx,GGy,GG)
		if HH<6
			HH+=processFlaxSeeds(HHx,HHy,HH)
		if AA<6
			AA+=processFlaxSeeds(AAx,AAy,AA)
		if BB<6
			BB+=processFlaxSeeds(BBx,BBy,BB)
		if CC<6
			CC+=processFlaxSeeds(CCx,CCy,CC)
		if DD<6
			DD+=processFlaxSeeds(DDx,DDy,DD)
	}
	SoundPlay *1, 1
}