From d1da18652d96212c05be10a9dfb22bc02071f84e Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 10 Nov 2013 17:53:06 -0600 Subject: make givepoke work (h/t padz) --- pokemontools/vba/vba.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'pokemontools/vba/vba.py') diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index 62c16da..9d2be23 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -871,7 +871,7 @@ class crystal(object): self.vba.memory = memory - def givepoke(self, pokemon_id, level, nickname): + def givepoke(self, pokemon_id, level, nickname=None): """ Give the player a pokemon. """ @@ -899,9 +899,12 @@ class crystal(object): 0x91, # end ] + # picked this region of wram because it looks like it's probably unused + # in situations where givepoke will work. #address = 0xd073 #address = 0xc000 - address = 0xd8f1 + #address = 0xd8f1 + address = 0xd280 mem = list(self.vba.memory) backup_wram = mem[address : address + len(script)] @@ -928,8 +931,11 @@ class crystal(object): self.vba.press("a", hold=5, after=50) else: # no nickname - self.vba.press("d", hold=10, after=20) - self.vba.press("a", hold=5, after=30) + self.vba.press("b", hold=10, after=20) + + # Wait for the script to end in the engine before copying the original + # wram values back in. + self.vba.step(count=100) # reset whatever was in wram before this script was called mem = list(self.vba.memory) -- cgit v1.2.3