Made Mega Evolution properly use TryBattleFormChange

This commit is contained in:
Eduardo Quezada 2023-03-12 02:32:09 -03:00
parent 46bdd21e7a
commit 7ce68994ec
5 changed files with 45 additions and 136 deletions

View File

@ -7833,10 +7833,9 @@ BattleScript_MegaEvolutionAfeterString:
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
setbyte gIsCriticalHit, 0 setbyte gIsCriticalHit, 0
handlemegaevo BS_ATTACKER, 0 handlemegaevo BS_ATTACKER, 0
handlemegaevo BS_ATTACKER, 1
playanimation BS_ATTACKER, B_ANIM_MEGA_EVOLUTION playanimation BS_ATTACKER, B_ANIM_MEGA_EVOLUTION
waitanimation waitanimation
handlemegaevo BS_ATTACKER, 2 handlemegaevo BS_ATTACKER, 1
printstring STRINGID_MEGAEVOEVOLVED printstring STRINGID_MEGAEVOEVOLVED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
switchinabilities BS_ATTACKER switchinabilities BS_ATTACKER

View File

@ -8679,37 +8679,27 @@ static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega)
// Change species. // Change species.
if (caseId == 0) if (caseId == 0)
{ {
u16 newSpecies;
if (isMega) if (isMega)
{ {
//Checks regular Mega Evolution if (!TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM))
newSpecies = GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM); TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE);
//Checks Wish Mega Evolution
if (newSpecies == SPECIES_NONE)
newSpecies = GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE);
} }
else else
newSpecies = GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_PRIMAL_REVERSION); TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_PRIMAL_REVERSION);
gBattleMons[battlerId].species = newSpecies;
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battlerId].species); PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battlerId].species);
BtlController_EmitSetMonData(BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battlerId]], sizeof(gBattleMons[battlerId].species), &gBattleMons[battlerId].species); BtlController_EmitSetMonData(BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battlerId]], sizeof(gBattleMons[battlerId].species), &gBattleMons[battlerId].species);
MarkBattlerForControllerExec(battlerId); MarkBattlerForControllerExec(battlerId);
} }
// Change stats.
else if (caseId == 1)
{
RecalcBattlerStats(battlerId, mon);
if (isMega)
gBattleStruct->mega.alreadyEvolved[position] = TRUE;
}
// Update healthbox and elevation and play cry. // Update healthbox and elevation and play cry.
else else
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], mon, HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], mon, HEALTHBOX_ALL);
if (side == B_SIDE_OPPONENT) if (side == B_SIDE_OPPONENT)
SetBattlerShadowSpriteCallback(battlerId, gBattleMons[battlerId].species); SetBattlerShadowSpriteCallback(battlerId, gBattleMons[battlerId].species);
if (isMega)
gBattleStruct->mega.alreadyEvolved[position] = TRUE;
} }
} }

View File

@ -10071,11 +10071,17 @@ bool32 CanMegaEvolve(u8 battlerId)
bool32 IsBattlerMegaEvolved(u8 battlerId) bool32 IsBattlerMegaEvolved(u8 battlerId)
{ {
// While Transform does copy stats and visuals, it shouldn't be counted as true Mega Evolution.
if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)
return FALSE;
return (gSpeciesInfo[gBattleMons[battlerId].species].flags & SPECIES_FLAG_MEGA_EVOLUTION); return (gSpeciesInfo[gBattleMons[battlerId].species].flags & SPECIES_FLAG_MEGA_EVOLUTION);
} }
bool32 IsBattlerPrimalReverted(u8 battlerId) bool32 IsBattlerPrimalReverted(u8 battlerId)
{ {
// While Transform does copy stats and visuals, it shouldn't be counted as true Primal Revesion.
if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)
return FALSE;
return (gSpeciesInfo[gBattleMons[battlerId].species].flags & SPECIES_FLAG_PRIMAL_REVERSION); return (gSpeciesInfo[gBattleMons[battlerId].species].flags & SPECIES_FLAG_PRIMAL_REVERSION);
} }
@ -10145,6 +10151,18 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method)
return targetSpecies; return targetSpecies;
} }
bool32 CanBattlerFormChange(u8 battlerId, u16 method)
{
// Can't change form if transformed.
if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)
return FALSE;
// Mega Evolved Pokémon should always revert to normal upon fainting or ending the battle.
if (IsBattlerMegaEvolved(battlerId)
&& (method == FORM_CHANGE_FAINT || method == FORM_CHANGE_END_BATTLE))
return TRUE;
return DoesSpeciesHaveFormChangeMethod(gBattleMons[battlerId].species, method);
}
bool32 TryBattleFormChange(u8 battlerId, u16 method) bool32 TryBattleFormChange(u8 battlerId, u16 method)
{ {
u8 monId = gBattlerPartyIndexes[battlerId]; u8 monId = gBattlerPartyIndexes[battlerId];
@ -10152,14 +10170,12 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method)
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
u16 targetSpecies; u16 targetSpecies;
// Can't change form if transformed. if (!CanBattlerFormChange(battlerId, method))
if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)
return FALSE;
if (!DoesSpeciesHaveFormChangeMethod(gBattleMons[battlerId].species, method))
return FALSE; return FALSE;
targetSpecies = GetBattleFormChangeTargetSpecies(battlerId, method); targetSpecies = GetBattleFormChangeTargetSpecies(battlerId, method);
if (targetSpecies == SPECIES_NONE)
targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0);
if (targetSpecies != SPECIES_NONE) if (targetSpecies != SPECIES_NONE)
{ {
// Saves the original species on the first form change for the player. // Saves the original species on the first form change for the player.
@ -10172,27 +10188,26 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method)
RecalcBattlerStats(battlerId, &party[monId]); RecalcBattlerStats(battlerId, &party[monId]);
return TRUE; return TRUE;
} }
else if (gBattleStruct->changedSpecies[monId] != SPECIES_NONE)
targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0);
if (targetSpecies != SPECIES_NONE)
{ {
// Saves the original species on the first form change for the player. bool8 restoreSpecies = FALSE;
if (side == B_SIDE_PLAYER && gBattleStruct->changedSpecies[monId] == SPECIES_NONE)
gBattleStruct->changedSpecies[monId] = targetSpecies;
TryToSetBattleFormChangeMoves(&party[monId], method); // Mega Evolved Pokémon should always revert to normal upon fainting or ending the battle, so no need to add it to the form change tables.
SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); if (IsBattlerMegaEvolved(battlerId) && (method == FORM_CHANGE_FAINT || method == FORM_CHANGE_END_BATTLE))
gBattleMons[battlerId].species = targetSpecies; restoreSpecies = TRUE;
RecalcBattlerStats(battlerId, &party[monId]);
return TRUE; // Unlike Megas, Primal Reversion isn't canceled on fainting.
} else if (IsBattlerPrimalReverted(battlerId) && (method == FORM_CHANGE_END_BATTLE))
else if ((method == FORM_CHANGE_END_BATTLE || method == FORM_CHANGE_FAINT) restoreSpecies = TRUE;
&& gBattleStruct->changedSpecies[monId] != SPECIES_NONE)
{ if (restoreSpecies)
TryToSetBattleFormChangeMoves(&party[monId], method); {
SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); // Reverts the original species
RecalcBattlerStats(battlerId, &party[monId]); TryToSetBattleFormChangeMoves(&party[monId], method);
return TRUE; SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]);
RecalcBattlerStats(battlerId, &party[monId]);
return TRUE;
}
} }
return FALSE; return FALSE;

View File

@ -1,287 +1,207 @@
static const struct FormChange sVenusaurFormChangeTable[] = { static const struct FormChange sVenusaurFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE},
{FORM_CHANGE_FAINT, SPECIES_VENUSAUR},
{FORM_CHANGE_END_BATTLE, SPECIES_VENUSAUR},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sCharizardFormChangeTable[] = { static const struct FormChange sCharizardFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_X, ITEM_CHARIZARDITE_X}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_X, ITEM_CHARIZARDITE_X},
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_Y, ITEM_CHARIZARDITE_Y}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_Y, ITEM_CHARIZARDITE_Y},
{FORM_CHANGE_FAINT, SPECIES_CHARIZARD},
{FORM_CHANGE_END_BATTLE, SPECIES_CHARIZARD},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sBlastoiseFormChangeTable[] = { static const struct FormChange sBlastoiseFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLASTOISE_MEGA, ITEM_BLASTOISINITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLASTOISE_MEGA, ITEM_BLASTOISINITE},
{FORM_CHANGE_FAINT, SPECIES_BLASTOISE},
{FORM_CHANGE_END_BATTLE, SPECIES_BLASTOISE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sBeedrillFormChangeTable[] = { static const struct FormChange sBeedrillFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BEEDRILL_MEGA, ITEM_BEEDRILLITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BEEDRILL_MEGA, ITEM_BEEDRILLITE},
{FORM_CHANGE_FAINT, SPECIES_BEEDRILL},
{FORM_CHANGE_END_BATTLE, SPECIES_BEEDRILL},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sPidgeotFormChangeTable[] = { static const struct FormChange sPidgeotFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PIDGEOT_MEGA, ITEM_PIDGEOTITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PIDGEOT_MEGA, ITEM_PIDGEOTITE},
{FORM_CHANGE_FAINT, SPECIES_PIDGEOT},
{FORM_CHANGE_END_BATTLE, SPECIES_PIDGEOT},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sAlakazamFormChangeTable[] = { static const struct FormChange sAlakazamFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALAKAZAM_MEGA, ITEM_ALAKAZITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALAKAZAM_MEGA, ITEM_ALAKAZITE},
{FORM_CHANGE_FAINT, SPECIES_ALAKAZAM},
{FORM_CHANGE_END_BATTLE, SPECIES_ALAKAZAM},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sSlowbroFormChangeTable[] = { static const struct FormChange sSlowbroFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SLOWBRO_MEGA, ITEM_SLOWBRONITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SLOWBRO_MEGA, ITEM_SLOWBRONITE},
{FORM_CHANGE_FAINT, SPECIES_SLOWBRO},
{FORM_CHANGE_END_BATTLE, SPECIES_SLOWBRO},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sGengarFormChangeTable[] = { static const struct FormChange sGengarFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GENGAR_MEGA, ITEM_GENGARITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GENGAR_MEGA, ITEM_GENGARITE},
{FORM_CHANGE_FAINT, SPECIES_GENGAR},
{FORM_CHANGE_END_BATTLE, SPECIES_GENGAR},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sKangaskhanFormChangeTable[] = { static const struct FormChange sKangaskhanFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_KANGASKHAN_MEGA, ITEM_KANGASKHANITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_KANGASKHAN_MEGA, ITEM_KANGASKHANITE},
{FORM_CHANGE_FAINT, SPECIES_KANGASKHAN},
{FORM_CHANGE_END_BATTLE, SPECIES_KANGASKHAN},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sPinsirFormChangeTable[] = { static const struct FormChange sPinsirFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PINSIR_MEGA, ITEM_PINSIRITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PINSIR_MEGA, ITEM_PINSIRITE},
{FORM_CHANGE_FAINT, SPECIES_PINSIR},
{FORM_CHANGE_END_BATTLE, SPECIES_PINSIR},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sGyaradosFormChangeTable[] = { static const struct FormChange sGyaradosFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GYARADOS_MEGA, ITEM_GYARADOSITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GYARADOS_MEGA, ITEM_GYARADOSITE},
{FORM_CHANGE_FAINT, SPECIES_GYARADOS},
{FORM_CHANGE_END_BATTLE, SPECIES_GYARADOS},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sAerodactylFormChangeTable[] = { static const struct FormChange sAerodactylFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AERODACTYL_MEGA, ITEM_AERODACTYLITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AERODACTYL_MEGA, ITEM_AERODACTYLITE},
{FORM_CHANGE_FAINT, SPECIES_AERODACTYL},
{FORM_CHANGE_END_BATTLE, SPECIES_AERODACTYL},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sMewtwoFormChangeTable[] = { static const struct FormChange sMewtwoFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_X, ITEM_MEWTWONITE_X}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_X, ITEM_MEWTWONITE_X},
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_Y, ITEM_MEWTWONITE_Y}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_Y, ITEM_MEWTWONITE_Y},
{FORM_CHANGE_FAINT, SPECIES_MEWTWO},
{FORM_CHANGE_END_BATTLE, SPECIES_MEWTWO},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sAmpharosFormChangeTable[] = { static const struct FormChange sAmpharosFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AMPHAROS_MEGA, ITEM_AMPHAROSITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AMPHAROS_MEGA, ITEM_AMPHAROSITE},
{FORM_CHANGE_FAINT, SPECIES_AMPHAROS},
{FORM_CHANGE_END_BATTLE, SPECIES_AMPHAROS},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sSteelixFormChangeTable[] = { static const struct FormChange sSteelixFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_STEELIX_MEGA, ITEM_STEELIXITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_STEELIX_MEGA, ITEM_STEELIXITE},
{FORM_CHANGE_FAINT, SPECIES_STEELIX},
{FORM_CHANGE_END_BATTLE, SPECIES_STEELIX},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sScizorFormChangeTable[] = { static const struct FormChange sScizorFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCIZOR_MEGA, ITEM_SCIZORITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCIZOR_MEGA, ITEM_SCIZORITE},
{FORM_CHANGE_FAINT, SPECIES_SCIZOR},
{FORM_CHANGE_END_BATTLE, SPECIES_SCIZOR},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sHeracrossFormChangeTable[] = { static const struct FormChange sHeracrossFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HERACROSS_MEGA, ITEM_HERACRONITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HERACROSS_MEGA, ITEM_HERACRONITE},
{FORM_CHANGE_FAINT, SPECIES_HERACROSS},
{FORM_CHANGE_END_BATTLE, SPECIES_HERACROSS},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sHoundoomFormChangeTable[] = { static const struct FormChange sHoundoomFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HOUNDOOM_MEGA, ITEM_HOUNDOOMINITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HOUNDOOM_MEGA, ITEM_HOUNDOOMINITE},
{FORM_CHANGE_FAINT, SPECIES_HOUNDOOM},
{FORM_CHANGE_END_BATTLE, SPECIES_HOUNDOOM},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sTyranitarFormChangeTable[] = { static const struct FormChange sTyranitarFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_TYRANITAR_MEGA, ITEM_TYRANITARITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_TYRANITAR_MEGA, ITEM_TYRANITARITE},
{FORM_CHANGE_FAINT, SPECIES_TYRANITAR},
{FORM_CHANGE_END_BATTLE, SPECIES_TYRANITAR},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sSceptileFormChangeTable[] = { static const struct FormChange sSceptileFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCEPTILE_MEGA, ITEM_SCEPTILITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCEPTILE_MEGA, ITEM_SCEPTILITE},
{FORM_CHANGE_FAINT, SPECIES_SCEPTILE},
{FORM_CHANGE_END_BATTLE, SPECIES_SCEPTILE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sBlazikenFormChangeTable[] = { static const struct FormChange sBlazikenFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLAZIKEN_MEGA, ITEM_BLAZIKENITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLAZIKEN_MEGA, ITEM_BLAZIKENITE},
{FORM_CHANGE_FAINT, SPECIES_BLAZIKEN},
{FORM_CHANGE_END_BATTLE, SPECIES_BLAZIKEN},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sSwampertFormChangeTable[] = { static const struct FormChange sSwampertFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SWAMPERT_MEGA, ITEM_SWAMPERTITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SWAMPERT_MEGA, ITEM_SWAMPERTITE},
{FORM_CHANGE_FAINT, SPECIES_SWAMPERT},
{FORM_CHANGE_END_BATTLE, SPECIES_SWAMPERT},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sSableyeFormChangeTable[] = { static const struct FormChange sSableyeFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SABLEYE_MEGA, ITEM_SABLENITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SABLEYE_MEGA, ITEM_SABLENITE},
{FORM_CHANGE_FAINT, SPECIES_SABLEYE},
{FORM_CHANGE_END_BATTLE, SPECIES_SABLEYE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sSharpedoFormChangeTable[] = { static const struct FormChange sSharpedoFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SHARPEDO_MEGA, ITEM_SHARPEDONITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SHARPEDO_MEGA, ITEM_SHARPEDONITE},
{FORM_CHANGE_FAINT, SPECIES_SHARPEDO},
{FORM_CHANGE_END_BATTLE, SPECIES_SHARPEDO},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sManectricFormChangeTable[] = { static const struct FormChange sManectricFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MANECTRIC_MEGA, ITEM_MANECTITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MANECTRIC_MEGA, ITEM_MANECTITE},
{FORM_CHANGE_FAINT, SPECIES_MANECTRIC},
{FORM_CHANGE_END_BATTLE, SPECIES_MANECTRIC},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sCameruptFormChangeTable[] = { static const struct FormChange sCameruptFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CAMERUPT_MEGA, ITEM_CAMERUPTITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CAMERUPT_MEGA, ITEM_CAMERUPTITE},
{FORM_CHANGE_FAINT, SPECIES_CAMERUPT},
{FORM_CHANGE_END_BATTLE, SPECIES_CAMERUPT},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sGlalieFormChangeTable[] = { static const struct FormChange sGlalieFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GLALIE_MEGA, ITEM_GLALITITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GLALIE_MEGA, ITEM_GLALITITE},
{FORM_CHANGE_FAINT, SPECIES_GLALIE},
{FORM_CHANGE_END_BATTLE, SPECIES_GLALIE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sMawileFormChangeTable[] = { static const struct FormChange sMawileFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MAWILE_MEGA, ITEM_MAWILITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MAWILE_MEGA, ITEM_MAWILITE},
{FORM_CHANGE_FAINT, SPECIES_MAWILE},
{FORM_CHANGE_END_BATTLE, SPECIES_MAWILE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sMedichamFormChangeTable[] = { static const struct FormChange sMedichamFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEDICHAM_MEGA, ITEM_MEDICHAMITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEDICHAM_MEGA, ITEM_MEDICHAMITE},
{FORM_CHANGE_FAINT, SPECIES_MEDICHAM},
{FORM_CHANGE_END_BATTLE, SPECIES_MEDICHAM},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sAltariaFormChangeTable[] = { static const struct FormChange sAltariaFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALTARIA_MEGA, ITEM_ALTARIANITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALTARIA_MEGA, ITEM_ALTARIANITE},
{FORM_CHANGE_FAINT, SPECIES_ALTARIA},
{FORM_CHANGE_END_BATTLE, SPECIES_ALTARIA},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sAbsolFormChangeTable[] = { static const struct FormChange sAbsolFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABSOL_MEGA, ITEM_ABSOLITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABSOL_MEGA, ITEM_ABSOLITE},
{FORM_CHANGE_FAINT, SPECIES_ABSOL},
{FORM_CHANGE_END_BATTLE, SPECIES_ABSOL},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sBanetteFormChangeTable[] = { static const struct FormChange sBanetteFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BANETTE_MEGA, ITEM_BANETTITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BANETTE_MEGA, ITEM_BANETTITE},
{FORM_CHANGE_FAINT, SPECIES_BANETTE},
{FORM_CHANGE_END_BATTLE, SPECIES_BANETTE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sAggronFormChangeTable[] = { static const struct FormChange sAggronFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AGGRON_MEGA, ITEM_AGGRONITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AGGRON_MEGA, ITEM_AGGRONITE},
{FORM_CHANGE_FAINT, SPECIES_AGGRON},
{FORM_CHANGE_END_BATTLE, SPECIES_AGGRON},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sGardevoirFormChangeTable[] = { static const struct FormChange sGardevoirFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARDEVOIR_MEGA, ITEM_GARDEVOIRITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARDEVOIR_MEGA, ITEM_GARDEVOIRITE},
{FORM_CHANGE_FAINT, SPECIES_GARDEVOIR},
{FORM_CHANGE_END_BATTLE, SPECIES_GARDEVOIR},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sSalamenceFormChangeTable[] = { static const struct FormChange sSalamenceFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SALAMENCE_MEGA, ITEM_SALAMENCITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SALAMENCE_MEGA, ITEM_SALAMENCITE},
{FORM_CHANGE_FAINT, SPECIES_SALAMENCE},
{FORM_CHANGE_END_BATTLE, SPECIES_SALAMENCE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sMetagrossFormChangeTable[] = { static const struct FormChange sMetagrossFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_METAGROSS_MEGA, ITEM_METAGROSSITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_METAGROSS_MEGA, ITEM_METAGROSSITE},
{FORM_CHANGE_FAINT, SPECIES_METAGROSS},
{FORM_CHANGE_END_BATTLE, SPECIES_METAGROSS},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sLatiasFormChangeTable[] = { static const struct FormChange sLatiasFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIAS_MEGA, ITEM_LATIASITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIAS_MEGA, ITEM_LATIASITE},
{FORM_CHANGE_FAINT, SPECIES_LATIAS},
{FORM_CHANGE_END_BATTLE, SPECIES_LATIAS},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sLatiosFormChangeTable[] = { static const struct FormChange sLatiosFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIOS_MEGA, ITEM_LATIOSITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIOS_MEGA, ITEM_LATIOSITE},
{FORM_CHANGE_FAINT, SPECIES_LATIOS},
{FORM_CHANGE_END_BATTLE, SPECIES_LATIOS},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sKyogreFormChangeTable[] = { static const struct FormChange sKyogreFormChangeTable[] = {
{FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_KYOGRE_PRIMAL, ITEM_BLUE_ORB}, {FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_KYOGRE_PRIMAL, ITEM_BLUE_ORB},
{FORM_CHANGE_END_BATTLE, SPECIES_KYOGRE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sGroudonFormChangeTable[] = { static const struct FormChange sGroudonFormChangeTable[] = {
{FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_GROUDON_PRIMAL, ITEM_RED_ORB}, {FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_GROUDON_PRIMAL, ITEM_RED_ORB},
{FORM_CHANGE_END_BATTLE, SPECIES_GROUDON},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sRayquazaFormChangeTable[] = { static const struct FormChange sRayquazaFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT},
{FORM_CHANGE_FAINT, SPECIES_RAYQUAZA},
{FORM_CHANGE_END_BATTLE, SPECIES_RAYQUAZA},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
@ -300,36 +220,26 @@ static const struct FormChange sBurmyFormChangeTable[] = {
static const struct FormChange sLopunnyFormChangeTable[] = { static const struct FormChange sLopunnyFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE},
{FORM_CHANGE_FAINT, SPECIES_LOPUNNY},
{FORM_CHANGE_END_BATTLE, SPECIES_LOPUNNY},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sGarchompFormChangeTable[] = { static const struct FormChange sGarchompFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARCHOMP_MEGA, ITEM_GARCHOMPITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARCHOMP_MEGA, ITEM_GARCHOMPITE},
{FORM_CHANGE_FAINT, SPECIES_GARCHOMP},
{FORM_CHANGE_END_BATTLE, SPECIES_GARCHOMP},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sLucarioFormChangeTable[] = { static const struct FormChange sLucarioFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LUCARIO_MEGA, ITEM_LUCARIONITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LUCARIO_MEGA, ITEM_LUCARIONITE},
{FORM_CHANGE_FAINT, SPECIES_LUCARIO},
{FORM_CHANGE_END_BATTLE, SPECIES_LUCARIO},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sAbomasnowFormChangeTable[] = { static const struct FormChange sAbomasnowFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABOMASNOW_MEGA, ITEM_ABOMASITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABOMASNOW_MEGA, ITEM_ABOMASITE},
{FORM_CHANGE_FAINT, SPECIES_ABOMASNOW},
{FORM_CHANGE_END_BATTLE, SPECIES_ABOMASNOW},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
static const struct FormChange sGalladeFormChangeTable[] = { static const struct FormChange sGalladeFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GALLADE_MEGA, ITEM_GALLADITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GALLADE_MEGA, ITEM_GALLADITE},
{FORM_CHANGE_FAINT, SPECIES_GALLADE},
{FORM_CHANGE_END_BATTLE, SPECIES_GALLADE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
@ -388,8 +298,6 @@ static const struct FormChange sArceusFormChangeTable[] = {
#if P_GEN_5_POKEMON == TRUE #if P_GEN_5_POKEMON == TRUE
static const struct FormChange sAudinoFormChangeTable[] = { static const struct FormChange sAudinoFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AUDINO_MEGA, ITEM_AUDINITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AUDINO_MEGA, ITEM_AUDINITE},
{FORM_CHANGE_FAINT, SPECIES_AUDINO},
{FORM_CHANGE_END_BATTLE, SPECIES_AUDINO},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };
@ -478,8 +386,6 @@ static const struct FormChange sZygardePowerConstructFormChangeTable[] = {
static const struct FormChange sDiancieFormChangeTable[] = { static const struct FormChange sDiancieFormChangeTable[] = {
{FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_DIANCIE_MEGA, ITEM_DIANCITE}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_DIANCIE_MEGA, ITEM_DIANCITE},
{FORM_CHANGE_FAINT, SPECIES_DIANCIE},
{FORM_CHANGE_END_BATTLE, SPECIES_DIANCIE},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };

View File

@ -8659,7 +8659,6 @@ bool32 ShouldShowFemaleDifferences(u16 species, u32 personality)
return (gSpeciesInfo[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE; return (gSpeciesInfo[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE;
} }
// Returns species that it transformed into. If it didn't, returns SPECIES_NONE.
bool32 TryFormChange(u32 monId, u32 side, u16 method) bool32 TryFormChange(u32 monId, u32 side, u16 method)
{ {
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;