diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 33c89d55d..a59af74d0 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1888,6 +1888,11 @@ .4byte \ptr .endm + .macro cantarshotwork battler:req, ptr:req + various \battler, VARIOUS_CAN_TAR_SHOT_WORK + .4byte \ptr + .endm + .macro checkpoltergeist battler:req, ptr:req various \battler, VARIOUS_CHECK_POLTERGEIST .4byte \ptr diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a4036bef1..3e29989b4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -461,6 +461,7 @@ BattleScript_EffectTarShot: attackcanceler jumpifsubstituteblocks BattleScript_ButItFailedAtkStringPpReduce accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + cantarshotwork BS_TARGET, BattleScript_ButItFailedAtkStringPpReduce attackstring ppreduce setstatchanger STAT_SPEED, 1, TRUE diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index cc67ef2e3..64809532d 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -200,9 +200,10 @@ #define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127 #define VARIOUS_TRY_NO_RETREAT 128 #define VARIOUS_TRY_TAR_SHOT 129 -#define VARIOUS_CHECK_POLTERGEIST 130 -#define VARIOUS_SET_OCTOLOCK 131 -#define VARIOUS_CUT_1_3_HP_RAISE_STATS 132 +#define VARIOUS_CAN_TAR_SHOT_WORK 130 +#define VARIOUS_CHECK_POLTERGEIST 131 +#define VARIOUS_SET_OCTOLOCK 132 +#define VARIOUS_CUT_1_3_HP_RAISE_STATS 133 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index eddde6b44..7875e5e65 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9107,6 +9107,15 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; } return; + case VARIOUS_CAN_TAR_SHOT_WORK: + // Tar Shot will fail if it's already been used on the target and its speed can't be lowered further + if (gDisableStructs[gActiveBattler].tarShot + && (gBattleMons[gActiveBattler].statStages[STAT_SPEED] == MIN_STAT_STAGE + || (gBattleMons[gActiveBattler].statStages[STAT_SPEED] == MAX_STAT_STAGE && GetBattlerAbility(gActiveBattler) == ABILITY_CONTRARY))) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; } gBattlescriptCurrInstr += 3;