Fix Tranformed mon changing forms when fainting (#9106)

This commit is contained in:
Eduardo Quezada 2026-02-01 12:52:53 -03:00 committed by GitHub
parent 90e4cc4906
commit 4d52960780
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View File

@ -3304,8 +3304,10 @@ const u8* FaintClearSetData(u32 battler)
gBattleMons[battler].statStages[i] = DEFAULT_STAT_STAGE;
bool32 keepGastroAcid = gBattleMons[battler].volatiles.gastroAcid;
bool32 keepTransformed = gBattleMons[battler].volatiles.transformed;
memset(&gBattleMons[battler].volatiles, 0, sizeof(struct Volatiles));
gBattleMons[battler].volatiles.gastroAcid = keepGastroAcid; // Edge case: Keep Gastro Acid if pokemon's ability can have effect after fainting, for example Innards Out.
gBattleMons[battler].volatiles.transformed = keepTransformed; // Edge case: Keep Transformed status to prevent triggering FORM_CHANGE_FAINT on transformed mons.
for (i = 0; i < gBattlersCount; i++)
{

View File

@ -28,3 +28,17 @@ SINGLE_BATTLE_TEST("(TERA) Transform does not copy the target's Tera Type, and i
NOT { HP_BAR(opponent); }
}
}
SINGLE_BATTLE_TEST("Transform returns the user to normal at the end of the battle after fainting")
{
GIVEN {
PLAYER(SPECIES_DITTO) { HP(1); }
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_PIDGEOT) { Item(ITEM_PIDGEOTITE); }
} WHEN {
TURN { MOVE(opponent, MOVE_CELEBRATE, gimmick: GIMMICK_MEGA); MOVE(player, MOVE_TRANSFORM); }
TURN { MOVE(opponent, MOVE_SCRATCH); SEND_OUT(player, 1); }
} THEN {
EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_DITTO);
}
}