• 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!
  • 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.

firered, change starters

  • 1
    Posts
    1
    Days
    • Seen yesterday
    I'm trying to make it so each ball presents one random pokemon out of a pool of the respective type, ie a random water, random grass, and random fire pokemon. I have been able to modify the starter each respective ball gives you in the data/maps/PalletTown_ProfessorOaksLab/scripts.inc file, but I found a spot in src/field_specials.c that specifies starters. I'd prefer to modify that if possible as c is more my strength. I've only successfully done what I intend by changing the script, changing the lines in the field_specials file makes no change at all, i still am presented with only the traditional starters.
    My question is, is there a way to modify the presented starters using the c code?
     
    My question is, is there a way to modify the presented starters using the c code?
    You can do whatever you want with the codebase.
    It contains the entirety of the code and assets that compose the game, so you can do anything you want within the limits of the GBA's hardware.

    The first way that I can think of to go about this is by adding a `special` function that grabs a random Pokémon species' ID and feeds it into the variable used to store the Player's Pokémon's species ID during the event at Oak's Lab, that is the VAR_TEMP_2 as you can see near the top of the scripts.inc file that corresponds to the map of Oak's Lab.
    Most of the special functions related to events in the game's overworld are added in src/field_specials.c, the file you mentioned. I'd just throw my function/s in there too.

    Here's a quick implementation as an example:
    Diff:
    diff --git a/data/maps/PalletTown_ProfessorOaksLab/scripts.inc b/data/maps/PalletTown_ProfessorOaksLab/scripts.inc
    index c23534df8..2a8f9bda2 100644
    --- a/data/maps/PalletTown_ProfessorOaksLab/scripts.inc
    +++ b/data/maps/PalletTown_ProfessorOaksLab/scripts.inc
    @@ -1078,7 +1078,7 @@ PalletTown_ProfessorOaksLab_EventScript_BulbasaurBall::
         lock
         faceplayer
         setvar PLAYER_STARTER_NUM, 0
    -    setvar PLAYER_STARTER_SPECIES, SPECIES_BULBASAUR
    +    special RandomGrassStarter
         setvar RIVAL_STARTER_SPECIES, SPECIES_CHARMANDER
         setvar RIVAL_STARTER_ID, LOCALID_CHARMANDER_BALL
         goto_if_ge VAR_MAP_SCENE_PALLET_TOWN_PROFESSOR_OAKS_LAB, 3, PalletTown_ProfessorOaksLab_EventScript_LastPokeBall
    @@ -1221,7 +1221,7 @@ PalletTown_ProfessorOaksLab_EventScript_SquirtleBall::
         lock
         faceplayer
         setvar PLAYER_STARTER_NUM, 1
    -    setvar PLAYER_STARTER_SPECIES, SPECIES_SQUIRTLE
    +    special RandomWaterStarter
         setvar RIVAL_STARTER_SPECIES, SPECIES_BULBASAUR
         setvar RIVAL_STARTER_ID, LOCALID_BULBASAUR_BALL
         goto_if_ge VAR_MAP_SCENE_PALLET_TOWN_PROFESSOR_OAKS_LAB, 3, PalletTown_ProfessorOaksLab_EventScript_LastPokeBall
    @@ -1234,7 +1234,7 @@ PalletTown_ProfessorOaksLab_EventScript_CharmanderBall::
         lock
         faceplayer
         setvar PLAYER_STARTER_NUM, 2
    -    setvar PLAYER_STARTER_SPECIES, SPECIES_CHARMANDER
    +    special RandomFireStarter
         setvar RIVAL_STARTER_SPECIES, SPECIES_SQUIRTLE
         setvar RIVAL_STARTER_ID, LOCALID_SQUIRTLE_BALL
         goto_if_ge VAR_MAP_SCENE_PALLET_TOWN_PROFESSOR_OAKS_LAB, 3, PalletTown_ProfessorOaksLab_EventScript_LastPokeBall
    diff --git a/data/specials.inc b/data/specials.inc
    index d880bf6b9..4ffddc50c 100644
    --- a/data/specials.inc
    +++ b/data/specials.inc
    @@ -452,4 +452,7 @@ gSpecials::
         def_special UpdateLoreleiDollCollection
         def_special LoopWingFlapSound
         def_special CreateEnemyEventMon
    +    def_special RandomGrassStarter
    +    def_special RandomWaterStarter
    +    def_special RandomFireStarter
     gSpecialsEnd::
    diff --git a/src/field_specials.c b/src/field_specials.c
    index d7dbb6f81..a1d3bc1a7 100644
    --- a/src/field_specials.c
    +++ b/src/field_specials.c
    @@ -2553,3 +2553,21 @@ static void Task_WingFlapSound(u8 taskId)
         if (data[0] == gSpecialVar_0x8004 - 1)
             DestroyTask(taskId);
     }
    +
    +void RandomGrassStarter(void)
    +{
    +    static const u16 sRandomSpecies[] = { SPECIES_BULBASAUR, SPECIES_ODDISH, SPECIES_BELLSPROUT, SPECIES_EXEGGCUTE, SPECIES_TANGELA };
    +    VarSet(VAR_TEMP_2, sRandomSpecies[Random() % ARRAY_COUNT(sRandomSpecies)]);
    +}
    +
    +void RandomWaterStarter(void)
    +{
    +    static const u16 sRandomSpecies[] = { SPECIES_CHARMANDER, SPECIES_VULPIX, SPECIES_GROWLITHE, SPECIES_PONYTA, SPECIES_MAGMAR };
    +    VarSet(VAR_TEMP_2, sRandomSpecies[Random() % ARRAY_COUNT(sRandomSpecies)]);
    +}
    +
    +void RandomFireStarter(void)
    +{
    +    static const u16 sRandomSpecies[] = { SPECIES_SQUIRTLE, SPECIES_PSYDUCK, SPECIES_POLIWAG, SPECIES_TENTACOOL, SPECIES_SLOWPOKE };
    +    VarSet(VAR_TEMP_2, sRandomSpecies[Random() % ARRAY_COUNT(sRandomSpecies)]);
    +}

    [PokeCommunity.com] firered, change starters

    Things to consider:
    -You can use bufferspeciesname to store a species' name in one of 3 text buffers. Use that knowledge to update the strings for Oak's Lab's map that use hardcoded species names.
    -Rather than generating a random species on the spot, you'll probably want to do it at some point before the Player accesses the event.
    -Keep in mind, if you decide to stick to a temporary var like VAR_TEMP_2, that those reset when you move between maps or warp around.
     
    Back
    Top