Revert Dynamax HP on fainting (#4681)

* Revert Dynamax HP on fainting

Calls UndoDynamax whenever a mon faints to ensure that its HP is reverted and the relevant data is cleared. Updates UndoDynamax to CalculateMonStats after applying the HP reversion to prevent fainted mons from retaining their boosted Max HP until the end of the battle.

* Update src/battle_main.c

---------

Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
WillKolada 2024-05-31 15:33:31 -05:00 committed by GitHub
parent 13d4d29e1e
commit 0ed8d09d47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -207,6 +207,7 @@ void UndoDynamax(u16 battlerId)
u16 mult = UQ_4_12(1.0/1.5); // placeholder
gBattleMons[battlerId].hp = UQ_4_12_TO_INT((GetMonData(mon, MON_DATA_HP) * mult + 1) + UQ_4_12_ROUND); // round up
SetMonData(mon, MON_DATA_HP, &gBattleMons[battlerId].hp);
CalculateMonStats(mon);
}
// Makes sure there are no Dynamax flags set, including on switch / faint.

View file

@ -3677,6 +3677,9 @@ const u8* FaintClearSetData(u32 battler)
gBattleStruct->zmove.active = FALSE;
gBattleStruct->zmove.toBeUsed[battler] = MOVE_NONE;
gBattleStruct->zmove.effect = EFFECT_HIT;
// Clear Dynamax data
UndoDynamax(battler);
return result;
}