Need Help writing code for pokemon(simple pseudocode)

Ask gaming related questions (AHK v1.1 and older)
calibur26
Posts: 3
Joined: 30 Jan 2020, 20:49

Need Help writing code for pokemon(simple pseudocode)

30 Jan 2020, 20:58

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
w0z
Posts: 230
Joined: 19 Jun 2014, 08:21

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

30 Jan 2020, 23:06

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.
If I was helpful consider Donate me. :beer: , plz :D
calibur26
Posts: 3
Joined: 30 Jan 2020, 20:49

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

30 Jan 2020, 23:48

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)
Sid4G
Posts: 48
Joined: 02 Apr 2016, 19:11

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

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.
gregster
Posts: 9000
Joined: 30 Sep 2013, 06:48

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

31 Jan 2020, 05:30

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.
calibur26
Posts: 3
Joined: 30 Jan 2020, 20:49

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

31 Jan 2020, 14:49

I dont mind being mocked but if you know how to do this would it hurt to show me how?

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 60 guests