Advertiser Content

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
For Emerald see this post by kleenexfeu.

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.

#define KEYSTONE_PLAYER_VAR 0x4001 /* Variable that holds item index for player keystone */
#define KEYSTONE_OPPONENT_VAR 0x4002 /* Same as above but for partner */
#define KEYSTONE_DEFAULT 0x161    /* Default Key Stone item index */
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.

Inserting (window users): See this post

Usage:

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.

PurpleOrange

still don't know what I'm doing

Age 22
Male
Littleroot Town (UK)
Seen November 27th, 2018
Posted September 29th, 2018
366 posts
6.2 Years
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

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
Wow this is great Touched! Thank you for sharing this! Also I have questions ^ what PurpleOrange said :D
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:

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.

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
I have another question will you make a tool for this? Or even a tutorial on how to insert it? What Bela made is looking pretty sweet btw! I hope it can be implemented that way.
I'll probably just put instructions in the README. It's not exactly difficult to insert and is entirely automated for testing purposes.

I'm sorry, I am a Chinese, can't speak English, see you MEGA results, I am very happy, because I'm doing this I hope we can have a good communication once if possible



Interesting. Could you post a video and source code for this? I would be good to combine projects if possible.

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

Percy

Male
Asia
Seen 7 Hours Ago
Posted 6 Days Ago
2,990 posts
5.3 Years
Nice work, Touched! I hope to see the Emerald version of this.

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
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.

https://youtu.be/5ZylfytAdgc
Very nice. Could you show me the code for this? I would like to see how you programmed this.

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

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
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.

Deokishisu

Mr. Magius

Male
If I'm online, it's a safe bet I'm at a computer.
Seen January 9th, 2019
Posted March 4th, 2018
859 posts
13.8 Years
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!
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.

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
793 posts
5.3 Years
Wow! This is great!
I'm waiting for the complete code of this hack!
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
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.

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:

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.
Male
Seen 3 Days Ago
Posted 5 Days Ago
244 posts
7.1 Years
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...

LCCoolJ95

Limited Capacity

Age 24
Male
The World That Never Was
Seen 4 Hours Ago
Posted October 12th, 2019
608 posts
10.5 Years
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

Pokémon Theta Emerald EX: https://www.pokecommunity.com/showthread.php?t=386240

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
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:
if (haz_mega) do_mega();

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

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
5.4 Years
So, that means should I expand the evolution methods?
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.

Joexv

ManMadeOfGouda
joexv.github.io

Age 22
Male
Oregon
Seen 1 Week Ago
Posted August 7th, 2018
1,031 posts
7.2 Years
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.
I died and am dead

Exelis'20

Cancer

Male
Paris, France
Seen January 23rd, 2017
Posted December 19th, 2016
22 posts
5 Years
Make a folder called "build" in the location of the routines and such.
Ohh.. So that's how it is.. I just don't understand the term.. Thanks sir!
"For everything we do, all that really matters are results." :)


Current Hack:
Pokemon Exelis Version

Pokemon Exelis Version Facebook Page:
Pokemon Exelis Facebook Page
Advertiser Content