From 0069ec1f0c1c096caa09ccc2aa12a366bb067b8f Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Mon, 21 Apr 2025 11:01:01 +0200 Subject: [PATCH] Fix captivate-oblivious interaction and related test (#6653) --- asm/macros/battle_script.inc | 2 +- data/battle_scripts_1.s | 10 ++++++---- src/battle_script_commands.c | 22 ++++++++++++++++------ test/battle/ability/oblivious.c | 2 +- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index e386c389c9..2af5c1fcc8 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1331,7 +1331,7 @@ .byte \stat .endm - .macro jumpifoppositegenders jumpInstr:req + .macro jumpifcaptivateaffected jumpInstr:req .byte 0xfc .4byte \jumpInstr .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 9a44235816..5631934ed1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2743,11 +2743,13 @@ BattleScript_EffectRoost:: BattleScript_EffectCaptivate:: setstatchanger STAT_SPATK, 2, TRUE attackcanceler - jumpifsubstituteblocks BattleScript_FailedFromAtkString - jumpifoppositegenders BattleScript_CaptivateCheckAcc - goto BattleScript_FailedFromAtkString + attackstring + ppreduce + jumpifsubstituteblocks BattleScript_ButItFailed + jumpifcaptivateaffected BattleScript_CaptivateCheckAcc + goto BattleScript_ButItFailed BattleScript_CaptivateCheckAcc: - accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + accuracycheck BattleScript_MoveMissedPause, ACC_CURR_MOVE goto BattleScript_StatDownFromAttackString BattleScript_EffectHealBlock:: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 069ffb1737..f743879fc6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -599,7 +599,7 @@ static void Cmd_trainerslideout(void); static void Cmd_settelekinesis(void); static void Cmd_swapstatstages(void); static void Cmd_averagestats(void); -static void Cmd_jumpifoppositegenders(void); +static void Cmd_jumpifcaptivateaffected(void); static void Cmd_unused(void); static void Cmd_tryworryseed(void); static void Cmd_callnative(void); @@ -836,8 +836,8 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_jumpifhasnohp, //0xE3 Cmd_jumpifnotcurrentmoveargtype, //0xE4 Cmd_pickup, //0xE5 - Cmd_unused_0xE6, //0xE6 - Cmd_unused_0xE7, //0xE7 + Cmd_unused_0xE6, //0xE6 + Cmd_unused_0xE7, //0xE7 Cmd_settypebasedhalvers, //0xE8 Cmd_jumpifsubstituteblocks, //0xE9 Cmd_tryrecycleitem, //0xEA @@ -858,7 +858,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_settelekinesis, //0xF9 Cmd_swapstatstages, //0xFA Cmd_averagestats, //0xFB - Cmd_jumpifoppositegenders, //0xFC + Cmd_jumpifcaptivateaffected, //0xFC Cmd_unused, //0xFD Cmd_tryworryseed, //0xFE Cmd_callnative, //0xFF @@ -16665,14 +16665,24 @@ static void Cmd_averagestats(void) gBattlescriptCurrInstr = cmd->nextInstr; } -static void Cmd_jumpifoppositegenders(void) +static void Cmd_jumpifcaptivateaffected(void) { CMD_ARGS(const u8 *jumpInstr); - if (AreBattlersOfOppositeGender(gBattlerAttacker, gBattlerTarget)) + if (GetBattlerAbility(gBattlerTarget) == ABILITY_OBLIVIOUS) + { + gBattlescriptCurrInstr = BattleScript_NotAffectedAbilityPopUp; + gLastUsedAbility = ABILITY_OBLIVIOUS; + RecordAbilityBattle(gBattlerTarget, ABILITY_OBLIVIOUS); + } + else if (AreBattlersOfOppositeGender(gBattlerAttacker, gBattlerTarget)) + { gBattlescriptCurrInstr = cmd->jumpInstr; + } else + { gBattlescriptCurrInstr = cmd->nextInstr; + } } static void Cmd_unused(void) diff --git a/test/battle/ability/oblivious.c b/test/battle/ability/oblivious.c index 3ac979a271..a787ec6578 100644 --- a/test/battle/ability/oblivious.c +++ b/test/battle/ability/oblivious.c @@ -23,7 +23,7 @@ SINGLE_BATTLE_TEST("Oblivious prevents Captivate") PLAYER(SPECIES_SLOWPOKE) { Ability(ABILITY_OBLIVIOUS); Gender(MON_MALE); } OPPONENT(SPECIES_WOBBUFFET) { Gender(MON_FEMALE); } } WHEN { - TURN { MOVE(opponent, MOVE_ATTRACT); } + TURN { MOVE(opponent, MOVE_CAPTIVATE); } } SCENE { ABILITY_POPUP(player, ABILITY_OBLIVIOUS); NONE_OF { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); }