From 112f088f17e96700b64e1e1d175b54c3f1f3b859 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 18 May 2012 21:53:17 -0500 Subject: find last trainer id in each trainer group original-commit-id: 2d4d6399db87b34b81be02cb610d7176515a790b --- crystal.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'crystal.py') diff --git a/crystal.py b/crystal.py index dca98f6..491be4e 100644 --- a/crystal.py +++ b/crystal.py @@ -3432,6 +3432,40 @@ class TrainerFragmentParam(PointerLabelParam): self.dependencies = deps return deps +def find_trainer_ids_from_scripts(): + """ Looks through all scripts to find trainer group numbers and trainer numbers. + + This can be used with trainer_group_maximums to figure out the current number of + trainers in each of the originating trainer groups. + """ + + # look at each possibly relevant script + for item in script_parse_table.items(): + object = item[1] + if isinstance(object, Script): + check_script_has_trainer_data(object) + +def check_script_has_trainer_data(script): + """ see find_trainer_ids_from_scripts + """ + for command in script.commands: + trainer_group = None + trainer_id = None + + if command.id == 0x43: + trainer_group = command.params[1].byte + trainer_id = command.params[0].byte + elif command.id == 0x5E: + trainer_group = command.params[0].byte + trainer_id = command.params[1].byte + + if trainer_group != None and trainer_id != None: + if trainer_group in trainer_group_maximums.keys(): + if trainer_id > trainer_group_maximums[trainer_group]: + trainer_group_maximums[trainer_group] = trainer_id + else: + trainer_group_maximums[trainer_group] = trainer_id + class PeopleEvent(Command): size = people_event_byte_size macro_name = "person_event" -- cgit v1.2.3