From dffaaeaaa6f6c0aba96ee50a096e48661830e796 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Wed, 12 Jun 2024 09:31:59 +0200 Subject: [PATCH] Add Leader's Crest evolution method (#4768) * Add Leader's Crest evolution method * Fix typo in in HGSS dex * Update src/pokedex_plus_hgss.c Co-authored-by: sneed <56992013+Sneed69@users.noreply.github.com> * Update src/battle_script_commands.c --------- Co-authored-by: sneed <56992013+Sneed69@users.noreply.github.com> Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> --- asm/macros/battle_script.inc | 4 ++++ data/battle_scripts_1.s | 1 + include/constants/pokemon.h | 1 + src/battle_script_commands.c | 12 ++++++++++++ src/data/pokemon/species_info/gen_5_families.h | 2 +- src/pokedex_plus_hgss.c | 7 +++++++ src/pokemon.c | 4 ++++ 7 files changed, 30 insertions(+), 1 deletion(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9c6ccd87d8..a3b800aa71 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1641,6 +1641,10 @@ callnative BS_TryUpdateRecoilTracker .endm + .macro tryupdateleaderscresttracker + callnative BS_TryUpdateLeadersCrestTracker + .endm + .macro trytidyup clear:req, jumpInstr:req callnative BS_TryTidyUp .byte \clear diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 32049c38b9..fe7c5b6349 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5477,6 +5477,7 @@ BattleScript_FaintAttacker:: BattleScript_FaintTarget:: tryillusionoff BS_TARGET tryactivategulpmissile + tryupdateleaderscresttracker playfaintcry BS_TARGET pause B_WAIT_TIME_LONG dofaintanimation BS_TARGET diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 6d50fac4df..e49c949b7b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -296,6 +296,7 @@ #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_WITH_ITEM 51 // Pokémon levels up after having defeat 3 Pokémon of the same species holding the specified item // Evolution 'modes,' for GetEvolutionTargetSpecies #define EVO_MODE_NORMAL 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b73e05d45f..e61028bddf 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16914,6 +16914,11 @@ static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 use val = 0; SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val); break; + case EVO_DEFEAT_WITH_ITEM: + if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES) == GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_SPECIES) + && GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_HELD_ITEM) == evolutions[i].param) + SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val); + break; } return; } @@ -16939,6 +16944,13 @@ void BS_TryUpdateRecoilTracker(void) gBattlescriptCurrInstr = cmd->nextInstr; } +void BS_TryUpdateLeadersCrestTracker(void) +{ + NATIVE_ARGS(); + TryUpdateEvolutionTracker(EVO_DEFEAT_WITH_ITEM, 1, MOVE_NONE); + gBattlescriptCurrInstr = cmd->nextInstr; +} + void BS_TryTidyUp(void) { NATIVE_ARGS(u8 clear, const u8 *jumpInstr); diff --git a/src/data/pokemon/species_info/gen_5_families.h b/src/data/pokemon/species_info/gen_5_families.h index 25aa4cb4dd..997ae5f5f5 100644 --- a/src/data/pokemon/species_info/gen_5_families.h +++ b/src/data/pokemon/species_info/gen_5_families.h @@ -9814,7 +9814,7 @@ const struct SpeciesInfo gSpeciesInfoGen5[] = ) .levelUpLearnset = sBisharpLevelUpLearnset, .teachableLearnset = sBisharpTeachableLearnset, - .evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_KINGAMBIT}), + .evolutions = EVOLUTION({EVO_DEFEAT_WITH_ITEM, ITEM_LEADERS_CREST, SPECIES_KINGAMBIT}), }, #if P_GEN_9_CROSS_EVOS diff --git a/src/pokedex_plus_hgss.c b/src/pokedex_plus_hgss.c index 3599fb1ccb..bec3308065 100644 --- a/src/pokedex_plus_hgss.c +++ b/src/pokedex_plus_hgss.c @@ -249,6 +249,7 @@ static const u8 sText_EVO_USE_MOVE_TWENTY_TIMES[] = _("{LV}{UP_ARROW} after 20x static const u8 sText_EVO_RECOIL_DAMAGE_MALE[] = _("{LV}{UP_ARROW} with {STR_VAR_2} recoil, male"); static const u8 sText_EVO_RECOIL_DAMAGE_FEMALE[] = _("{LV}{UP_ARROW} with {STR_VAR_2} recoil, female"); static const u8 sText_EVO_ITEM_COUNT_999[] = _("{LV}{UP_ARROW} with 999 {STR_VAR_2} in bag"); +static const u8 sText_EVO_DEFEAT_WITH_ITEM[] = _("{LV}{UP_ARROW} defeating {STR_VAR_3} holding {STR_VAR_2}"); static const u8 sText_EVO_UNKNOWN[] = _("Method unknown"); static const u8 sText_EVO_NONE[] = _("{STR_VAR_1} has no evolution."); @@ -6627,6 +6628,12 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, sText_EVO_ITEM_COUNT_999); break; + case EVO_DEFEAT_WITH_ITEM: + item = evolutions[i].param; + CopyItemName(item, gStringVar2); + StringCopy(gStringVar3, GetSpeciesName(species)); + StringExpandPlaceholders(gStringVar4, sText_EVO_DEFEAT_WITH_ITEM); + break; default: StringExpandPlaceholders(gStringVar4, sText_EVO_UNKNOWN); break; diff --git a/src/pokemon.c b/src/pokemon.c index 6a761ea3f8..4fdb9ef6ba 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4684,6 +4684,10 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s if (evolutionTracker >= evolutions[i].param && GetMonGender(mon) == MON_FEMALE) targetSpecies = evolutions[i].targetSpecies; break; + case EVO_DEFEAT_WITH_ITEM: + if (evolutionTracker >= 3) + targetSpecies = evolutions[i].targetSpecies; + break; } } break;