Skip to content

Commit

Permalink
Add support for legendary fusion (#3274)
Browse files Browse the repository at this point in the history
* Legendary Mon Fusion Evolution Compatibility Added

Kyurem, Calyrex, and Necrozma Fusions have been implemented, however, the animation for the the process is incomplete, the party menu screen needs to be updated while the screen is whited out and it has proved beyond me right now. Smh

* Added Fusion Move Prompts

Handles cases for learning the fusion moves from the other fused mon and deleting the move when you unfuse (plus learning confusion (well a set choice in the data struct) if there are no moves left after deleting one)

* Fix Bug With Fusion Mon Move Learning

If the main fusion came after the fused mon in the party order it would try to teach the move to the next member in the party

* Apply suggestions from code review

Co-authored-by: LOuroboros <[email protected]>

* Fix build

* Fix fusion items being used up

* Fixed animations

* RefreshPartyMenu

* Apply suggestions from code review

Co-authored-by: Eduardo Quezada D'Ottone <[email protected]>

* Apply suggestions

* Update form_change_tables.h

* Fix animation and simplify fusion tables

* Fix party full message

* Remove trailing whitespaces

* Update party_menu.c

* Update party_menu.c

* Make IsFusionMon better

* Apply suggestions from code review

Co-authored-by: Bassoonian <[email protected]>

---------

Co-authored-by: TeamAquasHideout <[email protected]>
Co-authored-by: Eduardo Quezada D'Ottone <[email protected]>
Co-authored-by: LOuroboros <[email protected]>
Co-authored-by: Bassoonian <[email protected]>
  • Loading branch information
5 people committed Nov 23, 2023
1 parent 8d6cb96 commit b6ff973
Show file tree
Hide file tree
Showing 14 changed files with 509 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/constants/form_change_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define DAY 1
#define NIGHT 2

#define FUSION_TERMINATOR 0xFF
#define FORM_CHANGE_TERMINATOR 0

// Form change that activates when the specified item is given to or taken from the selected Pokémon.
Expand Down
1 change: 1 addition & 0 deletions include/constants/party_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#define PARTY_MSG_DO_WHAT_WITH_MAIL 25
#define PARTY_MSG_ALREADY_HOLDING_ONE 26
#define PARTY_MSG_WHICH_APPLIANCE 27
#define PARTY_MSG_CHOOSE_SECOND_FUSION 28
#define PARTY_MSG_NONE 127

// IDs for DisplayPartyPokemonDescriptionText, to display a message in the party pokemon's box
Expand Down
1 change: 1 addition & 0 deletions include/item_use.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void ItemUseOutOfBattle_FormChange(u8);
void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8);
void ItemUseOutOfBattle_RotomCatalog(u8);
void ItemUseOutOfBattle_ZygardeCube(u8);
void ItemUseOutOfBattle_Fusion(u8);
void ItemUseOutOfBattle_Honey(u8);
void ItemUseOutOfBattle_CannotUse(u8);
void ItemUseOutOfBattle_ExpShare(u8);
Expand Down
1 change: 1 addition & 0 deletions include/party_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void ItemUseCB_FormChange(u8 taskId, TaskFunc task);
void ItemUseCB_FormChange_ConsumedOnUse(u8 taskId, TaskFunc task);
void ItemUseCB_RotomCatalog(u8 taskId, TaskFunc task);
void ItemUseCB_ZygardeCube(u8 taskId, TaskFunc task);
void ItemUseCB_Fusion(u8 taskId, TaskFunc task);
const u8* GetItemEffect(u16 item);
u8 GetItemEffectType(u16 item);
void CB2_PartyMenuFromStartMenu(void);
Expand Down
13 changes: 13 additions & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,19 @@ struct FormChange
u16 param3;
};

struct Fusion
{
u16 fusionStorageIndex;
u16 itemId;
u16 targetSpecies1;
u16 targetSpecies2;
u16 fusingIntoMon;
u16 fusionMove;
u16 unfuseForgetMove;
};

extern const struct Fusion *const gFusionTablePointers[NUM_SPECIES];

#define NUM_UNOWN_FORMS 28

#define GET_UNOWN_LETTER(personality) (( \
Expand Down
2 changes: 2 additions & 0 deletions include/pokemon_storage_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define IN_BOX_COLUMNS 6 // Number of columns, 5 Pokémon per column
#define IN_BOX_COUNT (IN_BOX_ROWS * IN_BOX_COLUMNS)
#define BOX_NAME_LENGTH 8
#define MAX_FUSION_STORAGE 4

/*
COLUMNS
Expand All @@ -22,6 +23,7 @@ struct PokemonStorage
/*0x0001*/ struct BoxPokemon boxes[TOTAL_BOXES_COUNT][IN_BOX_COUNT];
/*0x8344*/ u8 boxNames[TOTAL_BOXES_COUNT][BOX_NAME_LENGTH + 1];
/*0x83C2*/ u8 boxWallpapers[TOTAL_BOXES_COUNT];
/*0x8432*/ struct Pokemon fusions[MAX_FUSION_STORAGE];
};

extern struct PokemonStorage *gPokemonStoragePtr;
Expand Down
1 change: 1 addition & 0 deletions include/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ extern const u8 gText_UsedVar2WildLured[];
extern const u8 gText_UsedVar2WildRepelled[];
extern const u8 gText_BoxFull[];
extern const u8 gText_WontHaveEffect[];
extern const u8 gText_NextFusionMon[];

extern const u8 gText_LevelSymbol[];
extern const u8 gText_PkmnInfo[];
Expand Down
23 changes: 15 additions & 8 deletions src/data/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -8502,6 +8502,7 @@ const struct Item gItems[] =
{
.name = _("Gracidea"),
.price = 0,
.importance = 1,
.description = sGracideaDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_PARTY_MENU,
Expand All @@ -8512,6 +8513,7 @@ const struct Item gItems[] =
{
.name = _("Reveal Glass"),
.price = 0,
.importance = 1,
.description = sRevealGlassDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_PARTY_MENU,
Expand All @@ -8522,10 +8524,11 @@ const struct Item gItems[] =
{
.name = _("DNA Splicers"),
.price = 0,
.importance = 1,
.description = sDNASplicersDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_Fusion,
},

[ITEM_ZYGARDE_CUBE] =
Expand All @@ -8543,6 +8546,7 @@ const struct Item gItems[] =
{
.name = _("Prison Bottle"),
.price = 0,
.importance = 1,
.description = sPrisonBottleDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_PARTY_MENU,
Expand All @@ -8553,30 +8557,33 @@ const struct Item gItems[] =
{
.name = _("N-Solarizer"),
.price = 0,
.importance = 1,
.description = sNSolarizerDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_Fusion,
},

[ITEM_N_LUNARIZER] =
{
.name = _("N-Lunarizer"),
.price = 0,
.importance = 1,
.description = sNLunarizerDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_Fusion,
},

[ITEM_REINS_OF_UNITY] =
{
.name = _("ReinsOfUnity"),
.price = 0,
.importance = 1,
.description = sReinsOfUnityDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_Fusion,
},

// Battle Mechanic Key Items
Expand Down
1 change: 1 addition & 0 deletions src/data/party_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ static const u8 *const sActionStringTable[] =
[PARTY_MSG_DO_WHAT_WITH_MAIL] = gText_DoWhatWithMail,
[PARTY_MSG_ALREADY_HOLDING_ONE] = gText_AlreadyHoldingOne,
[PARTY_MSG_WHICH_APPLIANCE] = gText_WhichAppliance,
[PARTY_MSG_CHOOSE_SECOND_FUSION] = gText_NextFusionMon,
};

static const u8 *const sDescriptionStringTable[] =
Expand Down
25 changes: 25 additions & 0 deletions src/data/pokemon/form_change_table_pointers.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,28 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] =
[SPECIES_OGERPON_CORNERSTONE_MASK_TERA] = sOgerponFormChangeTable,
#endif
};

const struct Fusion *const gFusionTablePointers[NUM_SPECIES] =
{
#if P_GEN_5_POKEMON == TRUE
[SPECIES_KYUREM] = sKyuremFusionTable,
[SPECIES_KYUREM_BLACK] = sKyuremFusionTable,
[SPECIES_KYUREM_WHITE] = sKyuremFusionTable,
[SPECIES_RESHIRAM] = sKyuremFusionTable,
[SPECIES_ZEKROM] = sKyuremFusionTable,
#endif
#if P_GEN_7_POKEMON == TRUE
[SPECIES_NECROZMA] = sNecrozmaFusionTable,
[SPECIES_NECROZMA_DAWN_WINGS] = sNecrozmaFusionTable,
[SPECIES_NECROZMA_DUSK_MANE] = sNecrozmaFusionTable,
[SPECIES_SOLGALEO] = sNecrozmaFusionTable,
[SPECIES_LUNALA] = sNecrozmaFusionTable,
#endif
#if P_GEN_8_POKEMON == TRUE
[SPECIES_CALYREX] = sCalyrexFusionTable,
[SPECIES_CALYREX_ICE_RIDER] = sCalyrexFusionTable,
[SPECIES_CALYREX_SHADOW_RIDER] = sCalyrexFusionTable,
[SPECIES_SPECTRIER] = sCalyrexFusionTable,
[SPECIES_GLASTRIER] = sCalyrexFusionTable,
#endif
};
19 changes: 19 additions & 0 deletions src/data/pokemon/form_change_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ static const struct FormChange sLandorusFormChangeTable[] = {
{FORM_CHANGE_TERMINATOR},
};

static const struct Fusion sKyuremFusionTable[] = {
{0, ITEM_DNA_SPLICERS, SPECIES_KYUREM, SPECIES_RESHIRAM, SPECIES_KYUREM_WHITE},
{0, ITEM_DNA_SPLICERS, SPECIES_KYUREM, SPECIES_ZEKROM, SPECIES_KYUREM_BLACK},
{FUSION_TERMINATOR},
};

static const struct FormChange sKeldeoFormChangeTable[] = {
{FORM_CHANGE_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED},
{FORM_CHANGE_MOVE, SPECIES_KELDEO_ORDINARY, MOVE_SECRET_SWORD, WHEN_FORGOTTEN},
Expand Down Expand Up @@ -588,6 +594,13 @@ static const struct FormChange sMiniorYellowFormChangeTable[] = {
{FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_YELLOW},
{FORM_CHANGE_TERMINATOR},
};

static const struct Fusion sNecrozmaFusionTable[] = {
{1, ITEM_N_SOLARIZER, SPECIES_NECROZMA, SPECIES_SOLGALEO, SPECIES_NECROZMA_DUSK_MANE, MOVE_SUNSTEEL_STRIKE, MOVE_CONFUSION},
{2, ITEM_N_LUNARIZER, SPECIES_NECROZMA, SPECIES_LUNALA, SPECIES_NECROZMA_DAWN_WINGS, MOVE_MOONGEIST_BEAM, MOVE_CONFUSION},
{FUSION_TERMINATOR},
};

static const struct FormChange sNecrozmaDuskManeFormChangeTable[] = {
{FORM_CHANGE_BATTLE_ULTRA_BURST, SPECIES_NECROZMA_ULTRA, ITEM_ULTRANECROZIUM_Z},
{FORM_CHANGE_TERMINATOR},
Expand Down Expand Up @@ -635,6 +648,12 @@ static const struct FormChange sZamazentaFormChangeTable[] = {
{FORM_CHANGE_TERMINATOR},
};

static const struct Fusion sCalyrexFusionTable[] = {
{3, ITEM_REINS_OF_UNITY, SPECIES_CALYREX, SPECIES_GLASTRIER, SPECIES_CALYREX_ICE_RIDER, MOVE_GLACIAL_LANCE, MOVE_CONFUSION},
{3, ITEM_REINS_OF_UNITY, SPECIES_CALYREX, SPECIES_SPECTRIER, SPECIES_CALYREX_SHADOW_RIDER, MOVE_ASTRAL_BARRAGE, MOVE_CONFUSION},
{FUSION_TERMINATOR},
};

static const struct FormChange sEnamorusFormChangeTable[] = {
{FORM_CHANGE_ITEM_USE, SPECIES_ENAMORUS_INCARNATE, ITEM_REVEAL_GLASS},
{FORM_CHANGE_ITEM_USE, SPECIES_ENAMORUS_THERIAN, ITEM_REVEAL_GLASS},
Expand Down
7 changes: 7 additions & 0 deletions src/item_use.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,13 @@ void ItemUseOutOfBattle_ZygardeCube(u8 taskId)
}
}

void ItemUseOutOfBattle_Fusion(u8 taskId)
{
gItemUseCB = ItemUseCB_Fusion;
gTasks[taskId].data[0] = FALSE;
SetUpItemUseCallback(taskId);
}

void Task_UseHoneyOnField(u8 taskId)
{
//ResetInitialPlayerAvatarState();
Expand Down
Loading

0 comments on commit b6ff973

Please sign in to comment.