• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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.

[pokeemerald-expansion] Custom special causes loop after Trainer Battle

  • 1
    Posts
    157
    Days
    • Seen yesterday
    I am trying to randomize a trainer's party using a custom special before a normal trainer battle.
    However, when I call the special and then start the trainer battle, it causes an infinite loop, and I cannot use release or releaseall properly after the battle.
    If anyone knows how to solve this issue, please let me know.

    Development environment:
    pokeemerald-expansion latest ver 1.10

    Here is my current script:
    // .inc script
    Route102_Test::
    special SetRandomTrainerParty // custom special
    goto Route102_Test2
    end

    Route102_EventScript_Calvin::
    goto Route102_Test

    Route102_Test2::
    trainerbattle_single TRAINER_RANDOMIZER, Route102_Text_CalvinIntro, Route102_Text_CalvinDefeated
    msgbox Route102_Text_RickPostBattle, MSGBOX_AUTOCLOSE
    releaseall
    end
    // random_team.c

    #define RANDOM_TEAM_SIZE 3
    static const u16 sRandomSpeciesList[] = {
    SPECIES_BULBASAUR,
    SPECIES_CHARMANDER,
    SPECIES_SQUIRTLE,
    SPECIES_PIKACHU,
    SPECIES_EEVEE,
    SPECIES_JIGGLYPUFF
    };


    void Special_UserSpecial0(void)
    {
    MgbaPrintf(MGBA_LOG_WARN, "My value: %u", 10);
    u8 i;
    u8 speciesCount = ARRAY_COUNT(sRandomSpeciesList);

    for (i = 0; i < RANDOM_TEAM_SIZE; i++)
    {
    u16 species = sRandomSpeciesList[Random() % speciesCount];
    u8 level = 10 + (Random() % 10); // Random level between 10 and 19

    // Create Pokémon directly into gEnemyParty
    CreateMon(&gEnemyParty, species, level, 32, FALSE, 0, OT_ID_PLAYER_ID, 0);

    // If needed, moves could be randomized here manually
    }
    }

    void SetRandomTrainerParty(void)
    {
    Special_UserSpecial0();
    }
     
    Back
    Top