diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index d14005b1ae..abcdd44c35 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -6575,12 +6575,14 @@ static void AnimTask_AllySwitchDataSwap(u8 taskId) SwapStructData(&gProtectStructs[battlerAtk], &gProtectStructs[battlerPartner], data, sizeof(struct ProtectStruct)); SwapStructData(&gBattleSpritesDataPtr->battlerData[battlerAtk], &gBattleSpritesDataPtr->battlerData[battlerPartner], data, sizeof(struct BattleSpriteInfo)); + SWAP(gBattleSpritesDataPtr->battlerData[battlerAtk].invisible, gBattleSpritesDataPtr->battlerData[battlerPartner].invisible, temp); SWAP(gTransformedPersonalities[battlerAtk], gTransformedPersonalities[battlerPartner], temp); SWAP(gTransformedShininess[battlerAtk], gTransformedShininess[battlerPartner], temp); SWAP(gStatuses3[battlerAtk], gStatuses3[battlerPartner], temp); SWAP(gStatuses4[battlerAtk], gStatuses4[battlerPartner], temp); SWAP(gBattleStruct->chosenMovePositions[battlerAtk], gBattleStruct->chosenMovePositions[battlerPartner], temp); SWAP(gChosenMoveByBattler[battlerAtk], gChosenMoveByBattler[battlerPartner], temp); + SWAP(gLockedMoves[battlerAtk], gLockedMoves[battlerPartner], temp); SWAP(gBattleStruct->moveTarget[battlerAtk], gBattleStruct->moveTarget[battlerPartner], temp); SWAP(gMoveSelectionCursor[battlerAtk], gMoveSelectionCursor[battlerPartner], temp); // Swap turn order, so that all the battlers take action @@ -6688,6 +6690,12 @@ void AnimTask_AllySwitchAttacker(u8 taskId) PrepareDoubleTeamAnim(taskId, ANIM_ATTACKER, TRUE); gSprites[gBattlerSpriteIds[gBattlerAttacker]].invisible = TRUE; gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattlerAttacker)]].invisible = TRUE; + // Edge case: Partner's sprite is invisible(i.e. after using Dig). + if (gBattleSpritesDataPtr->battlerData[BATTLE_PARTNER(gBattlerAttacker)].invisible) + { + gBattleSpritesDataPtr->battlerData[BATTLE_PARTNER(gBattlerAttacker)].invisible = FALSE; + gBattleSpritesDataPtr->battlerData[gBattlerAttacker].invisible = TRUE; + } } void AnimTask_AllySwitchPartner(u8 taskId) diff --git a/test/battle/move_effect/ally_switch.c b/test/battle/move_effect/ally_switch.c index 3271fd0cbe..bbfb774539 100644 --- a/test/battle/move_effect/ally_switch.c +++ b/test/battle/move_effect/ally_switch.c @@ -207,3 +207,24 @@ DOUBLE_BATTLE_TEST("Ally Switch increases the Protect-like moves counter") EXPECT(gDisableStructs[B_POSITION_PLAYER_RIGHT].protectUses == 1); } } + +DOUBLE_BATTLE_TEST("Ally Switch works if ally used two-turn move like Dig") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerRight, MOVE_DIG, target:opponentRight); } + TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); SKIP_TURN(playerRight); } + } SCENE { + MESSAGE("Wynaut used Dig!"); + MESSAGE("Wobbuffet used Ally Switch!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); + MESSAGE("Wobbuffet and Wynaut switched places!"); + NOT MESSAGE("Wynaut used -!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_DIG); + HP_BAR(opponentRight); + } +}