Merge pull request #2112 from AgustinGDLV/evo_battle

Gen 8 Evolution Mechanics (Battle Engine)
This commit is contained in:
Eduardo Quezada D'Ottone 2022-05-09 17:40:19 -04:00 committed by GitHub
commit f80bab897f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 7 deletions

View File

@ -931,5 +931,6 @@ extern bool8 gHasFetchedBall;
extern u8 gLastUsedBall; extern u8 gLastUsedBall;
extern u16 gLastThrownBall; extern u16 gLastThrownBall;
extern bool8 gSwapDamageCategory; // Photon Geyser, Shell Side Arm, Light That Burns the Sky extern bool8 gSwapDamageCategory; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
extern u8 gPartyCriticalHits[PARTY_SIZE];
#endif // GUARD_BATTLE_H #endif // GUARD_BATTLE_H

View File

@ -379,14 +379,20 @@
#define EVO_SPECIFIC_MAP 32 // Pokémon levels up on specified map #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_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_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_CRITICAL_HITS 35 // Pokémon performs specified number of critical hits in one battle
#define EVO_SCRIPT_TRIGGER_DMG 36 // Pokémon has specified HP below max, then player interacts trigger
#define EVO_DARK_SCROLL 37 // interacts with Scroll of Darkness
#define EVO_WATER_SCROLL 38 // interacts with Scroll of Waters
#define EVOS_PER_MON 10 #define EVOS_PER_MON 10
// Evolution 'modes,' for GetEvolutionTargetSpecies // Evolution 'modes,' for GetEvolutionTargetSpecies
#define EVO_MODE_NORMAL 0 #define EVO_MODE_NORMAL 0
#define EVO_MODE_TRADE 1 #define EVO_MODE_TRADE 1
#define EVO_MODE_ITEM_USE 2 #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_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_BATTLE_SPECIAL 4
#define EVO_MODE_OVERWORLD_SPECIAL 5
#define NUM_MALE_LINK_FACILITY_CLASSES 8 #define NUM_MALE_LINK_FACILITY_CLASSES 8
#define NUM_FEMALE_LINK_FACILITY_CLASSES 8 #define NUM_FEMALE_LINK_FACILITY_CLASSES 8

View File

@ -117,6 +117,7 @@ static void HandleEndTurn_MonFled(void);
static void HandleEndTurn_FinishBattle(void); static void HandleEndTurn_FinishBattle(void);
static void SpriteCB_UnusedBattleInit(struct Sprite* sprite); static void SpriteCB_UnusedBattleInit(struct Sprite* sprite);
static void SpriteCB_UnusedBattleInit_Main(struct Sprite *sprite); static void SpriteCB_UnusedBattleInit_Main(struct Sprite *sprite);
static void TrySpecialEvolution(void);
EWRAM_DATA u16 gBattle_BG0_X = 0; EWRAM_DATA u16 gBattle_BG0_X = 0;
EWRAM_DATA u16 gBattle_BG0_Y = 0; EWRAM_DATA u16 gBattle_BG0_Y = 0;
@ -239,6 +240,8 @@ EWRAM_DATA bool8 gHasFetchedBall = FALSE;
EWRAM_DATA u8 gLastUsedBall = 0; EWRAM_DATA u8 gLastUsedBall = 0;
EWRAM_DATA u16 gLastThrownBall = 0; EWRAM_DATA u16 gLastThrownBall = 0;
EWRAM_DATA bool8 gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky EWRAM_DATA bool8 gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
EWRAM_DATA u8 gPartyCriticalHits[PARTY_SIZE] = {0};
EWRAM_DATA static u8 sTriedEvolving = 0;
void (*gPreBattleCallback1)(void); void (*gPreBattleCallback1)(void);
void (*gBattleMainFunc)(void); void (*gBattleMainFunc)(void);
@ -3001,6 +3004,7 @@ static void BattleStartClearSetData(void)
gBattleStruct->usedHeldItems[i][0] = 0; gBattleStruct->usedHeldItems[i][0] = 0;
gBattleStruct->usedHeldItems[i][1] = 0; gBattleStruct->usedHeldItems[i][1] = 0;
gBattleStruct->itemStolen[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); gBattleStruct->itemStolen[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
gPartyCriticalHits[i] = 0;
} }
gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
@ -5163,9 +5167,16 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void)
gIsFishingEncounter = FALSE; gIsFishingEncounter = FALSE;
gIsSurfingEncounter = FALSE; gIsSurfingEncounter = FALSE;
ResetSpriteData(); ResetSpriteData();
if (gLeveledUpInBattle && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT)) if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK
| BATTLE_TYPE_RECORDED_LINK
| BATTLE_TYPE_FIRST_BATTLE
| BATTLE_TYPE_SAFARI
| BATTLE_TYPE_FRONTIER
| BATTLE_TYPE_EREADER_TRAINER
| BATTLE_TYPE_WALLY_TUTORIAL))
&& (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT))
{ {
gBattleMainFunc = TryEvolvePokemon; gBattleMainFunc = TrySpecialEvolution;
} }
else else
{ {
@ -5183,6 +5194,30 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void)
} }
} }
static void TrySpecialEvolution(void) // Attempts to perform non-level related battle evolutions (not the script command).
{
s32 i;
for (i = 0; i < PARTY_SIZE; i++)
{
#ifndef POKEMON_EXPANSION
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i);
#else
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL);
#endif
if (species != SPECIES_NONE && !(sTriedEvolving & gBitTable[i]))
{
sTriedEvolving |= gBitTable[i];
FreeAllWindowBuffers();
gBattleMainFunc = WaitForEvoSceneToFinish;
EvolutionScene(&gPlayerParty[i], species, TRUE, i);
return;
}
}
sTriedEvolving = 0;
gBattleMainFunc = TryEvolvePokemon;
}
static void TryEvolvePokemon(void) static void TryEvolvePokemon(void)
{ {
s32 i; s32 i;
@ -5217,7 +5252,7 @@ static void TryEvolvePokemon(void)
static void WaitForEvoSceneToFinish(void) static void WaitForEvoSceneToFinish(void)
{ {
if (gMain.callback2 == BattleMainCB2) if (gMain.callback2 == BattleMainCB2)
gBattleMainFunc = TryEvolvePokemon; gBattleMainFunc = TrySpecialEvolution;
} }
static void ReturnFromBattleToOverworld(void) static void ReturnFromBattleToOverworld(void)

View File

@ -1906,6 +1906,7 @@ s8 GetInverseCritChance(u8 battlerAtk, u8 battlerDef, u32 move)
static void Cmd_critcalc(void) static void Cmd_critcalc(void)
{ {
u16 partySlot;
s32 critChance = CalcCritChanceStage(gBattlerAttacker, gBattlerTarget, gCurrentMove, TRUE); s32 critChance = CalcCritChanceStage(gBattlerAttacker, gBattlerTarget, gCurrentMove, TRUE);
gPotentialItemEffectBattler = gBattlerAttacker; gPotentialItemEffectBattler = gBattlerAttacker;
@ -1920,6 +1921,12 @@ static void Cmd_critcalc(void)
else else
gIsCriticalHit = FALSE; gIsCriticalHit = FALSE;
// Counter for EVO_CRITICAL_HITS.
partySlot = gBattlerPartyIndexes[gBattlerAttacker];
if (gIsCriticalHit && GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER
&& !(gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gBattlerAttacker) == B_POSITION_PLAYER_LEFT))
gPartyCriticalHits[partySlot]++;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
} }