• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Maximum number of trainers in Pokeemerald

23
Posts
6
Years
    • Seen Nov 28, 2023
    Hi all,

    does anyone know whether there is a hard-coded limit for the number of trainers one can include in Pokeemerald? I've been adding new trainers and trainer parties without problems to a total number of 864 (#define TRAINERS_COUNT 864) compared to 855 in default Emerald. However, I can't seem to make any new trainer battle work after hitting this magic number. Upon interaction, the NPCs say their default message as if the battle was already complete although it never happened. I've been trying to understand the gTrainers structure but nothing seems to hint that it should have a limit in size (as far as I understand). As for compilation, make runs without warnings or other issues.

    If anyone has a better understanding of this issue, I would be very grateful for your insights!
     
    1,591
    Posts
    10
    Years
    • Seen Mar 20, 2024
    Hi all,

    does anyone know whether there is a hard-coded limit for the number of trainers one can include in Pokeemerald? I've been adding new trainers and trainer parties without problems to a total number of 864 (#define TRAINERS_COUNT 864) compared to 855 in default Emerald. However, I can't seem to make any new trainer battle work after hitting this magic number. Upon interaction, the NPCs say their default message as if the battle was already complete although it never happened. I've been trying to understand the gTrainers structure but nothing seems to hint that it should have a limit in size (as far as I understand). As for compilation, make runs without warnings or other issues.

    If anyone has a better understanding of this issue, I would be very grateful for your insights!

    Hey, there's no set limit anywhere, but each normal trainer needs a flag in the save file to work.

    If the trainers are acting like they've already been battled, you probably need more trainer flags. All the flags are defined in include/constants/flags.h. Plenty of them are unused, so you could shuffle them around a bit to make the block of trainer flags bigger, or add a second block of them and figure out how to get the game to access them.
     
    23
    Posts
    6
    Years
    • Seen Nov 28, 2023
    Hey, there's no set limit anywhere, but each normal trainer needs a flag in the save file to work.

    If the trainers are acting like they've already been battled, you probably need more trainer flags. All the flags are defined in include/constants/flags.h. Plenty of them are unused, so you could shuffle them around a bit to make the block of trainer flags bigger, or add a second block of them and figure out how to get the game to access them.

    Hi, thanks for your reply. I'll try to check out the flags. Thank you very much for the advice!
     
    23
    Posts
    6
    Years
    • Seen Nov 28, 2023
    Hey, there's no set limit anywhere, but each normal trainer needs a flag in the save file to work.

    If the trainers are acting like they've already been battled, you probably need more trainer flags. All the flags are defined in include/constants/flags.h. Plenty of them are unused, so you could shuffle them around a bit to make the block of trainer flags bigger, or add a second block of them and figure out how to get the game to access them.

    Hi again,
    I tried increasing TRAINERS_FLAG_NO from 0x356 to 0x3E8 (dec 1000), but it messed up some things. I started a new game just to be sure, and the sprites for Birch's intro Pokémon and starters in the bag selection screen were shiny. Also, after receiving the starter, the Pokémon menu was still not accessible, so I guess that increasing the flags allocated to trainers interferes with the system flags. I don't know why because SYSTEM_FLAGS is defined relative to the offset of trainer flag start and the number of trainer flags. Would you think that this could be related to the sizes of different memory sections?
     
    1,591
    Posts
    10
    Years
    • Seen Mar 20, 2024
    Hi again,
    I tried increasing TRAINERS_FLAG_NO from 0x356 to 0x3E8 (dec 1000), but it messed up some things. I started a new game just to be sure, and the sprites for Birch's intro Pokémon and starters in the bag selection screen were shiny. Also, after receiving the starter, the Pokémon menu was still not accessible, so I guess that increasing the flags allocated to trainers interferes with the system flags. I don't know why because SYSTEM_FLAGS is defined relative to the offset of trainer flag start and the number of trainer flags. Would you think that this could be related to the sizes of different memory sections?
    I don't know why that would be happening; I've only ever seen that caused by changing the shiny rate. It's possible there's more to adding new flags than just defining new ones, but I haven't tried to do that yet so I can't say for sure.

    You could try removing some unused flags and renumbering all the following ones to make room for more trainer flags, but that's a lot of work and very tedious.
     
    23
    Posts
    6
    Years
    • Seen Nov 28, 2023
    I don't know why that would be happening; I've only ever seen that caused by changing the shiny rate. It's possible there's more to adding new flags than just defining new ones, but I haven't tried to do that yet so I can't say for sure.

    You could try removing some unused flags and renumbering all the following ones to make room for more trainer flags, but that's a lot of work and very tedious.

    Thanks for your insight. I will probably shuffle the unused flags and see if I can use some of them for trainers. Fortunately I can lessen the workload with Python. Again, thank you so much for your help!
     
    1,591
    Posts
    10
    Years
    • Seen Mar 20, 2024
    Thanks for your insight. I will probably shuffle the unused flags and see if I can use some of them for trainers. Fortunately I can lessen the workload with Python. Again, thank you so much for your help!
    You're welcome! Good luck with this, hope you get it working!
     
    Back
    Top