• 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

106
Posts
11
Years
Removing Badge Checks for HMs

As it says, it's just a quick way to disable badge checks so HM moves can be used without gym badges. For now, I've only commented out the code in case I need to undo it later, however, you could simply delete the commented code if you wished.

In:
Code:
src/field_control_Avatar.c

Spoiler:

In:
Code:
data\scripts\field_move_scripts.inc

Spoiler:

And finally, in:
Code:
src\party_menu.c

Spoiler:
 
Last edited:
1,591
Posts
10
Years
  • Age 30
  • Seen Mar 20, 2024
Trainer Class-Based Poké Balls (Emerald)
G4PC9Bn.gif
Trainers in the gen VII games send out their Pokemon in different balls depending what class they are, so I've implemented that in Emerald.

First, go to include\battle_main.h and add a new struct like so:
Code:
struct TrainerBall
{
    u8 classId;
    u8 Ball; // make this a u16 if needed
};
Then add a table of these to src\battle_main.c:
Spoiler:
Finally, add the code in bold to the end of the first for loop in the function CreateNPCTrainerParty, which is also in src\battle_main.c, like so:
Spoiler:
 
Last edited:
1,591
Posts
10
Years
  • Age 30
  • Seen Mar 20, 2024
BUGGED: Evolution Moves (Emerald)​
NOTE: I've just found a nasty bug with this: if a Pokemon tries to learn a move it already knows while evolving, the game will freeze. I haven't been able to find the cause, so I'd recommend using the implementation posted by Lunos instead.

In the gen VII games many Pokemon have level up moves that they learn upon evolving, regardless of what level they are. This is a fantastic addition because it means Pokemon like Feebas don't stay useless if they evolve a level too late to learn their first damaging move.

To implement this in Emerald, first open include/pokemon.h and add an extra input argument to the function "MonTryLearningNewMove":
Code:
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove, bool8 isEvolving);

Next, modify all code that calls this function to include a third input argument. There are two instances in src/evolution_scene.c where this should be set to "1", like so:
Code:
var = MonTryLearningNewMove(mon, gTasks[taskID].tLearnsFirstMove, [B][COLOR="Red"]1[/COLOR][/B]);
All other instances should be set to "0". These can be found in src/party_menu.c, src/battle_script_commands.c, and src/daycare.c.

Following that, open pokemon.c and navigate to the function "MonTryLearningNewMove". Replace it with the following:
Spoiler:
Finally, add some evolution moves to src\data\pokemon\level_up_learnsets.h. These must be the first entries in each Pokemon's list, and must be learned at level zero e.g.
Spoiler:
 
Last edited:
50
Posts
6
Years
  • Age 25
  • Seen Oct 20, 2023
Trainer Pokemon Individual Poké Balls (Emerald)

After being inspired by Buffel Saft - Trainer Class-Based Poké Balls (Emerald) I wanted to do the same but with a different aproach. Where every Trainers Poké Ball can optionally be changed in src/data/trainer_parties.h.

Code:
const struct TrainerMonNoItemDefaultMoves gTrainerParty_May7[] = {
    {
    .iv_ball = ((ITEM_ULTRA_BALL << 8) | 0),
    .lvl = 5,
    .species = SPECIES_DEOXYS,
    }
};

I noticed the .iv propperty is stored in an u16 and never exceeds 255 wich leaves the 8 upper bits unused (for as far as I know). So I used the 8 upper bits for a ball.


In src/data/trainer_parties.h.
Spoiler:


Than still in include/battle.h, add these 2 lines at the top.
Spoiler:


Than in src/battle_main.c go to CreateNPCTrainerParty
Spoiler:

Result
He9LZ2.gif
 
Last edited:

Lunos

Random Uruguayan User
3,114
Posts
15
Years
Gen. 6 styled Exp. Share (Em)
Blurose implemented this mechanic from the newer pokémon games on Pokeruby sometime ago.
Today, I took some time to port his version to Pokeemerald.
To add it to your project, you just need to track my repository via git remote and pull the branch where the code is.

For battle_engine users:
Code:
git remote add lunos https://github.com/LOuroboros/pokeemerald
git pull lunos gen6_exp_share_BE

Manual changes: https://github.com/rh-hideout/pokee...er...LOuroboros:pokeemerald:gen6_exp_share_BE

For vanilla Pokeemerald users:
Code:
git remote add lunos https://github.com/LOuroboros/pokeemerald
git pull lunos gen6_exp_share

Manual changes: https://github.com/rh-hideout/pokee...aster...LOuroboros:pokeemerald:gen6_exp_share

Video:


EDIT (07/03/2019):
It has been brought to my attention by Discord user Lightbox that a label was changed, and since I deleted the branch where I pushed the commit I linked here originally, I decided to grab a clean copy of Pokeemerald and make a branch specifically for this feature.
I already modified the link to the commit above and it's ready to go.


EDIT (06/12/2020):
It has been brought to my attention by Jaizu that the value of gSaveBlock2Ptr->expShare wasn't being reset upon starting a New Game, which means that if you turned on the Exp. Share, saved the game, started a New Game and tried to use the Exp. Share, it would still be considered by the game as being enabled. I fixed that in the latest commit that I pushed to the branch.


EDIT (10/06/2022):
I edited the post yet again, linking an alternative branch I made for battle_engine users, mostly because handling the changes to Cmd_getexp can be daunting to newbies.
If anyone spots any mistakes I may have made, please let me know.

Also, this branch varies quiet a bit from the other one, as I now use an unused flag to handle toggling the system On/Off instead of adding a whole new variable to the SaveBlock1 for it pointlessly.
Feel free to change which flag is used or whatever if you want or need to.


EDIT (19/09/2023):
Users of the Pokeemerald-expansion will no longer need this soon enough, as the Gen. 6 Exp. Share was implemented over there. Once it's merged into the Master branch, I plan to port that into a standalone branch for vanilla Pokeemerald users, and that will be the only branch I'll distribute on my end.
 
Last edited:
788
Posts
17
Years
  • Age 29
  • Seen today
Wrapping Summary Screen [EM]

In XY and later games, the Summary Screen wraps around. By that I mean if you press down on the summary screen of the last Pokémon in your party, you'll be taken back to the first Pokémon in your party (in earlier games, it would just do nothing). Similarly, if you press up while on the first Pokémon in your party, you'll go to the last.

To copy this behavior in In pokeemerald, in src/pokemon_summary_screen.c, change sub_81C08F8 to the following:

Code:
static s8 sub_81C08F8(s8 delta)
{
    struct Pokemon *mon = sMonSummaryScreen->monList.mons;
    u8 index = sMonSummaryScreen->curMonIndex;
    u8 numMons = sMonSummaryScreen->maxMonIndex + 1;
    delta += numMons;

    index = (index + delta) % numMons;

    // skip over any Eggs unless on the Info Page
    if (sMonSummaryScreen->currPageIndex != PSS_PAGE_INFO)
        while (GetMonData(&mon[index], MON_DATA_IS_EGG))
            index = (index + delta) % numMons;

    // to avoid "scrolling" to the same Pokemon
    if (index == sMonSummaryScreen->curMonIndex)
        return -1;
    else
        return index;
}

Edit: As pointed out by Lunos, sub_81C08F8 has been renamed to AdvanceMonIndex since I posted this.
 
Last edited:
1,309
Posts
12
Years
  • Age 31
  • Seen Nov 24, 2023
Updated the first post! Thanks a lot for sharing your contributions, troops x
 

AsparagusEdu

AsparagusEduardo
30
Posts
10
Years
  • Age 30
  • Seen Apr 14, 2024
White out money calculation [EM]
In Gen I & II and RSE, you lose half of your money when defeated. However, in FLRG & Gen IV onwards the amount you lose is calculated by a formula based on the amount of badges and the highest level in your Pokémon's Party.
[Bulbapedia source]

This mod implements that formula (using the FLRG values).

ZLtoR8R.png
p9G3iea.png
r9AfS26.png
PDUqr0y.png


GitHub link:
https://github.com/AsparagusEduardo/pokeemerald/tree/WhiteOutMoney
 
Last edited:

AsparagusEdu

AsparagusEduardo
30
Posts
10
Years
  • Age 30
  • Seen Apr 14, 2024
"Move Pokémon" as first PSS option [EM]
WTwxHm8.png

In "src/pokemon_storage_system.c", look for the enum where OPTION_MOVE_MONS is defined and change its order.

Spoiler:
 
Last edited:
5
Posts
10
Years
  • Seen Jan 6, 2024
About "Surviving poison outside of battle with 1hp":
It looks like the code there's an error in the code, or did I did something wrong ?

Error:
src/field_poison.c: In function `DoPoisonFieldEffect':
src/field_poison.c:135: `EventScript_PoisonSurvial' undeclared (first use in this function)
src/field_poison.c:135: (Each undeclared identifier is reported only once
src/field_poison.c:135: for each function it appears in.)
make: *** [Makefile:242: build/emerald/src/field_poison.o] Error 1
 

Lunos

Random Uruguayan User
3,114
Posts
15
Years
About "Surviving poison outside of battle with 1hp":
It looks like the code there's an error in the code, or did I did something wrong ?

Error:
src/field_poison.c: In function `DoPoisonFieldEffect':
src/field_poison.c:135: `EventScript_PoisonSurvial' undeclared (first use in this function)
src/field_poison.c:135: (Each undeclared identifier is reported only once
src/field_poison.c:135: for each function it appears in.)
make: *** [Makefile:242: build/emerald/src/field_poison.o] Error 1

Yeah, it doesn't seem to work. I asked TheXaman about this on his profile back in March and he never really answered.
I guess this is a good time to post this. I really should have done it sooner, but I kind of forgot :P

Overworld 1HP Poison Survival [EM]
Some time ago, Blurose made his own version of this mechanic for his project in Pokeruby.
Some months ago, I ported it to Pokeemerald, and this seems to be a good time to post it here as an alternative.

The relevant modifications can be seen in this commit, it's veery simple.
https://github.com/LOuroboros/pokeemerald/commit/c162100fdc5439ebd7eefabc5890dae56d1a88f7

Pics:
2019-04-27_19-58-36.gif
2019-04-27_20-01-34.gif


And that's pretty much it.

EDIT (31/12/2020): I decided to put this feature on a standalone branch too because why not.
To easily merge it in a project that is up-to-date with Pret's Pokeemerald, you just have to track my repository via git remote and then pull the branch in which I put it.
Code:
git remote add lunos https://github.com/LOuroboros/pokeemerald
git pull lunos ow_1hp_psn_survival
 
Last edited:

Lunos

Random Uruguayan User
3,114
Posts
15
Years
Full National Dex [EM]

Method 1: Script Loop
Spoiler:


Method 2: Code function
Spoiler:


EDIT (22/09/2021): I added an alternative method that I wrote back in March, but I completely forgot to post here.​
 
Last edited:

Lunos

Random Uruguayan User
3,114
Posts
15
Years
Gen. 8 Synchronize [EM]
Synchronize in Gen. 8 always makes it so your Pokémon copies their nature onto the wild Pokémon that you can find. The effect doesn't have a 50% chance anymore.

This is a very simple thing to do. Just go to src/wild_encounter.c, Ctrl+F ABILITY_SYNCHRONIZE and delete the 3rd condition stated there.

From this:
Code:
if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)
        && GetMonAbility(&gPlayerParty[0]) == ABILITY_SYNCHRONIZE
        && Random() % 2 == 0)

It'll become this:
Code:
if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)
        && GetMonAbility(&gPlayerParty[0]) == ABILITY_SYNCHRONIZE)

And that's pretty much it.

The credits for this go to Fontbane.
They dropped the tip in a certain Discord server and I decided to post it here as well, because there's no reason not to.

EDIT (16/12/2022): Fixed a typo. Thanks to Snowcloud1 for pointing it out.​
 
Last edited:
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
BW Repel

Whenever the Repel's effect wears off, a prompt will appear asking player if they wish to use another one. Similarly to my old pre-decomp implementation, this one also lets you choose which Repel(Regular, Super, Max) to use. Obviously, if you have only one kind, this part is skipped.

Code:
src/script_menu.c DrawMultichoiceMenu
I modified the function, so it works with custom menu options, in ours case Repels ones. Change that part to:
Spoiler:

Now
Code:
data/scripts/repel.inc
Spoiler:

Screenshots:
Spoiler:

I also have the code in my github branch called repel, so you can pull directly from it.
this one didn't work for me. it don't ask me if I want to use another repel...
EDIT: Solved, i didnt do a "make -j2", just a "make NODEP=1"
sorry for that
 
Last edited:
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
Evolution Moves (Emerald)​
In the gen VII games many Pokemon have level up moves that they learn upon evolving, regardless of what level they are. This is a fantastic addition because it means Pokemon like Feebas don't stay useless if they evolve a level too late to learn their first damaging move.

To implement this in Emerald, first open include/pokemon.h and add an extra input argument to the function "MonTryLearningNewMove":
Code:
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove, bool8 isEvolving);

Next, modify all code that calls this function to include a third input argument. There are two instances in src/evolution_scene.c where this should be set to "1", like so:
Code:
var = MonTryLearningNewMove(mon, gTasks[taskID].tLearnsFirstMove, [B][COLOR="Red"]1[/COLOR][/B]);
All other instances should be set to "0". These can be found in src/party_menu.c, src/battle_script_commands.c, and src/daycare.c.

Following that, open pokemon.c and navigate to the function "MonTryLearningNewMove". Replace it with the following:
Spoiler:
Finally, add some evolution moves to src\data\pokemon\level_up_learnsets.h. These must be the first entries in each Pokemon's list, and must be learned at level zero e.g.
Spoiler:

i've been trying to add this system, but the version used here is outdated and it makes my pokémon learn no moves at all
i tried this:
Code:
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove, bool8 isEvolving)
{
    u16 moveLevel;
    u32 retVal = 0;
    u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
    u8 level = GetMonData(mon, MON_DATA_LEVEL, NULL);
	moveLevel = (gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV);

    // since you can learn more than one move per level
    // the game needs to know whether you decided to
    // learn it or keep the old set to avoid asking
    // you to learn the same move over and over again
    if (firstMove)
    {
        sLearningMoveTableID = 0;
    // Added evolution moves; Pokemon will learn moves listed at level zero upon evolution
		if(isEvolving && (moveLevel > 0))
		{
			while ((gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV) != (level << 9))
			{
				sLearningMoveTableID++;
				if (gLevelUpLearnsets[species][sLearningMoveTableID] == LEVEL_UP_END)
					return 0;
			}
		}
		else if(isEvolving && (moveLevel == 0))
		{
			while ((gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV) != (level << 9))
			{
				sLearningMoveTableID++;
				if (gLevelUpLearnsets[species][sLearningMoveTableID] == LEVEL_UP_END)
					return 0;
			}
		}
		else

			if ((gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV) == (level << 9))
			{
				gMoveToLearn = (gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_ID);
				sLearningMoveTableID++;
				retVal = GiveMoveToMon(mon, gMoveToLearn);
			}
	}

    return retVal;
}
 

Lunos

Random Uruguayan User
3,114
Posts
15
Years
Evolution Moves (Emerald)​
Back in July 2018, Sagiri made an implementation of Evolution Moves for Pokémon Fire Red via C Injection.
Not so long ago, UltimaSoul ported it to Pokeemerald.
Today I got their permission to drop over here a commit of mine, showing pretty quickly that implementation of Evolution Moves as an alternative to Buffel's.

It's nothing particularly complicated, just 3 simple changes and then it's a matter of setting the Evolution Moves in the src/data/pokemon/level_up_learnsets.h file.
https://github.com/LOuroboros/pokeemerald/commit/b67b5bdd1d5d893c1cbe26386658094a8d1f3f84

Quick demonstration:


And that's pretty much it.


EDIT (27/07/2020): The commit linked above will not work on a clean copy of Pokeemerald. That was my mistake. I should have tested it better when I wrote this post.
It took some time until that fact was brought to my attention by user Funny Valentine, but hey, better late than never, right?

Here's an alternative commit, tested on a clean copy of Pokeemerald. It'll work there.
https://github.com/LOuroboros/pokeemerald/commit/d5f48a1af85be80f01ff2c3adde121db924727d1

Shout-out to ExpoSeed who helped me getting it to work.​
 
Last edited:
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024

Back in July 2018, Sagiri made an implementation of Evolution Moves for Pokémon Fire Red via C Injection.
Not so long ago, UltimaSoul ported it to Pokeemerald.
Today I got their permission to drop over here a commit of mine, showing pretty quickly that implementation of Evolution Moves as an alternative to Buffel's.

It's nothing particularly complicated, just 3 simple changes and then it's a matter of setting the Evolution Moves in the src/data/pokemon/level_up_learnsets.h file.
https://github.com/LOuroboros/pokeemerald/commit/b67b5bdd1d5d893c1cbe26386658094a8d1f3f84

Quick demonstration:


And that's pretty much it.​

That still doesn't work for me.
It gives me an error with the ".level" and ".move" things, and when i replace them with the " & LEVEL_UP_MOVE_ID" and " & LEVEL_UP_MOVE_LV" that the original script uses, it just freezes when the Pokémon is learning the move...
 

Lunos

Random Uruguayan User
3,114
Posts
15
Years
That still doesn't work for me.
It gives me an error with the ".level" and ".move" things, and when i replace them with the " & LEVEL_UP_MOVE_ID" and " & LEVEL_UP_MOVE_LV" that the original script uses, it just freezes when the Pokémon is learning the move...
I'm pretty sure I told you this in a different thread, but you seemed to be using an old version of Pokeemerald, at least back then.
Try it on the latest repository of Pokeemerald, it should work.
 
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
Set Trainer's Levels Dynamically POKEEMERALD
how to implement it?
just go to src/battle_main.c and inside of CreateNPCTrainerParty, define this:
Code:
	u8 reallevel = 0;
	u8 fixedLVL = 0;
	{
	if (GetMonData(&gPlayerParty[5], MON_DATA_SPECIES) != SPECIES_NONE)
		fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[1], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[2], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[3], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[4], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[5], MON_DATA_LEVEL)) / 6;
	else if ((GetMonData(&gPlayerParty[5], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[4], MON_DATA_SPECIES) != SPECIES_NONE))
			fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[2], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[3], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[4], MON_DATA_LEVEL)) / 5;
		else if ((GetMonData(&gPlayerParty[4], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[3], MON_DATA_SPECIES) != SPECIES_NONE))
			fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[2], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[3], MON_DATA_LEVEL)) / 4;
			else if ((GetMonData(&gPlayerParty[3], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[2], MON_DATA_SPECIES) != SPECIES_NONE))
				fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[2], MON_DATA_LEVEL)) / 3;
				else if ((GetMonData(&gPlayerParty[2], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[1], MON_DATA_SPECIES) != SPECIES_NONE))
					fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)) / 2;
					else if ((GetMonData(&gPlayerParty[1], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES) != SPECIES_NONE))
						fixedLVL = GetMonData(&gPlayerParty[0], MON_DATA_LEVEL);
	}
Now, search "CreateMon(&party, partyData.species" and replace the whole line with this:
Code:
                CreateMon(&party[i], partyData[i].species, reallevel, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0);
now, right before those lines, put this:
Code:
			    {
					min = fixedLVL-2;
					max = fixedLVL+2;
				        range = max - min + 1;
				        rand = Random() % range;
				}

				if (min <=0)
					min=1;
				reallevel = min + rand;
now, modify the "-2" in the first one, and put a -4 or a -3 (this will be the minimum level that the trainer will have) and in the last one, change the +2 for a +3 or a +4.
this is for making regular trainers weaker and gym leaders, rivals and elite 4 stronger and making the game harder without having to grind so much... because you don't have to grind at all...

PD: I don't know if i can post this here, because it already has its own page but, i wanted to contribute
 
Last edited:
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
Set Wild Pokémon's Levels Dynamically POKEEEMERALD
And now, you'll learn how to make Wild Pokémon's level being around the same as yours, and is easier than trainer's one...
just go to
Code:
src\wild_encounter.c
and search this:
Code:
static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon)
Now, just replace this part:
Code:
    // Make sure minimum level is less than maximum level
    if (wildPokemon->maxLevel >= wildPokemon->minLevel)
    {
        min = wildPokemon->minLevel;
        max = wildPokemon->maxLevel;
    }
    else
    {
        min = wildPokemon->maxLevel;
        max = wildPokemon->minLevel;
    }
    range = max - min + 1;
    rand = Random() % range;
with this:
Code:
	u8 fixedLVL = 0;
	{
	if (GetMonData(&gPlayerParty[5], MON_DATA_SPECIES) != SPECIES_NONE)
		fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[1], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[2], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[3], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[4], MON_DATA_LEVEL) + GetMonData(&gPlayerParty[5], MON_DATA_LEVEL)) / 6;
	else if ((GetMonData(&gPlayerParty[5], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[4], MON_DATA_SPECIES) != SPECIES_NONE))
			fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[2], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[3], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[4], MON_DATA_LEVEL)) / 5;
		else if ((GetMonData(&gPlayerParty[4], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[3], MON_DATA_SPECIES) != SPECIES_NONE))
			fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[2], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[3], MON_DATA_LEVEL)) / 4;
			else if ((GetMonData(&gPlayerParty[3], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[2], MON_DATA_SPECIES) != SPECIES_NONE))
				fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[2], MON_DATA_LEVEL)) / 3;
				else if ((GetMonData(&gPlayerParty[2], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[1], MON_DATA_SPECIES) != SPECIES_NONE))
					fixedLVL = (GetMonData(&gPlayerParty[0], MON_DATA_LEVEL)+GetMonData(&gPlayerParty[1], MON_DATA_LEVEL)) / 2;
					else if ((GetMonData(&gPlayerParty[1], MON_DATA_SPECIES) == SPECIES_NONE) && (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES) != SPECIES_NONE))
						fixedLVL = GetMonData(&gPlayerParty[0], MON_DATA_LEVEL);
	}

    // Make sure minimum level is less than maximum level
    {
        min = fixedLVL-3;
        max = fixedLVL+3;
    }
	if (min <= 0)
		min = 1;
    range = max - min + 1;
    rand = Random() % range;
And that's it! now Wild Pokémon's levels will be minor by 3 or mayor by 3 to yours. if the "min" value is equal or minor than 0, it'll be set to one, just for the optimal calculations and a wild pokémon not having level 0 or 57.
 
Back
Top