From 883a2498364d1a8d40989ea5642b2ea24f81f38c Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 09:20:32 -0400 Subject: [PATCH 1/4] config for catching semi-invulnerable mons --- include/constants/battle_config.h | 1 + src/item_use.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index bce49719ee..eb9d9639ef 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -178,6 +178,7 @@ #define B_POWDER_GRASS GEN_7 // In Gen6+, Grass-type Pokémon are immune to powder and spore moves. #define B_STEEL_RESISTANCES GEN_7 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark-type and Ghost-type moves. #define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. +#define B_SEMI_INVULNERABLE_CATCH GEN_5 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/item_use.c b/src/item_use.c index 63854a1ac1..93604efef5 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -947,11 +947,18 @@ u32 CanThrowBall(void) { return 2; // No room for mon } + #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 + else if (gStatuses3[B_POSITION_OPPONENT_LEFT] & STATUS3_SEMI_INVULNERABLE) + { + return 3; // in semi-invulnerable state + } + #endif return 0; // usable } -static const u8 sText_CantThrowPokeBall_TwoMons[] = _("Cannot throw a ball!\nThere are two pokemon out there!\p"); +static const u8 sText_CantThrowPokeBall_TwoMons[] = _("Cannot throw a ball!\nThere are two Pokémon out there!\p"); +static const u8 sText_CantThrowPokeBall_SemiInvulnerable[] = _("Cannot throw a ball!\nThere's no Pokémon in sight!\p"); void ItemUseInBattle_PokeBall(u8 taskId) { switch (CanThrowBall()) @@ -976,6 +983,14 @@ void ItemUseInBattle_PokeBall(u8 taskId) else DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, Task_CloseBattlePyramidBagMessage); break; + #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 + case 3: // Semi-Invulnerable + if (!InBattlePyramid()) + DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_SemiInvulnerable, CloseItemMessage); + else + DisplayItemMessageInBattlePyramid(taskId, sText_CantThrowPokeBall_SemiInvulnerable, Task_CloseBattlePyramidBagMessage); + break; + #endif } } From ef19c8c415b0f583bc686f131a58fba169c58fe6 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 09:22:50 -0400 Subject: [PATCH 2/4] fix gen define --- include/constants/battle_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index eb9d9639ef..62c8705e53 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -178,7 +178,7 @@ #define B_POWDER_GRASS GEN_7 // In Gen6+, Grass-type Pokémon are immune to powder and spore moves. #define B_STEEL_RESISTANCES GEN_7 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark-type and Ghost-type moves. #define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. -#define B_SEMI_INVULNERABLE_CATCH GEN_5 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) +#define B_SEMI_INVULNERABLE_CATCH GEN_4 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. From c077091dbf917a17f469168c86a84c012a88d2ef Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 14:57:26 -0400 Subject: [PATCH 3/4] small fixes, check GetCatchingBattler's semi-invulnerability --- include/constants/battle_config.h | 2 +- src/item_use.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 62c8705e53..fc9bc9f4e9 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -178,7 +178,7 @@ #define B_POWDER_GRASS GEN_7 // In Gen6+, Grass-type Pokémon are immune to powder and spore moves. #define B_STEEL_RESISTANCES GEN_7 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark-type and Ghost-type moves. #define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. -#define B_SEMI_INVULNERABLE_CATCH GEN_4 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) +#define B_SEMI_INVULNERABLE_CATCH GEN_7 // In Gen4+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/item_use.c b/src/item_use.c index 93604efef5..9a1fd2478a 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -947,8 +947,8 @@ u32 CanThrowBall(void) { return 2; // No room for mon } - #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 - else if (gStatuses3[B_POSITION_OPPONENT_LEFT] & STATUS3_SEMI_INVULNERABLE) + #if B_SEMI_INVULNERABLE_CATCH >= GEN_4 + else if (gStatuses3[GetCatchingBattler()] & STATUS3_SEMI_INVULNERABLE) { return 3; // in semi-invulnerable state } @@ -983,7 +983,7 @@ void ItemUseInBattle_PokeBall(u8 taskId) else DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, Task_CloseBattlePyramidBagMessage); break; - #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 + #if B_SEMI_INVULNERABLE_CATCH >= GEN_4 case 3: // Semi-Invulnerable if (!InBattlePyramid()) DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_SemiInvulnerable, CloseItemMessage); From 1f176242aad724148a507c6adc40b72013ee5034 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 16:06:50 -0400 Subject: [PATCH 4/4] add missing func definition --- include/battle_script_commands.h | 1 + src/battle_script_commands.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index dec1596f21..b55ac1391d 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -37,6 +37,7 @@ bool32 TryResetBattlerStatChanges(u8 battler); bool32 CanCamouflage(u8 battlerId); u16 GetNaturePowerMove(void); void StealTargetItem(u8 battlerStealer, u8 battlerItem); +u8 GetCatchingBattler(void); extern void (* const gBattleScriptingCommandsTable[])(void); extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 29614e09b4..2c0614ada5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12565,7 +12565,7 @@ static void Cmd_removelightscreenreflect(void) // brick break gBattlescriptCurrInstr++; } -static u8 GetCatchingBattler(void) +u8 GetCatchingBattler(void) { if (IsBattlerAlive(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))) return GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);