diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-11-03 01:41:07 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-11-03 01:41:07 -0500 |
commit | a4179b5337ef767d215185d65a0f7af0f4cd4dbd (patch) | |
tree | 2211526f66b05f2ab3a6c4b74479d31cc661931f | |
parent | a9a9568d142b81d07a6aa37721fe29ebbbb898ee (diff) |
attempting a few more trainer battles
-rw-r--r-- | pokemontools/vba/vba.py | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index a64a75a..05d4fad 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -581,7 +581,7 @@ class crystal(object): hp = ((self.vba.memory[0xd218] << 8) | self.vba.memory[0xd217]) return hp - def start_trainer_battle(self, map_group=0x1, map_id=0xc, x=6, y=8, direction="l", loop_limit=10): + def start_trainer_battle_lamely(self, map_group=0x1, map_id=0xc, x=6, y=8, direction="l", loop_limit=10): """ Starts a trainer battle by warping into a map at the designated coordinates, pressing the direction button for a full walk step (which @@ -614,36 +614,61 @@ class crystal(object): self.registers["pc"] = address % 0x4000 self.call(address / 0x4000, address % 0x4000) - def broken_start_battle(self): - # go to a map with wildmons - self.warp(0x1, 0xc, 6, 8) - self.nstep(200) + def start_trainer_battle(self, trainer_group=0x1, trainer_id=0x1): + """ + This will fail after the first mon is defeated. + """ + Script_startbattle_address = 0x97436 + # setup the battle memory = self.vba.memory + memory[0xd459] = 0x81 + memory[0xd22f] = trainer_group + memory[0xd231] = trainer_id + self.vba.memory = memory - Script_startbattle_address = 0x97436 + self.call(0x25, (Script_startbattle_address % 0x4000) + 0x4000) + + def broken_start_random_battle_by_rocksmash_battle_script(self): + """ + This doesn't start a battle. + """ CallScript_address = 0x261f RockSmashBattleScript_address = 0x97cf9 - RockSmashEncounter_address = 0x97cc0 - StartBattle_address = 0x3f4c1 ScriptRunning = 0xd438 ScriptBank = 0xd439 ScriptPos = 0xd43a - start_wild_battle = 0x3f4dd - script = 0x1a1dc6 - # setup the battle - #memory[0xd459] = 0x81 - #memory[0xd22f] = trainer_group - #memory[0xd231] = trainer_id + memory = self.vba.memory + memory[ScriptBank] = RockSmashBattleScript_address / 0x4000 + memory[ScriptPos] = ((RockSmashBattleScript_address % 0x4000 + 0x4000) & 0xff00) >> 8 + memory[ScriptPos+1] = ((RockSmashBattleScript_address % 0x4000 + 0x4000) & 0xff) + memory[ScriptRunning] = 0xff + self.vba.memory = memory - #self.vba.memory = memory + self.vba.registers["af"] = ((RockSmashBattleScript_address / 0x4000) << 8) | (self.vba.registers.af & 0xff) + self.vba.registers["hl"] = (RockSmashBattleScript_address % 0x4000) + 0x4000 + self.call(0x0, CallScript_address) - #self.call(0x25, Script_startbattle_address % 0x4000) + #def attempt_start_battle_by_startbattle(self): + # StartBattle_address = 0x3f4c1 + # self.call(StartBattle_address / 0x4000, (StartBattle_address % 0x4000) + 0x4000) - #self.vba.registers["af"] = ((RockSmashBattleScript_address / 0x4000) << 8) | (self.vba.registers.af & 0xff) - #self.vba.registers["hl"] = RockSmashBattleScript_address % 0x4000 - #self.call(0x0, CallScript_address) + #def attempt_start_random_battle_by_wild_battle(self): + # start_wild_battle = 0x3f4dd + # #self.call(start_wild_battle / 0x4000, start_wild_battle % 0x4000) + # #self.vba.registers["pc"] = ... + + def old_crap(self): + CallScript_address = 0x261f + RockSmashBattleScript_address = 0x97cf9 + RockSmashEncounter_address = 0x97cc0 + StartBattle_address = 0x3f4c1 + ScriptRunning = 0xd438 + ScriptBank = 0xd439 + ScriptPos = 0xd43a + start_wild_battle = 0x3f4dd + script = 0x1a1dc6 #self.call(StartBattle_address / 0x4000, StartBattle_address % 0x4000) #self.call(RockSmashEncounter_address / 0x4000, RockSmashEncounter_address % 0x4000) |