Changes Evolution methods to Enums (#4977)

* Changes Evolution methods to Enums

* make U8_ENUM to include/constants/global.h

* revert previous commit

* Update include/constants/pokemon.h

---------

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>
This commit is contained in:
Alex 2024-08-05 21:54:37 +02:00 committed by GitHub
parent 9ac8d0de25
commit 12351d520d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 73 additions and 64 deletions

View file

@ -243,71 +243,80 @@
#define F_SUMMARY_SCREEN_FLIP_SPRITE 0x80
// Evolution types
#define EVOLUTIONS_END 0xFFFF // Not an actual evolution, used to mark the end of an evolution array.
#define EVO_NONE 0xFFFE // Not an actual evolution, used to generate offspring that can't evolve into the specified species, like regional forms.
#define EVO_FRIENDSHIP 1 // Pokémon levels up with friendship ≥ 220
#define EVO_FRIENDSHIP_DAY 2 // Pokémon levels up during the day with friendship ≥ 220
#define EVO_FRIENDSHIP_NIGHT 3 // Pokémon levels up at night with friendship ≥ 220
#define EVO_LEVEL 4 // Pokémon reaches the specified level
#define EVO_TRADE 5 // Pokémon is traded
#define EVO_TRADE_ITEM 6 // Pokémon is traded while it's holding the specified item
#define EVO_ITEM 7 // specified item is used on Pokémon
#define EVO_LEVEL_ATK_GT_DEF 8 // Pokémon reaches the specified level with attack > defense
#define EVO_LEVEL_ATK_EQ_DEF 9 // Pokémon reaches the specified level with attack = defense
#define EVO_LEVEL_ATK_LT_DEF 10 // Pokémon reaches the specified level with attack < defense
#define EVO_LEVEL_SILCOON 11 // Pokémon reaches the specified level with a Silcoon personality value
#define EVO_LEVEL_CASCOON 12 // Pokémon reaches the specified level with a Cascoon personality value
#define EVO_LEVEL_NINJASK 13 // Pokémon reaches the specified level (special value for Ninjask)
#define EVO_LEVEL_SHEDINJA 14 // Pokémon reaches the specified level (special value for Shedinja)
#define EVO_BEAUTY 15 // Pokémon levels up with beauty ≥ specified value
#define EVO_LEVEL_FEMALE 16 // Pokémon reaches the specified level, is female
#define EVO_LEVEL_MALE 17 // Pokémon reaches the specified level, is male
#define EVO_LEVEL_NIGHT 18 // Pokémon reaches the specified level, is night
#define EVO_LEVEL_DAY 19 // Pokémon reaches the specified level, is day
#define EVO_LEVEL_DUSK 20 // Pokémon reaches the specified level, is dusk (5-6 P.M)
#define EVO_ITEM_HOLD_DAY 21 // Pokémon levels up, holds specified item at day
#define EVO_ITEM_HOLD_NIGHT 22 // Pokémon levels up, holds specified item at night
#define EVO_MOVE 23 // Pokémon levels up, knows specified move
#define EVO_FRIENDSHIP_MOVE_TYPE 24 // Pokémon levels up with friendship ≥ 220, knows move with specified type
#define EVO_MAPSEC 25 // Pokémon levels up on specified mapsec
#define EVO_ITEM_MALE 26 // specified item is used on a male Pokémon
#define EVO_ITEM_FEMALE 27 // specified item is used on a female Pokémon
#define EVO_LEVEL_RAIN 28 // Pokémon reaches the specified level during rain in the overworld
#define EVO_SPECIFIC_MON_IN_PARTY 29 // Pokémon levels up with a specified Pokémon in party
#define EVO_LEVEL_DARK_TYPE_MON_IN_PARTY 30 // Pokémon reaches the specified level with a Dark Type Pokémon in party
#define EVO_TRADE_SPECIFIC_MON 31 // Pokémon is traded for a specified Pokémon
#define EVO_SPECIFIC_MAP 32 // Pokémon levels up on specified map
#define EVO_LEVEL_NATURE_AMPED 33 // Pokémon reaches the specified level, it has a Hardy, Brave, Adamant, Naughty, Docile, Impish, Lax, Hasty, Jolly, Naive, Rash, Sassy, or Quirky nature.
#define EVO_LEVEL_NATURE_LOW_KEY 34 // Pokémon reaches the specified level, it has a Lonely, Bold, Relaxed, Timid, Serious, Modest, Mild, Quiet, Bashful, Calm, Gentle, or Careful nature.
#define EVO_CRITICAL_HITS 35 // Pokémon performs specified number of critical hits in one battle
#define EVO_SCRIPT_TRIGGER_DMG 36 // Pokémon has specified HP below max, then player interacts trigger
#define EVO_DARK_SCROLL 37 // interacts with Scroll of Darkness
#define EVO_WATER_SCROLL 38 // interacts with Scroll of Waters
#define EVO_ITEM_NIGHT 39 // specified item is used on Pokémon, is night
#define EVO_ITEM_DAY 40 // specified item is used on Pokémon, is day
#define EVO_ITEM_HOLD 41 // Pokémon levels up, holds specified item
#define EVO_LEVEL_FOG 42 // Pokémon reaches the specified level during fog in the overworld
#define EVO_MOVE_TWO_SEGMENT 43 // Pokémon levels up, knows specified move, has a personality value with a modulus of 0
#define EVO_MOVE_THREE_SEGMENT 44 // Pokémon levels up, knows specified move, has a personality value with a modulus of 1-99
#define EVO_LEVEL_FAMILY_OF_THREE 45 // Pokémon reaches the specified level in battle with a personality value with a modulus of 0
#define EVO_LEVEL_FAMILY_OF_FOUR 46 // Pokémon reaches the specified level in battle with a personality value with a modulus of 1-99
#define EVO_USE_MOVE_TWENTY_TIMES 47 // Pokémon levels up after having used a move for at least 20 times
#define EVO_RECOIL_DAMAGE_MALE 48 // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a male
#define EVO_RECOIL_DAMAGE_FEMALE 49 // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a female
#define EVO_ITEM_COUNT_999 50 // Pokémon levels up after trainer has collected 999 of a specific item
#define EVO_DEFEAT_THREE_WITH_ITEM 51 // Pokémon levels up after having defeat 3 Pokémon of the same species holding the specified item
#define EVO_OVERWORLD_STEPS 52 // Pokémon levels up after having taken a specific amount of steps in the overworld (or as the party lead if OW_FOLLOWERS_ENABLED is FALSE) without switching
// Evolution 'modes,' for GetEvolutionTargetSpecies
#define EVO_MODE_NORMAL 0
#define EVO_MODE_CANT_STOP 1
#define EVO_MODE_TRADE 2
#define EVO_MODE_ITEM_USE 3
#define EVO_MODE_ITEM_CHECK 4 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve
#define EVO_MODE_BATTLE_SPECIAL 5
#define EVO_MODE_OVERWORLD_SPECIAL 6
#define EVO_MODE_BATTLE_ONLY 7 // This mode is only used in battles to support Tandemaus' unique requirement
#if MODERN
#define U8_ENUM : u8
#else
#define U8_ENUM
#endif
enum EvolutionMethods U8_ENUM {
EVO_FRIENDSHIP, // Pokémon levels up with friendship ≥ 220
EVO_FRIENDSHIP_DAY, // Pokémon levels up during the day with friendship ≥ 220
EVO_FRIENDSHIP_NIGHT, // Pokémon levels up at night with friendship ≥ 220
EVO_LEVEL, // Pokémon reaches the specified level
EVO_TRADE, // Pokémon is traded
EVO_TRADE_ITEM, // Pokémon is traded while it's holding the specified item
EVO_ITEM, // specified item is used on Pokémon
EVO_LEVEL_ATK_GT_DEF, // Pokémon reaches the specified level with attack > defense
EVO_LEVEL_ATK_EQ_DEF, // Pokémon reaches the specified level with attack = defense
EVO_LEVEL_ATK_LT_DEF, // Pokémon reaches the specified level with attack < defense
EVO_LEVEL_SILCOON, // Pokémon reaches the specified level with a Silcoon personality value
EVO_LEVEL_CASCOON, // Pokémon reaches the specified level with a Cascoon personality value
EVO_LEVEL_NINJASK, // Pokémon reaches the specified level (special value for Ninjask)
EVO_LEVEL_SHEDINJA, // Pokémon reaches the specified level (special value for Shedinja)
EVO_BEAUTY, // Pokémon levels up with beauty ≥ specified value
EVO_LEVEL_FEMALE, // Pokémon reaches the specified level, is female
EVO_LEVEL_MALE, // Pokémon reaches the specified level, is male
EVO_LEVEL_NIGHT, // Pokémon reaches the specified level, is night
EVO_LEVEL_DAY, // Pokémon reaches the specified level, is day
EVO_LEVEL_DUSK, // Pokémon reaches the specified level, is dusk (5-6 P.M)
EVO_ITEM_HOLD_DAY, // Pokémon levels up, holds specified item at day
EVO_ITEM_HOLD_NIGHT, // Pokémon levels up, holds specified item at night
EVO_MOVE, // Pokémon levels up, knows specified move
EVO_FRIENDSHIP_MOVE_TYPE, // Pokémon levels up with friendship ≥ 220, knows move with specified type
EVO_MAPSEC, // Pokémon levels up on specified mapsec
EVO_ITEM_MALE, // specified item is used on a male Pokémon
EVO_ITEM_FEMALE, // specified item is used on a female Pokémon
EVO_LEVEL_RAIN, // Pokémon reaches the specified level during rain in the overworld
EVO_SPECIFIC_MON_IN_PARTY, // Pokémon levels up with a specified Pokémon in party
EVO_LEVEL_DARK_TYPE_MON_IN_PARTY, // Pokémon reaches the specified level with a Dark Type Pokémon in party
EVO_TRADE_SPECIFIC_MON, // Pokémon is traded for a specified Pokémon
EVO_SPECIFIC_MAP, // Pokémon levels up on specified map
EVO_LEVEL_NATURE_AMPED, // Pokémon reaches the specified level, it has a Hardy, Brave, Adamant, Naughty, Docile, Impish, Lax, Hasty, Jolly, Naive, Rash, Sassy, or Quirky nature.
EVO_LEVEL_NATURE_LOW_KEY, // Pokémon reaches the specified level, it has a Lonely, Bold, Relaxed, Timid, Serious, Modest, Mild, Quiet, Bashful, Calm, Gentle, or Careful nature.
EVO_CRITICAL_HITS, // Pokémon performs specified number of critical hits in one battle
EVO_SCRIPT_TRIGGER_DMG, // Pokémon has specified HP below max, then player interacts trigger
EVO_DARK_SCROLL, // interacts with Scroll of Darkness
EVO_WATER_SCROLL, // interacts with Scroll of Waters
EVO_ITEM_NIGHT, // specified item is used on Pokémon, is night
EVO_ITEM_DAY, // specified item is used on Pokémon, is day
EVO_ITEM_HOLD, // Pokémon levels up, holds specified item
EVO_LEVEL_FOG, // Pokémon reaches the specified level during fog in the overworld
EVO_MOVE_TWO_SEGMENT, // Pokémon levels up, knows specified move, has a personality value with a modulus of 0
EVO_MOVE_THREE_SEGMENT, // Pokémon levels up, knows specified move, has a personality value with a modulus of 1-99
EVO_LEVEL_FAMILY_OF_THREE, // Pokémon reaches the specified level in battle with a personality value with a modulus of 0
EVO_LEVEL_FAMILY_OF_FOUR, // Pokémon reaches the specified level in battle with a personality value with a modulus of 1-99
EVO_USE_MOVE_TWENTY_TIMES, // Pokémon levels up after having used a move for at least 20 times
EVO_RECOIL_DAMAGE_MALE, // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a male
EVO_RECOIL_DAMAGE_FEMALE, // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a female
EVO_ITEM_COUNT_999, // Pokémon levels up after trainer has collected 999 of a specific item
EVO_DEFEAT_THREE_WITH_ITEM, // Pokémon levels up after having defeat 3 Pokémon of the same species holding the specified item
EVO_OVERWORLD_STEPS, // Pokémon levels up after having taken a specific amount of steps in the overworld
};
enum EvolutionMode U8_ENUM {
EVO_MODE_NORMAL,
EVO_MODE_CANT_STOP,
EVO_MODE_TRADE,
EVO_MODE_ITEM_USE,
EVO_MODE_ITEM_CHECK, // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve
EVO_MODE_BATTLE_SPECIAL,
EVO_MODE_OVERWORLD_SPECIAL,
EVO_MODE_BATTLE_ONLY, // This mode is only used in battles to support Tandemaus' unique requirement
};
#define MON_PIC_WIDTH 64
#define MON_PIC_HEIGHT 64

View file

@ -798,7 +798,7 @@ u8 GetItemEffectParamOffset(u32 battler, u16 itemId, u8 effectByte, u8 effectBit
u8 *UseStatIncreaseItem(u16 itemId);
u8 GetNature(struct Pokemon *mon);
u8 GetNatureFromPersonality(u32 personality);
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem, struct Pokemon *tradePartner);
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner);
bool8 IsMonPastEvolutionLevel(struct Pokemon *mon);
u16 NationalPokedexNumToSpecies(u16 nationalNum);
u16 NationalToHoennOrder(u16 nationalNum);

View file

@ -4410,7 +4410,7 @@ static u32 GetGMaxTargetSpecies(u32 species)
return SPECIES_NONE;
}
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, struct Pokemon *tradePartner)
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner)
{
int i, j;
u16 targetSpecies = SPECIES_NONE;