From e5d05a44fee22c3bf677a4c5e8f2c3d757156e1e Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Sun, 9 Jun 2024 01:28:21 -0400 Subject: [PATCH] Fix autorepel --- config.yaml | 2 +- pokemonred_puffer/environment.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/config.yaml b/config.yaml index 1a2e7f8..a83d8f3 100644 --- a/config.yaml +++ b/config.yaml @@ -7,7 +7,7 @@ debug: env: headless: False stream_wrapper: False - init_state: cut + init_state: Bulbasaur max_steps: 1_000_000 disable_wild_encounters: True disable_ai_actions: True diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index e5cc79d..0cd2edf 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -601,9 +601,11 @@ def register_hooks(self): # self.pyboy.hook_register(None, "UsedCut.nothingToCut", self.cut_hook, context=True) # self.pyboy.hook_register(None, "UsedCut.canCut", self.cut_hook, context=False) if self.disable_wild_encounters: + print("registering") + bank, addr = self.pyboy.symbol_lookup("TryDoWildEncounter.gotWildEncounterType") self.pyboy.hook_register( - None, - "TryDoWildEncounter.gotWildEncounterType", + bank, + addr + 8, self.disable_wild_encounter_hook, None, ) @@ -884,9 +886,6 @@ def step(self, action): if self.save_video and self.step_count == 0: self.start_video() - if self.disable_wild_encounters: - self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = 100 - _, wMapPalOffset = self.pyboy.symbol_lookup("wMapPalOffset") if self.auto_flash and self.pyboy.memory[wMapPalOffset] == 6: self.pyboy.memory[wMapPalOffset] = 0 @@ -1131,8 +1130,8 @@ def cut_hook(self, context): self.cut_tiles[wTileInFrontOfPlayer] = 1 def disable_wild_encounter_hook(self, *args, **kwargs): - self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = 100 - self.pyboy.memory[self.pyboy.symbol_lookup("wCurEnemyLVL")[1] + 1] = 1 + self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = 0xFFFF + self.pyboy.memory[self.pyboy.symbol_lookup("wCurEnemyLVL")[1]] = 1 def agent_stats(self, action): levels = [self.read_m(f"wPartyMon{i+1}Level") for i in range(self.read_m("wPartyCount"))]