Page 1 of 1

Need Help writing code for pokemon(simple pseudocode)

Posted: 30 Jan 2020, 20:58
by calibur26
Hi, I just wanted to make a simple battling macro (in ahk) for pokemon, so far i have

Code: Select all

#SingleInstance,Force
CoordMode,Pixel,Screen
CoordMode,Mouse,Screen

^z::
    IfWinActive, ahk_class 
	
	Stop=0
	While Stop=0
	{
	  Send {w down}
	  Sleep 3000
	  Send {w up}
	  Send {a down}
	  Sleep 3000
	  Send {a up}
	  Send {s down}
	  Sleep 3000
	  Send {s up}
	  Send {d down}
	  Sleep 3000
	  Send {d up}
	  
	  PixelSearch,ax,ay,0,0,700,700,000000,0,RGB Fast
	  if !ErrorLevel
	   {
	    Sleep 5000
	    Send {f 20}
	   }
	
	
	return
	
	
^a::ExitApp
[Mod edit: [code][/code] tags added.]


I want it to walk in a square/rectangle and when it detects a black screen it presses f 20 times, I want the whole thing to keep looping until I manually stop it. I just dont know how to make it check if theres a black screen all the time.
also how would i add ifwinactive in this so it only runs on my emulator
Thanks for the help

Re: Need Help writing code for pokemon(simple pseudocode)

Posted: 30 Jan 2020, 23:06
by w0z

Code: Select all

; replace "ahk_exe EXCEL.EXE"  with your desire window Class or WinTitle, you can get it with tool "Window Spy" that comes with AutoHotkey
#IfWinActive ahk_exe EXCEL.EXE 
^z::
	CoordMode,Pixel,Relative
	
	bol := 1
	While bol
	{
	  Send {w down}
	  Sleep 3000
	  Send {w up}
	  Send {a down}
	  Sleep 3000
	  Send {a up}
	  Send {s down}
	  Sleep 3000
	  Send {s up}
	  Send {d down}
	  Sleep 3000
	  Send {d up}
	  
	  PixelSearch,ax,ay,0,0,700,700,000000,0,Fast RGB
	  if !ErrorLevel
	  {
	    Sleep 5000
	    Send {f 20}
	  }
	  Sleep, 500
	}
	
return
	
^q::
	bol:=0	;stop the loop because   0 = false
	if bol=0
		MsgBox, the loop will stop after PixelSearch!. %bol%
	else
		MsgBox, Nope loop is running.
Return

^a::ExitApp

#IfWinActive
You have to find a unique color that is particular in the game to work with PixelSearch.
or you could use ImageSearch instead.

Re: Need Help writing code for pokemon(simple pseudocode)

Posted: 30 Jan 2020, 23:48
by calibur26
Thanks for the reply!
I'm on discord if you have that:Saintv#1387
I used Window spy and it shows the colour as black(000000) is it fine to just put that? or would i have to learn how to do pixelsearch
what the code does now:it moves in a square,checks if there is a black screen,moves in a square.Until i hit q and then it stops?
How do I make it constantly check if a black screen is coming up(while im pressing w i might enter a battle, so i want it to pixelsearch every time i send a movement command)

Re: Need Help writing code for pokemon(simple pseudocode)

Posted: 31 Jan 2020, 04:32
by Sid4G
Holly shit, I am appaled at myself that I understood the exact principle of your pseudo code in a second or two xD
Going to farm some wild pokemon? :DD
Btw for me it would be no problem to make such routine.

Re: Need Help writing code for pokemon(simple pseudocode)

Posted: 31 Jan 2020, 05:30
by gregster
Sid4G wrote:
31 Jan 2020, 04:32
Holly shit, I am appaled at myself that I understood the exact principle of your pseudo code in a second or two xD
Going to farm some wild pokemon? :DD
Btw for me it would be no problem to make such routine.
Well, then feel free to contribute in the forum in a constructive way and please refrain from making mocking comments.

Re: Need Help writing code for pokemon(simple pseudocode)

Posted: 31 Jan 2020, 14:49
by calibur26
I dont mind being mocked but if you know how to do this would it hurt to show me how?

Re: Need Help writing code for pokemon(simple pseudocode)

Posted: 01 Feb 2020, 05:53
by Tcharr
I believe you might find the code you need in this thread-> https://www.autohotkey.com/boards/viewtopic.php?f=18&t=14665