-
Notifications
You must be signed in to change notification settings - Fork 57
Create Written Mail In PC Mailbox
By wiz1989.
Creating mail (in the PC mailbox) can be a convenient way for a ROM hacker to communicate with the player. You could give additional instructions, hints or simply troll the user (Archie, this could be one for you). Whatever suits you best.
Each mail text is defined as an array of Easy Chat Words (see Bulbapedia).
You can define several mail texts as separate array elements.
Of course, if the existing words are not sufficient for your case, then creating new words and phrases is easily possible in the easy_chat files. Just search for an existing term (like EC_WORD_GIVES
) and take it from there.
const u16 sMail[][MAIL_WORDS_COUNT + 1] =
{
{
EC_POKEMON_NATIONAL(KABUTOPS),
EC_WORD_GIVES,
EC_WORD_TIME,
EC_WORD_TO,
EC_WORD_ATTACK,
EC_WORD_EXCL,
EC_WORD_THINK,
EC_WORD_ABOUT,
EC_WORD_WHY,
EC_WORD_EXCL
},
{
next mail
}
};
I did this in src/data/trade.h as a similar array sIngameTradeMail
was already available there.
Be aware that you shouldn't exceed 10 word elements as stated in MAIL_WORDS_COUNT
.
You can write a simple function to create the mail based on your text template. I did it in trade.c as once again similar functions already exist and all dependencies are already there. When registering this as a special you could easily call this from ASM/poryscript as well.
void CreateMail(void)
{
s32 i;
u32 otId;
u8 otName[11] = _("WIZ1989");
//save mail in saveblock1 -> index 6 is the first slot the mailbox reads from
struct Mail *mail = &gSaveBlock1Ptr->mail[PARTY_SIZE];
otId = 1989;
for (i = 0; i < MAIL_WORDS_COUNT; i++)
mail->words[i] = sMail[0][i];
StringCopy(mail->playerName, otName);
PadNameString(mail->playerName, CHAR_SPACE);
mail->trainerId[0] = otId >> 24;
mail->trainerId[1] = otId >> 16;
mail->trainerId[2] = otId >> 8;
mail->trainerId[3] = otId;
mail->species = SPECIES_KABUTOPS;
mail->itemId = ITEM_RETRO_MAIL;
}
This code basically fills all variables of the Mail struct and writes it into the corresponding saveblock (where the game saves all the required data) object.
By using &gSaveBlock1Ptr->mail[PARTY_SIZE]
I am using an index > the party mons. This is important as the PC function for the mail box reads from slots 6-15. So you can have a maximum of 10 mails in the PC.
For the big picture, here is the mail struct from global.h
that's being used.
struct Mail
{
/*0x00*/ u16 words[MAIL_WORDS_COUNT];
/*0x12*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x1A*/ u8 trainerId[TRAINER_ID_LENGTH];
/*0x1E*/ u16 species;
/*0x20*/ u16 itemId;
};
git clone https://github.com/pret/pokeemerald.git cd pokeemerald git remote rename origin upstream git remote add origin https://github.com/DEN-DALI-KAVKA/Copy-of-the-World.git git push -u origin