From 34c6771e9418c2ca09854a2703ee46317bf325df Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Wed, 27 Jan 2021 16:26:18 -0600 Subject: [PATCH] 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