From a6c3d950f6b710bdaf3a28b91e11ee6922a1fb6b Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 1 Nov 2020 16:15:42 -0700 Subject: [PATCH 1/5] critical capture config option and catching charm --- include/constants/battle_config.h | 4 +++ src/battle_script_commands.c | 43 +++++++++++++++++++------------ 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 778314f643..f7d4946622 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -130,6 +130,10 @@ #define B_PARALYZE_ELECTRIC GEN_6 // In Gen6+, Electric type Pokémon can't be paralyzed. #define B_POWDER_GRASS GEN_6 // In Gen6+, Grass type Pokémon are immune to powder and spore moves. +// Critical Capture +#define CRITICAL_CAPTURE TRUE // if set to TRUE, critical capture will be enabled +#define CATCHING_CHARM_BOOST 20 // % boost in critical capture odds if player has the catching charm + // Animation Settings #define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. #define B_NEW_LEECH_SEED_PARTICLE TRUE // If set to TRUE, it updates Leech Seed's animation particle. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 36355d10da..ed8086d7de 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12389,25 +12389,34 @@ static void Cmd_metalburstdamagecalculator(void) static bool32 CriticalCapture(u32 odds) { - u16 numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); + #if CRITICAL_CAPTURE == TRUE + u16 numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); - if (numCaught <= 30) - odds = 0; - else if (numCaught <= 150) - odds /= 2; - else if (numCaught <= 300) - ; - else if (numCaught <= 450) - odds = (odds * 150) / 100; - else if (numCaught <= 600) - odds *= 2; - else - odds = (odds * 250) / 100; + if (numCaught <= 30) + odds = 0; + else if (numCaught <= 150) + odds /= 2; + else if (numCaught <= 300) + ; + else if (numCaught <= 450) + odds = (odds * 150) / 100; + else if (numCaught <= 600) + odds *= 2; + else + odds = (odds * 250) / 100; - odds /= 6; - if ((Random() % 255) < odds) - return TRUE; + #ifdef ITEM_CATCHING_CHARM + if (CheckBagHasItem(ITEM_CATCHING_CHARM, 1)) + odds = (odds * (100 + CATCHING_CHARM_BOOST)) / 100; + #endif - return FALSE; + odds /= 6; + if ((Random() % 255) < odds) + return TRUE; + + return FALSE; + #else + return FALSE; + #endif } From 59692e8e7fc315a85c2ce74ae8e6e743d6e6bac0 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 1 Nov 2020 21:08:58 -0700 Subject: [PATCH 2/5] styling fix --- include/constants/battle_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index f7d4946622..c1b4c71c83 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -131,8 +131,8 @@ #define B_POWDER_GRASS GEN_6 // In Gen6+, Grass type Pokémon are immune to powder and spore moves. // Critical Capture -#define CRITICAL_CAPTURE TRUE // if set to TRUE, critical capture will be enabled -#define CATCHING_CHARM_BOOST 20 // % boost in critical capture odds if player has the catching charm +#define CRITICAL_CAPTURE TRUE // if set to TRUE, critical capture will be enabled +#define CATCHING_CHARM_BOOST 20 // % boost in critical capture odds if player has the catching charm // Animation Settings #define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. From e7372e7c5b601205826c7e71975cd77b8995bd28 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 1 Nov 2020 21:50:34 -0700 Subject: [PATCH 3/5] add B_ prefix to critical capture configs --- include/constants/battle_config.h | 4 ++-- src/battle_script_commands.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index c1b4c71c83..0d6e878723 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -131,8 +131,8 @@ #define B_POWDER_GRASS GEN_6 // In Gen6+, Grass type Pokémon are immune to powder and spore moves. // Critical Capture -#define CRITICAL_CAPTURE TRUE // if set to TRUE, critical capture will be enabled -#define CATCHING_CHARM_BOOST 20 // % 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_CATCHING_CHARM_BOOST 20 // % boost in critical capture odds if player has the catching charm // Animation Settings #define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ed8086d7de..151d95135d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12389,7 +12389,7 @@ static void Cmd_metalburstdamagecalculator(void) static bool32 CriticalCapture(u32 odds) { - #if CRITICAL_CAPTURE == TRUE + #if B_CRITICAL_CAPTURE == TRUE u16 numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); if (numCaught <= 30) @@ -12407,7 +12407,7 @@ static bool32 CriticalCapture(u32 odds) #ifdef ITEM_CATCHING_CHARM if (CheckBagHasItem(ITEM_CATCHING_CHARM, 1)) - odds = (odds * (100 + CATCHING_CHARM_BOOST)) / 100; + odds = (odds * (100 + B_CATCHING_CHARM_BOOST)) / 100; #endif odds /= 6; From b3d1e8b5b834a9f3416298ca5b64c28d4bd74ce2 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 3 Nov 2020 08:57:11 -0700 Subject: [PATCH 4/5] turn crit capture odds into a ratio --- include/constants/battle_config.h | 8 ++++---- src/battle_script_commands.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 0d6e878723..fa358de7a8 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -124,16 +124,16 @@ #define B_SHOW_TARGETS TRUE // If set to TRUE, all available targets, for moves hitting 2 or 3 Pokémon, will be shown before selecting a move. #define B_SHOW_SPLIT_ICON TRUE // If set to TRUE, it will show an icon in the summary showing the move's category split. +// Critical Capture +#define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled. +#define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm. + // Other #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. #define B_SLEEP_TURNS GEN_6 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. #define B_PARALYZE_ELECTRIC GEN_6 // In Gen6+, Electric type Pokémon can't be paralyzed. #define B_POWDER_GRASS GEN_6 // In Gen6+, Grass type Pokémon are immune to powder and spore moves. -// Critical Capture -#define B_CRITICAL_CAPTURE TRUE // if set to TRUE, critical capture will be enabled -#define B_CATCHING_CHARM_BOOST 20 // % boost in critical capture odds if player has the catching charm - // Animation Settings #define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. #define B_NEW_LEECH_SEED_PARTICLE TRUE // If set to TRUE, it updates Leech Seed's animation particle. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 151d95135d..2e85e667f1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12390,17 +12390,17 @@ static void Cmd_metalburstdamagecalculator(void) static bool32 CriticalCapture(u32 odds) { #if B_CRITICAL_CAPTURE == TRUE - u16 numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); + u32 numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); - if (numCaught <= 30) + if (numCaught <= (NUM_SPECIES * 30) / 650) odds = 0; - else if (numCaught <= 150) + else if (numCaught <= (NUM_SPECIES * 150) / 650) odds /= 2; - else if (numCaught <= 300) - ; - else if (numCaught <= 450) + else if (numCaught <= (NUM_SPECIES * 300) / 650) + ; // odds = (odds * 100) / 100; + else if (numCaught <= (NUM_SPECIES * 450) / 650) odds = (odds * 150) / 100; - else if (numCaught <= 600) + else if (numCaught <= (NUM_SPECIES * 600) / 650) odds *= 2; else odds = (odds * 250) / 100; From 980f208b78c8bb6296ce5c5cebbffbf58ddc96b0 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 8 Nov 2020 14:07:43 -0700 Subject: [PATCH 5/5] use NATIONAL_DEX_COUNT for critical capture odds --- include/constants/battle_config.h | 4 ++-- src/battle_script_commands.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index fa358de7a8..a484b9dbcd 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -125,8 +125,8 @@ #define B_SHOW_SPLIT_ICON TRUE // If set to TRUE, it will show an icon in the summary showing the move's category split. // Critical Capture -#define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled. -#define B_CATCHING_CHARM_BOOST 20 // % 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_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm. // Other #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2e85e667f1..1b3cb2a7f5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12392,15 +12392,15 @@ static bool32 CriticalCapture(u32 odds) #if B_CRITICAL_CAPTURE == TRUE u32 numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); - if (numCaught <= (NUM_SPECIES * 30) / 650) + if (numCaught <= (NATIONAL_DEX_COUNT * 30) / 650) odds = 0; - else if (numCaught <= (NUM_SPECIES * 150) / 650) + else if (numCaught <= (NATIONAL_DEX_COUNT * 150) / 650) odds /= 2; - else if (numCaught <= (NUM_SPECIES * 300) / 650) + else if (numCaught <= (NATIONAL_DEX_COUNT * 300) / 650) ; // odds = (odds * 100) / 100; - else if (numCaught <= (NUM_SPECIES * 450) / 650) + else if (numCaught <= (NATIONAL_DEX_COUNT * 450) / 650) odds = (odds * 150) / 100; - else if (numCaught <= (NUM_SPECIES * 600) / 650) + else if (numCaught <= (NATIONAL_DEX_COUNT * 600) / 650) odds *= 2; else odds = (odds * 250) / 100;