Skip to content

Commit

Permalink
Revert Dynamax HP on fainting (#4681)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
WillKolada and AlexOn1ine authored May 31, 2024
1 parent 13d4d29 commit 0ed8d09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/battle_dynamax.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0ed8d09

Please sign in to comment.