- 825
- Posts
- 9
- Years
- The Dissa Region
- Seen Oct 7, 2024
My game has some quite gimmicky Megas, and I thought I'd show others how I pulled them off so that they too could do something similar.
First off, we have Mega Castform. As most Pokemon players know, Castform changes form based on the weather - which makes sense since it's the Pokemon equivalent of a weather balloon.
My Mega Castform is interesting because it becomes a different Mega depending on what form it's in when the player triggers Mega Evolution.
You might be tempted to go "Okay, I think I know how to do this. Just write a subroutine that goes 'If pokemon.form==1, return 5. If pokemon.form==2, return 6. Etc, etc."
That's the way I had it before. But it turns out that the getMegaForm subroutine is also used to determine if the Pokemon is a Mega. Thus, because the Mega is determined by the base form, the game wouldn't think that Castform was Mega after changing form.
This is why I use the codes like pokemon.form%4==1. X%4 will divide X by 4, then give off the remainder. If X is either 1 or 5, the function will throw up 1. This allows both Sun Castform and Blazing Castform to go "Blazing Castform is the Mega form".
X%4 will return 0 if X is evenly divisible by four, which means that 0, 4, and 8 (normal Castform, Sand Castform, and Diamond Castform) would all all give Diamond Castform as their Mega. Thus I have the "next if pokemon.form==0" at the beginning - so that the function doesn't even check for Megas if Castform is in form 0.
The companion function to this would be:
However, Castform always reverts to normal after the end of a battle, so
is perfectly fine.
Next up we have Mega Chesnaught. The Mega changes forms in and of itself based on how it battles, much like a sort of Stance Change.
This is fine and dandy, just make it Mega Evolve into form 1 and use Stance Change (or Chesnaught's version) to change back and forth between forms at will. EXCEPT, we again run into the issue that isMega? uses the getMegaForm function, meaning that only form #1 - which in my game is "Ball Forme" - would go "yes, I'm a Mega".
However, this is a simple fix, as can be seen above. Adding the red line of code tells the game that form #2 - "Attack Forme" - is also a Mega for Chesnaught. Yes, Chesnaught Mega Evolves into Ball Forme, but almost invariably will he change immediately into Attack Forme.
This is accompanied by the standard
since both Ball Forme and Attack Forme revert to normal Chesnaught.
Code:
MultipleForms.register(:CASTFORM,{
"getMegaForm"=>proc{|pokemon|
next if pokemon.form==0
next 5 if isConst?(pokemon.item,PBItems,:CASTFORMITE) && pokemon.form%4==1
next 6 if isConst?(pokemon.item,PBItems,:CASTFORMITE) && pokemon.form%4==2
next 7 if isConst?(pokemon.item,PBItems,:CASTFORMITE) && pokemon.form%4==3
next 8 if isConst?(pokemon.item,PBItems,:CASTFORMITE) && pokemon.form%4==0
next
},
}
First off, we have Mega Castform. As most Pokemon players know, Castform changes form based on the weather - which makes sense since it's the Pokemon equivalent of a weather balloon.
My Mega Castform is interesting because it becomes a different Mega depending on what form it's in when the player triggers Mega Evolution.
You might be tempted to go "Okay, I think I know how to do this. Just write a subroutine that goes 'If pokemon.form==1, return 5. If pokemon.form==2, return 6. Etc, etc."
That's the way I had it before. But it turns out that the getMegaForm subroutine is also used to determine if the Pokemon is a Mega. Thus, because the Mega is determined by the base form, the game wouldn't think that Castform was Mega after changing form.
This is why I use the codes like pokemon.form%4==1. X%4 will divide X by 4, then give off the remainder. If X is either 1 or 5, the function will throw up 1. This allows both Sun Castform and Blazing Castform to go "Blazing Castform is the Mega form".
X%4 will return 0 if X is evenly divisible by four, which means that 0, 4, and 8 (normal Castform, Sand Castform, and Diamond Castform) would all all give Diamond Castform as their Mega. Thus I have the "next if pokemon.form==0" at the beginning - so that the function doesn't even check for Megas if Castform is in form 0.
The companion function to this would be:
Code:
"getUnmegaForm"=>proc{|pokemon|
next 0 if pokemon.form==0
next 4 if pokemon.form%4==0
next pokemon.form%4
},
Code:
"getUnmegaForm"=>proc{|pokemon|
next 0
},
Code:
MultipleForms.register(:CHESNAUGHT,{
"getMegaForm"=>proc{|pokemon|
[COLOR="Red"]next 2 if pokemon.form==2[/COLOR]
next 1 if isConst?(pokemon.item,PBItems,:CHESNAUGHTITE)
next
},
This is fine and dandy, just make it Mega Evolve into form 1 and use Stance Change (or Chesnaught's version) to change back and forth between forms at will. EXCEPT, we again run into the issue that isMega? uses the getMegaForm function, meaning that only form #1 - which in my game is "Ball Forme" - would go "yes, I'm a Mega".
However, this is a simple fix, as can be seen above. Adding the red line of code tells the game that form #2 - "Attack Forme" - is also a Mega for Chesnaught. Yes, Chesnaught Mega Evolves into Ball Forme, but almost invariably will he change immediately into Attack Forme.
This is accompanied by the standard
Code:
"getUnmegaForm"=>proc{|pokemon|
next 0
},