diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index af17d3f250..d5439d97a6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6169,6 +6169,20 @@ static u32 GetNextTarget(u32 moveTarget, bool32 excludeCurrent) return battler; } +static inline bool32 IsProtectivePadsProtected(u32 battler, u32 move) +{ + if (!IsMoveMakingContact(move, battler)) + return FALSE; + + if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_PROTECTIVE_PADS) + { + RecordItemEffectBattle(battler, HOLD_EFFECT_PROTECTIVE_PADS); + return TRUE; + } + + return FALSE; +} + static void Cmd_moveend(void) { CMD_ARGS(u8 endMode, u8 endState); @@ -6206,6 +6220,7 @@ static void Cmd_moveend(void) { if (gProtectStructs[gBattlerTarget].spikyShielded && moveEffect != EFFECT_COUNTER + && !IsProtectivePadsProtected(gBattlerAttacker, gCurrentMove) && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; @@ -6217,7 +6232,8 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_SpikyShieldEffect; effect = 1; } - else if (gProtectStructs[gBattlerTarget].kingsShielded) + else if (gProtectStructs[gBattlerTarget].kingsShielded + && !IsProtectivePadsProtected(gBattlerAttacker, gCurrentMove)) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; i = gBattlerAttacker; @@ -6231,7 +6247,8 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_KingsShieldEffect; effect = 1; } - else if (gProtectStructs[gBattlerTarget].banefulBunkered) + else if (gProtectStructs[gBattlerTarget].banefulBunkered + && !IsProtectivePadsProtected(gBattlerAttacker, gCurrentMove)) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER; @@ -6241,7 +6258,9 @@ static void Cmd_moveend(void) effect = 1; } else if (gProtectStructs[gBattlerTarget].obstructed - && moveEffect != EFFECT_SUCKER_PUNCH && moveEffect != EFFECT_UPPER_HAND) + && moveEffect != EFFECT_SUCKER_PUNCH + && moveEffect != EFFECT_UPPER_HAND + && !IsProtectivePadsProtected(gBattlerAttacker, gCurrentMove)) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; i = gBattlerAttacker; @@ -6252,7 +6271,8 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_KingsShieldEffect; effect = 1; } - else if (gProtectStructs[gBattlerTarget].silkTrapped) + else if (gProtectStructs[gBattlerTarget].silkTrapped + && !IsProtectivePadsProtected(gBattlerAttacker, gCurrentMove)) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; i = gBattlerAttacker; @@ -6263,7 +6283,8 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_KingsShieldEffect; effect = 1; } - else if (gProtectStructs[gBattlerTarget].burningBulwarked) + else if (gProtectStructs[gBattlerTarget].burningBulwarked + && !IsProtectivePadsProtected(gBattlerAttacker, gCurrentMove)) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; gBattleScripting.moveEffect = MOVE_EFFECT_BURN | MOVE_EFFECT_AFFECTS_USER; diff --git a/test/battle/hold_effect/protective_pads.c b/test/battle/hold_effect/protective_pads.c index 843d2fa003..41ffc83d4b 100644 --- a/test/battle/hold_effect/protective_pads.c +++ b/test/battle/hold_effect/protective_pads.c @@ -73,3 +73,40 @@ SINGLE_BATTLE_TEST("Protective Pads protects from Rocly Helmet Damage") } } } + +SINGLE_BATTLE_TEST("Protective Pads protects from Protect's secondary effects") +{ + u32 move; + + PARAMETRIZE { move = MOVE_SPIKY_SHIELD; } + PARAMETRIZE { move = MOVE_BANEFUL_BUNKER; } + PARAMETRIZE { move = MOVE_BURNING_BULWARK; } + PARAMETRIZE { move = MOVE_KINGS_SHIELD; } + PARAMETRIZE { move = MOVE_SILK_TRAP; } + PARAMETRIZE { move = MOVE_OBSTRUCT; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_PROTECTIVE_PADS); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, move); MOVE(player, MOVE_TACKLE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, move, opponent); + NONE_OF { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + if (move == MOVE_SPIKY_SHIELD) { + HP_BAR(player); + } else if (move == MOVE_BANEFUL_BUNKER) { + STATUS_ICON(player, STATUS1_BURN); + } else if (move == MOVE_BURNING_BULWARK) { + STATUS_ICON(player, STATUS1_POISON); + } else if (move == MOVE_KINGS_SHIELD) { + MESSAGE("Wobbuffet's Attack fell!"); + } else if (move == MOVE_SILK_TRAP) { + MESSAGE("Wobbuffet's Speed fell!"); + } else if (move == MOVE_OBSTRUCT) { + MESSAGE("Wobbuffet's Defense harshly fell!"); + } + } + } +}