From 137d9801c01d0c631ffd72f90f76e984a177844e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 01:25:54 -0300 Subject: [PATCH 01/21] Key Items configuration in file. --- include/constants/item_config.h | 20 ++++++++++++++++++++ include/item.h | 1 + src/data/items.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 include/constants/item_config.h diff --git a/include/constants/item_config.h b/include/constants/item_config.h new file mode 100644 index 0000000000..bffe5740e9 --- /dev/null +++ b/include/constants/item_config.h @@ -0,0 +1,20 @@ +#ifndef GUARD_CONSTANTS_ITEM_CONFIG_H +#define GUARD_CONSTANTS_ITEM_CONFIG_H + +// Used by other branches to communicate with each other. +#define ITEM_EXPANSION + +#ifndef GEN_3 +#define GEN_3 0 +#define GEN_4 1 +#define GEN_5 2 +#define GEN_6 3 +#define GEN_7 4 +#define GEN_8 5 +#endif + +// Item config +#define P_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. +#define P_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. + +#endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/include/item.h b/include/item.h index 87ff57bc79..9090789437 100644 --- a/include/item.h +++ b/include/item.h @@ -2,6 +2,7 @@ #define GUARD_ITEM_H #include "constants/item.h" +#include "constants/item_config.h" typedef void (*ItemUseFunc)(u8); diff --git a/src/data/items.h b/src/data/items.h index 3f5ffac217..ee7865898c 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -1283,7 +1283,13 @@ const struct Item gItems[] = .itemId = ITEM_ESCAPE_ROPE, .price = 550, .description = sEscapeRopeDesc, + #if P_KEY_ESCAPE_ROPE >= GEN_8 + .importance = 1, + .pocket = POCKET_KEY_ITEMS, + #else + .importance = 0, .pocket = POCKET_ITEMS, + #endif .type = 2, .fieldUseFunc = ItemUseOutOfBattle_EscapeRope, .secondaryId = 0, @@ -4813,8 +4819,13 @@ const struct Item gItems[] = .itemId = ITEM_OLD_AMBER, .price = 0, .description = sOldAmberDesc, + #if P_KEY_FOSSILS >= GEN_4 .importance = 1, .pocket = POCKET_KEY_ITEMS, + #else + .importance = 0, + .pocket = POCKET_ITEMS, + #endif .type = 4, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .secondaryId = 0, @@ -4878,8 +4889,13 @@ const struct Item gItems[] = .itemId = ITEM_HELIX_FOSSIL, .price = 0, .description = sHelixFossilDesc, + #if P_KEY_FOSSILS >= GEN_4 + .importance = 1, + .pocket = POCKET_KEY_ITEMS, + #else .importance = 0, .pocket = POCKET_ITEMS, + #endif .type = 4, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .secondaryId = 0, @@ -4891,8 +4907,13 @@ const struct Item gItems[] = .itemId = ITEM_DOME_FOSSIL, .price = 0, .description = sDomeFossilDesc, + #if P_KEY_FOSSILS >= GEN_4 + .importance = 1, + .pocket = POCKET_KEY_ITEMS, + #else .importance = 0, .pocket = POCKET_ITEMS, + #endif .type = 4, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .secondaryId = 0, @@ -4904,8 +4925,13 @@ const struct Item gItems[] = .itemId = ITEM_ROOT_FOSSIL, .price = 0, .description = sRootFossilDesc, + #if P_KEY_FOSSILS >= GEN_4 + .importance = 1, + .pocket = POCKET_KEY_ITEMS, + #else .importance = 0, .pocket = POCKET_ITEMS, + #endif .type = 4, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .secondaryId = 0, @@ -4917,8 +4943,13 @@ const struct Item gItems[] = .itemId = ITEM_CLAW_FOSSIL, .price = 0, .description = sClawFossilDesc, + #if P_KEY_FOSSILS >= GEN_4 + .importance = 1, + .pocket = POCKET_KEY_ITEMS, + #else .importance = 0, .pocket = POCKET_ITEMS, + #endif .type = 4, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .secondaryId = 0, From 7fbd64ec37293cf5d7430ac9bb5698e3d89fbf82 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 01:26:51 -0300 Subject: [PATCH 02/21] Moved Shiny Charm rerolls into config file --- include/constants/item_config.h | 1 + include/constants/pokemon.h | 1 - src/pokemon.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index bffe5740e9..30c1805218 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -14,6 +14,7 @@ #endif // Item config +#define P_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. #define P_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. #define P_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 47e1978241..8cc78d8cec 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -91,7 +91,6 @@ // Shiny odds #define SHINY_ODDS 8 // Actual probability is SHINY_ODDS/65536 -#define SHINY_CHARM_REROLLS 3 // Amount of re-rolls if has Shiny Charm. // Flags for Get(Box)MonData / Set(Box)MonData #define MON_DATA_PERSONALITY 0 diff --git a/src/pokemon.c b/src/pokemon.c index 4fbdcffd00..2e6b02e59c 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2233,7 +2233,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, personality = Random32(); shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality); rolls++; - } while (shinyValue >= SHINY_ODDS && rolls < SHINY_CHARM_REROLLS); + } while (shinyValue >= SHINY_ODDS && rolls < P_SHINY_CHARM_REROLLS); } } From e65f22a76cd92508ad85f61620c205ca5821571a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 01:33:10 -0300 Subject: [PATCH 03/21] Lure Ball modifier in config. --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 30c1805218..5e9c99874e 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -17,5 +17,6 @@ #define P_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. #define P_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. #define P_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. +#define P_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bc689117a8..f115fc073b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9829,7 +9829,11 @@ static void Cmd_handleballthrow(void) break; case ITEM_LURE_BALL: if (gIsFishingEncounter) - ballMultiplier = 30; + #if P_LURE_BALL_MODIFIER >= GEN_7 + ballMultiplier = 50; + #else + ballMultiplier = 30; + #endif break; case ITEM_MOON_BALL: for (i = 0; i < EVOS_PER_MON; i++) From 0dfbbde7ce0629083b451eff28498bcc60335bda Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 01:47:04 -0300 Subject: [PATCH 04/21] Heavy Ball modifier in config. --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 5e9c99874e..018efcff7f 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -18,5 +18,6 @@ #define P_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. #define P_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. #define P_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. +#define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f115fc073b..5b3d97fcbe 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9855,16 +9855,27 @@ static void Cmd_handleballthrow(void) break; case ITEM_HEAVY_BALL: i = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1); - if (i < 1024) - ballMultiplier = 5; - else if (i < 2048) - ballMultiplier = 10; - else if (i < 3072) - ballMultiplier = 20; - else if (i < 4096) - ballMultiplier = 30; - else - ballMultiplier = 40; + #if P_HEAVY_BALL_MODIFIER >= GEN_7 + if (i < 1000) + ballMultiplier = 5; + else if (i < 2000) + ballMultiplier = 10; + else if (i < 3000) + ballMultiplier = 20; + else + ballMultiplier = 30; + #else + if (i < 1024) + ballMultiplier = 5; + else if (i < 2048) + ballMultiplier = 10; + else if (i < 3072) + ballMultiplier = 20; + else if (i < 4096) + ballMultiplier = 30; + else + ballMultiplier = 40; + #endif break; case ITEM_FAST_BALL: if (gBaseStats[gBattleMons[gBattlerTarget].species].baseSpeed >= 100) From 66764513530aefc06427ed23ea7fab6ef23df028 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 01:52:14 -0300 Subject: [PATCH 05/21] Net ball modifier in config --- include/constants/item_config.h | 3 +++ src/battle_script_commands.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 018efcff7f..410623cdfb 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -17,7 +17,10 @@ #define P_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. #define P_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. #define P_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. + +// Ball config #define P_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. #define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. +#define P_NET_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5b3d97fcbe..5ec8eb4347 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9786,7 +9786,11 @@ static void Cmd_handleballthrow(void) { case ITEM_NET_BALL: if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_BUG)) - ballMultiplier = 30; + #if P_NET_BALL_MODIFIER >= GEN_7 + ballMultiplier = 50; + #else + ballMultiplier = 30; + #endif break; case ITEM_DIVE_BALL: if (GetCurrentMapType() == MAP_TYPE_UNDERWATER) From 6af4425081c3d0b7fbf9afe06c80b436f84b8dd8 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:00:53 -0300 Subject: [PATCH 06/21] Nest Ball modifier in config. --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 410623cdfb..3a5ebfaa85 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -22,5 +22,6 @@ #define P_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. #define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. #define P_NET_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. +#define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5ec8eb4347..3a13ffeebd 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9797,12 +9797,23 @@ static void Cmd_handleballthrow(void) ballMultiplier = 35; break; case ITEM_NEST_BALL: - if (gBattleMons[gBattlerTarget].level < 40) - { - ballMultiplier = 40 - gBattleMons[gBattlerTarget].level; - if (ballMultiplier <= 9) - ballMultiplier = 10; - } + #if P_NEST_BALL_MODIFIER >= GEN_6 + //((41 - Pokémon's level) ÷ 10)× if Pokémon's level is between 1 and 29, 1× otherwise. + if (gBattleMons[gBattlerTarget].level < 30) + ballMultiplier = 41 - gBattleMons[gBattlerTarget].level; + #elif P_NEST_BALL_MODIFIER == GEN_5 + //((41 - Pokémon's level) ÷ 10)×, minimum 1× + if (gBattleMons[gBattlerTarget].level < 31) + ballMultiplier = 41 - gBattleMons[gBattlerTarget].level; + #else + //((40 - Pokémon's level) ÷ 10)×, minimum 1× + if (gBattleMons[gBattlerTarget].level < 40) + { + ballMultiplier = 40 - gBattleMons[gBattlerTarget].level; + if (ballMultiplier <= 9) + ballMultiplier = 10; + } + #endif break; case ITEM_REPEAT_BALL: if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), FLAG_GET_CAUGHT)) From 32a2f91ecb9b06a5190808bf7535b880f2fb48d9 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:04:39 -0300 Subject: [PATCH 07/21] Repeat Ball modifier in config. --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 3a5ebfaa85..eacad0af30 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -23,5 +23,6 @@ #define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. #define P_NET_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. #define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. +#define P_REPEAT_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3.5 instead of x3. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3a13ffeebd..6f07c6bca3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9817,7 +9817,11 @@ static void Cmd_handleballthrow(void) break; case ITEM_REPEAT_BALL: if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), FLAG_GET_CAUGHT)) - ballMultiplier = 30; + #if P_REPEAT_BALL_MODIFIER >= GEN_7 + ballMultiplier = 35; + #else + ballMultiplier = 30; + #endif break; case ITEM_TIMER_BALL: ballMultiplier = gBattleResults.battleTurnCounter + 10; From 14c243b273795bb44d5edd4861e834f3cd879a4f Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:08:58 -0300 Subject: [PATCH 08/21] Timer ball config. --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index eacad0af30..f9524e5775 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -24,5 +24,6 @@ #define P_NET_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. #define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. #define P_REPEAT_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3.5 instead of x3. +#define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6f07c6bca3..a5895cbc73 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9824,7 +9824,11 @@ static void Cmd_handleballthrow(void) #endif break; case ITEM_TIMER_BALL: - ballMultiplier = gBattleResults.battleTurnCounter + 10; + #if P_TIMER_BALL_MODIFIER >= GEN_5 + ballMultiplier = (gBattleResults.battleTurnCounter * 3) + 10; + #else + ballMultiplier = gBattleResults.battleTurnCounter + 10; + #endif if (ballMultiplier > 40) ballMultiplier = 40; break; From ce3b877666df878af14e4a025fcad0b693008a9b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:33:15 -0300 Subject: [PATCH 09/21] Dive Ball config. --- include/constants/item_config.h | 1 + include/wild_encounter.h | 1 + src/battle_main.c | 1 + src/battle_script_commands.c | 9 +++++++-- src/wild_encounter.c | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index f9524e5775..bd3cc87f1f 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -25,5 +25,6 @@ #define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. #define P_REPEAT_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3.5 instead of x3. #define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 +#define P_DIVE_BALL_MODIFIER GEN_3 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/include/wild_encounter.h b/include/wild_encounter.h index a9479d34db..626eee468c 100644 --- a/include/wild_encounter.h +++ b/include/wild_encounter.h @@ -30,6 +30,7 @@ struct WildPokemonHeader }; extern bool8 gIsFishingEncounter; +extern bool8 gIsSurfingEncounter; extern const struct WildPokemonHeader gWildMonHeaders[]; diff --git a/src/battle_main.c b/src/battle_main.c index c050616567..ccbdafebf8 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5073,6 +5073,7 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void) if (!gPaletteFade.active) { gIsFishingEncounter = FALSE; + gIsSurfingEncounter = FALSE; ResetSpriteData(); if (gLeveledUpInBattle == 0 || gBattleOutcome != B_OUTCOME_WON) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a5895cbc73..39194911ca 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9793,8 +9793,13 @@ static void Cmd_handleballthrow(void) #endif break; case ITEM_DIVE_BALL: - if (GetCurrentMapType() == MAP_TYPE_UNDERWATER) - ballMultiplier = 35; + #if P_DIVE_BALL_MODIFIER >= GEN_4 + if (GetCurrentMapType() == MAP_TYPE_UNDERWATER || gIsFishingEncounter || gIsSurfingEncounter) + ballMultiplier = 35; + #else + if (GetCurrentMapType() == MAP_TYPE_UNDERWATER) + ballMultiplier = 35; + #endif break; case ITEM_NEST_BALL: #if P_NEST_BALL_MODIFIER >= GEN_6 diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 6ef4987f24..7d8edca4c4 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -39,6 +39,7 @@ static bool8 IsAbilityAllowingEncounter(u8 level); // EWRAM vars EWRAM_DATA static u8 sWildEncountersDisabled = 0; EWRAM_DATA bool8 gIsFishingEncounter = 0; +EWRAM_DATA bool8 gIsSurfingEncounter = 0; EWRAM_DATA static u32 sFeebasRngValue = 0; #include "data/wild_encounters.h" @@ -615,6 +616,7 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi { if (TryGenerateWildMon(gWildMonHeaders[headerId].waterMonsInfo, WILD_AREA_WATER, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE) { + gIsSurfingEncounter = TRUE; BattleSetup_StartWildBattle(); return TRUE; } From 6f246bb0c720b683dfefbdca3edf76f55149347d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:41:02 -0300 Subject: [PATCH 10/21] Dusk Ball config --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index bd3cc87f1f..4da6630eb8 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -26,5 +26,6 @@ #define P_REPEAT_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3.5 instead of x3. #define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 #define P_DIVE_BALL_MODIFIER GEN_3 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. +#define P_DUSK_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3 instead of x3.5. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 39194911ca..a508a520bd 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9916,7 +9916,11 @@ static void Cmd_handleballthrow(void) case ITEM_DUSK_BALL: RtcCalcLocalTime(); if ((gLocalTime.hours >= 20 && gLocalTime.hours <= 3) || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND) - ballMultiplier = 30; + #if P_DUSK_BALL_MODIFIER >= GEN_7 + ballMultiplier = 30; + #else + ballMultiplier = 35; + #endif break; } } From e320e6f7fff0ef650dbe8469b335afa3a8d5af79 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:44:09 -0300 Subject: [PATCH 11/21] Quick Ball config. --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 4da6630eb8..04eb7a5470 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -27,5 +27,6 @@ #define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 #define P_DIVE_BALL_MODIFIER GEN_3 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. #define P_DUSK_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3 instead of x3.5. +#define P_QUICK_BALL_MODIFIER GEN_7 // In Gen5+, Quick Ball's catch multiplier is x5 instead of x4. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a508a520bd..0e087266b7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9911,7 +9911,11 @@ static void Cmd_handleballthrow(void) break; case ITEM_QUICK_BALL: if (gBattleResults.battleTurnCounter == 0) - ballMultiplier = 40; + #if P_QUICK_BALL_MODIFIER >= GEN_5 + ballMultiplier = 50; + #else + ballMultiplier = 40; + #endif break; case ITEM_DUSK_BALL: RtcCalcLocalTime(); From 0717783651421c3cd3b2ff4fa5e9e60decf40d56 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:51:08 -0300 Subject: [PATCH 12/21] Dream ball config. --- include/constants/item_config.h | 1 + src/battle_script_commands.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 04eb7a5470..8689de640c 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -28,5 +28,6 @@ #define P_DIVE_BALL_MODIFIER GEN_3 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. #define P_DUSK_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3 instead of x3.5. #define P_QUICK_BALL_MODIFIER GEN_7 // In Gen5+, Quick Ball's catch multiplier is x5 instead of x4. +#define P_DREAM_BALL_MODIFIER GEN_8 // In Gen8+, Dream Ball's catch multiplier is x4 when the target is asleep. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0e087266b7..750f1a6fd5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9926,6 +9926,14 @@ static void Cmd_handleballthrow(void) ballMultiplier = 35; #endif break; + case ITEM_DREAM_BALL: + #if P_DREAM_BALL_MODIFIER >= GEN_8 + if (gBattleMons[gBattlerTarget].status1 & STATUS1_SLEEP) + ballMultiplier = 40; + #else + ballMultiplier = 10; + #endif + break; } } else From ffe23b246b8e0084f7db84071378daaf2630f4fc Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 02:54:13 -0300 Subject: [PATCH 13/21] Ordered config. --- include/constants/item_config.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 8689de640c..4d9a5f0683 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -20,14 +20,14 @@ // Ball config #define P_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. -#define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. #define P_NET_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. -#define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. #define P_REPEAT_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3.5 instead of x3. -#define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 -#define P_DIVE_BALL_MODIFIER GEN_3 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. #define P_DUSK_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3 instead of x3.5. #define P_QUICK_BALL_MODIFIER GEN_7 // In Gen5+, Quick Ball's catch multiplier is x5 instead of x4. #define P_DREAM_BALL_MODIFIER GEN_8 // In Gen8+, Dream Ball's catch multiplier is x4 when the target is asleep. +#define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 +#define P_DIVE_BALL_MODIFIER GEN_3 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. +#define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. +#define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H From 12bc93dc789f51382da801ea0fafdbc91f38b9a6 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 17 Oct 2020 17:07:54 -0300 Subject: [PATCH 14/21] Review changes --- include/constants/item_config.h | 2 +- src/data/items.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 4d9a5f0683..666ed9adf1 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -26,7 +26,7 @@ #define P_QUICK_BALL_MODIFIER GEN_7 // In Gen5+, Quick Ball's catch multiplier is x5 instead of x4. #define P_DREAM_BALL_MODIFIER GEN_8 // In Gen8+, Dream Ball's catch multiplier is x4 when the target is asleep. #define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 -#define P_DIVE_BALL_MODIFIER GEN_3 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. +#define P_DIVE_BALL_MODIFIER GEN_7 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. #define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. #define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. diff --git a/src/data/items.h b/src/data/items.h index ee7865898c..070eca4226 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -1281,12 +1281,13 @@ const struct Item gItems[] = { .name = _("Escape Rope"), .itemId = ITEM_ESCAPE_ROPE, - .price = 550, .description = sEscapeRopeDesc, #if P_KEY_ESCAPE_ROPE >= GEN_8 + .price = 0, .importance = 1, .pocket = POCKET_KEY_ITEMS, #else + .price = 550, .importance = 0, .pocket = POCKET_ITEMS, #endif From e861abeff38f44bd8226c2eb400aeb4b1950078d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 23 Oct 2020 22:19:37 -0300 Subject: [PATCH 15/21] Initial review changes. --- include/constants/item_config.h | 26 +++++++++++++------------- src/battle_script_commands.c | 22 +++++++++++----------- src/data/items.h | 12 ++++++------ src/pokemon.c | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index 666ed9adf1..f8618fc00c 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -14,20 +14,20 @@ #endif // Item config -#define P_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. -#define P_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. -#define P_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. +#define I_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. +#define I_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. +#define I_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. // Ball config -#define P_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. -#define P_NET_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. -#define P_REPEAT_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3.5 instead of x3. -#define P_DUSK_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x3 instead of x3.5. -#define P_QUICK_BALL_MODIFIER GEN_7 // In Gen5+, Quick Ball's catch multiplier is x5 instead of x4. -#define P_DREAM_BALL_MODIFIER GEN_8 // In Gen8+, Dream Ball's catch multiplier is x4 when the target is asleep. -#define P_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 -#define P_DIVE_BALL_MODIFIER GEN_7 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. -#define P_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. -#define P_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. +#define I_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. +#define I_NET_BALL_MODIFIER GEN_7 // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. +#define I_REPEAT_BALL_MODIFIER GEN_7 // In Gen7+, Repeat Ball's catch multiplier is x3.5 instead of x3. +#define I_DUSK_BALL_MODIFIER GEN_7 // In Gen7+, Dusk Ball's catch multiplier is x3 instead of x3.5. +#define I_QUICK_BALL_MODIFIER GEN_7 // In Gen5+, Quick Ball's catch multiplier is x5 instead of x4. +#define I_DREAM_BALL_MODIFIER GEN_8 // In Gen8+, Dream Ball's catch multiplier is x4 when the target is asleep. +#define I_TIMER_BALL_MODIFIER GEN_7 // In Gen5+, Timer Ball's effectiveness increases by x0.3 per turn instead of x0.1 +#define I_DIVE_BALL_MODIFIER GEN_7 // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. +#define I_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. +#define I_NEST_BALL_MODIFIER GEN_7 // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow. #endif // GUARD_CONSTANTS_ITEM_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 750f1a6fd5..d730c3fe55 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9786,14 +9786,14 @@ static void Cmd_handleballthrow(void) { case ITEM_NET_BALL: if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_BUG)) - #if P_NET_BALL_MODIFIER >= GEN_7 + #if I_NET_BALL_MODIFIER >= GEN_7 ballMultiplier = 50; #else ballMultiplier = 30; #endif break; case ITEM_DIVE_BALL: - #if P_DIVE_BALL_MODIFIER >= GEN_4 + #if I_DIVE_BALL_MODIFIER >= GEN_4 if (GetCurrentMapType() == MAP_TYPE_UNDERWATER || gIsFishingEncounter || gIsSurfingEncounter) ballMultiplier = 35; #else @@ -9802,11 +9802,11 @@ static void Cmd_handleballthrow(void) #endif break; case ITEM_NEST_BALL: - #if P_NEST_BALL_MODIFIER >= GEN_6 + #if I_NEST_BALL_MODIFIER >= GEN_6 //((41 - Pokémon's level) ÷ 10)× if Pokémon's level is between 1 and 29, 1× otherwise. if (gBattleMons[gBattlerTarget].level < 30) ballMultiplier = 41 - gBattleMons[gBattlerTarget].level; - #elif P_NEST_BALL_MODIFIER == GEN_5 + #elif I_NEST_BALL_MODIFIER == GEN_5 //((41 - Pokémon's level) ÷ 10)×, minimum 1× if (gBattleMons[gBattlerTarget].level < 31) ballMultiplier = 41 - gBattleMons[gBattlerTarget].level; @@ -9822,14 +9822,14 @@ static void Cmd_handleballthrow(void) break; case ITEM_REPEAT_BALL: if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), FLAG_GET_CAUGHT)) - #if P_REPEAT_BALL_MODIFIER >= GEN_7 + #if I_REPEAT_BALL_MODIFIER >= GEN_7 ballMultiplier = 35; #else ballMultiplier = 30; #endif break; case ITEM_TIMER_BALL: - #if P_TIMER_BALL_MODIFIER >= GEN_5 + #if I_TIMER_BALL_MODIFIER >= GEN_5 ballMultiplier = (gBattleResults.battleTurnCounter * 3) + 10; #else ballMultiplier = gBattleResults.battleTurnCounter + 10; @@ -9857,7 +9857,7 @@ static void Cmd_handleballthrow(void) break; case ITEM_LURE_BALL: if (gIsFishingEncounter) - #if P_LURE_BALL_MODIFIER >= GEN_7 + #if I_LURE_BALL_MODIFIER >= GEN_7 ballMultiplier = 50; #else ballMultiplier = 30; @@ -9883,7 +9883,7 @@ static void Cmd_handleballthrow(void) break; case ITEM_HEAVY_BALL: i = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1); - #if P_HEAVY_BALL_MODIFIER >= GEN_7 + #if I_HEAVY_BALL_MODIFIER >= GEN_7 if (i < 1000) ballMultiplier = 5; else if (i < 2000) @@ -9911,7 +9911,7 @@ static void Cmd_handleballthrow(void) break; case ITEM_QUICK_BALL: if (gBattleResults.battleTurnCounter == 0) - #if P_QUICK_BALL_MODIFIER >= GEN_5 + #if I_QUICK_BALL_MODIFIER >= GEN_5 ballMultiplier = 50; #else ballMultiplier = 40; @@ -9920,14 +9920,14 @@ static void Cmd_handleballthrow(void) case ITEM_DUSK_BALL: RtcCalcLocalTime(); if ((gLocalTime.hours >= 20 && gLocalTime.hours <= 3) || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND) - #if P_DUSK_BALL_MODIFIER >= GEN_7 + #if I_DUSK_BALL_MODIFIER >= GEN_7 ballMultiplier = 30; #else ballMultiplier = 35; #endif break; case ITEM_DREAM_BALL: - #if P_DREAM_BALL_MODIFIER >= GEN_8 + #if I_DREAM_BALL_MODIFIER >= GEN_8 if (gBattleMons[gBattlerTarget].status1 & STATUS1_SLEEP) ballMultiplier = 40; #else diff --git a/src/data/items.h b/src/data/items.h index 070eca4226..4788730924 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -1282,7 +1282,7 @@ const struct Item gItems[] = .name = _("Escape Rope"), .itemId = ITEM_ESCAPE_ROPE, .description = sEscapeRopeDesc, - #if P_KEY_ESCAPE_ROPE >= GEN_8 + #if I_KEY_ESCAPE_ROPE >= GEN_8 .price = 0, .importance = 1, .pocket = POCKET_KEY_ITEMS, @@ -4820,7 +4820,7 @@ const struct Item gItems[] = .itemId = ITEM_OLD_AMBER, .price = 0, .description = sOldAmberDesc, - #if P_KEY_FOSSILS >= GEN_4 + #if I_KEY_FOSSILS >= GEN_4 .importance = 1, .pocket = POCKET_KEY_ITEMS, #else @@ -4890,7 +4890,7 @@ const struct Item gItems[] = .itemId = ITEM_HELIX_FOSSIL, .price = 0, .description = sHelixFossilDesc, - #if P_KEY_FOSSILS >= GEN_4 + #if I_KEY_FOSSILS >= GEN_4 .importance = 1, .pocket = POCKET_KEY_ITEMS, #else @@ -4908,7 +4908,7 @@ const struct Item gItems[] = .itemId = ITEM_DOME_FOSSIL, .price = 0, .description = sDomeFossilDesc, - #if P_KEY_FOSSILS >= GEN_4 + #if I_KEY_FOSSILS >= GEN_4 .importance = 1, .pocket = POCKET_KEY_ITEMS, #else @@ -4926,7 +4926,7 @@ const struct Item gItems[] = .itemId = ITEM_ROOT_FOSSIL, .price = 0, .description = sRootFossilDesc, - #if P_KEY_FOSSILS >= GEN_4 + #if I_KEY_FOSSILS >= GEN_4 .importance = 1, .pocket = POCKET_KEY_ITEMS, #else @@ -4944,7 +4944,7 @@ const struct Item gItems[] = .itemId = ITEM_CLAW_FOSSIL, .price = 0, .description = sClawFossilDesc, - #if P_KEY_FOSSILS >= GEN_4 + #if I_KEY_FOSSILS >= GEN_4 .importance = 1, .pocket = POCKET_KEY_ITEMS, #else diff --git a/src/pokemon.c b/src/pokemon.c index 2e6b02e59c..5547baeb31 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2233,7 +2233,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, personality = Random32(); shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality); rolls++; - } while (shinyValue >= SHINY_ODDS && rolls < P_SHINY_CHARM_REROLLS); + } while (shinyValue >= SHINY_ODDS && rolls < I_SHINY_CHARM_REROLLS); } } From 3a3ef1a369176ba85cc0e376b535b9cc0dcc0521 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 23 Oct 2020 23:12:22 -0300 Subject: [PATCH 16/21] Reworked Heavy Ball --- src/battle_script_commands.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d730c3fe55..b7a58a15c2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9751,6 +9751,7 @@ static void Cmd_removelightscreenreflect(void) // brick break static void Cmd_handleballthrow(void) { u8 ballMultiplier = 10; + s8 ballAddition = 0; if (gBattleControllerExecFlags) return; @@ -9885,24 +9886,33 @@ static void Cmd_handleballthrow(void) i = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1); #if I_HEAVY_BALL_MODIFIER >= GEN_7 if (i < 1000) - ballMultiplier = 5; + ballAddition = -20; else if (i < 2000) - ballMultiplier = 10; + ballAddition = 0; else if (i < 3000) - ballMultiplier = 20; + ballAddition = 20; else - ballMultiplier = 30; + ballAddition = 30; + #elif I_HEAVY_BALL_MODIFIER >= GEN_4 + if (i < 2028) + ballAddition = -20; + else if (i < 3072) + ballAddition = 20; + else if (i < 4096) + ballAddition = 30; + else + ballAddition = 40; #else if (i < 1024) - ballMultiplier = 5; + ballAddition = -20; else if (i < 2048) - ballMultiplier = 10; + ballAddition = 0; else if (i < 3072) - ballMultiplier = 20; + ballAddition = 20; else if (i < 4096) - ballMultiplier = 30; + ballAddition = 30; else - ballMultiplier = 40; + ballAddition = 40; #endif break; case ITEM_FAST_BALL: @@ -9939,7 +9949,7 @@ static void Cmd_handleballthrow(void) else ballMultiplier = sBallCatchBonuses[gLastUsedItem - ITEM_ULTRA_BALL]; - odds = (catchRate * ballMultiplier / 10) + odds = ((catchRate + ballAddition) * ballMultiplier / 10) * (gBattleMons[gBattlerTarget].maxHP * 3 - gBattleMons[gBattlerTarget].hp * 2) / (3 * gBattleMons[gBattlerTarget].maxHP); From 14f3d69c83cdb06baae770c3b204a30079adf59f Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 23 Oct 2020 23:43:07 -0300 Subject: [PATCH 17/21] Beast ball effect. --- src/battle_script_commands.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b7a58a15c2..1f921d61f5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9781,6 +9781,19 @@ static void Cmd_handleballthrow(void) else catchRate = gBaseStats[gBattleMons[gBattlerTarget].species].catchRate; + + #ifdef POKEMON_EXPANSION + if (IS_ULTRA_BEAST(gBattleMons[gBattlerTarget].species)) + { + if (gLastUsedItem == ITEM_BEAST_BALL) + ballMultiplier = 50; + else + ballMultiplier = 1; + } + else + { + #endif + if (gLastUsedItem > ITEM_SAFARI_BALL) { switch (gLastUsedItem) @@ -9944,11 +9957,18 @@ static void Cmd_handleballthrow(void) ballMultiplier = 10; #endif break; + case ITEM_BEAST_BALL: + ballMultiplier = 1; + break; } } else ballMultiplier = sBallCatchBonuses[gLastUsedItem - ITEM_ULTRA_BALL]; + #ifdef POKEMON_EXPANSION + } + #endif + odds = ((catchRate + ballAddition) * ballMultiplier / 10) * (gBattleMons[gBattlerTarget].maxHP * 3 - gBattleMons[gBattlerTarget].hp * 2) / (3 * gBattleMons[gBattlerTarget].maxHP); From 9eeb574ad140180b58e441e888367ff9c2dc5a02 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 25 Oct 2020 01:08:27 -0300 Subject: [PATCH 18/21] Fixed Escape Rope using bug. Thanks ExpoSeed! --- src/data/items.h | 3 +-- src/item_use.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/data/items.h b/src/data/items.h index 4788730924..ab49bf5355 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -1281,13 +1281,12 @@ const struct Item gItems[] = { .name = _("Escape Rope"), .itemId = ITEM_ESCAPE_ROPE, + .price = 550, .description = sEscapeRopeDesc, #if I_KEY_ESCAPE_ROPE >= GEN_8 - .price = 0, .importance = 1, .pocket = POCKET_KEY_ITEMS, #else - .price = 550, .importance = 0, .pocket = POCKET_ITEMS, #endif diff --git a/src/item_use.c b/src/item_use.c index 1f223c6272..462fab48a5 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -910,7 +910,9 @@ void Task_UseDigEscapeRopeOnField(u8 taskId) static void ItemUseOnFieldCB_EscapeRope(u8 taskId) { Overworld_ResetStateAfterDigEscRope(); - RemoveUsedItem(); + #if I_KEY_ESCAPE_ROPE < GEN_8 + RemoveUsedItem(); + #endif gTasks[taskId].data[0] = 0; DisplayItemMessageOnField(taskId, gStringVar4, Task_UseDigEscapeRopeOnField); } From 4aa6442cd42635db8549df4ae3a7c1793e4fa2b4 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 25 Oct 2020 01:28:14 -0300 Subject: [PATCH 19/21] Fixed price mixed up. --- include/constants/item_config.h | 2 +- src/data/items.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/constants/item_config.h b/include/constants/item_config.h index f8618fc00c..4f111bc0ca 100644 --- a/include/constants/item_config.h +++ b/include/constants/item_config.h @@ -16,7 +16,7 @@ // Item config #define I_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. #define I_KEY_FOSSILS GEN_7 // In Gen4+, all Gen 3 fossils became regular items. -#define I_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. +#define I_KEY_ESCAPE_ROPE GEN_7 // In Gen8, Escape Rope became a Key Item. Keep in mind, this will make it free to buy in marts. // Ball config #define I_LURE_BALL_MODIFIER GEN_7 // In Gen7+, Lure Ball's catch multiplier is x5 instead of x3. diff --git a/src/data/items.h b/src/data/items.h index ab49bf5355..4788730924 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -1281,12 +1281,13 @@ const struct Item gItems[] = { .name = _("Escape Rope"), .itemId = ITEM_ESCAPE_ROPE, - .price = 550, .description = sEscapeRopeDesc, #if I_KEY_ESCAPE_ROPE >= GEN_8 + .price = 0, .importance = 1, .pocket = POCKET_KEY_ITEMS, #else + .price = 550, .importance = 0, .pocket = POCKET_ITEMS, #endif 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 20/21] 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); From 6c04aadff8acaff3542ec8c140a958b14574511d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 2 Nov 2020 00:31:04 -0300 Subject: [PATCH 21/21] Going to bed now --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index aa9a98091c..642e7b53dd 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9973,7 +9973,7 @@ static void Cmd_handleballthrow(void) if (catchRate < 21 && ballAddition == -20) catchRate = 1; else - catchRate = catchRate - ballAddition; + catchRate = catchRate + ballAddition; odds = ((catchRate) * ballMultiplier / 10) * (gBattleMons[gBattlerTarget].maxHP * 3 - gBattleMons[gBattlerTarget].hp * 2)