From 34c6771e9418c2ca09854a2703ee46317bf325df Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Wed, 27 Jan 2021 16:26:18 -0600 Subject: [PATCH 01/14] Create form change table --- include/constants/pokemon.h | 8 ++ include/constants/pokemon_config.h | 74 ++++++++++++- include/pokemon.h | 7 ++ src/data/pokemon/form_change_table.h | 149 +++++++++++++++++++++++++++ src/pokemon.c | 1 + 5 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 src/data/pokemon/form_change_table.h diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index df11815a3..ebb30a0cf 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -307,6 +307,14 @@ #define EVOS_PER_MON 10 +// Form change types +#define FORM_ITEM_HOLD 1 +#define FORM_ITEM_USE 2 +#define FORM_ITEM_USE_ONE_WAY 3 +#define FORM_MOVE 4 +#define FORM_STATUS 5 +#define FORM_ELAPSED_DAYS 6 + #define NUM_MALE_LINK_FACILITY_CLASSES 8 #define NUM_FEMALE_LINK_FACILITY_CLASSES 8 diff --git a/include/constants/pokemon_config.h b/include/constants/pokemon_config.h index 131702a85..e1e0540dd 100644 --- a/include/constants/pokemon_config.h +++ b/include/constants/pokemon_config.h @@ -93,6 +93,78 @@ #define ITEM_RAZOR_FANG ITEM_NONE #define ITEM_RAZOR_CLAW ITEM_NONE #define ITEM_OVAL_STONE ITEM_NONE -#endif + +//FORM_ITEM_HOLD +#define ITEM_GRISEOUS_ORB ITEM_NONE +#define ITEM_DRACO_PLATE ITEM_NONE +#define ITEM_DREAD_PLATE ITEM_NONE +#define ITEM_EARTH_PLATE ITEM_NONE +#define ITEM_FIST_PLATE ITEM_NONE +#define ITEM_FLAME_PLATE ITEM_NONE +#define ITEM_ICICLE_PLATE ITEM_NONE +#define ITEM_INSECT_PLATE ITEM_NONE +#define ITEM_IRON_PLATE ITEM_NONE +#define ITEM_MEADOW_PLATE ITEM_NONE +#define ITEM_MIND_PLATE ITEM_NONE +#define ITEM_PIXIE_PLATE ITEM_NONE +#define ITEM_SKY_PLATE ITEM_NONE +#define ITEM_SPLASH_PLATE ITEM_NONE +#define ITEM_SPOOKY_PLATE ITEM_NONE +#define ITEM_STONE_PLATE ITEM_NONE +#define ITEM_TOXIC_PLATE ITEM_NONE +#define ITEM_ZAP_PLATE ITEM_NONE +#define ITEM_FIGHTINIUM_Z ITEM_NONE +#define ITEM_FLYINIUM_Z ITEM_NONE +#define ITEM_POISONIUM_Z ITEM_NONE +#define ITEM_GROUNDIUM_Z ITEM_NONE +#define ITEM_ROCKIUM_Z ITEM_NONE +#define ITEM_BUGINIUM_Z ITEM_NONE +#define ITEM_GHOSTIUM_Z ITEM_NONE +#define ITEM_STEELIUM_Z ITEM_NONE +#define ITEM_FIRIUM_Z ITEM_NONE +#define ITEM_WATERIUM_Z ITEM_NONE +#define ITEM_GRASSIUM_Z ITEM_NONE +#define ITEM_ELECTRIUM_Z ITEM_NONE +#define ITEM_PSYCHIUM_Z ITEM_NONE +#define ITEM_ICIUM_Z ITEM_NONE +#define ITEM_DRAGONIUM_Z ITEM_NONE +#define ITEM_DARKINIUM_Z ITEM_NONE +#define ITEM_FAIRIUM_Z ITEM_NONE +#define ITEM_DOUSE_DRIVE ITEM_NONE +#define ITEM_SHOCK_DRIVE ITEM_NONE +#define ITEM_BURN_DRIVE ITEM_NONE +#define ITEM_CHILL_DRIVE ITEM_NONE +#define ITEM_BUG_MEMORY ITEM_NONE +#define ITEM_DARK_MEMORY ITEM_NONE +#define ITEM_DRAGON_MEMORY ITEM_NONE +#define ITEM_ELECTRIC_MEMORY ITEM_NONE +#define ITEM_FAIRY_MEMORY ITEM_NONE +#define ITEM_FIGHTING_MEMORY ITEM_NONE +#define ITEM_FIRE_MEMORY ITEM_NONE +#define ITEM_FLYING_MEMORY ITEM_NONE +#define ITEM_GHOST_MEMORY ITEM_NONE +#define ITEM_GRASS_MEMORY ITEM_NONE +#define ITEM_GROUND_MEMORY ITEM_NONE +#define ITEM_ICE_MEMORY ITEM_NONE +#define ITEM_POISON_MEMORY ITEM_NONE +#define ITEM_PSYCHIC_MEMORY ITEM_NONE +#define ITEM_ROCK_MEMORY ITEM_NONE +#define ITEM_STEEL_MEMORY ITEM_NONE +#define ITEM_WATER_MEMORY ITEM_NONE + +//FORM_ITEM_USE +#define ITEM_GRACIDEA ITEM_NONE +#define ITEM_REVEAL_GLASS ITEM_NONE +#define ITEM_PRISON_BOTTLE ITEM_NONE +#define ITEM_RED_NECTAR ITEM_NONE +#define ITEM_YELLOW_NECTAR ITEM_NONE +#define ITEM_PINK_NECTAR ITEM_NONE +#define ITEM_PURPLE_NECTAR ITEM_NONE +#endif // ITEM_EXPANSION + +#ifndef BATTLE_ENGINE +#define ABILITY_MULTITYPE ABILITY_NONE +#define ABILITY_RKS_SYSTEM ABILITY_NONE +#endif // BATTLE_ENGINE #endif // GUARD_CONSTANTS_POKEMON_CONFIG_H diff --git a/include/pokemon.h b/include/pokemon.h index 107241a3e..5a322c642 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -243,6 +243,13 @@ struct Evolution u16 targetSpecies; }; +struct FormChange { + u16 method; + u16 targetSpecies; + u16 param1; + u16 param2; +}; + extern u8 gPlayerPartyCount; extern struct Pokemon gPlayerParty[PARTY_SIZE]; extern u8 gEnemyPartyCount; diff --git a/src/data/pokemon/form_change_table.h b/src/data/pokemon/form_change_table.h new file mode 100644 index 000000000..4e3bf0553 --- /dev/null +++ b/src/data/pokemon/form_change_table.h @@ -0,0 +1,149 @@ +/* +All form changes are checked for the base species! +Putting a form change on a form has no effect + +FORM_ITEM_USE: + Changes any pokemon with a matching base species (even if + it is a form) to the target species. + param1 = item to use + param1 = ability to check for (none means any) + +FORM_ITEM_USE_ONE_WAY: + FORM_ITEM_USE_ONE_WAY differs in that the change will occur + from param2 to target. This is needed because FORM_ITEM_USE + represents a many-to-one relationship, while Shaymin and + Hoopa form changes have a one-to-one relationship + param1 = item to use + param2 = original species + +FORM_ITEM_HOLD: + param1 = item to hold + param2 = ability to check for (none means any) + +FORM_MOVE: + param1 = move to check for + +FORM_STATUS: Unimplemented + param1 = status to check for + +FORM_ELAPSED_DAYS: Unimplemented + param1 = how many days have passed since the last form change + +If a form change's target is the same as the base, this means that +it will change any form to the base +*/ + +#define FORM_CHANGE_END 0 + +const struct FormChange *gFormChangeTable[POKEMON_SLOTS_NUMBER] = +{ + [SPECIES_GIRATINA] = (const struct FormChange[]) + { + {FORM_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, + {FORM_CHANGE_END}, + }, + [SPECIES_SHAYMIN] = (const struct FormChange[]) + { + {FORM_ITEM_USE_ONE_WAY, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, SPECIES_SHAYMIN}, + {FORM_STATUS, SPECIES_SHAYMIN, STATUS1_FREEZE}, + {FORM_CHANGE_END}, + }, + [SPECIES_ARCEUS] = (const struct FormChange[]) + { + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIST_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIGHTINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_SKY_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_FLYINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_TOXIC_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_POISONIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_STONE_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_ROCKIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_EARTH_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_GROUNDIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_INSECT_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_BUGINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_SPOOKY_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_GHOSTIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_IRON_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_STEELIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FLAME_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FIRIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_SPLASH_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_WATERIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_MEADOW_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_GRASSIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ZAP_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ELECTRIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_MIND_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_PSYCHIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICICLE_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRACO_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRAGONIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DREAD_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DARKINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_PIXIE_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_FAIRIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_END}, + }, + [SPECIES_TORNADUS] = (const struct FormChange[]) + { + {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, + }, + [SPECIES_THUNDURUS] = (const struct FormChange[]) + { + {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, + }, + [SPECIES_LANDORUS] = (const struct FormChange[]) + { + {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, + }, + [SPECIES_KELDEO] = (const struct FormChange[]) + { + {FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD}, + {FORM_CHANGE_END}, + }, + [SPECIES_GENESECT] = (const struct FormChange[]) + { + {FORM_ITEM_HOLD, SPECIES_GENESECT_DOUSE_DRIVE, ITEM_DOUSE_DRIVE}, + {FORM_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, + {FORM_ITEM_HOLD, SPECIES_GENESECT_BURN_DRIVE, ITEM_BURN_DRIVE}, + {FORM_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, + }, + [SPECIES_HOOPA] = (const struct FormChange[]) + { + {FORM_ITEM_USE_ONE_WAY, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, + {FORM_ELAPSED_DAYS, SPECIES_HOOPA, 3}, + }, + [SPECIES_ORICORIO] = (const struct FormChange[]) + { + {FORM_ITEM_USE, SPECIES_ORICORIO, ITEM_RED_NECTAR}, + {FORM_ITEM_USE, SPECIES_ORICORIO_POM_POM, ITEM_YELLOW_NECTAR}, + {FORM_ITEM_USE, SPECIES_ORICORIO_PA_U, ITEM_PINK_NECTAR}, + {FORM_ITEM_USE, SPECIES_ORICORIO_SENSU, ITEM_PURPLE_NECTAR}, + {FORM_CHANGE_END}, + }, + [SPECIES_SILVALLY] = (const struct FormChange[]) + { + {FORM_ITEM_HOLD, SPECIES_SILVALLY_BUG, ITEM_BUG_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_DARK, ITEM_DARK_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_DRAGON, ITEM_DRAGON_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_ELECTRIC, ITEM_ELECTRIC_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FAIRY, ITEM_FAIRY_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIGHTING, ITEM_FIGHTING_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIRE, ITEM_FIRE_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FLYING, ITEM_FLYING_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_GHOST, ITEM_GHOST_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_GRASS, ITEM_GRASS_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_GROUND, ITEM_GROUND_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_ICE, ITEM_ICE_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_POISON, ITEM_POISON_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_PSYCHIC, ITEM_PSYCHIC_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_ROCK, ITEM_ROCK_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_STEEL, ITEM_STEEL_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_WATER, ITEM_WATER_MEMORY, ABILITY_RKS_SYSTEM}, + }, +}; diff --git a/src/pokemon.c b/src/pokemon.c index 1f6fc9832..8e8472b81 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1848,6 +1848,7 @@ const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] = #include "data/pokemon/level_up_learnset_pointers.h" #include "data/pokemon/form_species_tables.h" #include "data/pokemon/form_species_table_pointers.h" +#include "data/pokemon/form_change_table.h" // SPECIES_NONE are ignored in the following two tables, so decrement before accessing these arrays to get the right result From 7e8659c4eeaa6e9e984ffed598a183d39d3a2086 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 2 Mar 2021 14:17:48 -0600 Subject: [PATCH 02/14] Fix missed merge conflict --- include/pokemon.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 71189d6c0..07f7f00fc 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -244,14 +244,12 @@ struct Evolution u16 targetSpecies; }; -<<<<<<< HEAD struct FormChange { u16 method; u16 targetSpecies; u16 param1; u16 param2; }; -======= #define NUM_UNOWN_FORMS 28 #define GET_UNOWN_LETTER(personality) (( \ @@ -260,7 +258,6 @@ struct FormChange { | (((personality) & 0x00000300) >> 6) \ | (((personality) & 0x00000003) >> 0) \ ) % NUM_UNOWN_FORMS) ->>>>>>> b2a541a33b2a5116f6780f1830f2606a5dbc065e extern u8 gPlayerPartyCount; extern struct Pokemon gPlayerParty[PARTY_SIZE]; From ec1a09bcd58cbe8883fbe0bbf5b91bb8eb10b8bf Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 2 Mar 2021 14:18:01 -0600 Subject: [PATCH 03/14] Revamp table --- include/constants/pokemon.h | 6 +- src/data/pokemon/form_change_table_pointers.h | 61 +++++++ src/data/pokemon/form_change_tables.h | 172 ++++++++++++++++++ src/pokemon.c | 2 +- 4 files changed, 236 insertions(+), 5 deletions(-) create mode 100644 src/data/pokemon/form_change_table_pointers.h create mode 100644 src/data/pokemon/form_change_tables.h diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 3f41072ce..d5a410168 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -313,10 +313,8 @@ // Form change types #define FORM_ITEM_HOLD 1 #define FORM_ITEM_USE 2 -#define FORM_ITEM_USE_ONE_WAY 3 -#define FORM_MOVE 4 -#define FORM_STATUS 5 -#define FORM_ELAPSED_DAYS 6 +#define FORM_MOVE 3 +#define FORM_WITHDRAW 4 #define NUM_MALE_LINK_FACILITY_CLASSES 8 #define NUM_FEMALE_LINK_FACILITY_CLASSES 8 diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h new file mode 100644 index 000000000..3ec9952cf --- /dev/null +++ b/src/data/pokemon/form_change_table_pointers.h @@ -0,0 +1,61 @@ +const struct FormChange *gFormChangeTablePointers[POKEMON_SLOTS_NUMBER] = +{ + [SPECIES_GIRATINA] = sGiratinaFormChangeTable, + [SPECIES_SHAYMIN] = sShayminFormChangeTable, + [SPECIES_SHAYMIN_SKY] = sShayminSkyFormChangeTable, + [SPECIES_ARCEUS] = sArceusFormChangeTable, + [SPECIES_ARCEUS_FIGHTING] = sArceusFormChangeTable, + [SPECIES_ARCEUS_FLYING] = sArceusFormChangeTable, + [SPECIES_ARCEUS_POISON] = sArceusFormChangeTable, + [SPECIES_ARCEUS_ROCK] = sArceusFormChangeTable, + [SPECIES_ARCEUS_GROUND] = sArceusFormChangeTable, + [SPECIES_ARCEUS_BUG] = sArceusFormChangeTable, + [SPECIES_ARCEUS_GHOST] = sArceusFormChangeTable, + [SPECIES_ARCEUS_STEEL] = sArceusFormChangeTable, + [SPECIES_ARCEUS_FIRE] = sArceusFormChangeTable, + [SPECIES_ARCEUS_WATER] = sArceusFormChangeTable, + [SPECIES_ARCEUS_GRASS] = sArceusFormChangeTable, + [SPECIES_ARCEUS_ELECTRIC] = sArceusFormChangeTable, + [SPECIES_ARCEUS_PSYCHIC] = sArceusFormChangeTable, + [SPECIES_ARCEUS_ICE] = sArceusFormChangeTable, + [SPECIES_ARCEUS_DRAGON] = sArceusFormChangeTable, + [SPECIES_ARCEUS_DARK] = sArceusFormChangeTable, + [SPECIES_ARCEUS_FAIRY] = sArceusFormChangeTable, + [SPECIES_TORNADUS] = sTornadusFormChangeTable, + [SPECIES_TORNADUS_THERIAN] = sTornadusTherianFormChangeTable, + [SPECIES_THUNDURUS] = sThundurusFormChangeTable, + [SPECIES_THUNDURUS_THERIAN] = sThundurusTherianFormChangeTable, + [SPECIES_LANDORUS] = sLandorusFormChangeTable, + [SPECIES_LANDORUS_THERIAN] = sLandorusTherianFormChangeTable, + [SPECIES_KELDEO] = sKeldeoFormChangeTable, + [SPECIES_KELDEO_RESOLUTE] = sKeldeoResoluteFormChangeTable, + [SPECIES_GENESECT] = sGenesectFormChangeTable, + [SPECIES_GENESECT_DOUSE_DRIVE] = sGenesectFormChangeTable, + [SPECIES_GENESECT_SHOCK_DRIVE] = sGenesectFormChangeTable, + [SPECIES_GENESECT_BURN_DRIVE] = sGenesectFormChangeTable, + [SPECIES_GENESECT_CHILL_DRIVE] = sGenesectFormChangeTable, + [SPECIES_HOOPA] = sHoopaFormChangeTable, + [SPECIES_HOOPA_UNBOUND] = sHoopaUnboundFormChangeTable, + [SPECIES_ORICORIO] = sOricorioFormChangeTable, + [SPECIES_ORICORIO_POM_POM] = sOricorioFormChangeTable, + [SPECIES_ORICORIO_PAU] = sOricorioFormChangeTable, + [SPECIES_ORICORIO_SENSU] = sOricorioFormChangeTable, + [SPECIES_SILVALLY] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_BUG] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_DARK] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_DRAGON] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_ELECTRIC] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_FAIRY] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_FIGHTING] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_FIRE] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_FLYING] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_GHOST] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_GRASS] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_GROUND] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_ICE] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_POISON] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_PSYCHIC] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_ROCK] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_STEEL] = sSilvallyFormChangeTable, + [SPECIES_SILVALLY_WATER] = sSilvallyFormChangeTable, +}; diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h new file mode 100644 index 000000000..ce27e201a --- /dev/null +++ b/src/data/pokemon/form_change_tables.h @@ -0,0 +1,172 @@ +/* +All form changes are checked for the base species! +Putting a form change on a form has no effect + +FORM_ITEM_USE: + Changes any pokemon with a matching base species (even if + it is a form) to the target species. + param1 = item to use + param1 = ability to check for (none means any) + +FORM_ITEM_HOLD: + param1 = item to hold + param2 = ability to check for (none means any) + +FORM_MOVE: + param1 = move to check for + param2 = true if form change activates when move is forgotten, + false if form change activates when move is learned + +FORM_WITHDRAW: + Form change activates when the Pokemon is withdrawn from the PC or Daycare. + no parameters +*/ + +#define FORM_CHANGE_END 0 +#define WHEN_LEARNED FALSE +#define WHEN_FORGOTTEN TRUE + +const struct FormChange sGiratinaFormChangeTable[] = { + {FORM_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sShayminFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sShayminSkyFormChangeTable[] = { + {FORM_WITHDRAW, SPECIES_SHAYMIN}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sArceusFormChangeTable[] = { + {FORM_ITEM_HOLD, SPECIES_ARCEUS, ITEM_NONE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIST_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIGHTINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_SKY_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_FLYINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_TOXIC_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_POISONIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_STONE_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_ROCKIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_EARTH_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_GROUNDIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_INSECT_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_BUGINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_SPOOKY_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_GHOSTIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_IRON_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_STEELIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FLAME_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FIRIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_SPLASH_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_WATERIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_MEADOW_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_GRASSIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ZAP_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ELECTRIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_MIND_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_PSYCHIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICICLE_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRACO_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRAGONIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DREAD_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DARKINIUM_Z, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_PIXIE_PLATE, ABILITY_MULTITYPE}, + {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_FAIRIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sTornadusFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sTornadusTherianFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sThundurusFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sThundurusTherianFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sLandorusFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sLandorusTherianFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sKeldeoFormChangeTable[] = { + {FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sKeldeoResoluteFormChangeTable[] = { + {FORM_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sGenesectFormChangeTable[] = { + {FORM_ITEM_HOLD, SPECIES_GENESECT, ITEM_NONE}, + {FORM_ITEM_HOLD, SPECIES_GENESECT_DOUSE_DRIVE, ITEM_DOUSE_DRIVE}, + {FORM_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, + {FORM_ITEM_HOLD, SPECIES_GENESECT_BURN_DRIVE, ITEM_BURN_DRIVE}, + {FORM_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, +}; + +const struct FormChange sHoopaFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sHoopaUnboundFormChangeTable[] = { + {FORM_WITHDRAW, SPECIES_HOOPA}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sOricorioFormChangeTable[] = { + {FORM_ITEM_USE, SPECIES_ORICORIO, ITEM_RED_NECTAR}, + {FORM_ITEM_USE, SPECIES_ORICORIO_POM_POM, ITEM_YELLOW_NECTAR}, + {FORM_ITEM_USE, SPECIES_ORICORIO_PAU, ITEM_PINK_NECTAR}, + {FORM_ITEM_USE, SPECIES_ORICORIO_SENSU, ITEM_PURPLE_NECTAR}, + {FORM_CHANGE_END}, +}; + +const struct FormChange sSilvallyFormChangeTable[] = { + {FORM_ITEM_HOLD, SPECIES_SILVALLY, ITEM_NONE, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_BUG, ITEM_BUG_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_DARK, ITEM_DARK_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_DRAGON, ITEM_DRAGON_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_ELECTRIC, ITEM_ELECTRIC_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FAIRY, ITEM_FAIRY_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIGHTING, ITEM_FIGHTING_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIRE, ITEM_FIRE_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_FLYING, ITEM_FLYING_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_GHOST, ITEM_GHOST_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_GRASS, ITEM_GRASS_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_GROUND, ITEM_GROUND_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_ICE, ITEM_ICE_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_POISON, ITEM_POISON_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_PSYCHIC, ITEM_PSYCHIC_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_ROCK, ITEM_ROCK_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_STEEL, ITEM_STEEL_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_ITEM_HOLD, SPECIES_SILVALLY_WATER, ITEM_WATER_MEMORY, ABILITY_RKS_SYSTEM}, +}; + +#undef FORM_CHANGE_END +#undef WHEN_LEARNED +#undef WHEN_FORGOTTEN \ No newline at end of file diff --git a/src/pokemon.c b/src/pokemon.c index 4d6df5524..ec84c05c2 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1847,8 +1847,8 @@ const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] = #include "data/pokemon/evolution.h" #include "data/pokemon/level_up_learnset_pointers.h" #include "data/pokemon/form_species_tables.h" +#include "data/pokemon/form_change_tables.h" #include "data/pokemon/form_species_table_pointers.h" -#include "data/pokemon/form_change_table.h" // SPECIES_NONE are ignored in the following two tables, so decrement before accessing these arrays to get the right result From 6db5a98ad9043a3e7e8e9d0fc8e5acf0fd2cf4d6 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 2 Mar 2021 14:20:39 -0600 Subject: [PATCH 04/14] Delete old form change table --- src/data/pokemon/form_change_table.h | 149 --------------------------- 1 file changed, 149 deletions(-) delete mode 100644 src/data/pokemon/form_change_table.h diff --git a/src/data/pokemon/form_change_table.h b/src/data/pokemon/form_change_table.h deleted file mode 100644 index 4e3bf0553..000000000 --- a/src/data/pokemon/form_change_table.h +++ /dev/null @@ -1,149 +0,0 @@ -/* -All form changes are checked for the base species! -Putting a form change on a form has no effect - -FORM_ITEM_USE: - Changes any pokemon with a matching base species (even if - it is a form) to the target species. - param1 = item to use - param1 = ability to check for (none means any) - -FORM_ITEM_USE_ONE_WAY: - FORM_ITEM_USE_ONE_WAY differs in that the change will occur - from param2 to target. This is needed because FORM_ITEM_USE - represents a many-to-one relationship, while Shaymin and - Hoopa form changes have a one-to-one relationship - param1 = item to use - param2 = original species - -FORM_ITEM_HOLD: - param1 = item to hold - param2 = ability to check for (none means any) - -FORM_MOVE: - param1 = move to check for - -FORM_STATUS: Unimplemented - param1 = status to check for - -FORM_ELAPSED_DAYS: Unimplemented - param1 = how many days have passed since the last form change - -If a form change's target is the same as the base, this means that -it will change any form to the base -*/ - -#define FORM_CHANGE_END 0 - -const struct FormChange *gFormChangeTable[POKEMON_SLOTS_NUMBER] = -{ - [SPECIES_GIRATINA] = (const struct FormChange[]) - { - {FORM_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, - {FORM_CHANGE_END}, - }, - [SPECIES_SHAYMIN] = (const struct FormChange[]) - { - {FORM_ITEM_USE_ONE_WAY, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, SPECIES_SHAYMIN}, - {FORM_STATUS, SPECIES_SHAYMIN, STATUS1_FREEZE}, - {FORM_CHANGE_END}, - }, - [SPECIES_ARCEUS] = (const struct FormChange[]) - { - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIST_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIGHTINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_SKY_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_FLYINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_TOXIC_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_POISONIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_STONE_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_ROCKIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_EARTH_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_GROUNDIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_INSECT_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_BUGINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_SPOOKY_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_GHOSTIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_IRON_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_STEELIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FLAME_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FIRIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_SPLASH_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_WATERIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_MEADOW_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_GRASSIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ZAP_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ELECTRIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_MIND_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_PSYCHIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICICLE_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRACO_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRAGONIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DREAD_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DARKINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_PIXIE_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_FAIRIUM_Z, ABILITY_MULTITYPE}, - {FORM_CHANGE_END}, - }, - [SPECIES_TORNADUS] = (const struct FormChange[]) - { - {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, - {FORM_CHANGE_END}, - }, - [SPECIES_THUNDURUS] = (const struct FormChange[]) - { - {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, - {FORM_CHANGE_END}, - }, - [SPECIES_LANDORUS] = (const struct FormChange[]) - { - {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, - {FORM_CHANGE_END}, - }, - [SPECIES_KELDEO] = (const struct FormChange[]) - { - {FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD}, - {FORM_CHANGE_END}, - }, - [SPECIES_GENESECT] = (const struct FormChange[]) - { - {FORM_ITEM_HOLD, SPECIES_GENESECT_DOUSE_DRIVE, ITEM_DOUSE_DRIVE}, - {FORM_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, - {FORM_ITEM_HOLD, SPECIES_GENESECT_BURN_DRIVE, ITEM_BURN_DRIVE}, - {FORM_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, - }, - [SPECIES_HOOPA] = (const struct FormChange[]) - { - {FORM_ITEM_USE_ONE_WAY, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, - {FORM_ELAPSED_DAYS, SPECIES_HOOPA, 3}, - }, - [SPECIES_ORICORIO] = (const struct FormChange[]) - { - {FORM_ITEM_USE, SPECIES_ORICORIO, ITEM_RED_NECTAR}, - {FORM_ITEM_USE, SPECIES_ORICORIO_POM_POM, ITEM_YELLOW_NECTAR}, - {FORM_ITEM_USE, SPECIES_ORICORIO_PA_U, ITEM_PINK_NECTAR}, - {FORM_ITEM_USE, SPECIES_ORICORIO_SENSU, ITEM_PURPLE_NECTAR}, - {FORM_CHANGE_END}, - }, - [SPECIES_SILVALLY] = (const struct FormChange[]) - { - {FORM_ITEM_HOLD, SPECIES_SILVALLY_BUG, ITEM_BUG_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_DARK, ITEM_DARK_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_DRAGON, ITEM_DRAGON_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_ELECTRIC, ITEM_ELECTRIC_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FAIRY, ITEM_FAIRY_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIGHTING, ITEM_FIGHTING_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIRE, ITEM_FIRE_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FLYING, ITEM_FLYING_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_GHOST, ITEM_GHOST_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_GRASS, ITEM_GRASS_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_GROUND, ITEM_GROUND_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_ICE, ITEM_ICE_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_POISON, ITEM_POISON_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_PSYCHIC, ITEM_PSYCHIC_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_ROCK, ITEM_ROCK_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_STEEL, ITEM_STEEL_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_WATER, ITEM_WATER_MEMORY, ABILITY_RKS_SYSTEM}, - }, -}; From aac7028703e88ff0040d54c9066edeb7e3c8e904 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 2 Mar 2021 14:21:29 -0600 Subject: [PATCH 05/14] Add newline at end of file --- src/data/pokemon/form_change_tables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index ce27e201a..a5bba1cb6 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -169,4 +169,4 @@ const struct FormChange sSilvallyFormChangeTable[] = { #undef FORM_CHANGE_END #undef WHEN_LEARNED -#undef WHEN_FORGOTTEN \ No newline at end of file +#undef WHEN_FORGOTTEN From f7d42cd3c8a77d5ef166a8704eb22eb674031554 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 2 Mar 2021 14:25:15 -0600 Subject: [PATCH 06/14] Formatting --- include/pokemon.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/pokemon.h b/include/pokemon.h index 07f7f00fc..cd45d56c0 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -250,6 +250,7 @@ struct FormChange { u16 param1; u16 param2; }; + #define NUM_UNOWN_FORMS 28 #define GET_UNOWN_LETTER(personality) (( \ From 6f64c1b2b99547196cb2c9a2ab04ce59a4f07194 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Wed, 3 Mar 2021 13:07:50 -0600 Subject: [PATCH 07/14] Implement GetFormChangeTargetSpecies --- include/constants/pokemon.h | 1 + include/pokemon.h | 2 +- src/data/pokemon/form_change_table_pointers.h | 2 +- src/data/pokemon/form_change_tables.h | 36 +++++++++--------- src/pokemon.c | 38 ++++++++++++++++++- 5 files changed, 57 insertions(+), 22 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index d5a410168..f10c1e364 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -311,6 +311,7 @@ #define EVOS_PER_MON 10 // Form change types +#define FORM_CHANGE_END 0 #define FORM_ITEM_HOLD 1 #define FORM_ITEM_USE 2 #define FORM_MOVE 3 diff --git a/include/pokemon.h b/include/pokemon.h index cd45d56c0..3fe9c66df 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -440,5 +440,5 @@ void sub_806F47C(u8 id); u8 *sub_806F4F8(u8 id, u8 arg1); u16 GetFormSpeciesId(u16 speciesId, u8 formId); u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId); - +u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg); #endif // GUARD_POKEMON_H diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h index 3ec9952cf..777b174a4 100644 --- a/src/data/pokemon/form_change_table_pointers.h +++ b/src/data/pokemon/form_change_table_pointers.h @@ -1,4 +1,4 @@ -const struct FormChange *gFormChangeTablePointers[POKEMON_SLOTS_NUMBER] = +const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = { [SPECIES_GIRATINA] = sGiratinaFormChangeTable, [SPECIES_SHAYMIN] = sShayminFormChangeTable, diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index a5bba1cb6..dd5e1e7b0 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -22,26 +22,25 @@ FORM_WITHDRAW: no parameters */ -#define FORM_CHANGE_END 0 #define WHEN_LEARNED FALSE #define WHEN_FORGOTTEN TRUE -const struct FormChange sGiratinaFormChangeTable[] = { +static const struct FormChange sGiratinaFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, {FORM_CHANGE_END}, }; -const struct FormChange sShayminFormChangeTable[] = { +static const struct FormChange sShayminFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA}, {FORM_CHANGE_END}, }; -const struct FormChange sShayminSkyFormChangeTable[] = { +static const struct FormChange sShayminSkyFormChangeTable[] = { {FORM_WITHDRAW, SPECIES_SHAYMIN}, {FORM_CHANGE_END}, }; -const struct FormChange sArceusFormChangeTable[] = { +static const struct FormChange sArceusFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_ARCEUS, ITEM_NONE, ABILITY_MULTITYPE}, {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIST_PLATE, ABILITY_MULTITYPE}, {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIGHTINIUM_Z, ABILITY_MULTITYPE}, @@ -80,47 +79,47 @@ const struct FormChange sArceusFormChangeTable[] = { {FORM_CHANGE_END}, }; -const struct FormChange sTornadusFormChangeTable[] = { +static const struct FormChange sTornadusFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; -const struct FormChange sTornadusTherianFormChangeTable[] = { +static const struct FormChange sTornadusTherianFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; -const struct FormChange sThundurusFormChangeTable[] = { +static const struct FormChange sThundurusFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; -const struct FormChange sThundurusTherianFormChangeTable[] = { +static const struct FormChange sThundurusTherianFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; -const struct FormChange sLandorusFormChangeTable[] = { +static const struct FormChange sLandorusFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; -const struct FormChange sLandorusTherianFormChangeTable[] = { +static const struct FormChange sLandorusTherianFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; -const struct FormChange sKeldeoFormChangeTable[] = { +static const struct FormChange sKeldeoFormChangeTable[] = { {FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED}, {FORM_CHANGE_END}, }; -const struct FormChange sKeldeoResoluteFormChangeTable[] = { +static const struct FormChange sKeldeoResoluteFormChangeTable[] = { {FORM_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN}, {FORM_CHANGE_END}, }; -const struct FormChange sGenesectFormChangeTable[] = { +static const struct FormChange sGenesectFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_GENESECT, ITEM_NONE}, {FORM_ITEM_HOLD, SPECIES_GENESECT_DOUSE_DRIVE, ITEM_DOUSE_DRIVE}, {FORM_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, @@ -128,17 +127,17 @@ const struct FormChange sGenesectFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, }; -const struct FormChange sHoopaFormChangeTable[] = { +static const struct FormChange sHoopaFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, {FORM_CHANGE_END}, }; -const struct FormChange sHoopaUnboundFormChangeTable[] = { +static const struct FormChange sHoopaUnboundFormChangeTable[] = { {FORM_WITHDRAW, SPECIES_HOOPA}, {FORM_CHANGE_END}, }; -const struct FormChange sOricorioFormChangeTable[] = { +static const struct FormChange sOricorioFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_ORICORIO, ITEM_RED_NECTAR}, {FORM_ITEM_USE, SPECIES_ORICORIO_POM_POM, ITEM_YELLOW_NECTAR}, {FORM_ITEM_USE, SPECIES_ORICORIO_PAU, ITEM_PINK_NECTAR}, @@ -146,7 +145,7 @@ const struct FormChange sOricorioFormChangeTable[] = { {FORM_CHANGE_END}, }; -const struct FormChange sSilvallyFormChangeTable[] = { +static const struct FormChange sSilvallyFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_SILVALLY, ITEM_NONE, ABILITY_RKS_SYSTEM}, {FORM_ITEM_HOLD, SPECIES_SILVALLY_BUG, ITEM_BUG_MEMORY, ABILITY_RKS_SYSTEM}, {FORM_ITEM_HOLD, SPECIES_SILVALLY_DARK, ITEM_DARK_MEMORY, ABILITY_RKS_SYSTEM}, @@ -167,6 +166,5 @@ const struct FormChange sSilvallyFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_SILVALLY_WATER, ITEM_WATER_MEMORY, ABILITY_RKS_SYSTEM}, }; -#undef FORM_CHANGE_END #undef WHEN_LEARNED #undef WHEN_FORGOTTEN diff --git a/src/pokemon.c b/src/pokemon.c index ec84c05c2..fcb94204a 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1847,8 +1847,9 @@ const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] = #include "data/pokemon/evolution.h" #include "data/pokemon/level_up_learnset_pointers.h" #include "data/pokemon/form_species_tables.h" -#include "data/pokemon/form_change_tables.h" #include "data/pokemon/form_species_table_pointers.h" +#include "data/pokemon/form_change_tables.h" +#include "data/pokemon/form_change_table_pointers.h" // SPECIES_NONE are ignored in the following two tables, so decrement before accessing these arrays to get the right result @@ -7880,3 +7881,38 @@ u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId) } return targetFormId; } + +// returns SPECIES_NONE if no form change is possible +u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg) +{ + u32 i; + u16 targetSpecies = SPECIES_NONE; + u16 originalSpecies = GetMonData(mon, MON_DATA_SPECIES, NULL); + const struct FormChange *formChanges = gFormChangeTablePointers[originalSpecies]; + if (formChanges == NULL) + return SPECIES_NONE; + + for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) { + if (method == formChanges[i].method) { + u32 ability = GetAbilityBySpecies(originalSpecies, GetMonData(mon, MON_DATA_ABILITY_NUM, NULL)); + switch (method) + { + case FORM_ITEM_HOLD: + if (GetMonData(mon, MON_DATA_HELD_ITEM, NULL) == formChanges[i].param1 && (ability == formChanges[i].param2 || formChanges[i].param2 == ABILITY_NONE)) + break; + case FORM_ITEM_USE: + if (arg == formChanges[i].param1 && (ability == formChanges[i].param2 || formChanges[i].param2 == ABILITY_NONE)) + targetSpecies = formChanges[i].targetSpecies; + break; + case FORM_MOVE: + if (MonKnowsMove(mon, formChanges[i].param1) != formChanges[i].param2) + targetSpecies = formChanges[i].targetSpecies; + break; + case FORM_WITHDRAW: + targetSpecies = formChanges[i].targetSpecies; + break; + } + } + } + return originalSpecies != targetSpecies ? targetSpecies : SPECIES_NONE; +} From 07af84db8a112003bff35c7c0f5cfbbb09dd98a6 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Wed, 3 Mar 2021 13:54:25 -0600 Subject: [PATCH 08/14] Implement FORM_ITEM_USE. Credits to Lunos for work on Gracidea --- include/item_use.h | 2 ++ include/party_menu.h | 1 + src/item_use.c | 14 ++++++++++++++ src/party_menu.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/include/item_use.h b/include/item_use.h index f577f8d46..3bc3c2226 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -23,6 +23,8 @@ void ItemUseOutOfBattle_BlackWhiteFlute(u8); void ItemUseOutOfBattle_EvolutionStone(u8); void ItemUseOutOfBattle_Berry(u8); void ItemUseOutOfBattle_EnigmaBerry(u8); +void ItemUseOutOfBattle_FormChange(u8); +void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8); void ItemUseOutOfBattle_CannotUse(u8); void ItemUseInBattle_PokeBall(u8); void ItemUseInBattle_StatIncrease(u8); diff --git a/include/party_menu.h b/include/party_menu.h index 7f51d08c9..7ef6c2455 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -59,6 +59,7 @@ void ItemUseCB_TMHM(u8 taskId, TaskFunc task); void ItemUseCB_RareCandy(u8 taskId, TaskFunc task); void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task); void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task); +void ItemUseCB_FormChange(u8 taskId, TaskFunc task); u8 GetItemEffectType(u16 item); void CB2_PartyMenuFromStartMenu(void); void CB2_ChooseMonToGiveItem(void); diff --git a/src/item_use.c b/src/item_use.c index af0ca9ee5..785b5ad54 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -1118,6 +1118,20 @@ void ItemUseInBattle_EnigmaBerry(u8 taskId) } } +void ItemUseOutOfBattle_FormChange(u8 taskId) +{ + gItemUseCB = ItemUseCB_FormChange; + gTasks[taskId].data[0] = FALSE; + SetUpItemUseCallback(taskId); +} + +void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8 taskId) +{ + gItemUseCB = ItemUseCB_FormChange; + gTasks[taskId].data[0] = TRUE; + SetUpItemUseCallback(taskId); +} + void ItemUseOutOfBattle_CannotUse(u8 taskId) { DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem); diff --git a/src/party_menu.c b/src/party_menu.c index 2d4432367..fe2db7f9c 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -409,6 +409,8 @@ static bool8 SetUpFieldMove_Dive(void); #include "data/pokemon/tutor_learnsets.h" #include "data/party_menu.h" +static const u8 ChangedForm[] = _("{STR_VAR_1} changed Forme!{PAUSE_UNTIL_PRESS}"); + // code static void InitPartyMenu(u8 menuType, u8 layout, u8 partyAction, bool8 keepCursorPos, u8 messageId, TaskFunc task, MainCallback callback) { @@ -5165,6 +5167,38 @@ void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task) } } +void ItemUseCB_FormChange(u8 taskId, TaskFunc task) +{ + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; + u16 species = GetMonData(mon, MON_DATA_SPECIES); + u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_ITEM_USE, gSpecialVar_ItemId); + if (targetSpecies != SPECIES_NONE) + { + gPartyMenuUseExitCallback = TRUE; + PlaySE(SE_USE_ITEM); + PlayCry2(targetSpecies, 0, 0x7D, 0xA); + SetMonData(mon, MON_DATA_SPECIES, &targetSpecies); + FreeAndDestroyMonIconSprite(&gSprites[sPartyMenuBoxes[gPartyMenu.slotId].monSpriteId]); + CreatePartyMonIconSpriteParameterized(targetSpecies, GetMonData(mon, MON_DATA_PERSONALITY, NULL), &sPartyMenuBoxes[gPartyMenu.slotId], 0); + CalculateMonStats(mon); + GetMonNickname(mon, gStringVar1); + StringExpandPlaceholders(gStringVar4, ChangedForm); + DisplayPartyMenuMessage(gStringVar4, FALSE); + if (gTasks[taskId].data[0] == TRUE) + RemoveBagItem(gSpecialVar_ItemId, 1); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = task; + } + else + { + gPartyMenuUseExitCallback = FALSE; + PlaySE(SE_SELECT); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = task; + } +} + u8 GetItemEffectType(u16 item) { const u8 *itemEffect; From f49da96f1ddb51a15257062455d922f580ab0633 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Wed, 3 Mar 2021 15:08:28 -0600 Subject: [PATCH 09/14] Fix consumable item form change --- include/party_menu.h | 1 + src/item_use.c | 2 +- src/party_menu.c | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/party_menu.h b/include/party_menu.h index 7ef6c2455..75fe7b958 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -60,6 +60,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task); void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task); void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task); void ItemUseCB_FormChange(u8 taskId, TaskFunc task); +void ItemUseCB_FormChange_ConsumedOnUse(u8 taskId, TaskFunc task); u8 GetItemEffectType(u16 item); void CB2_PartyMenuFromStartMenu(void); void CB2_ChooseMonToGiveItem(void); diff --git a/src/item_use.c b/src/item_use.c index 785b5ad54..39d0d77e1 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -1127,7 +1127,7 @@ void ItemUseOutOfBattle_FormChange(u8 taskId) void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8 taskId) { - gItemUseCB = ItemUseCB_FormChange; + gItemUseCB = ItemUseCB_FormChange_ConsumedOnUse; gTasks[taskId].data[0] = TRUE; SetUpItemUseCallback(taskId); } diff --git a/src/party_menu.c b/src/party_menu.c index fe2db7f9c..f029ffff1 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5167,7 +5167,7 @@ void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task) } } -void ItemUseCB_FormChange(u8 taskId, TaskFunc task) +bool32 TryItemUseFormChange(u8 taskId, TaskFunc task) { struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 species = GetMonData(mon, MON_DATA_SPECIES); @@ -5184,10 +5184,9 @@ void ItemUseCB_FormChange(u8 taskId, TaskFunc task) GetMonNickname(mon, gStringVar1); StringExpandPlaceholders(gStringVar4, ChangedForm); DisplayPartyMenuMessage(gStringVar4, FALSE); - if (gTasks[taskId].data[0] == TRUE) - RemoveBagItem(gSpecialVar_ItemId, 1); ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; + return TRUE; } else { @@ -5196,6 +5195,20 @@ void ItemUseCB_FormChange(u8 taskId, TaskFunc task) DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; + return FALSE; + } +} + +void ItemUseCB_FormChange(u8 taskId, TaskFunc task) +{ + TryItemUseFormChange(taskId, task); +} + +void ItemUseCB_FormChange_ConsumedOnUse(u8 taskId, TaskFunc task) +{ + if (TryItemUseFormChange(taskId, task)) + { + RemoveBagItem(gSpecialVar_ItemId, 1); } } From dd73d8fc066ccafc1270abfbcba8d606779b9b09 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Wed, 3 Mar 2021 16:47:31 -0600 Subject: [PATCH 10/14] Fix wrong comment --- src/data/pokemon/form_change_tables.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index dd5e1e7b0..f199dbeea 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1,7 +1,4 @@ /* -All form changes are checked for the base species! -Putting a form change on a form has no effect - FORM_ITEM_USE: Changes any pokemon with a matching base species (even if it is a form) to the target species. From f8dfd8f353fc060cb24801ec08aa6ac50b8fa8d7 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 9 Mar 2021 11:53:01 -0600 Subject: [PATCH 11/14] Remove special casing --- src/pokemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokemon.c b/src/pokemon.c index fcb94204a..60a49468e 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -7908,7 +7908,7 @@ u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg) if (MonKnowsMove(mon, formChanges[i].param1) != formChanges[i].param2) targetSpecies = formChanges[i].targetSpecies; break; - case FORM_WITHDRAW: + default: targetSpecies = formChanges[i].targetSpecies; break; } From 3655fe52f37e3267060a5001ca9a9098f630614c Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 9 Mar 2021 11:53:39 -0600 Subject: [PATCH 12/14] Prison Bottle and Reveal Glass don't exist yet --- include/constants/pokemon_config.h | 4 ++-- src/data/pokemon/form_change_tables.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/constants/pokemon_config.h b/include/constants/pokemon_config.h index e1e0540dd..48c90073f 100644 --- a/include/constants/pokemon_config.h +++ b/include/constants/pokemon_config.h @@ -154,8 +154,8 @@ //FORM_ITEM_USE #define ITEM_GRACIDEA ITEM_NONE -#define ITEM_REVEAL_GLASS ITEM_NONE -#define ITEM_PRISON_BOTTLE ITEM_NONE +// #define ITEM_REVEAL_GLASS ITEM_NONE +// #define ITEM_PRISON_BOTTLE ITEM_NONE #define ITEM_RED_NECTAR ITEM_NONE #define ITEM_YELLOW_NECTAR ITEM_NONE #define ITEM_PINK_NECTAR ITEM_NONE diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index f199dbeea..5ea28e309 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -77,32 +77,32 @@ static const struct FormChange sArceusFormChangeTable[] = { }; static const struct FormChange sTornadusFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, + // {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sTornadusTherianFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, + // {FORM_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sThundurusFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, + // {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sThundurusTherianFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS}, + // {FORM_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sLandorusFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, + // {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sLandorusTherianFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS}, + // {FORM_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; @@ -125,7 +125,7 @@ static const struct FormChange sGenesectFormChangeTable[] = { }; static const struct FormChange sHoopaFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, + // {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, {FORM_CHANGE_END}, }; From c0040b5ce55f221dcc058ebdd8a73f9b9b97bea6 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Tue, 9 Mar 2021 12:20:13 -0600 Subject: [PATCH 13/14] Form change on daycare withdraw --- src/daycare.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/daycare.c b/src/daycare.c index 2a1efefcc..82c196c72 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -247,6 +247,7 @@ static void ApplyDaycareExperience(struct Pokemon *mon) static u16 TakeSelectedPokemonFromDaycare(struct DaycareMon *daycareMon) { u16 species; + u16 newSpecies; u32 experience; struct Pokemon pokemon; @@ -254,6 +255,13 @@ static u16 TakeSelectedPokemonFromDaycare(struct DaycareMon *daycareMon) species = GetBoxMonData(&daycareMon->mon, MON_DATA_SPECIES); BoxMonToMon(&daycareMon->mon, &pokemon); + newSpecies = GetFormChangeTargetSpecies(&pokemon, FORM_WITHDRAW, 0); + if (newSpecies != SPECIES_NONE) { + SetMonData(&pokemon, MON_DATA_SPECIES, &newSpecies); + CalculateMonStats(&pokemon); + species = newSpecies; + } + if (GetMonData(&pokemon, MON_DATA_LEVEL) != MAX_LEVEL) { experience = GetMonData(&pokemon, MON_DATA_EXP) + daycareMon->steps; From 22478b857b36b7b59d5daa2b41826289d8563d0d Mon Sep 17 00:00:00 2001 From: ExpoSeed <43502820+ExpoSeed@users.noreply.github.com> Date: Fri, 28 May 2021 19:24:44 -0500 Subject: [PATCH 14/14] Add {FORM_CHANGE_END} to Silvally and Genesect --- src/data/pokemon/form_change_tables.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 5ea28e309..737a05ee8 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -122,6 +122,7 @@ static const struct FormChange sGenesectFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, {FORM_ITEM_HOLD, SPECIES_GENESECT_BURN_DRIVE, ITEM_BURN_DRIVE}, {FORM_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, + {FORM_CHANGE_END}, }; static const struct FormChange sHoopaFormChangeTable[] = { @@ -161,6 +162,7 @@ static const struct FormChange sSilvallyFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_SILVALLY_ROCK, ITEM_ROCK_MEMORY, ABILITY_RKS_SYSTEM}, {FORM_ITEM_HOLD, SPECIES_SILVALLY_STEEL, ITEM_STEEL_MEMORY, ABILITY_RKS_SYSTEM}, {FORM_ITEM_HOLD, SPECIES_SILVALLY_WATER, ITEM_WATER_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_END}, }; #undef WHEN_LEARNED