Ally Switch attract battler swapping, test for leech seed (#7634)

Co-authored-by: ghoulslash <pokevoyager0@gmail.com>
This commit is contained in:
ghoulslash 2025-08-28 07:51:02 -04:00 committed by GitHub
parent f0bd3d544e
commit de790e4815
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 86 additions and 0 deletions

View File

@ -6864,6 +6864,33 @@ static void TrySwapWishBattlerIds(u32 battlerAtk, u32 battlerPartner)
SWAP(gWishFutureKnock.wishPartyId[battlerAtk], gWishFutureKnock.wishPartyId[battlerPartner], temp);
}
static void TrySwapAttractBattlerIds(u32 battlerAtk, u32 battlerPartner)
{
u32 attractedTo;
// our own infatuation handled with gBattleMons struct data swapping
// if another battler is infatuated with one of us, change to other battler
for (u32 i = 0; i < gBattlersCount; i++) {
if (i == battlerAtk || i == battlerPartner || !(gBattleMons[i].status2 & STATUS2_INFATUATION))
continue;
attractedTo = CountTrailingZeroBits((gBattleMons[i].status2 & STATUS2_INFATUATION) >> 0x10);
if (attractedTo == battlerAtk)
{
gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battlerAtk);
gBattleMons[i].status2 |= STATUS2_INFATUATED_WITH(battlerPartner);
break;
}
else if (attractedTo == battlerPartner)
{
gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battlerPartner);
gBattleMons[i].status2 |= STATUS2_INFATUATED_WITH(battlerAtk);
break;
}
}
}
static void SwapBattlerMoveData(u32 battler1, u32 battler2)
{
u32 temp;
@ -6936,6 +6963,7 @@ static void AnimTask_AllySwitchDataSwap(u8 taskId)
TrySwapSkyDropTargets(battlerAtk, battlerPartner);
TrySwapStickyWebBattlerId(battlerAtk, battlerPartner);
TrySwapWishBattlerIds(battlerAtk, battlerPartner);
TrySwapAttractBattlerIds(battlerAtk, battlerPartner);
// For Snipe Shot and abilities Stalwart/Propeller Tail - keep the original target.
for (i = 0; i < gBattlersCount; i++)

View File

@ -348,5 +348,63 @@ DOUBLE_BATTLE_TEST("Ally switch updates last used moves for Mimic")
}
}
DOUBLE_BATTLE_TEST("Ally Switch does not update leech seed battler")
{
GIVEN {
PLAYER(SPECIES_WYNAUT);
PLAYER(SPECIES_SOLOSIS);
OPPONENT(SPECIES_BULBASAUR) { HP(50); MaxHP(100); }
OPPONENT(SPECIES_RALTS) { HP(50); MaxHP(100); }
} WHEN {
TURN { MOVE(opponentLeft, MOVE_LEECH_SEED, target: playerLeft); }
TURN { MOVE(opponentRight, MOVE_ALLY_SWITCH); }
TURN { ; }
} SCENE {
// turn 1
MESSAGE("The opposing Bulbasaur used Leech Seed!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_LEECH_SEED, opponentLeft);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_LEECH_SEED_DRAIN, playerLeft);
HP_BAR(playerLeft);
HP_BAR(opponentLeft);
MESSAGE("The opposing Ralts used Ally Switch!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, opponentRight);
MESSAGE("The opposing Ralts and the opposing Bulbasaur switched places!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_LEECH_SEED_DRAIN, playerLeft);
HP_BAR(playerLeft);
HP_BAR(opponentLeft); // Ralts now gets hp gain
} THEN {
EXPECT_GT(opponentLeft->hp, 50);
EXPECT_GT(opponentRight->hp, 50);
}
}
DOUBLE_BATTLE_TEST("Ally Switch updates attract battler")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Speed(100); Gender(MON_MALE); }
PLAYER(SPECIES_SOLOSIS) { Speed(50); }
OPPONENT(SPECIES_CLEFAIRY) { Speed(20); Gender(MON_FEMALE); Ability(ABILITY_CUTE_CHARM); }
OPPONENT(SPECIES_RALTS) { Speed(30); }
} WHEN {
TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); }
TURN { MOVE(opponentRight, MOVE_ALLY_SWITCH); }
TURN { ; }
} SCENE {
// turn 1
MESSAGE("Wobbuffet used Tackle!");
HP_BAR(opponentLeft);
ABILITY_POPUP(opponentLeft, ABILITY_CUTE_CHARM);
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_INFATUATION, playerLeft);
MESSAGE("The opposing Clefairy's Cute Charm infatuated Wobbuffet!");
// turn 2
MESSAGE("The opposing Ralts used Ally Switch!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, opponentRight);
MESSAGE("The opposing Ralts and the opposing Clefairy switched places!");
// turn 3
MESSAGE("Wobbuffet is in love with the opposing Clefairy!"); // tracks attract battler
}
}
// Triple Battles required to test
//TO_DO_BATTLE_TEST("Ally Switch fails if the user is in the middle of the field in a Triple Battle");