From 6dc3c7a14375ed776c3ee364f81dc399340da9d7 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Thu, 23 Mar 2023 21:27:45 -0700 Subject: [PATCH] level reappears in healthbox and form reversion occurs correctly when Dynamax ends --- include/battle_scripts.h | 2 +- src/battle_dynamax.c | 3 ++- src/battle_script_commands.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index eca739fb2f..8c670fb517 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -498,4 +498,4 @@ extern const u8 BattleScript_DynamaxBegins[]; extern const u8 BattleScript_DynamaxEnds[]; extern const u8 BattleScript_MoveBlockedByDynamax[]; -#endif // GUARD_BATTLE_SCRIPTS_H \ No newline at end of file +#endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_dynamax.c b/src/battle_dynamax.c index 8ca30e319b..58280c1917 100644 --- a/src/battle_dynamax.c +++ b/src/battle_dynamax.c @@ -193,13 +193,14 @@ void PrepareBattlerForDynamax(u16 battlerId) void UndoDynamax(u16 battlerId) { u8 side = GetBattlerSide(battlerId); - // Revert HP if battler is Dynamaxed. + // Revert HP and try form reversion if battler is Dynamaxed. if (IsDynamaxed(battlerId)) { struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; u16 mult = UQ_4_12(1.0/1.5); // placeholder u16 hp = UQ_4_12_TO_INT((gBattleMons[battlerId].hp * mult + 1) + UQ_4_12_ROUND); // round up SetMonData(&party[gBattlerPartyIndexes[battlerId]], MON_DATA_HP, &hp); + TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_SWITCH); } // Makes sure there are no Dynamax flags set, including on switch / faint. gBattleStruct->dynamax.dynamaxed[battlerId] = FALSE; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 16917a6fba..bf54f80e40 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11337,7 +11337,7 @@ static void Cmd_various(void) else mon = &gEnemyParty[gBattlerPartyIndexes[battler]]; RecalcBattlerStats(battler, mon); - UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], mon, HP_BOTH); + UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], mon, HEALTHBOX_ALL); break; } case VARIOUS_JUMP_IF_TARGET_DYNAMAXED: