From c912934a018f57bf88c4dd30b8f7a7b2629abeb9 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 17 Jan 2025 17:23:30 -0300 Subject: [PATCH] Evolution triggers --- include/constants/pokemon.h | 5 ++-- .../pokemon/species_info/gen_5_families.h | 2 +- .../pokemon/species_info/gen_8_families.h | 6 ++-- src/pokedex_plus_hgss.c | 2 -- src/pokemon.c | 29 +++++++------------ 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index a83aff12b6d7..fe3bea9981a7 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -274,6 +274,7 @@ enum EvolutionConditions { // Gen 8 IF_NATURE, // The Pokémon has a specific nature. IF_RECOIL_DAMAGE_GE, // The Pokémon suffered at least certain amount of non-fainting recoil damage. + IF_CURRENT_DAMAGE_GE, // The Pokémon has the specified difference of HP from its Max HP. IF_CRITICAL_HITS_GE, // The Pokémon performed the specified number of critical hits in one battle at least. IF_USED_MOVE_TWENTY_TIMES, // The Pokémon has used a move for at least 20 times. // Gen 9 @@ -291,9 +292,7 @@ enum EvolutionMethods { EVO_TRADE, // Pokémon is traded EVO_ITEM, // specified item is used on Pokémon EVO_SPLIT_FROM_EVO, // A clone is generated and evolved when another evolution happens - 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_SCRIPT_TRIGGER, // Player interacts with an overworld trigger EVO_LEVEL_BATTLE_ONLY, // Pokémon reaches the specified level, in battle only EVO_ITEM_COUNT_999, // Pokémon levels up after trainer has collected 999 of a specific item EVO_BATTLE_END, // Battle ends, doesn't need to level up diff --git a/src/data/pokemon/species_info/gen_5_families.h b/src/data/pokemon/species_info/gen_5_families.h index e1eea1f9aa26..57b2f262dc46 100644 --- a/src/data/pokemon/species_info/gen_5_families.h +++ b/src/data/pokemon/species_info/gen_5_families.h @@ -5316,7 +5316,7 @@ const struct SpeciesInfo gSpeciesInfoGen5[] = .teachableLearnset = sYamaskGalarTeachableLearnset, .eggMoveLearnset = sYamaskGalarEggMoveLearnset, .formSpeciesIdTable = sYamaskFormSpeciesIdTable, - .evolutions = EVOLUTION({EVO_SCRIPT_TRIGGER_DMG, 49, SPECIES_RUNERIGUS}), + .evolutions = EVOLUTION({EVO_SCRIPT_TRIGGER, 0, SPECIES_RUNERIGUS, CONDITIONS({IF_CURRENT_DAMAGE_GE, 49})}), }, [SPECIES_RUNERIGUS] = diff --git a/src/data/pokemon/species_info/gen_8_families.h b/src/data/pokemon/species_info/gen_8_families.h index 555b9e6dfef0..c721a9b6c2a4 100644 --- a/src/data/pokemon/species_info/gen_8_families.h +++ b/src/data/pokemon/species_info/gen_8_families.h @@ -6805,10 +6805,10 @@ const struct SpeciesInfo gSpeciesInfoGen8[] = .perfectIVCount = LEGENDARY_PERFECT_IV_COUNT, .levelUpLearnset = sKubfuLevelUpLearnset, .teachableLearnset = sKubfuTeachableLearnset, - .evolutions = EVOLUTION({EVO_DARK_SCROLL, 0, SPECIES_URSHIFU_SINGLE_STRIKE}, + .evolutions = EVOLUTION({EVO_SCRIPT_TRIGGER, 0, SPECIES_URSHIFU_SINGLE_STRIKE}, + {EVO_SCRIPT_TRIGGER, 1, SPECIES_URSHIFU_RAPID_STRIKE}, {EVO_ITEM, ITEM_SCROLL_OF_DARKNESS, SPECIES_URSHIFU_SINGLE_STRIKE}, - {EVO_WATER_SCROLL, 0, SPECIES_URSHIFU_RAPID_STRIKE}, - {EVO_ITEM, ITEM_SCROLL_OF_WATERS, SPECIES_URSHIFU_RAPID_STRIKE}), + {EVO_ITEM, ITEM_SCROLL_OF_WATERS, SPECIES_URSHIFU_RAPID_STRIKE}), }, [SPECIES_URSHIFU_SINGLE_STRIKE] = diff --git a/src/pokedex_plus_hgss.c b/src/pokedex_plus_hgss.c index ae58f2084ab9..165d0c999954 100644 --- a/src/pokedex_plus_hgss.c +++ b/src/pokedex_plus_hgss.c @@ -6602,7 +6602,6 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept ConvertIntToDecimalStringN(gStringVar2, evolutions[i].param, STR_CONV_MODE_LEADING_ZEROS, EVO_SCREEN_CRITS_DIGITS); //crits StringExpandPlaceholders(gStringVar4, sText_EVO_CRITICAL_HITS); break; - */ case EVO_SCRIPT_TRIGGER_DMG: ConvertIntToDecimalStringN(gStringVar2, evolutions[i].param, STR_CONV_MODE_LEADING_ZEROS, EVO_SCREEN_DMG_DIGITS); //damage StringExpandPlaceholders(gStringVar4, sText_EVO_SCRIPT_TRIGGER_DMG); @@ -6617,7 +6616,6 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, sText_EVO_WATER_SCROLL ); break; - /* case EVO_ITEM_NIGHT: item = evolutions[i].param; CopyItemName(item, gStringVar2); diff --git a/src/pokemon.c b/src/pokemon.c index 46daffb61e00..1ed02022abad 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4612,9 +4612,16 @@ static bool32 DoesMonMeetAdditionalConditions(struct Pokemon *mon, const struct if (evolutionTracker >= params[i].arg) currentCondition = TRUE; break; + case IF_CURRENT_DAMAGE_GE: + { + u32 currentHp = GetMonData(mon, MON_DATA_HP, NULL); + if (currentHp != 0 && (GetMonData(mon, MON_DATA_MAX_HP, NULL) - currentHp >= params[i].arg)) + currentCondition = TRUE; + break; + } case IF_CRITICAL_HITS_GE: if (partyId != PARTY_SIZE && gPartyCriticalHits[partyId] >= params[i].arg) - currentCondition = TRUE; + currentCondition = TRUE; break; case IF_USED_MOVE_TWENTY_TIMES: if (evolutionTracker >= 20) @@ -4828,21 +4835,8 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 switch (evolutions[i].method) { - case EVO_SCRIPT_TRIGGER_DMG: - { - u16 currentHp = GetMonData(mon, MON_DATA_HP, NULL); - if (evolutionItem == EVO_SCRIPT_TRIGGER_DMG - && currentHp != 0 - && (GetMonData(mon, MON_DATA_MAX_HP, NULL) - currentHp >= evolutions[i].param)) - conditionsMet = TRUE; - break; - } - case EVO_DARK_SCROLL: - if (evolutionItem == EVO_DARK_SCROLL) - conditionsMet = TRUE; - break; - case EVO_WATER_SCROLL: - if (evolutionItem == EVO_WATER_SCROLL) + case EVO_SCRIPT_TRIGGER: + if (gSpecialVar_0x8000 == evolutions[i].param) conditionsMet = TRUE; break; } @@ -6698,13 +6692,12 @@ void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv) void TrySpecialOverworldEvo(void) { u8 i; - u8 evoMethod = gSpecialVar_0x8000; u16 canStopEvo = gSpecialVar_0x8001; u16 tryMultiple = gSpecialVar_0x8002; for (i = 0; i < PARTY_SIZE; i++) { - u16 targetSpecies = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, evoMethod, SPECIES_NONE); + u16 targetSpecies = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, 0, SPECIES_NONE); if (targetSpecies != SPECIES_NONE && !(sTriedEvolving & (1u << i))) { sTriedEvolving |= 1u << i;