From 7aad95ae6326ec256417577f3cb4feb02391e449 Mon Sep 17 00:00:00 2001 From: Cooper McDonald Date: Sat, 20 Sep 2025 04:21:40 -0500 Subject: [PATCH] Fix Critical Capture RNG and Catching Charm boost (#7534) --- include/config/battle.h | 2 +- src/battle_script_commands.c | 38 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 6f48f0fc19..1e90fecd1e 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -286,7 +286,7 @@ // Catching settings #define B_SEMI_INVULNERABLE_CATCH GEN_LATEST // In Gen4+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) -#define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm. +#define B_CATCHING_CHARM_BOOST 100 // % boost in Critical Capture odds if player has the Catching Charm. #define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled. #define B_CRITICAL_CAPTURE_LOCAL_DEX TRUE // If set to FALSE, Critical Capture % is based off of the National Pokedex estimated by enabled generations. #define B_CRITICAL_CAPTURE_IF_OWNED GEN_LATEST // In Gen9, a capture appear critical if the pokemon you are trying to catch already has a dex entry (has already been caught) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ef38192cf6..796d966050 100755 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14372,6 +14372,7 @@ static bool32 CriticalCapture(u32 odds) { u32 numCaught; u32 totalDexCount; + u32 charmBoost = 1; if (B_CRITICAL_CAPTURE == FALSE) return FALSE; @@ -14381,27 +14382,28 @@ static bool32 CriticalCapture(u32 odds) else totalDexCount = NATIONAL_DEX_COUNT; - numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); - - if (numCaught <= (totalDexCount * 30) / 650) - odds = 0; - else if (numCaught <= (totalDexCount * 150) / 650) - odds /= 2; - else if (numCaught <= (totalDexCount * 300) / 650) - ; // odds = (odds * 100) / 100; - else if (numCaught <= (totalDexCount * 450) / 650) - odds = (odds * 150) / 100; - else if (numCaught <= (totalDexCount * 600) / 650) - odds *= 2; - else - odds = (odds * 250) / 100; - if (CheckBagHasItem(ITEM_CATCHING_CHARM, 1)) - odds = (odds * (100 + B_CATCHING_CHARM_BOOST)) / 100; + charmBoost = (100 + B_CATCHING_CHARM_BOOST) / 100; + + numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); + if (numCaught > (totalDexCount * 600) / 650) + odds = (odds * (250 * charmBoost)) / 100; + else if (numCaught > (totalDexCount * 450) / 650) + odds = (odds * (200 * charmBoost)) / 100; + else if (numCaught > (totalDexCount * 300) / 650) + odds = (odds * (150 * charmBoost)) / 100; + else if (numCaught > (totalDexCount * 150) / 650) + odds = (odds * (100 * charmBoost)) / 100; + else if (numCaught > (totalDexCount * 30) / 650) + odds = (odds * (50 * charmBoost)) / 100; + else + return FALSE; + + if (odds > 255) + odds = 255; odds /= 6; - - if ((Random() % 255) < odds) + if ((Random() % 256) < odds) return TRUE; return FALSE;