Skip to content

Commit

Permalink
Update catch curve for pokeballs (rh-hideout#3685)
Browse files Browse the repository at this point in the history
Since Gen 6, the capture rate curve was changed to make pokeballs more effective on lower level pokemon

It's by 65536 divided by 255 to the power of(1/5.33) and I did the work of translating that so a rough approximation can be done in integers, and so far, it seems to work close enough. I use this in my romhack for months now and it works fine.
  • Loading branch information
AZero13 authored Dec 12, 2023
1 parent 1ed07f7 commit 929ec54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/config/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define P_CUSTOM_GENDER_DIFF_ICONS TRUE // If TRUE, will give more Pokémon custom icons for their female forms, i.e. Hippopotas and Hippowdon
#define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs.
#define P_EV_CAP GEN_LATEST // Since Gen 6, the max EVs per stat is 252 instead of 255.
#define P_CATCH_CURVE GEN_LATEST // Since Gen 6, the capture rate curve was changed to make pokeballs more effective on lower level pokemon

// Flag settings
// To use the following features in scripting, replace the 0s with the flag ID you're assigning it to.
Expand Down
14 changes: 11 additions & 3 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -14959,7 +14959,7 @@ static void Cmd_handleballthrow(void)
if (gBattleResults.catchAttempts[gLastUsedItem - FIRST_BALL] < 255)
gBattleResults.catchAttempts[gLastUsedItem - FIRST_BALL]++;

if (odds > 254) // mon caught
if (odds >= 255) // mon caught
{
BtlController_EmitBallThrowAnim(gBattlerAttacker, BUFFER_A, BALL_3_SHAKES_SUCCESS);
MarkBattlerForControllerExec(gBattlerAttacker);
Expand Down Expand Up @@ -15004,8 +15004,16 @@ static void Cmd_handleballthrow(void)
}
else
{
odds = Sqrt(Sqrt(16711680 / odds));
odds = 1048560 / odds;
if (P_CATCH_CURVE >= GEN_6)
{
odds = (255 * 255 * 255) / (odds * odds * odds);
odds = 65536 / Sqrt(Sqrt(Sqrt(Sqrt(odds))));
}
else
{
odds = Sqrt(Sqrt(16711680 / odds));
odds = 1048560 / odds;
}
for (shakes = 0; shakes < maxShakes && Random() < odds; shakes++);
}

Expand Down

0 comments on commit 929ec54

Please sign in to comment.