Fixes protective pads against Protects secondary effects (#6474)

This commit is contained in:
Alex 2025-03-25 16:30:15 +01:00 committed by GitHub
parent ecab04d881
commit 10412e1a47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 63 additions and 5 deletions

View File

@ -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;

View File

@ -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!");
}
}
}
}