Fix Critical Capture RNG and Catching Charm boost (#7534)

This commit is contained in:
Cooper McDonald 2025-09-20 04:21:40 -05:00 committed by GitHub
parent 40ffcfb94a
commit 7aad95ae63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 19 deletions

View File

@ -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)

View File

@ -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;