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.
I was wondering if it would be possible to create a script that can be used to change the rival's name in game, similar to FireRed. I know something similar has been done for the player's name. I know you can change the rival's name by changing it in the files, but I was hoping there was some way to let the player name the rival in the game.
Emerald doesn't have a changeable rival name. The naming screen setup which in FireRed lets you rename the rival was repurposed for Walda. You'd need to add the rival name to one of the save blocks (FireRed uses save block 1) and extend the naming screen code.
This code allows you to create a naming screen to give a name to your rival. Right now, even though I've given text to be displayed on the naming screen (like "YOUR NAME?", which is used in the player naming screen), no text appears at all. That's just an aesthetic issue, since the rival's name is assigned just fine.
In data/specials.inc:
Spoiler:
Add this at the end:
Code:
def_special RivalNameChange
This just allows you to access the RivalNameChange function from naming_screen.c in a script.
In src/strings.c:
Spoiler:
Add this at the end:
Code:
const u8 gText_RivalName[] = _("What's her name?");
This is the text that SHOULD be appearing when the naming screen appears, but doesn't.
In include/global.h:
Spoiler:
Code:
struct SaveBlock2
{
/*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
u8 rivalName[PLAYER_NAME_LENGTH + 1];
/*0x08*/ u8 playerGender; // MALE, FEMALE
/*0x09*/ u8 specialSaveWarpFlags;
/*0x0A*/ u8 playerTrainerId[TRAINER_ID_LENGTH];
/*0x0E*/ u16 playTimeHours;
/*0x10*/ u8 playTimeMinutes;
/*0x11*/ u8 playTimeSeconds;
/*0x12*/ u8 playTimeVBlanks;
/*0x13*/ u8 optionsButtonMode; // OPTIONS_BUTTON_MODE_[NORMAL/LR/L_EQUALS_A]
/*0x14*/ u16 optionsTextSpeed:3; // OPTIONS_TEXT_SPEED_[SLOW/MID/FAST]
u16 optionsWindowFrameType:5; // Specifies one of the 20 decorative borders for text boxes
u16 optionsSound:1; // OPTIONS_SOUND_[MONO/STEREO]
u16 optionsBattleStyle:1; // OPTIONS_BATTLE_STYLE_[SHIFT/SET]
u16 optionsBattleSceneOff:1; // whether battle animations are disabled
u16 regionMapZoom:1; // whether the map is zoomed in
/*0x18*/ struct Pokedex pokedex;
/*0x90*/ u8 filler_90[0x8];
/*0x98*/ struct Time localTimeOffset;
/*0xA0*/ struct Time lastBerryTreeUpdate;
/*0xAC*/ u32 encryptionKey;
/*0xB0*/ struct PlayersApprentice playerApprentice;
/*0xDC*/ struct Apprentice apprentices[APPRENTICE_COUNT];
/*0x1EC*/ struct BerryCrush berryCrush;
/*0x1FC*/ struct PokemonJumpResults pokeJump;
/*0x20C*/ struct BerryPickingResults berryPick;
/*0x21C*/ struct RankingHall1P hallRecords1P[HALL_FACILITIES_COUNT][2][3]; // From record mixing.
/*0x57C*/ struct RankingHall2P hallRecords2P[2][3]; // From record mixing.
/*0x624*/ u16 contestLinkResults[5][4]; // 4 positions for 5 categories.
/*0x64C*/ struct BattleFrontier frontier;
/*0xA8*/ u32 gcnLinkFlags; //Read by Pokemon Colosseum/XD
}; // sizeof=0xF2C
The only thing that's changed here is that I added
Code:
u8 rivalName[PLAYER_NAME_LENGTH + 1];
in there. This is the variable that's used to hold the rival's name.
In src/main_menu.c:
Spoiler:
Code:
static void NewGameBirchSpeech_SetDefaultPlayerName(u8 nameId)
{
const u8* name;
const u8* rivalname;
u8 i;
if (gSaveBlock2Ptr->playerGender == MALE)
{
name = gMalePresetNames[nameId];
rivalname = gText_ExpandedPlaceholder_May;
}
else
{
name = gFemalePresetNames[nameId];
rivalname = gText_ExpandedPlaceholder_Brendan;
}
for (i = 0; i < 7; i++)
{
gSaveBlock2Ptr->playerName[i] = name[i];
gSaveBlock2Ptr->rivalName[i] = rivalname[i];
}
gSaveBlock2Ptr->playerName[7] = 0xFF;
gSaveBlock2Ptr->rivalName[7] = 0xFF;
}
I tweaked this bit of code so that it makes sure that the rival has a name even if the player never gives them one. If the rival is female, the rival's name will be "MAY". If they're male, their name will be "BRENDAN", just like in the vanilla game.
The only change here is in the final brackets. When the game looks at the trainer's name to print in battle, if it sees "MAY" or "BRENDAN", it will instead print the custom rival name.
This makes every instance of {RIVAL} in every piece of text (except in battles) prints the custom rival name.
The rest of the changes are just making sure all of the dialogue doesn't use the original rival's name, and instead uses the custom one.
In data/maps/EverGrandeCity_ChampionsRoom/scripts.inc,
data/maps/LavaridgeTown/scripts.inc,
data/maps/LilycoveCity/scripts.inc,
data/maps/LittlerootTown_MaysHouse_1F/scripts.inc,
data/maps/LittlerootTown_MaysHouse_2F/scripts.inc,
data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc,
data/maps/OldaleTown/scripts.inc,
data/maps/Route103/scripts.inc,
data/maps/Route104/scripts.inc,
data/maps/Route110/scripts.inc,
data/maps/Route119/scripts.inc,
data/maps/RustboroCity/scripts.inc,
data/text/match_call.inc, just replace every instance of MAY and BRENDAN in the text sections with {RIVAL}. If you're using Notepad++, (which I highly recommend), you can just search and replace every instance of MAY and BRENDAN with {RIVAL} in each file. Just make sure to make the search case-sensitive. Otherwise, you're going to ruin a ton of scripts in each file.
To actually use this code, within any script of your choice, just type
Code:
special RivalNameChange
At that point in the game, a naming screen will pop up, and you can name your rival whatever you want.
And with that, unless I missed some other change I made that I forgot, you should have a fully functioning custom rival name!
This code allows you to create a naming screen to give a name to your rival. Right now, even though I've given text to be displayed on the naming screen (like "YOUR NAME?", which is used in the player naming screen), no text appears at all. That's just an aesthetic issue, since the rival's name is assigned just fine.
In data/specials.inc:
Spoiler:
Add this at the end:
Code:
def_special RivalNameChange
This just allows you to access the RivalNameChange function from naming_screen.c in a script.
In src/strings.c:
Spoiler:
Add this at the end:
Code:
const u8 gText_RivalName[] = _("What's her name?");
This is the text that SHOULD be appearing when the naming screen appears, but doesn't.
In include/global.h:
Spoiler:
Code:
struct SaveBlock2
{
/*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
u8 rivalName[PLAYER_NAME_LENGTH + 1];
/*0x08*/ u8 playerGender; // MALE, FEMALE
/*0x09*/ u8 specialSaveWarpFlags;
/*0x0A*/ u8 playerTrainerId[TRAINER_ID_LENGTH];
/*0x0E*/ u16 playTimeHours;
/*0x10*/ u8 playTimeMinutes;
/*0x11*/ u8 playTimeSeconds;
/*0x12*/ u8 playTimeVBlanks;
/*0x13*/ u8 optionsButtonMode; // OPTIONS_BUTTON_MODE_[NORMAL/LR/L_EQUALS_A]
/*0x14*/ u16 optionsTextSpeed:3; // OPTIONS_TEXT_SPEED_[SLOW/MID/FAST]
u16 optionsWindowFrameType:5; // Specifies one of the 20 decorative borders for text boxes
u16 optionsSound:1; // OPTIONS_SOUND_[MONO/STEREO]
u16 optionsBattleStyle:1; // OPTIONS_BATTLE_STYLE_[SHIFT/SET]
u16 optionsBattleSceneOff:1; // whether battle animations are disabled
u16 regionMapZoom:1; // whether the map is zoomed in
/*0x18*/ struct Pokedex pokedex;
/*0x90*/ u8 filler_90[0x8];
/*0x98*/ struct Time localTimeOffset;
/*0xA0*/ struct Time lastBerryTreeUpdate;
/*0xAC*/ u32 encryptionKey;
/*0xB0*/ struct PlayersApprentice playerApprentice;
/*0xDC*/ struct Apprentice apprentices[APPRENTICE_COUNT];
/*0x1EC*/ struct BerryCrush berryCrush;
/*0x1FC*/ struct PokemonJumpResults pokeJump;
/*0x20C*/ struct BerryPickingResults berryPick;
/*0x21C*/ struct RankingHall1P hallRecords1P[HALL_FACILITIES_COUNT][2][3]; // From record mixing.
/*0x57C*/ struct RankingHall2P hallRecords2P[2][3]; // From record mixing.
/*0x624*/ u16 contestLinkResults[5][4]; // 4 positions for 5 categories.
/*0x64C*/ struct BattleFrontier frontier;
/*0xA8*/ u32 gcnLinkFlags; //Read by Pokemon Colosseum/XD
}; // sizeof=0xF2C
The only thing that's changed here is that I added
Code:
u8 rivalName[PLAYER_NAME_LENGTH + 1];
in there. This is the variable that's used to hold the rival's name.
In src/main_menu.c:
Spoiler:
Code:
static void NewGameBirchSpeech_SetDefaultPlayerName(u8 nameId)
{
const u8* name;
const u8* rivalname;
u8 i;
if (gSaveBlock2Ptr->playerGender == MALE)
{
name = gMalePresetNames[nameId];
rivalname = gText_ExpandedPlaceholder_May;
}
else
{
name = gFemalePresetNames[nameId];
rivalname = gText_ExpandedPlaceholder_Brendan;
}
for (i = 0; i < 7; i++)
{
gSaveBlock2Ptr->playerName[i] = name[i];
gSaveBlock2Ptr->rivalName[i] = rivalname[i];
}
gSaveBlock2Ptr->playerName[7] = 0xFF;
gSaveBlock2Ptr->rivalName[7] = 0xFF;
}
I tweaked this bit of code so that it makes sure that the rival has a name even if the player never gives them one. If the rival is female, the rival's name will be "MAY". If they're male, their name will be "BRENDAN", just like in the vanilla game.
The only change here is in the final brackets. When the game looks at the trainer's name to print in battle, if it sees "MAY" or "BRENDAN", it will instead print the custom rival name.
This makes every instance of {RIVAL} in every piece of text (except in battles) prints the custom rival name.
The rest of the changes are just making sure all of the dialogue doesn't use the original rival's name, and instead uses the custom one.
In data/maps/EverGrandeCity_ChampionsRoom/scripts.inc,
data/maps/LavaridgeTown/scripts.inc,
data/maps/LilycoveCity/scripts.inc,
data/maps/LittlerootTown_MaysHouse_1F/scripts.inc,
data/maps/LittlerootTown_MaysHouse_2F/scripts.inc,
data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc,
data/maps/OldaleTown/scripts.inc,
data/maps/Route103/scripts.inc,
data/maps/Route104/scripts.inc,
data/maps/Route110/scripts.inc,
data/maps/Route119/scripts.inc,
data/maps/RustboroCity/scripts.inc,
data/text/match_call.inc, just replace every instance of MAY and BRENDAN in the text sections with {RIVAL}. If you're using Notepad++, (which I highly recommend), you can just search and replace every instance of MAY and BRENDAN with {RIVAL} in each file. Just make sure to make the search case-sensitive. Otherwise, you're going to ruin a ton of scripts in each file.
To actually use this code, within any script of your choice, just type
Code:
special RivalNameChange
At that point in the game, a naming screen will pop up, and you can name your rival whatever you want.
And with that, unless I missed some other change I made that I forgot, you should have a fully functioning custom rival name!