- 250
- Posts
- 7
- Years
- Seen Apr 23, 2025
I've developed a simple (and not all that pretty) tool that can give you the ability to randomize the type matchups within your Pokeemerald decomp project! This means that Fire might be super-effective against Water, Normal might be immune to Normal, and Dragon might resist Dragon. Who knows what will happen? Whatever the result, it will completely revolutionize how you will have to strategize and play through your ROM hack.
How it Works:
How to Use:
Limitations:
Download:
Updates:
6/12/21: Fixed issue where sym_ewram.txt would fail to compile due to using CRLF new lines rather than LF.
How it Works:
Spoiler:
This software will edit the battle_util.c, sym_ewram.txt, and optionally main_menu.c files of your project, adding in a function that, when called, will randomly choose one type-matchup-table from a randomly generated list of tables to use in place of the normal matchup-table (battle_util.c). You can choose to have this random choice occur when the player starts a new game, or you may choose to have this randomization occur at a point in time of your choosing by directly placing the function somewhere in your project's code (main_menu.c). This process requires changing the normal type-matchup table from being a constant array to being considered EWRAM data so that it can be dynamically changed (sym_ewram.txt).
How to Use:
Spoiler:
Before you start using the software at all, make sure you have the Battle Engine Upgrade on your project, and that the following lines of code exist in the given files and look exactly as I have written them. If they aren't, problems will occur. If you don't have these lines of code, let me know, and I'll try to guide you through reorganizing to make the tool work. These lines kind of act as checkpoints for the software so as to write code in the proper places. With all of this said, I hope it's obvious to infer that you shouldn't mess with these lines of code, nor any code added via the tool, without using the tool itself.
src/battle_util.c:
src/main_menu.c:
sym_ewram.txt:
1. Click on the "Find Project Folder" button and choose the folder that contains your decomp project. For example, if the src folder for my project was at C:\PokemonHacking\pokeemerald\src, I would select the "pokeemerald" folder as my project folder. The directory path to this folder should show up below the button, like this:![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15313-28a3fe4cf3c3f82f9ba636fe7a9e0fcc.jpg)
2. Next, in the Number of Random Tables textbox, you enter the number of tables you want to generate, with a minimum of 1 and a maximum of 1,000. One table represents one possible layout of type matchups for every type. One table could have Normal resisting Normal, while another could have Normal being super-effective against Normal. Each table is guaranteed to be notably different from each other, so you don't have to worry about having two tables that are identical except for one single matchup. Each time the randomizing function is run, it will pick from one of these tables, so the more tables you have, the less likely you will be to encounter the same type-matchup layout again. Of course, the more tables you have, the more space you take up, so it's your choice how many you want. I want 100 tables, so now it looks like this:![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15314-ea35579751cdae70ba644d904fdd71fe.jpg)
3. After that, you choose whether or not you would like the type-matchups to be automatically randomized at the start of a new game. Check the box if you do, leave it blank if you don't. I think I do want to randomize the matchups at the start of a new game, so I'll mark the box:![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15315-4b6da943b9ba1bc3d3e048a98ba1fb98.jpg)
4. Now comes a critical decision: Balance or Chaos? A Balanced randomization makes sure no type has too many immunities, resistances, etc. If you want to see the specific limitations, you can read them in this spoiler:
A Chaos Randomization, on the other hand, will not care about a type having too many immunities or too few resistances. It is all random chance. One type might be immune to every other type and deal only super-effective damage. It's unlikely, admittedly, but not impossible with this method. Any one given matchup has an equal chance of dealing neutral, resisted, super-effective, or no damage. Only choose this method if you really want an off-the-wall kind of playthrough. I'm going to keep the randomization balanced, so I won't change anything compared to the last picture.
5. Click the Insert Random Tables button. If you chose a high number of tables to generate, it may take a couple of seconds, but you will eventually see a message saying "Randomization successfully completed!", like so:![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15316-7334c10bd9be6ce56106f1ac82701d89.jpg)
6. If, at some point, you wish to remove this randomization from your project entirely, just click the Remove Randomization button. It will remove all of the changes that were made to implement the randomization and print a simple message:![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15317-8845f6c3bf8d4dcf7ceafc8ace81e03d.jpg)
If you chose not to have the type-matchups be randomized at the start of a new game, you can do this instead:
1. Go to src/scrcmd.c and, somewhere immediately above or below this:
Write "extern void RandomizeTypeEffectiveness(void);"
2. At the bottom of this file, write:
3. Go to asm/macros/event.inc and, at the bottom of this file, write:
Now, you can simply write "randomizetypes" within an event script to randomize the type-matchup table whenever you want! If you really wanted to be cruel, you could randomize the types multiple times throughout a single playthrough by calling this script multiple times. Keep in mind that, if you want to remove the randomization later, the Remove Randomization button will not remove these changes, so you'll have to remove them yourself.
src/battle_util.c:
Code:
#undef X
src/main_menu.c:
Code:
static u8 sBirchSpeechMainTaskId;
.........................................................
default:
gPlttBufferUnfaded[0] = RGB_BLACK;
sym_ewram.txt:
Code:
.include "src/rayquaza_scene.o"
1. Click on the "Find Project Folder" button and choose the folder that contains your decomp project. For example, if the src folder for my project was at C:\PokemonHacking\pokeemerald\src, I would select the "pokeemerald" folder as my project folder. The directory path to this folder should show up below the button, like this:
![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15313-28a3fe4cf3c3f82f9ba636fe7a9e0fcc.jpg)
2. Next, in the Number of Random Tables textbox, you enter the number of tables you want to generate, with a minimum of 1 and a maximum of 1,000. One table represents one possible layout of type matchups for every type. One table could have Normal resisting Normal, while another could have Normal being super-effective against Normal. Each table is guaranteed to be notably different from each other, so you don't have to worry about having two tables that are identical except for one single matchup. Each time the randomizing function is run, it will pick from one of these tables, so the more tables you have, the less likely you will be to encounter the same type-matchup layout again. Of course, the more tables you have, the more space you take up, so it's your choice how many you want. I want 100 tables, so now it looks like this:
![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15314-ea35579751cdae70ba644d904fdd71fe.jpg)
3. After that, you choose whether or not you would like the type-matchups to be automatically randomized at the start of a new game. Check the box if you do, leave it blank if you don't. I think I do want to randomize the matchups at the start of a new game, so I'll mark the box:
![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15315-4b6da943b9ba1bc3d3e048a98ba1fb98.jpg)
4. Now comes a critical decision: Balance or Chaos? A Balanced randomization makes sure no type has too many immunities, resistances, etc. If you want to see the specific limitations, you can read them in this spoiler:
Spoiler:
Immunities: A given type will be immune to no more than 2 types, and there can only be a maximum of 1 type that is immune to the given type's damage.
Resistances: A given type will be resistant to no more than 10 types, and there will be anywhere between 1 to 7 types that resist the given type's damage.
Neutralities: A given type will receive normal damage from anywhere between 4 to 16 types, and there will be anywhere between 7 to 15 types that take normal damage from the given type.
Effectivenesses (that's not a word....): A given type will receive super-effective damage from anywhere between 1 to 5 types, and there can only be a maximum of 5 types that receive super-effective damage from the given type.
Any one given matchup has a 60% chance of dealing neutral damage, 20% chance of dealing resisted damage, 15% chance of dealing super-effective damage, and 5% chance of dealing no damage.
Resistances: A given type will be resistant to no more than 10 types, and there will be anywhere between 1 to 7 types that resist the given type's damage.
Neutralities: A given type will receive normal damage from anywhere between 4 to 16 types, and there will be anywhere between 7 to 15 types that take normal damage from the given type.
Effectivenesses (that's not a word....): A given type will receive super-effective damage from anywhere between 1 to 5 types, and there can only be a maximum of 5 types that receive super-effective damage from the given type.
Any one given matchup has a 60% chance of dealing neutral damage, 20% chance of dealing resisted damage, 15% chance of dealing super-effective damage, and 5% chance of dealing no damage.
A Chaos Randomization, on the other hand, will not care about a type having too many immunities or too few resistances. It is all random chance. One type might be immune to every other type and deal only super-effective damage. It's unlikely, admittedly, but not impossible with this method. Any one given matchup has an equal chance of dealing neutral, resisted, super-effective, or no damage. Only choose this method if you really want an off-the-wall kind of playthrough. I'm going to keep the randomization balanced, so I won't change anything compared to the last picture.
5. Click the Insert Random Tables button. If you chose a high number of tables to generate, it may take a couple of seconds, but you will eventually see a message saying "Randomization successfully completed!", like so:
![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15316-7334c10bd9be6ce56106f1ac82701d89.jpg)
6. If, at some point, you wish to remove this randomization from your project entirely, just click the Remove Randomization button. It will remove all of the changes that were made to implement the randomization and print a simple message:
![[PokeCommunity.com] [TOOL] Type Matchup Randomizer [PokeCommunity.com] [TOOL] Type Matchup Randomizer](https://data.pokecommunity.com/attachments/15/15317-8845f6c3bf8d4dcf7ceafc8ace81e03d.jpg)
If you chose not to have the type-matchups be randomized at the start of a new game, you can do this instead:
1. Go to src/scrcmd.c and, somewhere immediately above or below this:
Code:
extern const SpecialFunc gSpecials[];
extern const u8 *gStdScripts[];
extern const u8 *gStdScripts_End[];
2. At the bottom of this file, write:
Code:
void ScrCmd_randomizetypes(void)
{
RandomizeTypeEffectiveness();
}
3. Go to asm/macros/event.inc and, at the bottom of this file, write:
Code:
.macro randomizetypes
callnative ScrCmd_randomizetypes
.endm
Now, you can simply write "randomizetypes" within an event script to randomize the type-matchup table whenever you want! If you really wanted to be cruel, you could randomize the types multiple times throughout a single playthrough by calling this script multiple times. Keep in mind that, if you want to remove the randomization later, the Remove Randomization button will not remove these changes, so you'll have to remove them yourself.
Limitations:
Spoiler:
1. This only runs on Windows. Sorry, my computer runs on Windows and I like programming in C#, so that's the operating system I usually program for. If a lot of people want this tool for Mac or Linux, I might re-write this code in Java to allow for cross-platform capabilities.
2. This only works if you are using the Battle Engine Upgrade. This is due to the fact that, without the BEU, the type effectiveness data is held in battle_main.c rather than battle_util.c, and is organized in a different fashion. Again, if a lot of people want this tool to be non-BEU compatible, I can set that up.
2. This only works if you are using the Battle Engine Upgrade. This is due to the fact that, without the BEU, the type effectiveness data is held in battle_main.c rather than battle_util.c, and is organized in a different fashion. Again, if a lot of people want this tool to be non-BEU compatible, I can set that up.
Download:
Spoiler:
Dropbox Link: WindowsRandomType.exe
FYI: You're probably going to get some warnings when you download and/or when you run this software. This is due to this file being a standalone .exe file with no licensed publisher. I can honestly say that I'm not putting viruses on your computer, but if this makes you a bit too uneasy, I'm sorry, but there's not much I can do about that.
FYI: You're probably going to get some warnings when you download and/or when you run this software. This is due to this file being a standalone .exe file with no licensed publisher. I can honestly say that I'm not putting viruses on your computer, but if this makes you a bit too uneasy, I'm sorry, but there's not much I can do about that.
Updates:
6/12/21: Fixed issue where sym_ewram.txt would fail to compile due to using CRLF new lines rather than LF.
Last edited: