Research & DevelopmentGot a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!

A while back, some hacker posted a thread here on the same topic - however they refused to release the source and instead used the thread to advertise their hack/brag. This isn't that. As far as I'm concerned Mega Evolution should function exactly like Gen 6 or it shouldn't be implemented at all. Despite this, Mega Evolution remains a popular "feature" in many hacks - hackers resort to using true evolutions instead of implementing them properly.

So before this becomes tl;dr, here is a video sample. Thanks to SphericalIce for letting me use the video from his hack, Pokémon Gaia.

This code works by hacking the existing evolution table. I added a custom evolution type (0xFE) that allows you to do Mega Evolutions. The variants (Wishing, standard Mega Evolution and Primals) are controlled by a unused halfword at the end of each evolution entry. The level argument is either an item (Mega Stone/Orb) or a move depending on this variant. Because I'm using the evolution table, it should be really easy to modify existing tools to edit these Megas.

I've also made it possible to use any item index as the Mega Accessory (it displays the Standard Mega evolution message) for aesthetic purposes.

This code is open source and available on my GitHub. I will port to Emerald when it's completed.

Right now, Mega Evolution is triggered by pressing Start when selecting an attack, which is reflected in the button. The button image is pretty simple to change, however the alternate palettes (for enabled and unusable) are determined by the code.

There are still a few bugs, and it doesn't work with link battles, so stay tuned for updates.

Documentation:

Configuration:

See the file src/config.h when doing the insertion step. There are a number of variable indices and item indices you can change there.

Where it says "#define XXX 0xSOMEHEXNUMBER" Change ONLY 0xSOMEHEXNUMBER and leave the rest the same so that the code can find your changes. KEYSTONE_PLAYER_VAR is the variable used to store the item index for the player's keystone and KEYSTONE_OPPONENT_VAR is the same, but for the opponent (see Usage below). If, for some reason, you set the variable for KEYSTONE_OPPONENT_VAR to 0, then the message for mega evolution will default to using whatever item index whatever you have in KEYSTONE_DEFAULT. By default this is configured to "Gold Teeth" so you'll probably want to change it (despite their awesome power). These variables help you with tiny story-telling details that are probably insignificant, but I judged them to be important in my perfectionism.

The remaining configuration options are for controlling the colours that are changed in the Mega Evolution healthbox addition in it's various states. You can change the sprite just by replacing the file in the "assets" folder. You then will probably need to change the colours here (and the number of colours you ignore) in these options. The code changes parts of the palette to a lighter variant or desaturates them entirely, so you need to set these correctly lest your sprite look funny. If you have changed your HP box at all, this might be necessary to change. I will add options for changing the relative X and Y position of this sprite if it becomes an issue.

Mega evolutions are made using the evolution table data. It is preferable to hex edit these until tool support is adequate (see this guide for how to do this with G3T). Megas have evolution type 0xFE, so that they remain separate from regular evolution types. The unknown hword in this structure should stay 0 for Mega Evolution. Types 1 and 2 are reserved for Primal Reversion and Rayquaza's (move based) Mega Evolution. The target species is the species you want to Mega Evolve into. This Pokemon should have the same Dex number as the original. Try not to change much. You should keep the gender ratio, name, base HP, level curve and learnset the same to prevent strange things from happening. The argument for the mega evolution is the item index of your Mega Stone or Primal Orb. In type 2's case it is the move index.

Next, you need to make the species revert back to their original state. You need to add another evolution table entry, this time to the Pokemon's Mega Form. This should be identical to the one above, except the target species is the non-mega form, and the item index/argument is 0. I did it this way for speed reasons at the cost of making the configuration more complicated - searching through all the evolution data takes too long and makes the game lag.

Lastly, you'll need the item. In config.h, you should have put two free variables you'll use for this hack. The first is for the keystone item index for the player, the second is for the enemy trainer. For the player, simply set this to the index of your mega bracelet/anklet/whatever. You can do this via a script when you award the player their keystone. The code will then check whether you have this item and disabled Mega Evolution if you do not. The enemy trainer is the same, except this won't perform checks. It only changes the item used in the message (like certain characters in ORAS and XY). If you wish to disable Mega Evolution for the player at whatever time, either remove their bracelet item, or set the variable to 0.

Closing notes:

Please submit any issues, bugs and feature requests (or rather, improvements; I don't want large feature requests. Keep it to new configuration settings and such) on GitHub. You'll need an account there, but it helps me track these bugs and mark them as solved. It also allows me to follow up on them better than in this thread. It also is easier for other people to look up issues there.

__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.

a couple of quick questions:
1. Does the pokemon revert after battle? (the video didn't show if it did or not)
2. How possible is it for the mega symbol to appear by their name?
3. Have you been able to make mega-evolution only possible once per battle?
of course, i understand that this code's in early stages, i'm just very curious

Wow this is great Touched! Thank you for sharing this! Also I have questions ^ what PurpleOrange said :D

Quote:

Originally Posted by PurpleOrange

holy crap! that's awesome! amazing work touched!!

a couple of quick questions:
1. Does the pokemon revert after battle? (the video didn't show if it did or not)
2. How possible is it for the mega symbol to appear by their name?
3. Have you been able to make mega-evolution only possible once per battle?
of course, i understand that this code's in early stages, i'm just very curious

this is really a great achievement, so kudos to you :)

let's just hope hackers use this in a good way

1) Not yet. I haven't added the necessary hooks yet. I have to make it expire when you faint too.
2) Bela made this, which I hope to emulate (haha)

The part on the left will appear if you can Mega Evolve.

3) Yeah, not yet; but it will be done.

I would also like to get this working for the AI sometime so that we can have fully working mega battles.

EDIT:

Quote:

Originally Posted by KDS

Great work on this. Can we use this for stance change?

Thanks. Yes, I suppose you could - I hadn't really thought of that. Maybe I'll add (optional, through preprocessor macros) stance change when the mega and primal part is complete.

__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.

another quick question, how will you go about doing this for rayquaza since it doesn't need a mega stone to evolve?

Rayquaza needs the move Dragon Ascent to evolve. I made it possible to have Mega Evolution variants - one of which checks if you have a certain move and lets you trigger mega Evolution if the Pokemon has learned that move.

I'm very sorry, I'm completely with the ASM programming, because there is no habit of taking notes, so the code is very messy, I think I should have to tidy it up, if use the time。

It would be nice to see it anyway. Or could you give us a patch?

UPDATE:
Anyway, this hack seems to be moving smoothly. I have it loading from the evolution table. The downside is that you need to define the evolution twice so that the reversion works. The Pokemon revert to their normal forms when you exit a battle or they faint so long as you have this extra entry - otherwise it's permanent.

Next up is making Primal Reversion and AI Mega Evolution!

__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.

UPDATE:
Anyway, this hack seems to be moving smoothly. I have it loading from the evolution table. The downside is that you need to define the evolution twice so that the reversion works. The Pokemon revert to their normal forms when you exit a battle or they faint so long as you have this extra entry - otherwise it's permanent.

Next up is making Primal Reversion and AI Mega Evolution!

Meh, unless people are Mega Evolving Eevee, the extra entries aren't going to be an issue. This is amazing by the way. Is AI Mega Evolution going to be super complicated to code? Because it seems like it's going to be. Awesome work, and thank you for always sharing all of your stuff with the community.

Just to clarify how the extra evolution slot works by way of example. Say I have a Charizard and want Charizard Y. I would add the Charizard evolution using evolution type 0xFE (Mega) and variant 0 (standard Mega Evolution - not sure any tools can edit that padding yet). We used Charizard Y as the target species for the evolution. Next we use the item (Charizardite) as the evolution argument. This is the first evolution. The second is for Charizard Y. We define the 0xFE and variant 0 evolution, with target species Charizard. The argument is 0, which means that it's reversion information. At the end of the battle, the code checks all your party Pokemon for whether they have reversion information and reverts them if they do.

Quote:

Originally Posted by Deokishisu

Meh, unless people are Mega Evolving Eevee, the extra entries aren't going to be an issue. This is amazing by the way. Is AI Mega Evolution going to be super complicated to code? Because it seems like it's going to be. Awesome work, and thank you for always sharing all of your stuff with the community.

I don't think it will be hard at all. Even in Gen 6, the AI just Mega Evolves at the first possible opportunity. I'm going to copy this and make a check before the opponent makes a move:

Code:

if (can_mega_evolve(current_pokemon)) {
trigger_mega_evolve();
}

So hopefully this shouldn't be too difficult.

__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.

If you want to maintain 6gen-style AI mega handling -- that AI is also programmed to never select his Mega pokemon until it is the very last standing. This can be blatantly seen by fighting Steven, and if he has 2 pokemon left (Metagross + something else), if that other pokemon cannot touch you at all, he will send it out, and then immediately switch it out.Personally I wouldn't bother with this though, it only makes the AI worse...

If you want to maintain 6gen-style AI mega handling -- that AI is also programmed to never select his Mega pokemon until it is the very last standing. This can be blatantly seen by fighting Steven, and if he has 2 pokemon left (Metagross + something else), if that other pokemon cannot touch you at all, he will send it out, and then immediately switch it out.Personally I wouldn't bother with this though, it only makes the AI worse...

Same with Sidney, Phoebe, Glacia, and Drake. They didn't send out their Megas until they were down to their last Pokémon.

__________________

"The greatest obstacle in life is Yourself. Overcome it, and you will achieve the greatest accomplishment of all." -Art Beins, 1982

If you want to maintain 6gen-style AI mega handling -- that AI is also programmed to never select his Mega pokemon until it is the very last standing. This can be blatantly seen by fighting Steven, and if he has 2 pokemon left (Metagross + something else), if that other pokemon cannot touch you at all, he will send it out, and then immediately switch it out.Personally I wouldn't bother with this though, it only makes the AI worse...

I did some tests (on Sidney) and it if I force him to switch to Absol (with Roar), he immediately Mega Evolves. Maybe this is a bug with switching logic?

Anyhow, I will just force mega evolution - or as daniilS put it:

Code:

if (haz_mega) do_mega();

__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.

You don't need to at all. There is no Pokemon that has a Mega evolution that has a regular evolution, since all Megas are for fully evolved Pokemon anyway. You don't need more than 5 per Pokemon.

If you mean should you expand the ways you can evolve, then again, the answer is no. This hack will not interfere with standard evolutions and is not related to them at all. I'm just reusing the evolution table to store this data as it seemed convenient.

__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.

This looks very awesome! I've tried to insert it following what you've said at the github. But i'm quite lost with this part: Create a directory called 'build' in the project root. I can't understand this... Can you explain it, please?

This looks very awesome! I've tried to insert it following what you've said at the github. But i'm quite lost with this part: Create a directory called 'build' in the project root. I can't understand this... Can you explain it, please?

Make a folder called "build" in the location of the routines and such.

The PokéCommunity

Meta

Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, or The Pokémon Company International. We just love Pokémon.