Skip to content

Commit

Permalink
Opponents Shaymin Sky form correctly reverts on frozen status (#4559)
Browse files Browse the repository at this point in the history
* Fixed Shaymin form change with incorrect status condition

* Fixed Shaymin receiving damage again after changing form

* PR feedback updates - fixed missing commas in battle script

* Added Shaymin form change test by @AlexOn1ine
  • Loading branch information
TheJamesLJ authored May 14, 2024
1 parent 23b8804 commit 9cd3fbb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
12 changes: 8 additions & 4 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -6994,17 +6994,21 @@ BattleScript_CudChewActivates::
setbyte sBERRY_OVERRIDE, 0
end3

BattleScript_ApplyDisguiseFormChangeHPLoss::
.if B_DISGUISE_HP_LOSS >= GEN_8
healthbarupdate BS_SCRIPTING
datahpupdate BS_SCRIPTING
.endif
return

BattleScript_TargetFormChangeNoPopup:
flushtextbox
handleformchange BS_SCRIPTING, 0
handleformchange BS_SCRIPTING, 1
playanimation BS_TARGET, B_ANIM_FORM_CHANGE
waitanimation
handleformchange BS_SCRIPTING, 2
.if B_DISGUISE_HP_LOSS >= GEN_8
healthbarupdate BS_SCRIPTING
datahpupdate BS_SCRIPTING
.endif
jumpifability BS_TARGET, ABILITY_DISGUISE, BattleScript_ApplyDisguiseFormChangeHPLoss
return

BattleScript_TargetFormChange::
Expand Down
2 changes: 1 addition & 1 deletion src/data/pokemon/form_change_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ static const struct FormChange sShayminFormChangeTable[] = {
{FORM_CHANGE_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
{FORM_CHANGE_WITHDRAW, SPECIES_SHAYMIN_LAND},
{FORM_CHANGE_TIME_OF_DAY, SPECIES_SHAYMIN_LAND, NIGHT},
{FORM_CHANGE_STATUS, SPECIES_SHAYMIN_LAND, (STATUS1_FREEZE | STATUS1_FROSTBITE)},
{FORM_CHANGE_STATUS, SPECIES_SHAYMIN_LAND, STATUS1_FREEZE | STATUS1_FROSTBITE},
{FORM_CHANGE_TERMINATOR},
};
#endif //P_FAMILY_SHAYMIN
Expand Down
5 changes: 4 additions & 1 deletion src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -6226,9 +6226,12 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32
break;
case FORM_CHANGE_WITHDRAW:
case FORM_CHANGE_FAINT:
case FORM_CHANGE_STATUS:
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_CHANGE_STATUS:
if (GetBoxMonData(boxMon, MON_DATA_STATUS, NULL) & formChanges[i].param1)
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_CHANGE_TIME_OF_DAY:
switch (formChanges[i].param1)
{
Expand Down
29 changes: 27 additions & 2 deletions test/battle/form_change/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,38 @@

SINGLE_BATTLE_TEST("Shaymin-Sky reverts to Shaymin-Land when frozen or frostbitten")
{
u32 move;

PARAMETRIZE { move = MOVE_POWDER_SNOW; }
PARAMETRIZE { move = MOVE_EMBER; }
PARAMETRIZE { move = MOVE_THUNDERSHOCK; }
PARAMETRIZE { move = MOVE_POISON_STING; }
PARAMETRIZE { move = MOVE_POISON_FANG; }

ASSUME(MoveHasAdditionalEffect(MOVE_POWDER_SNOW, MOVE_EFFECT_FREEZE_OR_FROSTBITE));
ASSUME(MoveHasAdditionalEffect(MOVE_EMBER, MOVE_EFFECT_BURN));
ASSUME(MoveHasAdditionalEffect(MOVE_THUNDERSHOCK, MOVE_EFFECT_PARALYSIS));
ASSUME(MoveHasAdditionalEffect(MOVE_POISON_STING, MOVE_EFFECT_POISON));
ASSUME(MoveHasAdditionalEffect(MOVE_POISON_FANG, MOVE_EFFECT_TOXIC));
GIVEN {
PLAYER(SPECIES_SHAYMIN_SKY);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_POWDER_SNOW); }
TURN { MOVE(opponent, move); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, move, opponent);
if (move == MOVE_POWDER_SNOW) {
STATUS_ICON(player, freeze: TRUE);
NOT HP_BAR(player); // Regression caused by Mimikyu form change
MESSAGE("Shaymin transformed!");
} else {
NOT MESSAGE("Shaymin transformed!");
}
} THEN {
EXPECT_EQ(player->species, SPECIES_SHAYMIN_LAND);
if (move == MOVE_POWDER_SNOW)
EXPECT_EQ(player->species, SPECIES_SHAYMIN_LAND);
else
EXPECT_EQ(player->species, SPECIES_SHAYMIN_SKY);

}
}

0 comments on commit 9cd3fbb

Please sign in to comment.