Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix status curing of full restore when used on party member #4603

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1387,9 +1387,10 @@
.4byte \jumpInstr
.endm

.macro itemrestorehp jumpInstr:req
.macro itemrestorehp jumpInstr:req, restoreBattlerInstr:req
callnative BS_ItemRestoreHP
.4byte \jumpInstr
.4byte \restoreBattlerInstr
.endm

.macro itemcurestatus jumpInstr:req
Expand Down
15 changes: 12 additions & 3 deletions data/battle_scripts_2.s
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ BattleScript_ItemRestoreHPRet:

BattleScript_ItemRestoreHP::
call BattleScript_UseItemMessage
itemrestorehp BattleScript_ItemRestoreHPEnd
itemrestorehp BattleScript_ItemRestoreHPEnd, BattleScript_ItemRestoreHP_Battler
call BattleScript_ItemRestoreHP_Party
goto BattleScript_ItemRestoreHPEnd

BattleScript_ItemRestoreHP_Battler::
call BattleScript_ItemRestoreHPRet
BattleScript_ItemRestoreHPEnd:
end
Expand All @@ -67,7 +71,7 @@ BattleScript_ItemRestoreHP_Party::
bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
printstring STRINGID_ITEMRESTOREDSPECIESHEALTH
waitmessage B_WAIT_TIME_LONG
end
return

BattleScript_ItemRestoreHP_SendOutRevivedBattler:
switchinanim BS_SCRIPTING, FALSE
Expand All @@ -87,8 +91,13 @@ BattleScript_ItemCureStatusEnd:

BattleScript_ItemHealAndCureStatus::
call BattleScript_UseItemMessage
itemrestorehp BattleScript_ItemCureStatusAfterItemMsg
itemrestorehp BattleScript_ItemCureStatusAfterItemMsg, BattleScript_ItemHealAndCureStatus_Battler
call BattleScript_ItemRestoreHP_Party
goto BattleScript_ItemHealAndCureStatusEnd

BattleScript_ItemHealAndCureStatus_Battler::
call BattleScript_ItemRestoreHPRet
BattleScript_ItemHealAndCureStatusEnd::
goto BattleScript_ItemCureStatusAfterItemMsg

BattleScript_ItemIncreaseStat::
Expand Down
1 change: 0 additions & 1 deletion include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ extern const u8 BattleScript_TheRainbowDisappeared[];
extern const u8 BattleScript_HurtByTheSeaOfFire[];
extern const u8 BattleScript_TheSeaOfFireDisappeared[];
extern const u8 BattleScript_TheSwampDisappeared[];
extern const u8 BattleScript_ItemRestoreHP_Party[];
extern const u8 BattleScript_EffectPsychicNoise[];
extern const u8 BattleScript_AromaVeilProtectsRet[];

Expand Down
6 changes: 3 additions & 3 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -16021,7 +16021,7 @@ void ApplyExperienceMultipliers(s32 *expAmount, u8 expGetterMonId, u8 faintedBat

void BS_ItemRestoreHP(void)
{
NATIVE_ARGS(const u8 *alreadyMaxHpInstr);
NATIVE_ARGS(const u8 *alreadyMaxHpInstr, const u8 *restoreBattlerInstr);
u16 healAmount;
u32 battler = MAX_BATTLERS_COUNT;
u32 healParam = ItemId_GetEffect(gLastUsedItem)[6];
Expand Down Expand Up @@ -16074,7 +16074,7 @@ void BS_ItemRestoreHP(void)
if (battler != MAX_BATTLERS_COUNT && hp != 0)
{
gBattleMoveDamage = -healAmount;
gBattlescriptCurrInstr = cmd->nextInstr;
gBattlescriptCurrInstr = cmd->restoreBattlerInstr;
}
else
{
Expand All @@ -16087,7 +16087,7 @@ void BS_ItemRestoreHP(void)
gAbsentBattlerFlags &= ~gBitTable[battler];
gBattleCommunication[MULTIUSE_STATE] = TRUE;
}
gBattlescriptCurrInstr = BattleScript_ItemRestoreHP_Party;
gBattlescriptCurrInstr = cmd->nextInstr;
}
}
}
Expand Down
56 changes: 55 additions & 1 deletion test/battle/item_effect/heal_and_cure_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures any primary s
PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300); Status1(status); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN{ USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 0); }
TURN { USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 0); }
} SCENE {
MESSAGE("Wobbuffet had its HP restored!");
if (status != STATUS1_NONE) {
Expand All @@ -32,6 +32,35 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures any primary s
}
}

SINGLE_BATTLE_TEST("Full Restore restores a party members HP and cures any primary status")
{
u16 status;
PARAMETRIZE{ status = STATUS1_BURN; }
PARAMETRIZE{ status = STATUS1_FREEZE; }
PARAMETRIZE{ status = STATUS1_PARALYSIS; }
PARAMETRIZE{ status = STATUS1_POISON; }
PARAMETRIZE{ status = STATUS1_TOXIC_POISON; }
PARAMETRIZE{ status = STATUS1_SLEEP; }
PARAMETRIZE{ status = STATUS1_NONE; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300); Status1(status); }
PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(300); Status1(status); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 1); }
TURN { SWITCH(player, 1); }
} SCENE {
MESSAGE("Wynaut had its HP restored!");
if (status != STATUS1_NONE) {
MESSAGE("Wynaut had its status healed!"); // The message is not printed if status wasn't healed.
}
} THEN {
EXPECT_EQ(player->hp, player->maxHP);
EXPECT_EQ(player->species, SPECIES_WYNAUT);
EXPECT_EQ(player->status1, STATUS1_NONE);
}
}

SINGLE_BATTLE_TEST("Full Restore heals a battler from any primary status")
{
u16 status;
Expand All @@ -54,6 +83,31 @@ SINGLE_BATTLE_TEST("Full Restore heals a battler from any primary status")
}
}

SINGLE_BATTLE_TEST("Full Restore heals a party member from any primary status")
{
u16 status;
PARAMETRIZE{ status = STATUS1_BURN; }
PARAMETRIZE{ status = STATUS1_FREEZE; }
PARAMETRIZE{ status = STATUS1_PARALYSIS; }
PARAMETRIZE{ status = STATUS1_POISON; }
PARAMETRIZE{ status = STATUS1_TOXIC_POISON; }
PARAMETRIZE{ status = STATUS1_SLEEP; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_WYNAUT) { Status1(status); }
OPPONENT(SPECIES_WYNAUT);
} WHEN {
TURN { USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 1); }
TURN { SWITCH(player, 1); }
} SCENE {
NOT MESSAGE("Wynaut had its HP restored!"); // The message is not printed if mon has max HP.
MESSAGE("Wynaut had its status healed!");
} THEN {
EXPECT_EQ(player->species, SPECIES_WYNAUT);
EXPECT_EQ(player->status1, STATUS1_NONE);
}
}

SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures confusion")
{
GIVEN {
Expand Down
Loading