diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index a29b5f62e8..de509588bc 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -362,11 +362,6 @@ .byte 0x3f .endm - .macro jumpifaffectedbyprotect failInstr:req - .byte 0x40 - .4byte \failInstr - .endm - .macro call instr:req .byte 0x41 .4byte \instr diff --git a/include/battle.h b/include/battle.h index 8f28da7253..5fddd8d11f 100644 --- a/include/battle.h +++ b/include/battle.h @@ -773,7 +773,7 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER #define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP) #define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0) || (gBattleStruct->enduredDamage & gBitTable[gBattlerTarget])) -#define BATTLER_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0)) +#define BATTLER_TURN_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0) || (gBattleStruct->enduredDamage & gBitTable[battler])) #define IS_BATTLER_OF_TYPE(battlerId, type)((GetBattlerType(battlerId, 0) == type || GetBattlerType(battlerId, 1) == type || (GetBattlerType(battlerId, 2) != TYPE_MYSTERY && GetBattlerType(battlerId, 2) == type))) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cfa2959f75..a82825ff06 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -418,7 +418,7 @@ static void Cmd_return(void); static void Cmd_end(void); static void Cmd_end2(void); static void Cmd_end3(void); -static void Cmd_jumpifaffectedbyprotect(void); +static void Cmd_unused5(void); static void Cmd_call(void); static void Cmd_setroost(void); static void Cmd_jumpifabilitypresent(void); @@ -677,7 +677,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_end, //0x3D Cmd_end2, //0x3E Cmd_end3, //0x3F - Cmd_jumpifaffectedbyprotect, //0x40 + Cmd_unused5, //0x40 Cmd_call, //0x41 Cmd_setroost, //0x42 Cmd_jumpifabilitypresent, //0x43 @@ -1507,7 +1507,7 @@ static bool32 JumpIfMoveFailed(u8 adder, u16 move) return FALSE; } -static void Cmd_jumpifaffectedbyprotect(void) +static void Cmd_unused5(void) { CMD_ARGS(const u8 *failInstr); @@ -5853,7 +5853,7 @@ static void Cmd_moveend(void) if (IsBattlerAlive(battler) && gBattlerAttacker != battler && GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_EJECT_BUTTON - && TARGET_TURN_DAMAGED + && BATTLER_TURN_DAMAGED(battler) && CountUsablePartyMons(battler) > 0) // Has mon to switch into { gBattleScripting.battler = battler; @@ -5888,7 +5888,7 @@ static void Cmd_moveend(void) && IsBattlerAlive(battler) && !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) && GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_RED_CARD - && (gSpecialStatuses[battler].physicalDmg != 0 || gSpecialStatuses[battler].specialDmg != 0) + && BATTLER_TURN_DAMAGED(battler) && CanBattlerSwitch(gBattlerAttacker)) { gLastUsedItem = gBattleMons[battler].item; @@ -5952,7 +5952,7 @@ static void Cmd_moveend(void) // Attacker is mon who made contact, battler is mon with pickpocket if (battler != gBattlerAttacker // Cannot pickpocket yourself && GetBattlerAbility(battler) == ABILITY_PICKPOCKET // Target must have pickpocket ability - && BATTLER_DAMAGED(battler) // Target needs to have been damaged + && BATTLER_TURN_DAMAGED(battler) // Target needs to have been damaged && !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) // Subsitute unaffected && IsBattlerAlive(battler) // Battler must be alive to pickpocket && gBattleMons[battler].item == ITEM_NONE // Pickpocketer can't have an item already