From d2bcc2ad5b550ba1d403749d756f6440b3acb169 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 1 Sep 2021 00:14:02 -0300 Subject: [PATCH] Added configs for modern post-battle stat calcs --- include/constants/battle_config.h | 2 ++ src/battle_script_commands.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index bf31c77b3b..2b83b766f7 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -93,6 +93,8 @@ #define B_RECOIL_IF_MISS_DMG GEN_7 // In Gen5+, Jump Kick and High Jump Kick will always do half of the user's max HP when missing. #define B_PSYWAVE_DMG GEN_7 // Psywave's damage formula. See Cmd_psywavedamageeffect. #define B_BADGE_BOOST GEN_7 // In Gen4+, Gym Badges no longer boost a Pokémon's stats. +#define B_MAX_LEVEL_EV_GAINS GEN_7 // In Gen5+, Lv100 Pokémon can obtain Effort Values normally. +#define B_RECALCULATE_STATS GEN_7 // In Gen5+, the stats of the Pokémon who participate in battle are recalculated at the end of each battle. // Move data settings #define B_UPDATED_MOVE_DATA GEN_8 // Updates move data in gBattleMoves, including Power, Accuracy, PP, stat changes, targets, chances of secondary effects, etc. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 21bc7945b9..eaceb85450 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3783,6 +3783,9 @@ static void Cmd_getexp(void) *(&gBattleStruct->sentInPokes) >>= 1; gBattleScripting.getexpState = 5; gBattleMoveDamage = 0; // used for exp + #if B_MAX_LEVEL_EV_GAINS >= GEN_5 + MonGainEVs(&gPlayerParty[gBattleStruct->expGetterMonId], gBattleMons[gBattlerFainted].species); + #endif } else { @@ -3958,6 +3961,12 @@ static void Cmd_getexp(void) case 6: // increment instruction if (gBattleControllerExecFlags == 0) { + #if B_RECALCULATE_STATS >= GEN_5 + // Recalculate the stats of every party member before the end + for (i = 0; i < PARTY_SIZE; i++) + CalculateMonStats(&gPlayerParty[i]); + #endif + // not sure why gf clears the item and ability here gBattleMons[gBattlerFainted].item = 0; gBattleMons[gBattlerFainted].ability = 0;