-
Notifications
You must be signed in to change notification settings - Fork 829
Improve the trainer rematch system
This tutorial aims to remove the fight count check that the trainer rematch system performs before selecting a 'rematchable' trainer's party. First, I think it useful to provide a brief primer on the party selection component of the rematch system, what exactly we will change, and why this is desirable.
Before a rematch, the Pokemon Crystal rematch system performs two checks: it initially looks in memory for a count that is based on which of the rematchable trainer's parties you have last defeated, then it checks whether you have reached a certain point in the game. Upon first defeating a rematchable trainer, a count of 1 will be stored in memory, followed by a count of 2 once you defeat the first rematch party, etc. However, the first rematch party will not load unless you have also reached a certain point in the game, determined by either a location (flypoint check) or an event being cleared (event flag check).
In this tutorial, we will use Schoolboy Alan on Route 36 as an example. In order to rematch him a second time, you must have defeated him in the first rematch battle (storing a count of 2) in addition to having reached Blackthorn. Say that you never received a call from him by the time you have reached Blackthorn (a common scenario), so you never defeated him in a rematch. This means that, since you cannot load the required count (2), it does not matter whether you have reached Blackthorn or not; you must fight Alan's first rematch party, which will likely be thoroughly underleveled relative to your party.
We will resolve this by removing the fight count check entirely, thus checking only for the player's game progress in determining the rematch party that will be loaded. This will allow for rematch trainers to be much closer to the player's level even if they have not been defeated in a rematch before. Despite the impression perhaps left by my lengthy preamble, this is actually very simple to do.
The code to be changed is in the map file where the trainer is located - Route 36 in our case - so open and edit maps/Route36.asm:
.ChooseRematch:
scall .Rematch
winlosstext SchoolboyAlan1BeatenText, 0
- readmem wAlanFightCount
- ifequal 4, .Fight4
- ifequal 3, .Fight3
- ifequal 2, .Fight2
- ifequal 1, .Fight1
- ifequal 0, .LoadFight0
-.Fight4:
checkevent EVENT_RESTORED_POWER_TO_KANTO
iftrue .LoadFight4
-.Fight3:
checkevent EVENT_BEAT_ELITE_FOUR
iftrue .LoadFight3
-.Fight2:
checkflag ENGINE_FLYPOINT_BLACKTHORN
iftrue .LoadFight2
-.Fight1:
checkflag ENGINE_FLYPOINT_OLIVINE
iftrue .LoadFight1
-.LoadFight0:
loadtrainer SCHOOLBOY, ALAN1
startbattle
reloadmapafterbattle
loadmem wAlanFightCount, 1
clearflag ENGINE_ALAN_READY_FOR_REMATCH
end
And done! You will need to edit the equivalent code in each map file for every trainer that you want to have ignore the fight count check. This is technically all that is required to make the change, although you may want to clean up the code by removing the "loadmem wAlanFightCount" line in the edited code as well as from each ".LoadFight" just below it, since they are now useless.
The events that are checked in order to determine which party to load can be easily modified by swapping a checkflag _____ or checkevent ______ with any other listed in either the flypoints or event_flags asm files. This is especially useful if you wish to add rematch parties or simply upgrade rematch parties more frequently, progression-wise.
Also, when modifying rematch parties, keep in mind that not all of them correspond to the map file code as neatly as they do for Schoolboy Alan, where ALAN1 is loaded for the initial fight, ALAN2 for the first rematch, ALAN3 for the second rematch, etc. For example, some will load TRAINERNAME3 for the initial fight, so you must make sure that you enter the initial party data (in trainers/parties.asm) in the field for the given trainer's third party; generally, TRAINERNAME3 will correspond to the third field for a given trainer starting from the top of the parties file. The exact trainer that is loaded is indicated below each .Loadfight__ (directly below the code we edited), for example: "loadtrainer SCHOOLBOY, ALAN2".
Finally, for a list of rematchable trainers to help you find and change all of their codes, see the third header (Phone) on this page: https://www.serebii.net/crystal/pokegear.shtml