Skip to content

Commit

Permalink
Add status form change (#3734)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgriffin authored Dec 15, 2023
2 parents c44e133 + 0fd08a3 commit 6cc1ebf
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,10 @@
.4byte \failInstr
.endm

.macro trytriggerstatusform
callnative BS_TryTriggerStatusForm
.endm

@ various command changed to more readable macros
.macro cancelmultiturnmoves battler:req
various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES
Expand Down
2 changes: 2 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -8342,6 +8342,8 @@ BattleScript_MoveEffectSleep::
BattleScript_UpdateEffectStatusIconRet::
updatestatusicon BS_EFFECT_BATTLER
waitstate
trytriggerstatusform
flushtextbox
return

BattleScript_YawnMakesAsleep::
Expand Down
4 changes: 4 additions & 0 deletions include/constants/form_change_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@
// param1: multichoice list (starting at 0).
#define FORM_CHANGE_ITEM_USE_MULTICHOICE 19

// Form change that activates when inflicted with a specific status
// param1: status
#define FORM_CHANGE_STATUS 20

#endif // GUARD_CONSTANTS_FORM_CHANGE_TYPES_H
13 changes: 13 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -16496,3 +16496,16 @@ void BS_TryDefog(void)
gBattlescriptCurrInstr = cmd->failInstr;
}
}

void BS_TryTriggerStatusForm(void)
{
NATIVE_ARGS();
if (TryBattleFormChange(gBattlerTarget, FORM_CHANGE_STATUS))
{
gBattleScripting.battler = gBattlerTarget;
BattleScriptPush(cmd->nextInstr);
gBattlescriptCurrInstr = BattleScript_TargetFormChangeWithStringNoPopup;
return;
}
gBattlescriptCurrInstr = cmd->nextInstr;
}
4 changes: 4 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -10494,6 +10494,10 @@ u16 GetBattleFormChangeTargetSpecies(u32 battler, u16 method)
if (formChanges[i].param1 == GetBattlerAbility(battler))
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_CHANGE_STATUS:
if (gBattleMons[battler].status1 & formChanges[i].param1)
targetSpecies = formChanges[i].targetSpecies;
break;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/data/pokemon/form_change_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,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_TERMINATOR},
};
#endif //P_FAMILY_SHAYMIN
Expand Down
1 change: 1 addition & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -5821,6 +5821,7 @@ 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_TIME_OF_DAY:
Expand Down
15 changes: 15 additions & 0 deletions test/battle/form_change/status.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "global.h"
#include "test/battle.h"

SINGLE_BATTLE_TEST("Shaymin-Sky reverts to Shaymin-Land when frozen or frostbitten")
{
ASSUME(gBattleMoves[MOVE_POWDER_SNOW].effect == ((B_USE_FROSTBITE == TRUE) ? EFFECT_FROSTBITE_HIT : EFFECT_FREEZE_HIT));
GIVEN {
PLAYER(SPECIES_SHAYMIN_SKY);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_POWDER_SNOW); }
} THEN {
EXPECT_EQ(player->species, SPECIES_SHAYMIN_LAND);
}
}

0 comments on commit 6cc1ebf

Please sign in to comment.