From 7d42f9386151eabd2b471f591b28b55a519dbb62 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Thu, 5 May 2022 11:55:31 -0700 Subject: [PATCH] added special overworld evo changes --- asm/macros/event.inc | 9 +++++++++ include/constants/pokemon.h | 12 +++++++---- src/data/pokemon/evolution.h | 6 +++--- src/pokemon.c | 39 ++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 661e675c9..9d99d0432 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1939,3 +1939,12 @@ setvar VAR_0x8006, \item special CreateEventLegalEnemyMon .endm + + @ Attempts to trigger a special evolution method. + @ 'evoMethod' is the evolution you want to trigger. + @ There may be other conditions required which are coded for in GetEvolutionTargetSpecies. + @ EX: tryspecialevo EVO_WATER_SCROLL will trigger an evolution for Kubfu. + .macro tryspecialevo evoMethod:req + setvar VAR_0x8000, \evoMethod + special TrySpecialOverworldEvo + .endm \ No newline at end of file diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index ba9495158..2c2c98987 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -352,14 +352,18 @@ #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_SCRIPT_TRIGGER_DMG 35 // Pokémon has specified HP below max, then player interacts trigger +#define EVO_DARK_SCROLL 36 // interacts with Scroll of Darkness +#define EVO_WATER_SCROLL 37 // interacts with Scroll of Waters #define EVOS_PER_MON 10 // Evolution 'modes,' for GetEvolutionTargetSpecies -#define EVO_MODE_NORMAL 0 -#define EVO_MODE_TRADE 1 -#define EVO_MODE_ITEM_USE 2 -#define EVO_MODE_ITEM_CHECK 3 // 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_NORMAL 0 +#define EVO_MODE_TRADE 1 +#define EVO_MODE_ITEM_USE 2 +#define EVO_MODE_ITEM_CHECK 3 // 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_OVERWORLD_SPECIAL 4 // Form change types #define FORM_CHANGE_END 0 diff --git a/src/data/pokemon/evolution.h b/src/data/pokemon/evolution.h index b431b88a3..475e7fc91 100644 --- a/src/data/pokemon/evolution.h +++ b/src/data/pokemon/evolution.h @@ -493,8 +493,8 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_CUFANT] = {{EVO_LEVEL, 34, SPECIES_COPPERAJAH}}, [SPECIES_DREEPY] = {{EVO_LEVEL, 50, SPECIES_DRAKLOAK}}, [SPECIES_DRAKLOAK] = {{EVO_LEVEL, 60, SPECIES_DRAGAPULT}}, - [SPECIES_KUBFU] = {{EVO_LEVEL, 0, SPECIES_URSHIFU}, - {EVO_LEVEL, 0, SPECIES_URSHIFU_RAPID_STRIKE_STYLE}}, + [SPECIES_KUBFU] = {{EVO_DARK_SCROLL, 0, SPECIES_URSHIFU}, + {EVO_WATER_SCROLL, 0, SPECIES_URSHIFU_RAPID_STRIKE_STYLE}}, [SPECIES_RATTATA_ALOLAN] = {{EVO_LEVEL_NIGHT, 20, SPECIES_RATICATE_ALOLAN}}, [SPECIES_SANDSHREW_ALOLAN] = {{EVO_ITEM, ITEM_ICE_STONE, SPECIES_SANDSLASH_ALOLAN}}, [SPECIES_VULPIX_ALOLAN] = {{EVO_ITEM, ITEM_ICE_STONE, SPECIES_NINETALES_ALOLAN}}, @@ -513,7 +513,7 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_ZIGZAGOON_GALARIAN] = {{EVO_LEVEL, 20, SPECIES_LINOONE_GALARIAN}}, [SPECIES_LINOONE_GALARIAN] = {{EVO_LEVEL_NIGHT, 35, SPECIES_OBSTAGOON}}, [SPECIES_DARUMAKA_GALARIAN] = {{EVO_ITEM, ITEM_ICE_STONE, SPECIES_DARMANITAN_GALARIAN}}, - [SPECIES_YAMASK_GALARIAN] = {{EVO_LEVEL, 0, SPECIES_RUNERIGUS}}, + [SPECIES_YAMASK_GALARIAN] = {{EVO_SCRIPT_TRIGGER_DMG, 49, SPECIES_RUNERIGUS}}, [SPECIES_BURMY_SANDY_CLOAK] = {{EVO_LEVEL_FEMALE, 20, SPECIES_WORMADAM_SANDY_CLOAK}, {EVO_LEVEL_MALE, 20, SPECIES_MOTHIM}}, [SPECIES_BURMY_TRASH_CLOAK] = {{EVO_LEVEL_FEMALE, 20, SPECIES_WORMADAM_TRASH_CLOAK}, diff --git a/src/pokemon.c b/src/pokemon.c index 5b4027503..05047caec 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6755,6 +6755,28 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s } } break; + // Overworld evolution without leveling; evolution method is being passed into the evolutionItem arg. + case EVO_MODE_OVERWORLD_SPECIAL: + for (i = 0; i < EVOS_PER_MON; i++) + { + switch (gEvolutionTable[species][i].method) + { + case EVO_SCRIPT_TRIGGER_DMG: + if (evolutionItem == EVO_SCRIPT_TRIGGER_DMG + && (GetMonData(mon, MON_DATA_MAX_HP, NULL) - GetMonData(mon, MON_DATA_HP, NULL) >= gEvolutionTable[species][i].param)) + targetSpecies = gEvolutionTable[species][i].targetSpecies; + break; + case EVO_DARK_SCROLL: + if (evolutionItem == EVO_DARK_SCROLL) + targetSpecies = gEvolutionTable[species][i].targetSpecies; + break; + case EVO_WATER_SCROLL: + if (evolutionItem == EVO_WATER_SCROLL) + targetSpecies = gEvolutionTable[species][i].targetSpecies; + break; + } + } + break; } return targetSpecies; @@ -8431,3 +8453,20 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv) ivs[j++] = temp[i]; } } + +// Attempts to perform non-level/item related overworld evolutions; called by tryspecialevo command. +void TrySpecialOverworldEvo(void) +{ + u8 i; + u8 evoMethod = gSpecialVar_0x8000; + + for (i = 0; i < PARTY_SIZE; i++) + { + u16 targetSpecies = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, evoMethod, SPECIES_NONE); + if (targetSpecies != SPECIES_NONE) + { + gCB2_AfterEvolution = CB2_ReturnToField; + BeginEvolutionScene(&gPlayerParty[i], targetSpecies, TRUE, i); + } + } +}