If I'm not mistaken, if you're mentioning pokemonforms.txt, then you're not working on a ROM hack, you're working with Pokémon Essentials.
Golisopod-User made a
Gen 8 project which contains the script that you want.
The example I'm giving here is based on the case of Slowbro: form 0 can mega-evolve, and form 1 (Galarian) cannot.
So, how do you add a new Mega to another form?
Let's say you have a new form for Weavile. In your pokemonforms.txt, you have:
Code:
#-------------------------------
[WEAVILE,1]
FormName = This is a test form
Type1 = GRASS
Type2 = FAIRY
This is the "base form" for your new Mega. Then, you need to define a new form for your Mega:
Code:
#-------------------------------
[WEAVILE,2]
FormName = Mega Weavile of the Test form
Type1 = GRASS
Type2 = FAIRY
MegaStone = WEAVILETESTFORMITE
UnmegaForm = 1
Two lines require your attention here.
The first line is:
Code:
MegaStone = WEAVILETESTFORMITE
This is the name of the Mega Stone, here WEAVILETESTFORMITE - Weavile Test Formite.
The second line that requires your attention is:
Here, you are specifying that the form 2 being a Mega-form, should revert to form 1 instead of form 0 (which it would if you don't specify this line).
But that's not it.
You need to do a bit of scripting too.
Code:
MultipleForms.register(:WEAVILE,{
"getSpecificMegaForm" => proc { |pkmn|
next 2 if (pkmn.form == 1 && pkmn.hasItem?(:WEAVILETESTFORMITE))
next
},
"getSpecificUnmegaForm" => proc { |pkmn|
next 1 if pkmn.form == 2
next
}
})
This script says that only form 1 of Weavile can Mega-Evolve, and it will mega-evolve into form 2.
So, I am not sure why there seems to be redundancy between pokemonforms.txt and this script, the thing is, this script is necessary.