From 0f3fdd410af38066439a774cfe76135c62747d25 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Wed, 20 Jul 2022 13:06:41 -0400 Subject: [PATCH 1/2] Config for Sturdy's Gen5+ effect. --- include/constants/battle_config.h | 1 + src/battle_script_commands.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index c9b64d1a5..198267179 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -226,6 +226,7 @@ #define B_SYNCHRONIZE_TOXIC GEN_8 // In Gen5+, if a Pokémon with Synchronize is badly poisoned, the opponent will also become badly poisoned. Previously, the opponent would become regular poisoned. #define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities. It also activates Rattled. #define B_OBLIVIOUS_TAUNT GEN_7 // In Gen6+, Pokémon with Oblivious can't be taunted. +#define B_STURDY GEN_7 // In Gen5+, Sturdy causes the Pokémon to have 1 HP remaining if another Pokémon's attack or confusion damage would have brought it from full health to 0 HP. // Item settings #define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index eb3f32269..f72986edc 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1984,16 +1984,18 @@ static void Cmd_adjustdamage(void) RecordItemEffectBattle(gBattlerTarget, holdEffect); gSpecialStatuses[gBattlerTarget].focusBanded = TRUE; } - else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) - { - RecordItemEffectBattle(gBattlerTarget, holdEffect); - gSpecialStatuses[gBattlerTarget].focusSashed = TRUE; - } + #if B_STURDY >= GEN_5 else if (GetBattlerAbility(gBattlerTarget) == ABILITY_STURDY && BATTLER_MAX_HP(gBattlerTarget)) { RecordAbilityBattle(gBattlerTarget, ABILITY_STURDY); gSpecialStatuses[gBattlerTarget].sturdied = TRUE; } + #endif + else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) + { + RecordItemEffectBattle(gBattlerTarget, holdEffect); + gSpecialStatuses[gBattlerTarget].focusSashed = TRUE; + } if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattlerTarget].endured From 212ecb98ce13a61987316637d3abf281bf5c8c53 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Wed, 20 Jul 2022 14:28:49 -0400 Subject: [PATCH 2/2] Added AI checks. --- src/battle_ai_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index b8c42ed0c..57adf719e 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -2467,13 +2467,13 @@ bool32 ShouldPivot(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u8 mo if (!IS_MOVE_STATUS(move) && (shouldSwitch || (AtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH - || defAbility == ABILITY_STURDY || defAbility == ABILITY_MULTISCALE || defAbility == ABILITY_SHADOW_SHIELD)))) + || (defAbility == ABILITY_STURDY && B_STURDY >= GEN_5) || defAbility == ABILITY_MULTISCALE || defAbility == ABILITY_SHADOW_SHIELD)))) return PIVOT; // pivot to break sash/sturdy/multiscale } else if (!hasStatBoost) { if (!IS_MOVE_STATUS(move) && (AtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH - || defAbility == ABILITY_STURDY || defAbility == ABILITY_MULTISCALE || defAbility == ABILITY_SHADOW_SHIELD))) + || (defAbility == ABILITY_STURDY && B_STURDY >= GEN_5) || defAbility == ABILITY_MULTISCALE || defAbility == ABILITY_SHADOW_SHIELD))) return PIVOT; // pivot to break sash/sturdy/multiscale if (shouldSwitch)