From cf29c9eb69caf420672ed003d612b1af6d840847 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Wed, 19 Jul 2023 02:46:57 -0400 Subject: [PATCH] Fixed enemy parties not reverting to their original form post-battle (#3150) --- include/battle.h | 2 +- src/battle_main.c | 3 ++- src/battle_script_commands.c | 2 +- src/battle_util.c | 8 ++++---- src/pokemon.c | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/battle.h b/include/battle.h index 0219ebd72..b27062c12 100644 --- a/include/battle.h +++ b/include/battle.h @@ -636,7 +636,7 @@ struct BattleStruct bool8 friskedAbility; // If identifies two mons, show the ability pop-up only once. u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used. u16 moveEffect2; // For Knock Off - u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. + u16 changedSpecies[NUM_BATTLE_SIDES][PARTY_SIZE]; // For forms when multiple mons can change into the same pokemon. u8 quickClawBattlerId; struct LostItem itemLost[PARTY_SIZE]; // Player's team that had items consumed or stolen (two bytes per party member) u8 blunderPolicy:1; // should blunder policy activate diff --git a/src/battle_main.c b/src/battle_main.c index 3e19f247e..f6d822e3f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5434,7 +5434,8 @@ static void HandleEndTurn_FinishBattle(void) changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_END_BATTLE); // Clear original species field - gBattleStruct->changedSpecies[i] = SPECIES_NONE; + gBattleStruct->changedSpecies[B_SIDE_PLAYER][i] = SPECIES_NONE; + gBattleStruct->changedSpecies[B_SIDE_OPPONENT][i] = SPECIES_NONE; #if B_RECALCULATE_STATS >= GEN_5 // Recalculate the stats of every party member before the end diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 74e13b6d8..bc85f371c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10669,7 +10669,7 @@ static void Cmd_various(void) { gBattleStruct->battleBondTransformed[GET_BATTLER_SIDE2(gBattlerAttacker)] |= gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); - gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; + gBattleStruct->changedSpecies[GET_BATTLER_SIDE2(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; diff --git a/src/battle_util.c b/src/battle_util.c index 495f26cd5..baa365a0e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10227,8 +10227,8 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) if (targetSpecies != SPECIES_NONE) { // Saves the original species on the first form change for the player. - if (side == B_SIDE_PLAYER && gBattleStruct->changedSpecies[monId] == SPECIES_NONE) - gBattleStruct->changedSpecies[monId] = gBattleMons[battlerId].species; + if (gBattleStruct->changedSpecies[side][monId] == SPECIES_NONE) + gBattleStruct->changedSpecies[side][monId] = gBattleMons[battlerId].species; TryToSetBattleFormChangeMoves(&party[monId], method); SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); @@ -10236,7 +10236,7 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) RecalcBattlerStats(battlerId, &party[monId]); return TRUE; } - else if (gBattleStruct->changedSpecies[monId] != SPECIES_NONE) + else if (gBattleStruct->changedSpecies[side][monId] != SPECIES_NONE) { bool8 restoreSpecies = FALSE; @@ -10252,7 +10252,7 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) { // Reverts the original species TryToSetBattleFormChangeMoves(&party[monId], method); - SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); + SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[side][monId]); RecalcBattlerStats(battlerId, &party[monId]); return TRUE; } diff --git a/src/pokemon.c b/src/pokemon.c index 6d5b3d35e..b06abb6b5 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8507,7 +8507,7 @@ bool32 TryFormChange(u32 monId, u32 side, u16 method) targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); if (targetSpecies == SPECIES_NONE && gBattleStruct != NULL) - targetSpecies = gBattleStruct->changedSpecies[monId]; + targetSpecies = gBattleStruct->changedSpecies[side][monId]; if (targetSpecies != SPECIES_NONE) {