Fix Revive in double battles (#4784)

This commit is contained in:
DizzyEggg 2024-06-13 10:41:17 +02:00 committed by GitHub
parent 21339cf272
commit 8e41b9857f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 0 deletions

View file

@ -16073,6 +16073,7 @@ void BS_ItemRestoreHP(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && battler != MAX_BATTLERS_COUNT)
{
gAbsentBattlerFlags &= ~gBitTable[battler];
gBattleMons[battler].hp = hp;
gBattleCommunication[MULTIUSE_STATE] = TRUE;
}
gBattlescriptCurrInstr = cmd->nextInstr;

View file

@ -73,4 +73,30 @@ SINGLE_BATTLE_TEST("Max Honey restores a fainted battler's HP fully")
}
}
// Note: this test is oddly specific with implicit moves/speeds, because I had errors/invalids without them.
DOUBLE_BATTLE_TEST("Revive works for a partner in a double battle")
{
GIVEN {
ASSUME(gItemsInfo[ITEM_REVIVE].battleUsage == EFFECT_ITEM_REVIVE);
PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(200); Moves(MOVE_IRON_DEFENSE, MOVE_CELEBRATE); Speed(5); }
PLAYER(SPECIES_WOBBUFFET) { HP(1); Speed(4); }
OPPONENT(SPECIES_ABRA) { Speed(3); Moves(MOVE_TACKLE, MOVE_PSYCHIC, MOVE_CELEBRATE); }
OPPONENT(SPECIES_KADABRA) { Speed(2); Moves(MOVE_TACKLE, MOVE_PSYCHIC, MOVE_CELEBRATE, MOVE_EXPLOSION); }
} WHEN {
TURN { MOVE(opponentRight, MOVE_PSYCHIC, target:playerLeft); MOVE(playerLeft, MOVE_CELEBRATE); } // Wynaut faints
TURN { USE_ITEM(playerRight, ITEM_REVIVE, partyIndex: 0); MOVE(opponentRight, MOVE_PSYCHIC, target:playerRight); } // Wynaut gets revived, Wobb faints
// Wynaut is functionally back
TURN { MOVE(opponentLeft, MOVE_TACKLE, target:playerLeft); }
TURN { MOVE(opponentRight, MOVE_TACKLE, target:playerLeft); }
TURN { MOVE(opponentRight, MOVE_EXPLOSION); } // Everyone dies, the test can finish.
} SCENE {
MESSAGE("Wynaut fainted!");
MESSAGE("You used Revive!");
// Switch-in animation
MESSAGE("Wobbuffet fainted!");
HP_BAR(playerLeft);
HP_BAR(playerLeft);
}
}
TO_DO_BATTLE_TEST("Revive won't restore a battler's HP if it hasn't fainted")