Skip to content

Commit

Permalink
teach cut if possible to bulbasaur line
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 1, 2024
1 parent eb53a5d commit 90422fe
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,26 @@ def run_action_on_emulator(self, action):
self.pyboy.send_input(VALID_ACTIONS[action])
self.pyboy.send_input(VALID_RELEASE_ACTIONS[action], delay=8)
self.pyboy.tick(self.action_freq, render=True)
if self.check_if_party_has_cut():
self.cut_if_next()

if self.read_bit(0xD803, 0):
if not self.check_if_party_has_cut():
self.teach_cut_to_bulba()
self.cut_if_next()
else:
self.cut_if_next()

def teach_cut_to_bulba(self):
# find bulba and replace tackle (first skill) with cut
move_pp_addr = [0xD188, 0xD189, 0xD18A, 0xD18B]
# D164-D169
PARTY_ADDR = [0xD164, 0xD165, 0xD166, 0xD167, 0xD168, 0xD169]
for poke_idx, poke_addr in enumerate(PARTY_ADDR):
poke = self.pyboy.memory[poke_addr]
if poke in [9, 153, 154]: # bulba line
slot = 0 # this should have tackle
self.game.memory[poke_addr + 8 + slot] = 15
self.game.memory[move_pp_addr[slot] + 44 * poke_idx] = 30
# fill up pp: 30/30

def cut_if_next(self):
# https://github.com/pret/pokered/blob/d38cf5281a902b4bd167a46a7c9fd9db436484a7/constants/tileset_constants.asm#L11C8-L11C11
Expand Down

0 comments on commit 90422fe

Please sign in to comment.