From c823e19705e0fbe0f5ef5a8be3b0e766ac70e77b Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sat, 11 Mar 2023 10:48:21 -0800 Subject: [PATCH] implemented Gigantamax form change --- .../battle_interface/dynamax_indicator.png | Bin 5409 -> 268 bytes include/battle_interface.h | 3 +- include/constants/form_change_types.h | 2 ++ src/battle_dynamax.c | 26 +++++++++++++----- src/battle_util.c | 8 +++++- src/data/pokemon/form_change_tables.h | 17 ++++++++---- 6 files changed, 40 insertions(+), 16 deletions(-) diff --git a/graphics/battle_interface/dynamax_indicator.png b/graphics/battle_interface/dynamax_indicator.png index 767a71c1ad5ecd03bac3b3b0060582da49f574fa..ebfbe86da62bf52c553650480c987c1cff82ccf2 100644 GIT binary patch delta 241 zcmZ3e)x$JFxt@W&#M9T6{W&wYpdm~5gR&U>cv7h@-A}f$@5a1Ky`k#T} zfmha>S2?qE4ZbXDQK-Km;5}!@gAW}$9$Y22! zCXAms9)rP55O})>f~%?iG#mv!pEb9D0mJab;6-R4q{XY$N~tUs!J`Q(1dr%sQVd3S z?^)R5?X5N@107RV7+PZ|U9RL2dW=>K2rJ^XcTr(*?af-x&1qEEsjfCVyv`5SKCF6| zvLP+mcpu>pc^`h2gPPd-ye=6(UDRc^W+*zt<@QeNH{(4~utn z#ET?_9yTfGjngjgne!AQ8Eh1+-S$GdaQb$`D@lpbPd6Km>zyAk7!=$!W7p!`X?^oV z*76I~>tSa_`O87I|3~dCz~{wQXA+>i>K8we1l) zeA}s#Ia8`huD^s(H*!uC8+_k>+(|Sa5m!)cM0u{seaGxV)=fW0!$a-YPN7Dr)UcO| z$Lm~^Lr&2t`$MpW&eyf}MKw2K&iSlgYf-s<+|8(}+VaC?D7_}1mr=YREOpbog=RJG zil3m-&QVKv8|^B?5?0MEFfjbh=QNa5ZP`?9_N4Wf)(rdoqt~0gUOF}Z8Mx@YWNGPH8_L_jTR#mx=N12K?-#48zCc{v*xudZ&uPB!DXDD22U}|RUixuuR z_@TYVXfTSb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z+%HHxb1-G=nxEv4T1pOHT~X17Bfrh}U0=Vg zjGnRtr*q0vUc(~BMQ{& zQwRzC!Cw`pjvY!z0+WzfL=H?fAS&gvkX{0z=!1uzf=HQMHRJ`z{>&1UNk5YH+1m6o zL+O0F5a9j+_cQDFxeplwE1{65UaegY*>Xi!K2BYG$R?jQp=Fh>fL*)WADm9hW?heIWDIAkf2 z&VnI?&VZ#%4(k($0JRLL5{mtFReC51fTFXhOqQ4~C9)YTh)5^HWFiNWz(lEpErsb6 zDGW1*p(HTZQ>m6ipqw%}6p4^jipZfDdcwIbA_1R3bs&En5ye8N6gYrAAX7+`TFu9) zV3`~VLLoh$6efd7V>0M$4vRqs$48@3M6Cf@)T2_!4pjQkjJ_~jkPe_0(km4J42^?q zxNd3$LY3-Zr81UJ&@T$F_Z$*9o;O?;ZlO%N*^n!@9Ugv*8C z;UF3)9+308$OV)97;RqkPfPkJ1nWq1tqPSA=;AA0c!UwVc7gU5)>{=o6Oh1@11vV;kUz{gWch0!=WqoXORGl_r(lR2Q<_!ZOj=i{7Lp@}-}5POdbO dW{QoD#A9A%8adfT)(C(%M&RM^Uf>#$^dImOAYlLi 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)