Making Pokemon Emerald my own one tweak at a time - Scarlet's March of gaming

abanber.jpg

In the month of March I had such lofty ideals, as I often do. I said to myself “I really want to beat Skyrim”, and I really did want to. I got the game downloaded, and as I sat through Brynjolf's iconic monologue in the ever-romantic horse-drawn carriage ride, a further intrusive thought emerged. I don’t know where it came from, and I don’t know why it appeared as I watched a man try to escape captivity and shortly thereafter get shot by an Imperial arrow. I wanted to make a Pokemon Emerald ROM hack. In that moment I closed the game and jumped onto Google, so instead of my usual jaunt of talking about old games and discovering a few new gems for my collection, I wanted to instead take some time to talk about my first real dive into the world of Pokemon ROM hacking in this glorious era of decompiled games.

As a bit of a precursor I will mention that you don’t need programming experience to poke around and make some simple changes, though it surely doesn’t hurt. Available over at the pokeemerald GitHub repo you can find the vast majority of the game’s underlying workings transcribed to some pretty damn readable C code. I won’t pretend to understand the process of decompiling a game and getting it to this state, but the folks behind this project have made it entirely trivial for anybody to follow a simple list of instructions and build the game for themselves. With such power, how could I not want to poke around a little and fine-tune this already-great game to my liking?

title.png

Now while I am technically a professional programmer, my domain is largely the more intuitive language of C++, and beyond that I’m used to working in considerably smaller files than these 3000+ line behemoths. Even so, you might be surprised at just how easily you can add in a new feature or two by just hitting your head against the wall and searching for words. My first hack of sorts had four major objectives to get me going: implementing a level cap, an experience multiplier, adding in new natures, and for a bit of fun, making it so the Focus Band’s effect is always active.

If you managed to follow the instructions on the setup page, what you’ll be looking at is a built “pokeemerald.gba” ROM, and a whole bunch of files you don’t know what to do with. To make the project a bit easier to navigate, you’ll want to pick an IDE to load it into, with one of the more accessible (and free!) being Visual Studio Code. This is basically a lightweight code editor with a bunch of plugins you can use that’s able to load the full breadth of the project for you. This lets you move quickly between files, but perhaps more importantly for surface level edits like what we have planned here, lets you search for keywords through the entire project. This is really important if you operate the way I do.

Adding More RNG!

We’re basically all setup now, so let’s actually get started on making some edits; making the Focus Band always active seems like a good first task. If you’ve managed to sleep on this item, it’s one of very few viable items for competitive battling in Gen 3, and is held by a colossal 80 Pokemon in the Battle Tower (and 24 in Trainer Hill if you remember that’s a thing that exists in Emerald). Its purpose? To provide you with a 10% chance to survive any hit. A reusable 10% chance I might add. It throws in that bit of extra spice that Pokemon battling really needed on top of the variable damage formula and random critical hit chance. So where do we start? With the decompilation being labelled so well, searching for “FOCUS_BAND” across the project seems like a good place. You can do this in VS Code by clicking on the Search button on the left bar, or pressing Ctrl+Shift+F. And would you look at that, 150 results in 22 files!

focusbandsearch.png 1_focusband.png

This usage is split between a few different variables, and the way it works is actually pretty simple to follow. “ITEM_FOCUS_BAND” is the value that’s used to say the item is being held, and if it is being held, the hold effect is set to “HOLD_EFFECT_FOCUS_BAND”. Following that, the hold effect of the currently held item is checked against all known values in the “battle_script_commands.c” file to see which effect should happen. For the Focus Band in particular, it rolls a random number between 0 and 99, and if the value is less than 10, the effect triggers. We want this 10% check to remain intact, but we can kill the check for actually holding the Focus Band.

2_focusbandcode.png

And that’s basically it. There are five places where “HOLD_EFFECT_FOCUS_BAND” is checked for, so we just remove those and the game thinks we’re always holding the Focus Band. We’ve not messed with much more here, so other hold items should continue to work fine alongside this effect. If you wanted to be the most thorough, you can also edit the message that pops up when that 10% chance triggers, and this is again just a simple search for the relevant text. In “battle_message.c” you’ll find the appropriate message "{B_DEF_NAME_WITH_PREFIX} hung on\nusing its {B_LAST_ITEM}!". The {B_LAST_ITEM} is the key part we need to remove, since having no item will result in the message saying “Pokemon hung on using its ????????????!”, and that’s less than ideal. Changing it to say willpower or friendship is pretty fitting, but with that we’re done. Save your changes, remake the ROM and jump into battle. You should notice that every so often both you and your opponent won’t faint from a lethal hit, along with your custom survival message.

Changing the Natural Order

Moving onto my next goal, adding new natures largely followed a similar pattern. The idea here is that if we want to make a new nature we should probably search for instances of an already-existing nature and copy what they do, and a search for “BASHFUL” gives some good results.

5_naturesearch.png

From our search we can conclude that natures are stored as “NATURE_BASHFUL”, and there are nine places we’ll need to edit to put a new one in. A lot of these are pretty minor, like which type of AI the Pokemon will use in Battle Palace, so you don’t really need anything bespoke. Reusing another nature’s values that you feel fit close enough will do fine. The real point of interest for me is the “gNatureStatTable” value in “pokemon.c”. This is actually how the stat-altering effects of the natures are applied, with 0 meaning no change, +1 being a 10% boost, and -1 being a 10% reduction. By adding in your new nature to this table, you can have any assortment of stat boosts and reductions; you aren’t limited to one of each! I decided to have a Lucky and Unlucky nature myself, with these providing a boost and reduction to all stats respectively.

3_naturecode1.png

If you wanted to take this a step further, there’s a few other things you could do. By searching for where the “gNatureStatTable” value is used, you can see there’s only a few places where the stats are calculated. There’s nothing stopping you from having other values in this table between -128 and 127, and adding them into any place where these checks are done. I plan to mess with this further to have special natures to debuff particularly strong Pokemon, and the simplest way of doing this would be to have a -2 value that reduces certain stats by 20% as opposed to the standard 10%. You’d then alter the “PickWildMonNature” function to only use those natures with certain species. A bit more involved for sure, but with the code at your fingertips the sky really is the limit if you have the patience to poke around and figure things out.

4_naturecode2.png

I did actually edit PickWildMonNature myself to make my new natures appear as a separate 1/100 check

Making Nuzlocke Players Actually Fight Trainers

My last two changes of this post go somewhat hand in hand. In recent times, nuzlocking, the act of beating a Pokemon game with a number of set restrictions, has moved on a little. Gone are the days of forming an attachment with your team and getting through the games by any means necessary. Nowadays “hardcore nuzlockes” are all the rage on YouTube, and a large component of these playthroughs are a level cap that restricts your team’s level to the strongest Pokemon of the next gym leader’s party. These level limits are self-imposed, and these players often use Rare Candies to ensure their whole team is at the limit for the boss fight. We can do better.

The easiest way I could find for implementing a level cap was to just ensure a Pokemon didn’t level up unless we had enough badges. This means any experience gained while at the level cap will still be stored, and then be used after the next badge was obtained. There’s actually only two places edits need to be made here, and the flags we need to check already exist for each gym badge. After a bit of searching, I landed in the “battle_controller_player.c” and “pokemon.c” files, the former handling the act of levelling up in battle, and the latter being something I only really stumbled upon after a bit of play testing.

levelcap.png

When you gain experience in battle, your current experience and gained experience are added together to check if you’re beyond a threshold to level up. If you are, that satisfying ping of the experience bar will play, and your stats will be boosted. We’re keeping all of that, but just adding in a check to see which badges we have. If we have Badge 8, our level cap is 58. Badge 7 means a level cap of 46, and so on. We then just tack this onto the check, and we’ll only level up if we’re below the level cap. Nice! The changes to “pokemon.c” are a little less intuitive, but they do make sense. You see a Pokemon in the PC is stored differently to a Pokemon in your party. The game basically trims the fat and leaves the essential data to be able to recalculate what your Pokemon’s data will be when it’s in your party. The level is part of the fat that’s trimmed; it doesn’t need to be stored when it can always be recalculated using the Pokemon’s experience. With that in mind, we throw in the same bit of code for the level cap in the "GetLevelFromMonExp" function, and to my eye we’re set. Pokemon level up fine to the level cap, and then are frozen in time until you’ve beaten the respective gym. After that they’ll gain a slurry of stored experience all at once.

Now that’s out of the way, let’s look at tackling the use of Rare Candies. I get it, grinding is tiresome. So let’s just multiply the gained experience by, say, eight. On top of this, we can make it that you gain no experience for fighting wild Pokemon. I think this is actually pretty balanced, and a bit more of a fun approach when compared to using Rare Candies. This basically means that grinding isn’t a chore, but it also means that you do need to pick and choose some optional trainers to fight between your big challenges. It keeps the game fresh and challenging, and it’s just three lines of code! This one took me more tracking down than I’d care to admit, but it culminated in the below lines in the “battle_script_commands.c” file. It looks so simple, and that’s really because it is! A weird note is that gBattleMoveDamage is used to store the gained experience for some reason, and it needs to be set to 1 for wild Pokemon as opposed to 0 to avoid a softlock if you’ve gained 0 experience but are already over the threshold for levelling up… A conundrum I introduced myself with the previous tweak.

expboost.png

But that’s it for my first ROM hack. I didn’t change much, but I’ve made a version of Pokemon Emerald that really is to my own taste, and it’s only going to grow as I think up more weird things to do. I’m certain that everything I’ve done has been done before, but I had a great time figuring it out for myself (and subsequently trying to explain it here!). If you want a bit more guidance, I can wholeheartedly recommend checking out the Simple Modifications Directory over at PokeCommunity for a stellar catalogue of tweaks with instructions for adding them to your game. Paired with PoryMap to serve as a really in-depth map editor for the decompilation, and the ability to use git to be able to more easily track your changes and make backups, Pokemon ROM hacking has never been so accessible. If you’ve found any of this interesting, I can only recommend giving it a go for yourself. It’s been a great month for me of poking around in my spare time, and slowly coming to terms with the delightful language of C.

See You Next Month!

So that was my March. I did play a few other things, but with this being so interesting to me I wanted to really shine a spotlight on it. I’ll be back next month with some pretty heavy JRPG gaming having recently downloaded Final Fantasy 7 Remake on Steam. Will I actually manage to get through such a game with my limited time and motivation? We’ll find out at the end of April!
 

Flame

Me > You
Global Moderator
Joined
Jul 15, 2008
Messages
7,311
Trophies
3
XP
18,886
Nintendo/game freak/Pokémon company needs to do a new Pokémon game in gen 3 engine...

Or at least release gen 3 on switch online
 

Jayro

MediCat USB Dev
Developer
Joined
Jul 23, 2012
Messages
12,989
Trophies
4
Location
WA State
Website
ko-fi.com
XP
17,030
Country
United States
I'd love it if someone could change the annoying horn music into something that sounds pleasing. It's my biggest grievance against gen 3.
 

Flame

Me > You
Global Moderator
Joined
Jul 15, 2008
Messages
7,311
Trophies
3
XP
18,886
I'd love it if someone could change the annoying horn music into something that sounds pleasing. It's my biggest grievance against gen 3.

I'm no expert, but isn't music like the hardest part of GBA modding. You are limited to so much. Of course, that's if you want your game to work on a GBA itself?
 

Jayro

MediCat USB Dev
Developer
Joined
Jul 23, 2012
Messages
12,989
Trophies
4
Location
WA State
Website
ko-fi.com
XP
17,030
Country
United States
I'm no expert, but isn't music like the hardest part of GBA modding. You are limited to so much. Of course, that's if you want your game to work on a GBA itself?
Real hardware compatibility is definitely preferred, yes.
 

raxadian

Well-Known Member
Member
Joined
Nov 10, 2018
Messages
4,366
Trophies
1
Age
41
XP
4,578
Country
Argentina
Sorry, there is just so many amazing Pokemon fan games and hacks out there that this doesn't impress me at all.

For a Pokemon Emerald hack that makes me go "Holy fuck, this is amazing" there are a few out there, unfortunately they also happened to make the games extra hard and I was never one for playing a game just because it is hard, I play games because it is fun.

Honesty there is people out there not only making Custom Sprites for Pokemon GBA games, but backporting content from future Pokemon generations!

The amount of content and dedication that some people puts into that is actually kind of insane, so this feels like watching a soda and vinegar volcano experiment at a science fair.

I am like "Cute, but the kid in front of you made an actual robot!"
 
Last edited by raxadian,

Sir Tortoise

Well-Known Member
Member
Joined
Jan 5, 2016
Messages
150
Trophies
0
XP
1,317
Country
Sorry, there is just so many amazing Pokemon fan games and hacks out there that this doesn't impress me at all.

For a Pokemon Emerald hack that makes me go "Holy fuck, this is amazing" there are a few out there, unfortunately they also happened to make the games extra hard and I was never one for playing a game just because it is hard, I play games because it is fun.

Honesty there is people out there not only making Custom Sprites for Pokemon GBA games, but backporting content from future Pokemon generations!

The amount of content and dedication that some people puts into that is actually kind of insane, so this feels like watching a soda and vinegar volcano experiment at a science fair.

I am like "Cute, but yhe kid in front of you made an actual robot!"
Meanwhile volcano person has made a neat article showing how easy it is to get started. It's not a robot but it's also a hell of a lot better than this comment, which does not impress me at all.
 

eyeliner

Has an itch needing to be scratched.
Member
Joined
Feb 17, 2006
Messages
2,891
Trophies
2
Age
44
XP
5,540
Country
Portugal
Meanwhile volcano person has made a neat article showing how easy it is to get started. It's not a robot but it's also a hell of a lot better than this comment, which does not impress me at all.
That burn will leave a mark.

But it's true, the fact of telling people how to do it is a great effort.
 

porkiewpyne

Report-er
Supervisor
Joined
Jun 8, 2008
Messages
2,496
Trophies
2
XP
4,558
Country
Australia
Sorry, there is just so many amazing Pokemon fan games and hacks out there that this doesn't impress me at all.

For a Pokemon Emerald hack that makes me go "Holy fuck, this is amazing" there are a few out there, unfortunately they also happened to make the games extra hard and I was never one for playing a game just because it is hard, I play games because it is fun.

Honesty there is people out there not only making Custom Sprites for Pokemon GBA games, but backporting content from future Pokemon generations!

The amount of content and dedication that some people puts into that is actually kind of insane, so this feels like watching a soda and vinegar volcano experiment at a science fair.

I am like "Cute, but yhe kid in front of you made an actual robot!"
I generally refrain from speaking on behalf of others but in this case, I am certain you've missed the point of the article. It is not to show 1337 h4xX0r skills, but to demonstrate how far the decomp scene in the Pokemon romhack-o-sphere has come. The barrier to entry is lowered to the point where a newcomer can achieve quite major changes with relative ease. The floor may not be at the level of binary hacking's but the gap has certainly closed over the years
 

Scarlet

Onion Soup
OP
Editorial Team
GBAtemp Patron
Joined
Jan 7, 2015
Messages
5,161
Trophies
2
Location
Middleish North-Right
Website
scarlet.works
XP
14,865
Country
United Kingdom
I generally refrain from speaking on behalf of others but in this case, I am certain you've missed the point of the article. It is not to show 1337 h4xX0r skills, but to demonstrate how far the decomp scene in the Pokemon romhack-o-sphere has come. The barrier to entry is lowered to the point where a newcomer can achieve quite major changes with relative ease. The floor may not be at the level of binary hacking's but the gap has certainly closed over the years
Yeah this is basically it. It's something I've been doing this month that I thought was interesting, but as I said in the main post, pretty much everything I've done here will have already been done and probably documented better than me over at PokeCommunity. I kinda just wanted to show that my simple-minded approach does work for smaller edits, and that you don't necessarily need a wealth of knowledge to achieve it.
 

ChaosEternal

Well-Known Member
Member
GBAtemp Patron
Joined
Jul 27, 2015
Messages
567
Trophies
1
XP
2,899
Country
United States
Sorry, there is just so many amazing Pokemon fan games and hacks out there that this doesn't impress me at all.

For a Pokemon Emerald hack that makes me go "Holy fuck, this is amazing" there are a few out there, unfortunately they also happened to make the games extra hard and I was never one for playing a game just because it is hard, I play games because it is fun.

Honesty there is people out there not only making Custom Sprites for Pokemon GBA games, but backporting content from future Pokemon generations!

The amount of content and dedication that some people puts into that is actually kind of insane, so this feels like watching a soda and vinegar volcano experiment at a science fair.

I am like "Cute, but yhe kid in front of you made an actual robot!"
By that reasoning, the rom hacks shouldn't impress you either because they pale in comparison to the work of the people who made the decompilation in the first place.
 
  • Like
Reactions: Kirby6417

raxadian

Well-Known Member
Member
Joined
Nov 10, 2018
Messages
4,366
Trophies
1
Age
41
XP
4,578
Country
Argentina
By that reasoning, the rom hacks shouldn't impress you either because they pale in comparison to the work of the people who made the decompilation in the first place.

A lot of Pokemon hacks were made BEFORE the roms were decompilled. Sadly of those early hacks from the late 90s and early 2000s a lot have been lost. They may not have worked in real hardware but they were fun.
 

zxr750j

Longtime member
Member
Joined
Sep 29, 2003
Messages
936
Trophies
2
Location
Utrecht
XP
2,936
Country
Netherlands
Lovely read!
I like the rng-nature hack though a positive should also have a negative. So like if you raise the critical hit %, you also raise the damage done when receiving a crit yourself. And when your chance of hitting is reduced the damage is increased. I recently got a (real) emerald cartridge, I did want to do a play trough, now I'm doubting and might find me a nice romhack. I can dabble in python, but C is to hardcore for me I think.
 

RAHelllord

Literally the wurst.
Member
Joined
Jul 1, 2018
Messages
714
Trophies
1
XP
2,760
Country
Germany
Nice read, and nice to see the decomp and editing tools are getting better basically every year.

The amount of content and dedication that some people puts into that is actually kind of insane, so this feels like watching a soda and vinegar volcano experiment at a science fair.

I am like "Cute, but the kid in front of you made an actual robot!"
This sounds like you tried to make a soda and vinegar volcano yourself, failed at it, and now you're mad at other people actually succeeding at it. Really grasping at straws to make someone else look bad in comparison for not just showing a working soda and vinegar volcano but also explaining how people can make their own quite easily these days.
 

raxadian

Well-Known Member
Member
Joined
Nov 10, 2018
Messages
4,366
Trophies
1
Age
41
XP
4,578
Country
Argentina
This sounds like you tried to make a soda and vinegar volcano yourself

Science fairs are not a thing here and this is thread is not called a tutorial and says the creator already knows some kind of programing so why it should be posted in the main page when stuff like Star Fox EX isn't?

 
  • Like
Reactions: britain4

RAHelllord

Literally the wurst.
Member
Joined
Jul 1, 2018
Messages
714
Trophies
1
XP
2,760
Country
Germany
Science fairs are not a thing here and this is thread is not called a tutorial and says the creator already knows some kind of programing so why it should be posted in the main page when stuff like Star Fox EX isn't?


That was on the front page the day it released: https://gbatemp.net/threads/starfox...usic-enemies-more-to-the-snes-classic.621546/

I don't know about you but I don't think it needs to stay on the front page for over a year.

Also the title clearly says it's what Scarlet did in gaming during March, I'm not sure what groundbreaking news you expected to be there.
 

Charli

Well-Known Member
Member
GBAtemp Patron
Joined
Feb 16, 2011
Messages
106
Trophies
2
XP
1,429
Country
Germany
That's a neat project and a nice write up :) And I like your writing style, this was fun to read :D Oh, and this seems to me like time well spent, there are still other days to take an arrow to the knee in Skyrim ;P Cheers!
 
  • Haha
Reactions: Scarlet

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Mondooooo @ Mondooooo:
    wth is that?
  • bernard_kekette @ bernard_kekette:
    A version of ModMii
  • Mondooooo @ Mondooooo:
    and what is ModMii
  • bernard_kekette @ bernard_kekette:
    a tool to install WADs on the Wii
  • Mondooooo @ Mondooooo:
    nice
  • BakerMan @ BakerMan:
    WELCOME TO WARIO WORLD THE UNDERGROUND GBATEMP
    +2
  • Mondooooo @ Mondooooo:
    LMAO
  • Mondooooo @ Mondooooo:
    Wario world underground
  • K3Nv2 @ K3Nv2:
    Don't know why yellow potatoes come out so creamy when you roast them
  • AncientBoi @ AncientBoi:
    Did you soak them B4 hand?
  • AncientBoi @ AncientBoi:
    Cool. Though I'm Not the effeminate type. You know, the limp wrist, Sascha walking type of gay. :)
  • AncientBoi @ AncientBoi:
    Though I Do Cross-Dress Once in awhile :D
  • K3Nv2 @ K3Nv2:
    The home just confuses your wardrobe
  • AncientBoi @ AncientBoi:
    How are you doing today K3Nv2?
  • AncientBoi @ AncientBoi:
    You did? By whom?
  • AncientBoi @ AncientBoi:
    Ohh, Don't tell me lEOTck did it to you? :O:sad:
  • BakerMan @ BakerMan:
    nah we all know luke is who leo's smashing
    +1
  • AncientBoi @ AncientBoi:
    Oh :shit:! And I didn't get to 📽️ it! :angry::sad::cry: :hateit:
  • BakerMan @ BakerMan:
    GUYS I JUST FOUND OUT THAT ULTERIOR MOTIVES WAS FOUND YESTERDAY, AND IT WAS FROM P O R N 💀😭
    +1
  • AncientBoi @ AncientBoi:
    😱 .............................. :evil::tpi::evil:
    AncientBoi @ AncientBoi: 😱 .............................. :evil::tpi::evil: