From d98a4cb9a5acf3b7e51e8d21aab69aeedf0cb1ae Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Mon, 6 May 2024 12:07:22 +0200 Subject: [PATCH] Fixed evolution tracker updates (#4503) * update evolution tracker correctly * Update src/battle_script_commands.c --------- Co-authored-by: Bassoonian --- src/battle_script_commands.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 53b9cbb024..f80bebd8a2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -365,7 +365,7 @@ static void RemoveAllTerrains(void); static bool8 CanAbilityPreventStatLoss(u16 abilityDef, bool8 isIntimidate); static bool8 CanBurnHitThaw(u16 move); static u32 GetNextTarget(u32 moveTarget, bool32 excludeCurrent); -static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount); +static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 usedMove); static void Cmd_attackcanceler(void); static void Cmd_accuracycheck(void); @@ -6316,7 +6316,7 @@ static void Cmd_moveend(void) case MOVEEND_SET_EVOLUTION_TRACKER: // If the Pokémon needs to keep track of move usage for its evolutions, do it if (originallyUsedMove != MOVE_NONE) - TryUpdateEvolutionTracker(EVO_LEVEL_MOVE_TWENTY_TIMES, 1); + TryUpdateEvolutionTracker(EVO_LEVEL_MOVE_TWENTY_TIMES, 1, originallyUsedMove); gBattleScripting.moveendState++; break; case MOVEEND_CLEAR_BITS: // Clear/Set bits for things like using a move for all targets and all hits. @@ -16785,7 +16785,7 @@ void BS_RunStatChangeItems(void) ItemBattleEffects(ITEMEFFECT_STATS_CHANGED, GetBattlerForBattleScript(cmd->battler), FALSE); } -static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount) +static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 usedMove) { u32 i; @@ -16810,9 +16810,19 @@ static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount) // We only have 9 bits to use u16 val = min(511, GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER) + upAmount); // Reset progress if you faint for the recoil method. - if (gBattleMons[gBattlerAttacker].hp == 0 && (evolutionMethod == EVO_LEVEL_RECOIL_DAMAGE_MALE || evolutionMethod == EVO_LEVEL_RECOIL_DAMAGE_FEMALE)) - val = 0; - SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val); + switch (evolutionMethod) + { + case EVO_LEVEL_MOVE_TWENTY_TIMES: + if (evolutions[i].param == usedMove) + SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val); + break; + case EVO_LEVEL_RECOIL_DAMAGE_MALE: + case EVO_LEVEL_RECOIL_DAMAGE_FEMALE: + if (gBattleMons[gBattlerAttacker].hp == 0) + val = 0; + SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val); + break; + } return; } } @@ -16822,8 +16832,18 @@ static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount) void BS_TryUpdateRecoilTracker(void) { NATIVE_ARGS(); - TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_MALE, gBattleMoveDamage); - TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_FEMALE, gBattleMoveDamage); + u8 gender = GetMonGender(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]); + + switch(gender) + { + case MON_MALE: + TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_MALE, gBattleMoveDamage, MOVE_NONE); + break; + case MON_FEMALE: + TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_FEMALE, gBattleMoveDamage, MOVE_NONE); + break; + } + gBattlescriptCurrInstr = cmd->nextInstr; }