Skip to content

Commit

Permalink
fix ally switch dig issue (rh-hideout#3835)
Browse files Browse the repository at this point in the history
  • Loading branch information
DizzyEggg authored Dec 27, 2023
1 parent f5e0b3d commit 3e321d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/battle_anim_effects_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions test/battle/move_effect/ally_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 3e321d1

Please sign in to comment.