diff --git a/include/battle.h b/include/battle.h index 1d690a7fde..12e2caa805 100644 --- a/include/battle.h +++ b/include/battle.h @@ -538,6 +538,7 @@ struct BattleStruct bool8 friskedAbility; // If identifies two mons, show the ability pop-up only once. u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used. u16 moveEffect2; // For Knock Off + u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 2571972ba0..fd45ff2428 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -19,6 +19,9 @@ #define SPECIES_MINIOR 10003 #define SPECIES_WISHIWASHI 0 #define SPECIES_WISHIWASHI_SCHOOL 10004 +#define SPECIES_ZYGARDE 0 // 50% +#define SPECIES_ZYGARDE_10 10005 // 10 % +#define SPECIES_ZYGARDE_COMPLETE 10006 // 100 % // Items with peculiar battle effects. Remove them if they're properly placed in constant/items.h #define ITEM_GRISEOUS_ORB 0 diff --git a/src/battle_util.c b/src/battle_util.c index 8bc8863eef..7aa6817aeb 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3357,6 +3357,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if ((effect = ShouldChangeFormHpBased(battler))) BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3); break; + case ABILITY_POWER_CONSTRUCT: + if ((gBattleMons[battler].species == SPECIES_ZYGARDE || gBattleMons[battler].species == SPECIES_ZYGARDE_10) + && gBattleMons[battler].hp <= gBattleMons[battler].maxHP / 2) + { + gBattleStruct->changedSpecies[gBattlerPartyIndexes[battler]] = gBattleMons[battler].species; + gBattleMons[battler].species = SPECIES_ZYGARDE_COMPLETE; + BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3); + effect++; + } + break; } } break; @@ -6851,6 +6861,13 @@ void UndoMegaEvolution(u32 monId) SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleStruct->mega.playerEvolvedSpecies); CalculateMonStats(&gPlayerParty[monId]); } + // While not exactly a mega evolution, Zygarde follows the same rules. + else if (GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL) == SPECIES_ZYGARDE_COMPLETE) + { + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); + gBattleStruct->changedSpecies[monId] = 0; + CalculateMonStats(&gPlayerParty[monId]); + } } void UndoFormChange(u32 monId, u32 side)