- 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:
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();
}