diff --git a/include/constants/battle.h b/include/constants/battle.h index 1592a7af41..11a5a6a86e 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -364,7 +364,7 @@ #define MOVE_EFFECT_RECOIL_HP_25 0x44 #define MOVE_EFFECT_RELIC_SONG 0x45 #define MOVE_EFFECT_TRAP_BOTH 0x46 - + #define NUM_MOVE_EFFECTS 0x47 #define MOVE_EFFECT_AFFECTS_USER 0x4000 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e6192700e2..480b18a90e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14844,12 +14844,16 @@ bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId) { switch (GetBattlerMoveTargetType(battlerId, move)) { + // Both foes are alive, spread move strikes once case MOVE_TARGET_BOTH: - if (CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) >= 2) // Check for single target + if (IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(BATTLE_PARTNER(gBattlerTarget))) return FALSE; break; + // Either both foes or one foe and its ally are alive; spread move strikes once case MOVE_TARGET_FOES_AND_ALLY: - if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) >= 2) // Count mons on both sides; ignore attacker + if (IsBattlerAlive(BATTLE_PARTNER(gBattlerTarget)) + || (IsBattlerAlive(BATTLE_PARTNER(battlerId)) + && (IsBattlerAlive(BATTLE_PARTNER(gBattlerTarget)) || IsBattlerAlive(gBattlerTarget)))) return FALSE; break; default: diff --git a/src/battle_util.c b/src/battle_util.c index 1e99a23017..79a698eb72 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -59,6 +59,7 @@ functions instead of at the top of the file with the other declarations. static bool32 TryRemoveScreens(u8 battler); static bool32 IsUnnerveAbilityOnOpposingSide(u8 battlerId); static u8 GetFlingPowerFromItemId(u16 itemId); +static void SetRandomMultiHitCounter(); extern const u8 *const gBattleScriptsForMoveEffects[]; extern const u8 *const gBattlescriptsForRunningByItem[]; @@ -3868,35 +3869,8 @@ u8 AtkCanceller_UnableToUseMove(void) } else { - if (B_MULTI_HIT_CHANCE >= GEN_5) - { - // Based on Gen 5's odds - // 35% for 2 hits - // 35% for 3 hits - // 15% for 4 hits - // 15% for 5 hits - gMultiHitCounter = Random() % 100; - if (gMultiHitCounter < 35) - gMultiHitCounter = 2; - else if (gMultiHitCounter < 35 + 35) - gMultiHitCounter = 3; - else if (gMultiHitCounter < 35 + 35 + 15) - gMultiHitCounter = 4; - else - gMultiHitCounter =5; - } - else - { - // 2 and 3 hits: 37.5% - // 4 and 5 hits: 12.5% - gMultiHitCounter = Random() % 4; - if (gMultiHitCounter > 1) - gMultiHitCounter = (Random() % 4) + 2; - else - gMultiHitCounter += 2; - } + SetRandomMultiHitCounter(); } - PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0) } else if (gBattleMoves[gCurrentMove].flags & FLAG_TWO_STRIKES) @@ -10518,3 +10492,35 @@ bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move) return FALSE; // Pokémon affected by Heal Block cannot target allies with Pollen Puff return TRUE; } + +static void SetRandomMultiHitCounter() +{ + #if (B_MULTI_HIT_CHANCE >= GEN_5) + { + // Based on Gen 5's odds + // 35% for 2 hits + // 35% for 3 hits + // 15% for 4 hits + // 15% for 5 hits + gMultiHitCounter = Random() % 100; + if (gMultiHitCounter < 35) + gMultiHitCounter = 2; + else if (gMultiHitCounter < 35 + 35) + gMultiHitCounter = 3; + else if (gMultiHitCounter < 35 + 35 + 15) + gMultiHitCounter = 4; + else + gMultiHitCounter = 5; + } + #else + { + // 2 and 3 hits: 37.5% + // 4 and 5 hits: 12.5% + gMultiHitCounter = Random() % 4; + if (gMultiHitCounter > 1) + gMultiHitCounter = (Random() % 4) + 2; + else + gMultiHitCounter += 2; + } + #endif +}