diff --git a/scripts/gen_iii_tutors.py b/scripts/gen_iii_tutors.py new file mode 100644 index 0000000..07c69ac --- /dev/null +++ b/scripts/gen_iii_tutors.py @@ -0,0 +1,86 @@ +from struct import Struct +from sys import argv + +max_pokemon = 411 # Gen III indices are a Gen-I-esque mess past Celebi + +# I got the first fifteen from FR by looking at tutor NPCs' scripts. I got the +# full list from Emerald by searching for the first fifteen; the list starts at +# 0x61500C. +moves = ['mega-punch', 'swords-dance', 'mega-kick', 'body-slam', 'double-edge', + 'counter', 'seismic-toss', 'mimic', 'metronome', 'softboiled', + 'dream-eater', 'thunder-wave', 'explosion', 'rock-slide', 'substitute', + + # Emerald only + 'dynamicpunch', 'rollout', 'psych-up', 'snore', 'icy-wind', 'endure', + 'mud-slap', 'ice-punch', 'swagger', 'sleep-talk', 'swift', 'defense-curl', + 'thunderpunch', 'fire-punch', 'fury-cutter'] + +query_template = """ +insert into pokemon_moves (pokemon_id, version_group_id, move_id, + pokemon_move_method_id, level, "order") values ( + (select pokemon_id from pokemon_game_indices where version_id={version} + and game_index={game_index}), + {version_group}, + (select id from moves where identifier='{move}'), + 3, 0, null +); +""" + +version_constants = { + 'POKEMON FIRE': { + 'version_id': 10, + 'version_group_id': 7, + 'offset': 0x459B80, + 'moves': 15 + }, + + 'POKEMON LEAF': { + 'version_id': 11, + 'version_group_id': 7, + 'offset': 0x4595A0, + 'moves': 15 + }, + + 'POKEMON EMER': { + 'version_id': 9, + 'version_group_id': 6, + 'offset': 0x61504C, + 'moves': 30 + } +} + +with open(argv[1], 'rb') as rom: + rom.seek(0xA0) + version = rom.read(12).decode('ASCII') + stuff = version_constants[version] + + # Flags go from least significant bit to most significant, and then to the + # next byte, just like TMs, but there are few enough of them that we can + # treat the whole field as a little-endian int. + if stuff['moves'] == 15: + flag_struct = Struct('>= 1