need help automating Final Fantasy 3 combat

Ask gaming related questions (AHK v1.1 and older)
Glavitar
Posts: 1
Joined: 07 Mar 2016, 01:40

need help automating Final Fantasy 3 combat

07 Mar 2016, 02:13

I am using this code as my base https://www.dropbox.com/s/tschdt06ip7my ... y.txt?dl=0
and am trying to improve it, the current program uses long delays in the hopes that something will have happened before the code moves on.
the current part I am working on is to get the character in game to walk back and forth till combat and when combat has started to move on with the code

original section

Code: Select all

;Wander Overworld (To Find a Random Encounter)
FF3WanderLR(){
	;Walk Loop Cycle
			Loop 8
			{
				Sleep 600
				FF3WalkLeft()
				Sleep 600
				FF3WalkRight()
				Sleep 600
			}				
		}
	return
my current attempt at getting it to work

Code: Select all

;Wander Overworld (To Find a Random Encounter)
FF3WanderLR(){
	;Walk Loop Cycle
			Loop
			{
				PixelGetColor, color, 100, 740
				If Color <> 0xFFFFFF
				{
					Sleep 30
					FF3WalkLeft()
					Sleep 30
					FF3WalkRight()
					Sleep 30
				}
				Else
				 Break
			}
		}
	return
so instead of a loop of running back and forth 8 times I am trying to run back and forth till the in game cursor for combat shows up

my problem is it runs back and forth just fine, I can't get it to recognize the white of the hand cursor icon and move on

I have tried other scripts to confirm the location and color of my target, anyone have an idea what I might be doing wrong?
Tcharr
Posts: 41
Joined: 25 Jan 2020, 15:38

Re: need help automating Final Fantasy 3 combat

25 Jan 2020, 15:55

I know this is a couple years late, but maybe someone will benefit (like a Steam Achievement hunter ;)). I targeted the lower arrow at the right of the encounter menu. It is not completely opaque, so I searched for a small range of colors in a small square of pixels.

Code: Select all

;Wander Overworld (To Find a Random Encounter)
FF3WanderLR2(){
	;Walk Loop Cycle
			Loop
			{
				Sleep 300
				FF3WalkLeft()
				Sleep 300
				FF3WalkRight()
				;Sleep 600
			} Until FF3EncounterCheck()				
		}
	return
	
;Check for Encounter UI
FF3EncounterCheck(){
	;Check for white pixels in Encounter Menu area
		PixelSearch, Px, Py, 632, 931, 639, 938, 0xfefefe, 1, Fast
			if ErrorLevel
			    return false
			else
			    return true
}
Resolution was 1920x1080

cc AHK and FF III Steam forums
Tcharr
Posts: 41
Joined: 25 Jan 2020, 15:38

Re: need help automating Final Fantasy 3 combat

27 Jan 2020, 09:03

Here is what I am currently working with for job leveling in the Altar Cave near the healing pool. Resolution is 1920x1080 windowed, not full screen.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
;SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#p::Pause ; Pressing Win+P once will pause the script. Pressing it again will unpause.

;By Doubtful; Further Modified by Delta Omega
; This Script assumes The following for Keybindings, they may be configured at FF3 application launcher
;< ^ > v Arrow keys are set to WASD
; Select (Enter), Cancel (Backspace), Menu(Tab), Page(m)

;If FF3 is the active window
#IfWinActive ahk_class SDL_app
{
; Press Esc to force quit the application
Esc::ExitApp



	;___________________________________________
	;|KEYBINDINGS FOR PARTY/CHARACTER FUNCTIONS|
	;-------------------------------------------

	;Fighter, monk attack; wh. mage defend; bl. mage use fire staff
	;$r::
	;	FF3Custom1()
	;return

	;All attack
	$f::
		FF3AllAttack()
	return
	
	;All secondary attack
	$v::
		FF3All2ndAttack()
	return

	;First two attack, last two defend
	;$g::
	;	FF3MagesDefend()
	;return

	;All defend
	;$h::
	;	FF3AllDefend()
	;return

	;All swap rows (back attacked)
	$j::
		FF3AllSwapRows()
	return
	
	
	;__________________________________________________
	;|END OF KEYBINDINGS FOR PARTY/CHARACTER FUNCTIONS|
	;--------------------------------------------------

	;___________________________________________
	;|KEYBINDINGS FOR OVERWORLD FUNCTIONS|
	;-------------------------------------------
		
	;Wander Left & Right
	$e::
		FF3WanderLR()
	return
	
	;Presses confirm a bunch
	$Space::
		FF3ConfirmAbunch()
	return

	;Heal's the Party
	$i::
		FF3AutoHealHi()
	return
	
	;Enables Auto-Trainer indefinitely
	!^a::
		FF3Auto()
	return
	
	;___________________________________________
	;|END OF KEYBINDINGS FOR OVERWORLD FUNCTIONS|
	;-------------------------------------------
	
}


;____________________
;|CUSTOM ACTIONS|
;--------------------
;Auto-trainer. Attempts to Cycle through WANDER, Auto-Battle, & Confirm After Battle Scripts 120 times
;Heals after every 12 times the autobattle loop completes.
FF3Auto(){
;Limits the number of times the cycle runs.
Limit := 0
		While Limit < 10
			{
			Limit:=Limit+1
			;Counts the number of fights before attempting to heal. Counter resets after each full loop cycle.
			Counter := 0
			While Counter < 12
					{
						Counter:=Counter+1

						FF3WanderLR2() //Uses pixel check to detect encounter
						Sleep 3000
						;FF3All2ndAttack() //Enable if you want to attack instead of using 2nd actions
						FF3AllDefend5() //Enable if you want to level jobs, makes money grinding slower
						FF3AllAttack()
						Sleep 14000
						FF3ConfirmAbunch()
						Sleep 2000
						FF3ConfirmAbunch()
	FF3Progress:=(Limit-1)*12+Counter
	SplashTextOn, , 50, FF3JobLevel, %FF3Progress%
						Sleep 2000
						FF3ConfirmAbunch()
						Sleep 2000
					}
			;Counter is finished, time to heal.
			;FF3AutoHealHi()
			;Sleep 3000
			;FF3AutoHealHi()
			;Sleep 3000

			;Altar Cave heal alternative (pool)
				Loop{
					FF3WalkRight()
					If FF3EncounterCheck(){
						FF3AllAttack()
						Sleep 14000
						FF3ConfirmAbunch()
						Sleep 2000
						FF3ConfirmAbunch()
	FF3Progress:=(Limit-1)*12+Counter
	SplashTextOn, , 50, FF3JobLevel, Hjeal me!!
						Sleep 2000
						FF3ConfirmAbunch()
						Sleep 2000
					}	
				} until FF3ExclamationCheck()
				FF3Select()
				Sleep 5000
				FF3Select()
			}
	}
	return
	
;____________________
;|END OF CUSTOM ACTIONS|
;--------------------

;_____________________
;|RAW INPUT FUNCTIONS|
;---------------------

;Simulates a keypress of "select" (confirm) key
FF3Select(){

	;Send Enter down/up events
	Send {Enter down}
	Sleep 30
	Send {Enter up}
	;Send {Enter}
	Sleep 30
}

;Simulates a keypress of "back" (cancel) key
FF3Cancel(){

	;Send Backspace down/up events
	Send {Backspace down}
	Sleep 30
	Send {Backspace up}
	;Send {Backspace}
	Sleep 30
}

;Simulates a keypress of "Menu" (Menu) key
FF3Menu(){

	;Send Tab down/up events
	Send {Tab down}
	Sleep 30
	Send {Tab up}
	;Send {Tab}
	Sleep 30
}

;Simulates a keypress of "Next Page" (Page/Auto-Flee) key
FF3NextPage(){

	;Send m down/up events
	Send {m down}
	Sleep 30
	Send {m up}
	Sleep 30
}

;Simulates a keypress of "down" key
FF3Down(){

	;Send Down down/up events
	Send {s down}
	Sleep 30
	Send {s up}
	;Send s
	Sleep 30
}

;Simulates a press of "up" key
FF3Up(){

	;Send Up down/up events
	Send {w down}
	Sleep 30
	Send {w up}
	;Send w
	Sleep 30
}

;Simulates a press of "left" key
FF3Left(){

	;Send Left down/up events
	Send {a down}
	Sleep 30
	Send {a up}
	;Send a
	Sleep 30
}

;Simulates a 1-second long press of "left" key
FF3WalkLeft(){

	;Send Left down/up events
	Send {a down}
	Sleep 1000
	Send {a up}
	Sleep 30
}

;Simulates a press of "right" key
FF3Right(){

	;Send Right down/up events
	Send {d down}
	Sleep 30
	Send {d up}
	;Send d	
	Sleep 30
}

;Simulates a 1-second long press of "right" key
FF3WalkRight(){

	;Send Right down/up events
	Send {d down}
	Sleep 1000
	Send {d up}	
	Sleep 30
}

;Simulates a 1-second long press of "up" key
FF3WalkUp(){

	;Send Up down/up events
	Send {w down}
	Sleep 1000
	Send {w up}	
	Sleep 30
}

;Simulates a 1-second long press of "down" key
FF3WalkDown(){

	;Send Down down/up events
	Send {s down}
	Sleep 1000
	Send {s up}	
	Sleep 30
}


;Waits for next character to be ready
;Required at end of individual character actions for timing purposes
FF3NextChar(){

	Sleep 600
}

;Inserts extra wait to assist with complex character actions
FF3Wait(){
	Sleep 30
}

;____________________________
;|END OF RAW INPUT FUNCTIONS|
;----------------------------

;______________________________
;|INDIVIDUAL CHARACTER ACTIONS|
;------------------------------

;Simulates keypresses to make a character "Attack"
FF3Attack(){
	
	FF3Select()
	FF3Select()
	FF3NextChar()
}

FF32ndAttack(){
	
	FF3Down()
	FF3Select()
	FF3Select()
	FF3NextChar()
}

;Simulates keypresses to make a character "Guard" (defend)
FF3Defend(){
	
	FF3Down()
	FF3Wait()
	FF3Down()
	FF3Wait()
	FF3Select()
	FF3NextChar()
}

;Simulates keypresses to make character use R. hand weapon as item
FF3UseRightHand(){

	FF3Down()
	FF3Down()
	FF3Down()
	FF3Select()
	FF3Wait()
	FF3Up()
	FF3Select()
	FF3Select()
	FF3NextChar()
}

;Swap rows (front/rear)
FF3SwapRows(){

	FF3Up()
	FF3Select()
	FF3NextChar()
}

;_____________________________________
;|END OF INDIVIDUAL CHARACTER ACTIONS|
;-------------------------------------

;____________________
;|PARTY-WIDE ACTIONS|
;--------------------

;First two attack; third guards; fourth uses right hand item
FF3Custom1(){
	FF3Attack()
	FF3Attack()
	FF3Defend()
	FF3UseRightHand()
}

;All four characters attack
FF3AllAttack(){

	FF3Attack()
	FF3Attack()
	FF3Attack()
	FF3Attack()
}

FF3All2ndAttack(){

	FF32ndAttack()
	FF32ndAttack()
	FF32ndAttack()
	FF32ndAttack()
}

;All four characters Defend
FF3AllDefend(){

	FF3Defend()
	FF3Defend()
	FF3Defend()
	FF3Defend()
}

;All four characters Defend
FF3AllDefend5(){

	Loop 5
	{
		FF3AllDefend()
		Sleep 12000
	}		
}

;Bottom two characters defend
FF3MagesDefend(){

	FF3Attack()
	FF3Attack()
	FF3Defend()
	FF3Defend()
}

;All four characters swap rows (response to back attack)
FF3AllSwapRows(){

	FF3SwapRows()
	FF3SwapRows()
	FF3SwapRows()
	FF3SwapRows()
}

;___________________________
;|END OF PARTY-WIDE ACTIONS|
;---------------------------

;____________________
;|OVERWORLD ACTIONS|
;--------------------

;Wander Overworld (To Find a Random Encounter)
FF3WanderLR(){
	;Walk Loop Cycle
			Loop 8
			{
				Sleep 600
				FF3WalkLeft()
				Sleep 600
				FF3WalkRight()
				Sleep 600
			}				
		}
	return
	
;Wander Overworld (To Find a Random Encounter)
FF3WanderLR2(){
	;Walk Loop Cycle
			Loop
			{
				Sleep 300
				FF3WalkLeft()
				Sleep 300
				FF3WalkRight()
				Sleep 600
			} Until FF3EncounterCheck()				
		}
	return
	
;Wander Overworld (To Find a Random Encounter)	
FF3WanderUD(){
	;Walk Loop Cycle
			Loop 8
			{
				Sleep 600
				FF3WalkUp()
				Sleep 600
				FF3WalkDown()
				Sleep 600
			}				
		}
	return
		
		
;Check for Encounter UI
FF3EncounterCheck(){
	;Check for white pixels in Encounter Menu area
		PixelSearch, Px, Py, 632, 931, 639, 938, 0xfefefe, 1, Fast
			if ErrorLevel
			    return false
			else
			    return true
}

;Check for Exclamation Bubble
FF3ExclamationCheck(){
	;Check for white pixels in Exclamation area above head
		PixelSearch, Px, Py, 1033, 336, 1043, 346, 0xfefefe, 1, Fast
			if ErrorLevel
			    return false
			else
			    return true
}

;Press Confirm ABunch (Usually after battle)
FF3ConfirmAbunch(){
			Loop 12
			{
				FF3Select()
				Sleep 300
			}				
		}
	return
		
;____________________
;|END OF OVERWORLD ACTIONS|
;--------------------

;____________________
;|MENU ACTIONS|
;--------------------
;Opens Item Menu From Overworld
FF3OpenItemMenu(){
	sleep 600
	FF3Menu()
	sleep 2000
	FF3Select()
	sleep 600
		}
	return

;Closes the Item Menu and returns to Overworld
FF3CloseItemMenu(){
	sleep 600
	FF3Cancel()
	sleep 600
	FF3Cancel()
	sleep 600
		}
	return

;Use Slot 1 In Item Menu (Assumes Slot 1 is a Potion)
FF3UsePotion(){
	sleep 600
	FF3Select()
	sleep 600
	FF3Select()
	sleep 600
		}
	return

;Use Slot 2 In Item Menu (Assumes Slot 2 is a Hi-Potion)
FF3UseHiPotion(){
	sleep 600
	FF3Right()
	sleep 600
	FF3Select()
	sleep 600
	FF3Select()
	sleep 600
		}
	return
	
;Use 10 Potions on each Party Member
FF3PotionAll(){
	;Party Sub-Menu is Open. Begin Party Heal.
	;Slot 1
	Loop 3{
			sleep 600
			Loop 10{
				FF3Select()
				sleep 600
				FF3Down()
				}
			}
		Loop 10
		FF3Select()
		sleep 600
	;Party Heal Complete Close Sub-menu
	FF3Cancel()
	sleep 600
		}
	return

;Use 1 Hi-Potion on each Party Member
FF3HiPotionAll(){
	;Party Sub-Menu is Open. Begin Party Heal.
	Loop 3{
			sleep 600
			FF3Select()
			sleep 600
			FF3Down()
			}
		FF3Select()
		sleep 600
	;Party Heal Complete Close Sub-menu
	FF3Cancel()
	sleep 600
		}
	return
	
	
	
;Use 10 Potions on each Party Member (If possible, uses 40 potions)
FF3AutoHealSmall(){
	FF3OpenItemMenu()
	FF3UsePotion()
	FF3PotionAll()
	FF3CloseItemMenu()
		}
	return
	
;Use 1 Hi-Potion on each Party Member
FF3AutoHealHi(){
	FF3OpenItemMenu()
	FF3UseHiPotion()
	FF3HiPotionAll()
	FF3CloseItemMenu()
		}
	return
	
	
	
;____________________
;|END OF MENU ACTIONS|
;--------------------


Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 72 guests