implemented toggelable cancellation / multi-evo

This commit is contained in:
AgustinGDLV 2022-05-08 20:55:29 -07:00
parent 8a0a2a5a39
commit 54163240d8
5 changed files with 37 additions and 15 deletions

View File

@ -1940,11 +1940,14 @@
special CreateEventLegalEnemyMon
.endm
@ Attempts to trigger a special evolution method.
@ 'evoMethod' is the evolution you want to trigger.
@ Attempts to trigger a special evolution method in the overworld.
@ 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
@ EX: tryspecialevo EVO_WATER_SCROLL, FALSE, FALSE triggers Kubfu's EVO_WATER_SCROLL evolution
@ method, cannot be cancelled in the evolution scene, and will only evolve one Kubfu if there
@ are multiple in the player's party.
.macro tryspecialevo evoMethod:req, canStopEvo=TRUE, tryMultiple=TRUE
setvar VAR_0x8000, \evoMethod
setvar VAR_0x8001, \canStopEvo
setvar VAR_0x8002, \tryMultiple
special TrySpecialOverworldEvo
.endm

View File

@ -535,3 +535,4 @@ gSpecials::
def_special RemoveRecordsWindow
def_special CloseDeptStoreElevatorWindow
def_special TrySetBattleTowerLinkType
def_special TrySpecialOverworldEvo

View File

@ -507,11 +507,7 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] =
[SPECIES_PONYTA_GALARIAN] = {{EVO_LEVEL, 40, SPECIES_RAPIDASH_GALARIAN}},
[SPECIES_SLOWPOKE_GALARIAN] = {{EVO_ITEM, ITEM_NONE, SPECIES_SLOWBRO_GALARIAN},
{EVO_ITEM, ITEM_NONE, SPECIES_SLOWKING_GALARIAN}},
#ifdef BATTLE_ENGINE
[SPECIES_FARFETCHD_GALARIAN] = {{EVO_CRITICAL_HITS, 3, SPECIES_SIRFETCHD}},
#else
[SPECIES_FARFETCHD_GALARIAN] = {{EVO_LEVEL, 0, SPECIES_SIRFETCHD}},
#endif
[SPECIES_FARFETCHD_GALARIAN] = {{EVO_CRITICAL_HITS, 3, SPECIES_SIRFETCHD}},
[SPECIES_MR_MIME_GALARIAN] = {{EVO_LEVEL, 42, SPECIES_MR_RIME}},
[SPECIES_CORSOLA_GALARIAN] = {{EVO_LEVEL, 38, SPECIES_CURSOLA}},
[SPECIES_ZIGZAGOON_GALARIAN] = {{EVO_LEVEL, 20, SPECIES_LINOONE_GALARIAN}},

View File

@ -1,5 +1,4 @@
#define LEVEL_UP_MOVE(lvl, moveLearned) {.move = moveLearned, .level = lvl}
#define LEVEL_UP_END (0xffff)
static const struct LevelUpMove sBulbasaurLevelUpLearnset[] = {
LEVEL_UP_MOVE( 1, MOVE_TACKLE),

View File

@ -66,6 +66,7 @@ static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move);
static bool8 ShouldSkipFriendshipChange(void);
static u8 SendMonToPC(struct Pokemon* mon);
static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv);
void TrySpecialOverworldEvo();
EWRAM_DATA static u8 sLearningMoveTableID = 0;
EWRAM_DATA u8 gPlayerPartyCount = 0;
@ -74,6 +75,7 @@ EWRAM_DATA struct Pokemon gPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA struct Pokemon gEnemyParty[PARTY_SIZE] = {0};
EWRAM_DATA struct SpriteTemplate gMultiuseSpriteTemplate = {0};
EWRAM_DATA static struct MonSpritesGfxManager *sMonSpritesGfxManagers[MON_SPR_GFX_MANAGERS_COUNT] = {NULL};
EWRAM_DATA static u8 sTriedEvolving = 0;
#include "data/battle_moves.h"
@ -6777,10 +6779,14 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s
switch (gEvolutionTable[species][i].method)
{
case EVO_SCRIPT_TRIGGER_DMG:
{
u16 currentHp = GetMonData(mon, MON_DATA_HP, NULL);
if (evolutionItem == EVO_SCRIPT_TRIGGER_DMG
&& (GetMonData(mon, MON_DATA_MAX_HP, NULL) - GetMonData(mon, MON_DATA_HP, NULL) >= gEvolutionTable[species][i].param))
&& currentHp != 0
&& (GetMonData(mon, MON_DATA_MAX_HP, NULL) - currentHp >= gEvolutionTable[species][i].param))
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
}
case EVO_DARK_SCROLL:
if (evolutionItem == EVO_DARK_SCROLL)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
@ -8469,19 +8475,36 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv)
}
}
static void CB2_DoSpecialOverworldEvo(void)
{
TrySpecialOverworldEvo();
}
// Attempts to perform non-level/item related overworld evolutions; called by tryspecialevo command.
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);
if (targetSpecies != SPECIES_NONE)
if (targetSpecies != SPECIES_NONE && !(sTriedEvolving & gBitTable[i]))
{
gCB2_AfterEvolution = CB2_ReturnToField;
BeginEvolutionScene(&gPlayerParty[i], targetSpecies, TRUE, i);
if (tryMultiple)
{
gCB2_AfterEvolution = CB2_DoSpecialOverworldEvo;
sTriedEvolving |= gBitTable[i];
}
else
gCB2_AfterEvolution = CB2_ReturnToField;
BeginEvolutionScene(&gPlayerParty[i], targetSpecies, canStopEvo, i);
return;
}
}
sTriedEvolving = 0;
SetMainCallback2(CB2_ReturnToField);
}