From 28dc577a733c2e1c8d4666fa162d31353d3fd934 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 2 Nov 2020 00:24:19 -0300 Subject: [PATCH] Review changes. --- src/battle_script_commands.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1f921d61f5..aa9a98091c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9907,7 +9907,7 @@ static void Cmd_handleballthrow(void) else ballAddition = 30; #elif I_HEAVY_BALL_MODIFIER >= GEN_4 - if (i < 2028) + if (i < 2048) ballAddition = -20; else if (i < 3072) ballAddition = 20; @@ -9969,7 +9969,13 @@ static void Cmd_handleballthrow(void) } #endif - odds = ((catchRate + ballAddition) * ballMultiplier / 10) + // catchRate is unsigned, which means that it may potentially overflow if sum is applied directly. + if (catchRate < 21 && ballAddition == -20) + catchRate = 1; + else + catchRate = catchRate - ballAddition; + + odds = ((catchRate) * ballMultiplier / 10) * (gBattleMons[gBattlerTarget].maxHP * 3 - gBattleMons[gBattlerTarget].hp * 2) / (3 * gBattleMons[gBattlerTarget].maxHP);