From 9fe4eacd7da946e413c1f5de1ae83a7591fe4cc1 Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Thu, 22 Aug 2024 06:48:33 -0600 Subject: [PATCH] Fix set events and missables --- pokemonred_puffer/data/events.py | 3 ++- pokemonred_puffer/data/missable_objects.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pokemonred_puffer/data/events.py b/pokemonred_puffer/data/events.py index a0c7fa2..9a4c4a8 100644 --- a/pokemonred_puffer/data/events.py +++ b/pokemonred_puffer/data/events.py @@ -2594,8 +2594,9 @@ def set_event(self, event_name: str, value: bool): idx = [x[0] for x in self.b._fields_].index(event_name) addr = EVENT_FLAGS_START + idx // 8 bit = idx % 8 + mask = int(value) << bit - self.emu.memory[addr] = self.emu.memory[addr] & int(value) << bit + self.emu.memory[addr] = (self.emu.memory[addr] & ~mask) | mask setattr(self.b, event_name, int(value)) diff --git a/pokemonred_puffer/data/missable_objects.py b/pokemonred_puffer/data/missable_objects.py index 5f5a157..ef99a9f 100644 --- a/pokemonred_puffer/data/missable_objects.py +++ b/pokemonred_puffer/data/missable_objects.py @@ -254,6 +254,7 @@ def set_missable(self, missable: str, value: bool): idx = [x[0] for x in self.b._fields_].index(missable) addr = 0xD5A6 + idx // 8 bit = idx % 8 + mask = int(value) << bit - self.emu.memory[addr] = self.emu.memory[addr] & int(value) << bit + self.emu.memory[addr] = (self.emu.memory[addr] & ~mask) | mask setattr(self.b, missable, int(value))