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

Simple Modifications Directory

50
Posts
6
Years
  • Age 25
  • Seen Oct 20, 2023
Set Wild Pokémon's Levels Dynamically POKEEEMERALD
Spoiler:



Not to break you down, but your code can be a little improved. I assume your code calculates the mean and assign it to fixedLVL. It is untested but this version should essentially do the same as you posted:

Code:
static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon)
{
    u8 min;
    u8 max;
    u8 range;
    u8 rand;

    u8 count = gPlayerPartyCount;
    u8 fixedLVL = 0;

    while (count-- > 0)
    {
        if (GetMonData(&gPlayerParty[count], MON_DATA_SPECIES) != SPECIES_NONE){
            fixedLVL += (GetMonData(&gPlayerParty[count], MON_DATA_LEVEL);
        }
    }
    fixedLVL = fixedLVL / gPlayerPartyCount;
    

// Make sure minimum level is less than maximum level
    {
        min = fixedLVL-3;
        max = fixedLVL+3;
    }
	if (min <= 0)
		min = 1;
    range = max - min + 1; // note that range will always be equal to 7 in this case: fixedLVL+3 - (fixedLVL-3) + 1 = fixedLVL - fixedLVL + 3 +3 +1 = 7
    rand = Random() % range;

...
 
Last edited:
239
Posts
8
Years
  • Age 31
  • Seen Apr 15, 2024
Remove Pokemon Data Encryption [Pokeemerald]
This will remove all of the (in my opinion) unecessary data encryption of the pokemon structure. So you can freely mess around with the size or individual elements.

in pokemon.c:
Spoiler:


I also made a branch for simple repo pulling. Please report any errors.
 
788
Posts
17
Years
  • Age 29
  • Seen yesterday

Move Item [EM]


Adds a MOVE option to the ITEM menu which allows you to move held items directly between Pokémon in your party, instead of having to use the bag as a middle man.

I've had this up in my pokeemerald fork for a while, but I never got around to writing it up here. Since I originally made it, the relevant functions got actual names in pokeemerald, so I'm taking this as an opportunity to update it and post it here.

There's going to be multiple changes required across multiple files, so I'm going to try to keep them in a logical order that minimizes jumping between files. Also, at the end of each step, pokeemerald will still be in a compilable state if done properly.

In the code blocks throughout this post, new lines of code are highlighted with the color green. Red highlights denote deleted lines of code. If a line of code isn't highlighted either color, it is only included for context.

Adding the strings


In include/strings.h, add the following to the end of the file:

Spoiler:

In src/strings.c, add the following to the end of the file:

Spoiler:

Adding the code


You'll need to add a forward declaration for CursorCb_MoveItem in src/party_menu.c, like so:

Spoiler:

At the end of src/party_menu.c, add the following:

Spoiler:

Open include/constants/party_menu.h, and look for #defines of the form PARTY_MSG_WHATEVER. We need to add a #define for PARTY_MSG_MOVE_ITEM_WHERE like so:

Spoiler:

Updating relevant data


Everything from here on will be in src/data/party_menu.h.

Look for an unnamed enum with values such as MENU_SUMMARY. Add MENU_MOVE_ITEM to the enum's list of values, like so:

Spoiler:

Now, we need to add an entry to the sCursorOptions array. Add an entry for MENU_MOVE_ITEM like so:

Spoiler:

Next, find the definition of sActionStringTable. Add an entry to the end like so:

Spoiler:

And finally, we need to adjust the ITEM menu so that it actually includes our new menu option.

Find the definition of sPartyMenuAction_GiveTakeItemCancel, and modify it:

Spoiler:

Find the definition of sItemGiveTakeWindowTemplate and modify it:

Spoiler:

And that's it. Let me know if you have problems.

Edit: Oh, since I forgot to mention, my code here is licensed under the 0BSD license. In short, use it for whatever. Attribution is appreciated, but not required.
 
Last edited:

Lunos

Random Uruguayan User
3,114
Posts
15
Years
Nicknaming as an option in the Pokémon Party Screen (Emerald)​
This code allows you to change the nickname of a Pokémon in your party on the Pokémon Party Screen with a new option called "Nickname".
Honestly, the idea of requiring the service of an NPC in X Town or City to change a Pokémon's nickname is silly.
You should always be able to nickname your own Pokémon, in my opinion.

The code can be found in this commit, it's super easy stuff.
https://github.com/shinny456/pokeemerald/commit/c92e5861e3ba85abaf53af81aa0bb70acae505af

Quick demonstration:
xxnUgll.gif


Bugs:
-You can't nickname a Pokémon that knows 4 Field Moves
To fix this, simply change u8 actions[8]; in the Line 123 of src/party_menu.c to u8 actions[9]; instead.
Credits to Ghoulslash for this fix.

Improvements:
-Hide the "Nickname" option in the party screen's context menu for Pokémon whose OT ID doesn't match the Player's
Read this post: https://www.pokecommunity.com/showpost.php?p=10376476&postcount=279
Credits to TheXaman for that.

-Make the naming screen return to the party screen instead of the overworld
Apply the changes shown here: https://github.com/LOuroboros/pokeemerald/commit/7273fae0afe6026bb7561cc9ff67aa750617aadc

-When making the naming screen return to the party screen, highlight the slot of the Pokémon that was just renamed
Read this post: https://www.pokecommunity.com/showpost.php?p=10588684&postcount=441
Credits to Zadien for that.

The credits for this feature go to Shinny456. I'm just reposting it here because he wanted to share it with y'all.

EDIT (30/12/2022): This feature has its own article at the Pokeemerald wiki which I just finished updating.
https://github.com/pret/pokeemerald/wiki/Nickname-your-Pokémon-from-the-party-menu

And that's pretty much it.​
 
Last edited:
239
Posts
8
Years
  • Age 31
  • Seen Apr 15, 2024
[Emerald] Item Descriptions On First Obtain

Recent games included a description of an item when you obtain it for the first time. This adds that feature to pokeemerald. it also adds the item icon to your message box on subsequent events.

LielpRX.gif
wbrfpYa.gif


Here is my repo branch.

How to Add:
 
Last edited:
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
POKEEMERALD
Set a Trainer's Pokémon's abilities​
For doing this, we'll have first to set the option in include/data.h
We search for
Code:
TrainerMonNoItemDefaultMoves
(line 17) and we add in the ones which we want to add abilities (if you want to code more, you can make new ones for setting and not setting the ability...)
Therefore, we add this at the end, before the "};":
Code:
u8 abilityNums;
Like this:
xLGRQyW.png

We're done with this, we have to go to src/battle_main.c
We add this in every "TrainerMon" that we added the abilityNums:
Before the "break":
Code:
SetMonData(&party[i], MON_DATA_ABILITY_NUM, &partyData[i].abilityNums);
Like this:
f0gGQgV.png


Then, were ready to set Trainer's Pokémon's abilities in src/data/trainer_parties.h!
We will have to set the abilities to every single Pokémon of each Trainer of each "TrainerMon" we add the abilityNums, if you added new "TrainerMon", just create new Trainer for setting their Pokémon's abilities!
This is the most boring part, we'll need to add ".abilityNums =x," which x is "0=fist ability", "1=secondary ability" and (again, just if you have it) "2=hidden ability"
Like this:
vfCmF04.png


Then, when you're done with that, you'll need to add a "comma" in the line before the ".abilityNums = x" one.
It happens mostly in the "TrainerMonItemDefaultMoves" and the "TrainerMonNoItemCustomMoves", tho...

k2Ro4SG.png

PD: you'll have ALWAYS to add the .abilityNums = x for every Trainer's Pokémon that you added at first. Like, if you add this sistem just for "TrainerMonItemCustomMoves", you won't have to and DO NOT have to add this to the "TrainerMonNoItemDefaultMoves", for example.
When we're done with that, we successfully added the option to set a Trainer's Pokémon's ability!
 
Last edited:
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
POKEEMERALD
PSS IN THE START MENU
First, we add a new Flag in include/constants/flags.h
Code:
FLAG_POKEMONPCMENU
(this will be used after)
Then, we go to include/pokemon_storage_system.h
There, we add anywhere:
Code:
void EnterPokeStorage(u8);
Then we go to src/pokemon_storage_system.c, and we delete
Code:
static void EnterPokeStorage(u8);
(when its definied, the first one)
and we search for "static void EnterPokeStorage(u8 boxOption)", then we erase the "static " (the second one)
Then, we search for:
Code:
static void FieldTask_ReturnToPcMenu(void)
And we replace it entirely for this:
Code:
static void FieldTask_ReturnToPcMenu(void)
{
    u8 taskId;
    MainCallback vblankCb = gMain.vblankCallback;
	if (FlagGet(FLAG_POKEMONPCMENU)==TRUE)
	{
		SetVBlankCallback(NULL);
		taskId = CreateTask(Task_PCMainMenu, 80);
		gTasks[taskId].tState = 0;
		gTasks[taskId].tSelectedOption = sPreviousBoxOption;
		Task_PCMainMenu(taskId);
		SetVBlankCallback(vblankCb);
		FadeInFromBlack();
	}
	else {
		ScriptContext2_Disable();
		EnableBothScriptContexts();
		SetVBlankCallback(CB2_ReturnToField);
		FadeInFromBlack();
	}
}
Then, we go to src/start_menu.c, and we search for: static bool8 StartMenuBagCallback(void);, and right after, we add:
static bool8 StartMenuPCCallback(void);
Then, we go to "{gText_MenuBag, {.u8_void = StartMenuBagCallback}}," and again we add bellow:
{gText_MenuPC, {.u8_void = StartMenuPCCallback}},
Then, we go to "static bool8 StartMenuBagCallback(void)" and after the whole funcion we add:
Code:
static bool8 StartMenuPCCallback(void)
{
	u8 taskId;
    if (!gPaletteFade.active)
    {
        PlayRainStoppingSoundEffect();
        RemoveExtraStartMenuWindows();
		EnterPokeStorage(x);
        return TRUE;
    }

    return FALSE;
}
(in my case, its "0" the number for the Move Pokémon System, but I have made some changes {I changed the Move option to the first place}, and I'm sure the original number for the option is "2"...)

Then, we search for: "MENU_ACTION_BAG"
And after we add: "MENU_ACTION_PC,"

Now we go to: "if (FlagGet(FLAG_SYS_POKEMON_GET) == TRUE)" and inside there we add:
AddStartMenuAction(MENU_ACTION_PC);
Like this:
Code:
    if (FlagGet(FLAG_SYS_POKEMON_GET) == TRUE)
    {
        AddStartMenuAction(MENU_ACTION_POKEMON);
		AddStartMenuAction(MENU_ACTION_PC);
    }
Then, we go to "AddStartMenuAction(MENU_ACTION_BAG);" and right after we add:
AddStartMenuAction(MENU_ACTION_PC);

Then, we go to data/scripts/pc.inc and we add this after "playse SE_PC_ON" in "EventScript_PC:: @ 8271D92":
setflag FLAG_POKEMONPCMENU
Now, after "special DoPCTurnOffEffect", in "EventScript_TurnOffPC:: @ 8271E47" we add:
clearflag FLAG_POKEMONPCMENU

Lastly, we need to add the strings for the PC in the Start Menu, (thanks, Lunos)
We go to include/strings.h and we add this somewhere:

extern const u8 gText_MenuPC[];

And this is the last step. We go to src/strings.c and we add this somewhere:
const u8 gText_MenuPC[] = _("PC");

And we're done! this time, we are We should be able to enter the Move Pokémon PC, and the Pokécenter PC's won't be affected.

n11Cwen.gif
 
Last edited:

Lunos

Random Uruguayan User
3,114
Posts
15
Years
POKEEMERALD
PSS IN THE START MENU
You forgot to mention that the user needs to define the text for gText_MenuPC in include/strings.h and src/strings.c
Also, you can't really deposit Pokémon, for some reason. Not sure if it's intentional or not, but I thought I should mention it.
zSXRb1h.gif
 
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
You forgot to mention that the user needs to define the text for gText_MenuPC in include/strings.h and src/strings.c

Oh, you're right. I totally forgot about that, thank you!

Also, you can't really deposit Pokémon, for some reason. Not sure if it's intentional or not, but I thought I should mention it.
zSXRb1h.gif

Actually, that happens because of this: Cb2_EnterPSS(x);
Where "x" is a number between 0 and 2 if I recall, I think the number should be "2" in a game without the implementation of this: Move as first PSS Option, because I'm sure the reason because you can't deposite Pokémon is that you put the "Withdraw" option in "Cb2_EnterPSS(x);" (And would be nice if you say what number it is, maybe it could be helpfull)
 
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
"Move Pokémon" as first PSS option [EM]
WTwxHm8.png

In "src/pokemon_storage_system.c", change the order of this:
Spoiler:

and this:
Spoiler:

and below switch(task->data[2]) in Task_PokemonStorageSystemPC change these two:
Spoiler:

Yeah, that's cool but... Something happens when you do this...
You can't press the "B" button while on the "Deposit Pokémon" option, which softlockes the game, as you can't go back, you're stuck in the Deposite Option...
 

Lunos

Random Uruguayan User
3,114
Posts
15
Years
Actually, that happens because of this: Cb2_EnterPSS(x);
Where "x" is a number between 0 and 2 if I recall, I think the number should be "2" in a game without the implementation of this: Move as first PSS Option, because I'm sure the reason because you can't deposite Pokémon is that you put the "Withdraw" option in "Cb2_EnterPSS(x);" (And would be nice if you say what number it is, maybe it could be helpfull)
Oh, I see. I've been testing around the values, and these are the results I got:
0: Withdraw Pokémon. The menu goes directly into the last PC Box seen. You can't deposit a Pokémon.
1: Deposit Pokémon. The menu goes directly into the PC forcing you to deposit a Pokémon on the PC. You can't withdraw a Pokémon.
2: Move Pokémon. This is the good one. You can deposit a Pokémon but you can also withdraw Pokémon from your PC normally.

Certainly, in the base game, 2 is the proper value to have a fully functional PSS access in the menu.
 
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
EMERALD BROKEN RNG FIX [EM]
Well, this one is actually pretty simple, and all we have to do, is editting the usual "void SeedRngAndSetTrainerId(void)" in src/main.c
With this:
Code:
void SeedRngAndSetTrainerId(void)
{
    u32 seed = RtcGetMinuteCount();
    u16 val = RtcGetMinuteCount();
    seed = (seed >> 16) ^ (seed & 0xFFFF);
    SeedRng(seed);
    SeedRng(val);
    gTrainerId = val;
}
And then we go to:
void AgbMain()
And we add "SeedRngAndSetTrainerId();" right after "InitMapMusic();"
And that's it! We fixed Emerald's Broken RNG!
 
Last edited:

AsparagusEdu

AsparagusEduardo
30
Posts
10
Years
  • Age 30
  • Seen yesterday
Yeah, that's cool but... Something happens when you do this...
You can't press the "B" button while on the "Deposit Pokémon" option, which softlockes the game, as you can't go back, you're stuck in the Deposite Option...

Shoot, gotta fix this ^^;
 
239
Posts
8
Years
  • Age 31
  • Seen Apr 15, 2024
[EM] More Trainer Items

Rather than simply increase the size of the items array in the trainer data struct, let's just add itemCounts for each item slot! So each trainer item can be unique, and they can hold up to 255 of each (if you want to be especially cruel).

Code Changes:
Spoiler:


I've made a branch off of DizzyEgg's battle engine to pull from, but it doesn't update any of the trainer data so updating the code manually is easy enough.

Here's a really boring GIF of a trainer using 5 potions:
GU3hqF4.gif
 

AsparagusEdu

AsparagusEduardo
30
Posts
10
Years
  • Age 30
  • Seen yesterday
Shops with single items to buy [EM]
6IkX98R.gif
In later Generations, there are some shops that would only let you buy one of each item (like TM Shops), so I created a pokeemerald branch that implements the option to create shops of this type.

How to use:
  1. You first need to clone this branch into your project.
  2. Whenever you call the pokemart command in your map scripts, you can add a number that represents a TM Shop's id. Since 0 is the default value, setting it to 0 won't work. If you repeat that shop's id in another one, they will share the same flags.
    Spoiler:

  3. You can specify the amount of TMShops that you want to implement in include\shop.h.
    Spoiler:

  4. By default, the max amount of items per TM Shop is 16, so any item added past this will be ignored and not added to the list.
  5. If for any reason you need more than 16 items per TM Shop, you'll need to change the data type from u16 to u32 or u64 in the following sections:
    Spoiler:

Thanks to:
  • UltimaSoul for their help debugging and teaching me how to bit shift :P
  • ghoulslash for advice and the inspiration for this branch
 
Last edited:
239
Posts
8
Years
  • Age 31
  • Seen Apr 15, 2024
[EM] Register Items with LR

L and R are useless in the overworld, so let's give them something to do! This lets you register key items to L, R, and Select (which may be overkill but ah well)

7RjFKud.gif


Steps:
1. Pull from my repo branch
2. that's it. I may add code changes here if requested.
 
14
Posts
6
Years
  • Age 26
  • Seen Jan 17, 2021
[EM] ADDING EVs TO TRAINERS

This tutorial will allow you to add EV values to any trainers you wish.

First, in include/data.h, you need to do this in all (or some) of the trainer structs:

Code:
struct TrainerMonItemCustomMoves
{
    u16 iv;
    u8 lvl;
    [B][COLOR="Red"]u8 evs[NUM_STATS];[/COLOR][/B]
    u16 species;
    u16 heldItem;
    u16 moves[MAX_MON_MOVES];
};

Then, in src/battle_main.c, the next changes for the struct regarding the trainer type need to be done.

Code:
            case F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM:
            {
                const struct TrainerMonItemCustomMoves *partyData = gTrainers[trainerNum].party.ItemCustomMoves;

                for (j = 0; gSpeciesNames[partyData[i].species][j] != EOS; j++)
                    nameHash += gSpeciesNames[partyData[i].species][j];

                personalityValue += nameHash << 8;
                fixedIV = partyData[i].iv * 31 / 255;
                CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0);

                SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
                for (j = 0; j < MAX_MON_MOVES; j++)
                {
                    SetMonData(&party[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
                    SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
                }
[B]                [COLOR="Red"]for (j = 0; j < NUM_STATS; j++)
                {
                    SetMonData(&party[i], MON_DATA_HP_EV + j, &partyData[i].evs[j]);
                }
                CalculateMonStats(&party[i]);[/COLOR][/B]
                break;
            }

Last, but not least, you need to modify the trainer party mons, so they include the new value. This is the boring part, and depending on how many trainer structs you have modified, you'll have to modify some or all the trainers. Here's an example:

Code:
static const struct TrainerMonItemCustomMoves sParty_MayRoute103Mudkip[] = {
    {
    .iv = 0,
    .lvl = 5,
    .species = SPECIES_TREECKO,
    .heldItem = ITEM_NONE,
    [B][COLOR="Red"][I].evs = {0, 0, 0, 255, 0, 255},[/I][/COLOR][/B]
    .moves = {MOVE_POUND, MOVE_LEER, MOVE_NONE, MOVE_NONE}
    }
};

Thanks to GriffinR for giving me pointers on how to build the function. Please let me know if this works.
 
Last edited:
14
Posts
6
Years
  • Age 26
  • Seen Jan 17, 2021
[EM] FRLG / Gen IV and Onwards White Out Money Calculation (with messages)

This implementation is based on AsparagusEduardo's implementation of that same feature, but I added the required messages, taking the FRLG decomp as a point of start, and then modifying the getmoneyreward function in battle_script_commands.c, so it handles this part better and the buffer is updated, so the money value is taken correctly.

53dbf2a9599bdc6407160763125b1888.png
7a2e1d79aa7281633fe6b41d90664d90.png
6750aa92a3d60718a48283a5f308e436.png
f8cb3a7bcd2b4904f3e574d1ca8056b8.png
bec8f971008dbfab22b3adcafeb49630.png


You can pull this feature from this branch:

GitHub Link:
https://github.com/lightgod87/pokeemerald/tree/whiteoutmoney

Thanks to GriffinR and AsparagusEduardo for making this possible.
 
Last edited:
239
Posts
8
Years
  • Age 31
  • Seen Apr 15, 2024
[EM] Fast Surfing

To get the player to surf at mach bike speeds:

In src/field_player_avatar.c at line 640: replace PlayerGoSpeed2 with PlayerGoSpeed4

Alternatively, replace with the following code to "Run" at mach bike speeds while surfing
Code:
if (heldKeys & B_BUTTON)
    PlayerGoSpeed4(direction);
else
    PlayerGoSpeed2(direction);

2N98kM4.gif
 

Lunos

Random Uruguayan User
3,114
Posts
15
Years
Modifying the move of a TM/HM [EM/FR]
This is very very simple. I found it out pretty quickly when I was trying to help out lightbox87 in the Discord server yesterday.
The list of moves that each TM and HM contains is located in the src/data/party_menu.h file in both, Pokefirered and Pokeemerald.
https://github.com/pret/pokefirered...09533902c7605e7d4/src/data/party_menu.h#L1239
https://github.com/pret/pokeemerald...1c65bab31104e8c47/src/data/party_menu.h#L1195

You just have to modify the move contained in whatever TM/HM you want to change, save and compile.
notepad-2020-03-27_22-15-58.png


Naturally, if you want to modify anything related to the TM/HM item itself (like its description which as you can see here is Focus Punch's), you'll have to go to src/data/items.json as usual.

And that's pretty much it.​
 
Last edited:
Back
Top