Skip to content

Commit

Permalink
Evolution triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
AsparagusEduardo committed Jan 17, 2025
1 parent 00e2fc9 commit c912934
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 27 deletions.
5 changes: 2 additions & 3 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/data/pokemon/species_info/gen_5_families.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
6 changes: 3 additions & 3 deletions src/data/pokemon/species_info/gen_8_families.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
2 changes: 0 additions & 2 deletions src/pokedex_plus_hgss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
29 changes: 11 additions & 18 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c912934

Please sign in to comment.