From 8e7431ab4f3a6068a7ff58fa792db3f5f1094efc Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Sat, 31 Aug 2024 16:04:16 +0200 Subject: [PATCH 1/2] Fixes Tar Shot on Tera mon --- asm/macros/battle_script.inc | 10 +++---- data/battle_scripts_1.s | 2 +- src/battle_script_commands.c | 28 +++++++++---------- test/battle/move_effect/tar_shot.c | 43 ++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9d61889b4092..e18ce91f2800 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1674,6 +1674,11 @@ callnative BS_FickleBeamDamageCalculation .endm + .macro trytarshot failInstr:req + callnative BS_TryTarShot + .4byte \failInstr + .endm + @ various command changed to more readable macros .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES @@ -2210,11 +2215,6 @@ .4byte \failInstr .endm - .macro trytarshot battler:req, failInstr:req - various \battler, VARIOUS_TRY_TAR_SHOT - .4byte \failInstr - .endm - .macro cantarshotwork battler:req, failInstr:req various \battler, VARIOUS_CAN_TAR_SHOT_WORK .4byte \failInstr diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 9d0bc6fc1f04..1a80940b72b1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -902,7 +902,7 @@ BattleScript_EffectTarShot:: printfromtable gStatDownStringIds waitmessage B_WAIT_TIME_LONG BattleScript_TryTarShot: - trytarshot BS_TARGET, BattleScript_MoveEnd + trytarshot BattleScript_MoveEnd printstring STRINGID_PKMNBECAMEWEAKERTOFIRE waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8da71c45fb66..41e58928d518 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10715,20 +10715,6 @@ static void Cmd_various(void) } return; } - case VARIOUS_TRY_TAR_SHOT: - { - VARIOUS_ARGS(const u8 *failInstr); - if (gDisableStructs[battler].tarShot) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else - { - gDisableStructs[battler].tarShot = TRUE; - gBattlescriptCurrInstr = cmd->nextInstr; - } - return; - } case VARIOUS_CAN_TAR_SHOT_WORK: { VARIOUS_ARGS(const u8 *failInstr); @@ -17209,3 +17195,17 @@ void BS_FickleBeamDamageCalculation(void) gBattlescriptCurrInstr = cmd->nextInstr; } } + +void BS_TryTarShot(void) +{ + NATIVE_ARGS(const u8 *failInstr); + if (gDisableStructs[gBattlerTarget].tarShot || GetActiveGimmick(gBattlerTarget) == GIMMICK_TERA) + { + gBattlescriptCurrInstr = cmd->failInstr; + } + else + { + gDisableStructs[gBattlerTarget].tarShot = TRUE; + gBattlescriptCurrInstr = cmd->nextInstr; + } +} \ No newline at end of file diff --git a/test/battle/move_effect/tar_shot.c b/test/battle/move_effect/tar_shot.c index 61aca1bec1aa..2b780577ecc0 100644 --- a/test/battle/move_effect/tar_shot.c +++ b/test/battle/move_effect/tar_shot.c @@ -42,3 +42,46 @@ SINGLE_BATTLE_TEST("Tar Shot doubles the effectiveness of Fire-type moves used o } } +SINGLE_BATTLE_TEST("Tar Shot does not affect Pokemon that are Terastallized") +{ + s16 damage[2]; + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_NORMAL); } + OPPONENT(SPECIES_WOBBUFFET) ; + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE, gimmick: GIMMICK_TERA); MOVE(opponent, MOVE_EMBER); } + TURN { MOVE(opponent, MOVE_TAR_SHOT); } + TURN { MOVE(opponent, MOVE_EMBER); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_EMBER, opponent); + HP_BAR(player, captureDamage: &damage[0]); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TAR_SHOT, opponent); + ANIMATION(ANIM_TYPE_MOVE, MOVE_EMBER, opponent); + HP_BAR(player, captureDamage: &damage[1]); + NOT MESSAGE("It's super effective!"); + } THEN { + EXPECT_EQ(damage[0], damage[1]); + } +} + +SINGLE_BATTLE_TEST("Tar Shot does affect Pokemon that Terastallized after Tar Shot status was applied") +{ + s16 damage[2]; + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_NORMAL); } + OPPONENT(SPECIES_WOBBUFFET) ; + } WHEN { + TURN { MOVE(opponent, MOVE_EMBER); } + TURN { MOVE(opponent, MOVE_TAR_SHOT); } + TURN { MOVE(player, MOVE_CELEBRATE, gimmick: GIMMICK_TERA); MOVE(opponent, MOVE_EMBER); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_EMBER, opponent); + HP_BAR(player, captureDamage: &damage[0]); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TAR_SHOT, opponent); + ANIMATION(ANIM_TYPE_MOVE, MOVE_EMBER, opponent); + HP_BAR(player, captureDamage: &damage[1]); + MESSAGE("It's super effective!"); + } THEN { + EXPECT_MUL_EQ(damage[0], Q_4_12(2.0), damage[1]); + } +} From d63094a51683caffdbfcf1493a25db4cb0ab2d18 Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Sat, 31 Aug 2024 16:26:27 +0200 Subject: [PATCH 2/2] new line --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 41e58928d518..6509dab06943 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -17208,4 +17208,4 @@ void BS_TryTarShot(void) gDisableStructs[gBattlerTarget].tarShot = TRUE; gBattlescriptCurrInstr = cmd->nextInstr; } -} \ No newline at end of file +}