diff --git a/graphics/battle_interface/dynamax_indicator.png b/graphics/battle_interface/dynamax_indicator.png index 767a71c1ad..ebfbe86da6 100644 Binary files a/graphics/battle_interface/dynamax_indicator.png and b/graphics/battle_interface/dynamax_indicator.png differ diff --git a/include/battle_interface.h b/include/battle_interface.h index 6ea2501b77..595547c2b0 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -58,10 +58,9 @@ enum #define TAG_MEGA_TRIGGER_PAL 0xD777 #define TAG_MEGA_INDICATOR_PAL 0xD778 -#define TAG_ALPHA_OMEGA_INDICATOR_PAL 0xD779 // Alpha and Omega indicators use the same palette as each of them only uses 4 different colors. +#define TAG_MISC_INDICATOR_PAL 0xD779 // Alpha, Omega, and Dynamax indicators use the same palette as each of them only uses 4 different colors. #define TAG_ZMOVE_TRIGGER_PAL 0xD77B #define TAG_DYNAMAX_TRIGGER_PAL 0xD77C -#define TAG_DYNAMAX_INDICATOR_PAL 0xD77D enum diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index 175f1027c2..aac4f6866d 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -10,6 +10,8 @@ // FORM_CHANGE_ITEM_USE param2 Arguments #define DAY 1 #define NIGHT 2 +// FORM_CHANGE_BATTLE_SWITCH +#define PRESERVE_MEGA 1 #define FORM_CHANGE_TERMINATOR 0 diff --git a/src/battle_dynamax.c b/src/battle_dynamax.c index 8a7ddae8b3..e3e87e7337 100644 --- a/src/battle_dynamax.c +++ b/src/battle_dynamax.c @@ -128,22 +128,34 @@ void ApplyDynamaxHPMultiplier(u16 battlerId, struct Pokemon* mon) } } -// Sets flags used for Dynamaxing. +// Sets flags used for Dynamaxing and checks Gigantamax forms. void PrepareBattlerForDynamax(u16 battlerId) { u8 side = GetBattlerSide(battlerId); + u16 newSpecies; + gBattleStruct->dynamax.alreadyDynamaxed[side] = TRUE; gBattleStruct->dynamax.dynamaxed[battlerId] = TRUE; gBattleStruct->dynamax.dynamaxTurns[battlerId] = DYNAMAX_TURNS; + + // Try Gigantamax form change. + newSpecies = GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_GIGANTAMAX); + if (newSpecies != SPECIES_NONE) + { + gBattleMons[battlerId].species = newSpecies; + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battlerId].species); + BtlController_EmitSetMonData(BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battlerId]], sizeof(gBattleMons[battlerId].species), &gBattleMons[battlerId].species); + MarkBattlerForControllerExec(battlerId); + } } -// Sets flags needed for undoing Dynamax. +// Sets flags needed for undoing Dynamax and undoes Gigantamax forms. void UndoDynamax(u16 battlerId) { u8 side = GetBattlerSide(battlerId); gBattleStruct->dynamax.dynamaxed[battlerId] = FALSE; gBattleStruct->dynamax.dynamaxTurns[battlerId] = 0; // safety check for switch-in / faint - // TODO: Undo Gigantamax form change. + TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_SWITCH); // TODO: maybe nicer way to do this? } // Returns whether a move should be converted into a Max Move. @@ -806,7 +818,7 @@ void DestroyDynamaxTriggerSprite(void) // DYNAMAX INDICATOR: static const u8 ALIGNED(4) sDynamaxIndicatorGfx[] = INCBIN_U8("graphics/battle_interface/dynamax_indicator.4bpp"); -static const u16 sDynamaxIndicatorPal[] = INCBIN_U16("graphics/battle_interface/dynamax_indicator.gbapal"); +static const u16 sDynamaxIndicatorPal[] = INCBIN_U16("graphics/battle_interface/misc_indicator.gbapal"); static const struct SpriteSheet sSpriteSheet_DynamaxIndicator = { @@ -814,7 +826,7 @@ static const struct SpriteSheet sSpriteSheet_DynamaxIndicator = }; static const struct SpritePalette sSpritePalette_DynamaxIndicator = { - sDynamaxIndicatorPal, TAG_DYNAMAX_INDICATOR_PAL + sDynamaxIndicatorPal, TAG_MISC_INDICATOR_PAL }; static const struct SpriteSheet sDynamaxIndicator_SpriteSheet[] = @@ -824,7 +836,7 @@ static const struct SpriteSheet sDynamaxIndicator_SpriteSheet[] = static const struct SpritePalette sDynamaxIndicator_SpritePalette[] = { - sDynamaxIndicatorPal, TAG_DYNAMAX_INDICATOR_PAL + sDynamaxIndicatorPal, TAG_MISC_INDICATOR_PAL }; static const struct OamData sOamData_DynamaxIndicator = @@ -837,7 +849,7 @@ static const struct OamData sOamData_DynamaxIndicator = static const struct SpriteTemplate sSpriteTemplate_DynamaxIndicator = { .tileTag = TAG_DYNAMAX_INDICATOR_TILE, - .paletteTag = TAG_DYNAMAX_INDICATOR_PAL, + .paletteTag = TAG_MISC_INDICATOR_PAL, .oam = &sOamData_DynamaxIndicator, .anims = gDummySpriteAnimTable, .images = NULL, diff --git a/src/battle_util.c b/src/battle_util.c index 854ba4d272..eeb0f58af5 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10180,7 +10180,8 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) targetSpecies = formChanges[i].targetSpecies; break; case FORM_CHANGE_BATTLE_SWITCH: - targetSpecies = formChanges[i].targetSpecies; + if (!(IsBattlerMegaEvolved(battlerId) && formChanges[i].param1 == PRESERVE_MEGA)) + targetSpecies = formChanges[i].targetSpecies; break; case FORM_CHANGE_BATTLE_HP_PERCENT: if (formChanges[i].param1 == GetBattlerAbility(battlerId)) @@ -10200,6 +10201,11 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) } } break; + case FORM_CHANGE_BATTLE_GIGANTAMAX: + // TODO: check Gigantamax factor + if (IsDynamaxed(battlerId)) + targetSpecies = formChanges[i].targetSpecies; + break; case FORM_CHANGE_BATTLE_TURN_END: if (formChanges[i].param1 == GetBattlerAbility(battlerId)) targetSpecies = formChanges[i].targetSpecies; diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 0528d0d7af..00fb8e4c34 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1,6 +1,7 @@ static const struct FormChange sVenusaurFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE}, {FORM_CHANGE_BATTLE_GIGANTAMAX, SPECIES_VENUSAUR_GMAX}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_VENUSAUR, PRESERVE_MEGA}, {FORM_CHANGE_FAINT, SPECIES_VENUSAUR}, {FORM_CHANGE_END_BATTLE, SPECIES_VENUSAUR}, {FORM_CHANGE_TERMINATOR}, @@ -10,6 +11,7 @@ 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_Y, ITEM_CHARIZARDITE_Y}, {FORM_CHANGE_BATTLE_GIGANTAMAX, SPECIES_CHARIZARD_GMAX}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CHARIZARD, PRESERVE_MEGA}, {FORM_CHANGE_FAINT, SPECIES_CHARIZARD}, {FORM_CHANGE_END_BATTLE, SPECIES_CHARIZARD}, {FORM_CHANGE_TERMINATOR}, @@ -18,6 +20,7 @@ static const struct FormChange sCharizardFormChangeTable[] = { static const struct FormChange sBlastoiseFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLASTOISE_MEGA, ITEM_BLASTOISINITE}, {FORM_CHANGE_BATTLE_GIGANTAMAX, SPECIES_BLASTOISE_GMAX}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_BLASTOISE, PRESERVE_MEGA}, {FORM_CHANGE_FAINT, SPECIES_BLASTOISE}, {FORM_CHANGE_END_BATTLE, SPECIES_BLASTOISE}, {FORM_CHANGE_TERMINATOR}, @@ -54,6 +57,7 @@ static const struct FormChange sSlowbroFormChangeTable[] = { static const struct FormChange sGengarFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GENGAR_MEGA, ITEM_GENGARITE}, {FORM_CHANGE_BATTLE_GIGANTAMAX, SPECIES_GENGAR_GMAX}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_VENUSAUR, PRESERVE_MEGA}, {FORM_CHANGE_FAINT, SPECIES_GENGAR}, {FORM_CHANGE_END_BATTLE, SPECIES_GENGAR}, {FORM_CHANGE_TERMINATOR}, @@ -643,12 +647,13 @@ static const struct FormChange sEnamorusFormChangeTable[] = { #endif // Gigantamax Forms -#define GIGANTAMAX_FORM(species) \ - { \ - {FORM_CHANGE_BATTLE_GIGANTAMAX, SPECIES_##species##_GMAX}, \ - {FORM_CHANGE_FAINT, SPECIES_##species}, \ - {FORM_CHANGE_END_BATTLE, SPECIES_##species}, \ - {FORM_CHANGE_TERMINATOR}, \ +#define GIGANTAMAX_FORM(species) \ + { \ + {FORM_CHANGE_BATTLE_GIGANTAMAX, SPECIES_##species##_GMAX}, \ + {FORM_CHANGE_FAINT, SPECIES_##species}, \ + {FORM_CHANGE_END_BATTLE, SPECIES_##species}, \ + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_##species, PRESERVE_MEGA}, \ + {FORM_CHANGE_TERMINATOR}, \ }; static const struct FormChange sButterfreeFormChangeTable[] = GIGANTAMAX_FORM(BUTTERFREE)