From 2e43ffd5f7f1d9686d1c75d568270429d5d5ec19 Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Mon, 26 Aug 2024 21:59:39 +0200 Subject: [PATCH] Fixed Snore not hitting twice with Parental Bond (#5264) Co-authored-by: Hedara --- src/battle_script_commands.c | 14 +++++++------- test/battle/ability/parental_bond.c | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0fc9d7b3b1..cd5fd18268 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1240,10 +1240,10 @@ static void Cmd_attackcanceler(void) } if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_OFF - && GetBattlerAbility(gBattlerAttacker) == ABILITY_PARENTAL_BOND - && IsMoveAffectedByParentalBond(gCurrentMove, gBattlerAttacker) - && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]) - && GetActiveGimmick(gBattlerAttacker) != GIMMICK_Z_MOVE) + && GetBattlerAbility(gBattlerAttacker) == ABILITY_PARENTAL_BOND + && IsMoveAffectedByParentalBond(gCurrentMove, gBattlerAttacker) + && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + && GetActiveGimmick(gBattlerAttacker) != GIMMICK_Z_MOVE) { gSpecialStatuses[gBattlerAttacker].parentalBondState = PARENTAL_BOND_1ST_HIT; gMultiHitCounter = 2; @@ -6038,9 +6038,9 @@ static void Cmd_moveend(void) gBattlerTarget = BATTLE_PARTNER(gBattlerTarget); // Target the partner in doubles for second hit. if (gBattleMons[gBattlerAttacker].hp - && gBattleMons[gBattlerTarget].hp - && (gChosenMove == MOVE_SLEEP_TALK || !(gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP)) - && !(gBattleMons[gBattlerAttacker].status1 & STATUS1_FREEZE)) + && gBattleMons[gBattlerTarget].hp + && (gChosenMove == MOVE_SLEEP_TALK || (gChosenMove == MOVE_SNORE) || !(gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP)) + && !(gBattleMons[gBattlerAttacker].status1 & STATUS1_FREEZE)) { if (gSpecialStatuses[gBattlerAttacker].parentalBondState) gSpecialStatuses[gBattlerAttacker].parentalBondState--; diff --git a/test/battle/ability/parental_bond.c b/test/battle/ability/parental_bond.c index 945e975b77..3ee942e789 100644 --- a/test/battle/ability/parental_bond.c +++ b/test/battle/ability/parental_bond.c @@ -263,6 +263,29 @@ SINGLE_BATTLE_TEST("Parental Bond Smack Down effect triggers after 2nd hit") } } +SINGLE_BATTLE_TEST("Parental Bond Snore strikes twice while asleep") +{ + s16 damage[2]; + GIVEN { + ASSUME(gMovesInfo[MOVE_SNORE].effect == EFFECT_SNORE); + PLAYER(SPECIES_KANGASKHAN_MEGA) { Status1(STATUS1_SLEEP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SNORE); } + } SCENE { + MESSAGE("Kangaskhan is fast asleep."); + ANIMATION(ANIM_TYPE_MOVE, MOVE_SNORE, player); + HP_BAR(opponent, captureDamage: &damage[0]); + HP_BAR(opponent, captureDamage: &damage[1]); + MESSAGE("Hit 2 time(s)!"); + } THEN { + if (B_PARENTAL_BOND_DMG == GEN_6) + EXPECT_MUL_EQ(damage[0], Q_4_12(0.5), damage[1]); + else + EXPECT_MUL_EQ(damage[0], Q_4_12(0.25), damage[1]); + } +} + TO_DO_BATTLE_TEST("Parental Bond tests"); // Temporary TODO: Convert Bulbapedia description into tests.