From 5089b1d0b41c89985181df35be80ae36d2bf1329 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:52:26 +0200 Subject: [PATCH] Adds callnative for soundproofcheck to addtionally check the flag (#5301) * Adds callnative for soundproofcheck to addtionally check the flag * rename callnative, include parish song and missing ability recording --- asm/macros/battle_script.inc | 6 ++++++ data/battle_scripts_1.s | 4 ++-- src/battle_script_commands.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index f91313cb92..c9f9b28bef 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1679,6 +1679,12 @@ .4byte \failInstr .endm + .macro jumpifblockedbysoundproof battler:req, failInstr:req + callnative BS_JumpIfBlockedBySoundproof + .byte \battler + .4byte \failInstr + .endm + @ various command changed to more readable macros .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f9bb4565f0..c24dacb5c4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -508,7 +508,7 @@ BattleScript_EffectAttackUpUserAlly_TryAlly: BattleScript_EffectAttackUpUserAlly_End: goto BattleScript_MoveEnd BattleScript_EffectAttackUpUserAlly_TryAlly_: - jumpifability BS_ATTACKER_PARTNER, ABILITY_SOUNDPROOF, BattleScript_EffectAttackUpUserAlly_TryAllyBlocked + jumpifblockedbysoundproof BS_ATTACKER_PARTNER, BattleScript_EffectAttackUpUserAlly_TryAllyBlocked setstatchanger STAT_ATK, 1, FALSE statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_EffectAttackUpUserAlly_End jumpifbyte CMP_NOT_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_EffectAttackUpUserAlly_AllyAnim @@ -4281,7 +4281,7 @@ BattleScript_EffectPerishSong:: waitmessage B_WAIT_TIME_LONG setbyte gBattlerTarget, 0 BattleScript_PerishSongLoop:: - jumpifability BS_TARGET, ABILITY_SOUNDPROOF, BattleScript_PerishSongBlocked + jumpifblockedbysoundproof BS_TARGET, BattleScript_PerishSongBlocked jumpifpranksterblocked BS_TARGET, BattleScript_PerishSongNotAffected BattleScript_PerishSongLoopIncrement:: addbyte gBattlerTarget, 1 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index faa383f7ef..d4afe23be4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -17218,3 +17218,20 @@ void BS_TryTarShot(void) gBattlescriptCurrInstr = cmd->nextInstr; } } + +void BS_JumpIfBlockedBySoundproof(void) +{ + NATIVE_ARGS(u8 battler, const u8 *jumpInstr); + u32 battler = GetBattlerForBattleScript(cmd->battler); + if (gMovesInfo[gCurrentMove].soundMove && GetBattlerAbility(battler) == ABILITY_SOUNDPROOF) + { + gLastUsedAbility = ABILITY_SOUNDPROOF; + gBattlescriptCurrInstr = cmd->jumpInstr; + RecordAbilityBattle(battler, gLastUsedAbility); + gBattlerAbility = battler; + } + else + { + gBattlescriptCurrInstr = cmd->nextInstr; + } +}