Skip to content

Commit

Permalink
infinite safari zone
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Dec 5, 2024
1 parent b994d19 commit 81136cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ env:
auto_pokeflute: True
auto_next_elevator_floor: True
skip_safari_zone: False
infinite_safari_steps: True
insert_saffron_guard_drinks: True
infinite_money: True
use_global_map: False
Expand Down
17 changes: 17 additions & 0 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def __init__(self, env_config: DictConfig):
self.auto_pokeflute = env_config.auto_pokeflute
self.auto_next_elevator_floor = env_config.auto_next_elevator_floor
self.skip_safari_zone = env_config.skip_safari_zone
self.infinte_safari_steps = env_config.infinite_safari_steps
self.insert_saffron_guard_drinks = env_config.insert_saffron_guard_drinks
self.infinite_money = env_config.infinite_money
self.use_global_map = env_config.use_global_map
Expand Down Expand Up @@ -683,6 +684,9 @@ def step(self, action):
):
self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = 0xFF

if self.infinte_safari_steps:
self.update_safari_steps()

self.check_num_bag_items()

# update the a press before we use it so we dont trigger the font loaded early return
Expand Down Expand Up @@ -1683,6 +1687,19 @@ def remove_all_nonuseful_items(self):
self.pyboy.memory[wBagSavedMenuItem] = 0
self.pyboy.memory[wListScrollOffset] = 0

def update_safari_steps(self):
curMapId = MapIds(self.read_m("wCurMap"))
if curMapId in {
MapIds.SAFARI_ZONE_CENTER,
MapIds.SAFARI_ZONE_EAST,
MapIds.SAFARI_ZONE_WEST,
MapIds.SAFARI_ZONE_NORTH,
}:
_, wSafariSteps = self.pyboy.symbol_lookup("wSafariSteps")
# lazily set safari steps to 256. I dont want to do the math for 512
self.pyboy.memory[wSafariSteps] = 0
self.pyboy.memory[wSafariSteps + 1] = 0xFF

def read_hp_fraction(self):
party_size = self.read_m("wPartyCount")
hp_sum = sum(self.read_short(f"wPartyMon{i+1}HP") for i in range(party_size))
Expand Down

0 comments on commit 81136cd

Please sign in to comment.