From 94ec25319f2d51c6ab3f1211f9aba51f624c2359 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 23 Sep 2021 14:35:37 -0400 Subject: [PATCH] syntax fixes. Use BlocksPrankster for perish song battle script --- asm/macros/battle_script.inc | 5 +++++ data/battle_scripts_1.s | 7 +------ include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 12 +++++++----- src/battle_util.c | 22 +++++++++++----------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 7ca6bfa6d..6189c855d 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1796,6 +1796,11 @@ .4byte \terrainFlags .4byte \ptr .endm + + .macro jumpifpranksterblocked battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_PRANKSTER_BLOCKED + .4byte \ptr + .endm @ helpful macros .macro setstatchanger stat:req, stages:req, down:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ece6e73dc..e5d4466c4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3700,12 +3700,7 @@ BattleScript_EffectPerishSong:: setbyte gBattlerTarget, 0 BattleScript_PerishSongLoop:: jumpifability BS_TARGET, ABILITY_SOUNDPROOF, BattleScript_PerishSongBlocked - jumpifbyteequal gBattlerAttacker, gBattlerTarget, BattleScript_PerishSongLoopIncrement @ Cannot block your own perish song - jumpiftargetally BattleScript_PerishSongLoopIncrement @ Cannot block ally perish song - jumpifability BS_ATTACKER, ABILITY_PRANKSTER, BattleScript_PerishSongCheckPrankster - goto BattleScript_PerishSongLoopIncrement -BattleScript_PerishSongCheckPrankster: - jumpiftype BS_TARGET, TYPE_DARK, BattleScript_PerishSongNotAffected + jumpifpranksterblocked BS_TARGET, BattleScript_PerishSongNotAffected BattleScript_PerishSongLoopIncrement:: addbyte gBattlerTarget, 1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_PerishSongLoop diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 66f592503..e564f5479 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -179,6 +179,7 @@ #define VARIOUS_MAKE_INVISIBLE 107 #define VARIOUS_ROOM_SERVICE 108 #define VARIOUS_JUMP_IF_TERRAIN_AFFECTED 109 +#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 110 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cb0dfd23e..4d12ae8fe 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8604,6 +8604,12 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 11; } return; + case VARIOUS_JUMP_IF_PRANKSTER_BLOCKED: + if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gActiveBattler)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; } gBattlescriptCurrInstr += 3; @@ -10757,11 +10763,7 @@ static void Cmd_trysetperishsong(void) { if (gStatuses3[i] & STATUS3_PERISH_SONG || gBattleMons[i].ability == ABILITY_SOUNDPROOF - || (B_PRANKSTER_DARK_TYPES >= GEN_7 - && GetBattlerSide(i) != GetBattlerSide(gBattlerAttacker) - && GetBattlerAbility(gBattlerAttacker) == ABILITY_PRANKSTER - && IS_BATTLER_OF_TYPE(i, TYPE_DARK)) - ) + || BlocksPrankster(gCurrentMove, gBattlerAttacker, i)) { notAffectedCount++; } diff --git a/src/battle_util.c b/src/battle_util.c index 0854cb6e0..8655d47d8 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3414,17 +3414,15 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case CANCELLER_PRANKSTER: - #if B_PRANKSTER_DARK_TYPES >= GEN_7 - if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gBattlerTarget) - && !(IS_MOVE_STATUS(gCurrentMove) && GetBattlerAbility(gBattlerTarget) == ABILITY_MAGIC_BOUNCE)) - { - if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(gBattleMoves[gCurrentMove].target & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) - CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected - gBattleScripting.battler = gBattlerAbility = gBattlerTarget; - gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; - effect = 1; - } - #endif + if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gBattlerTarget) + && !(IS_MOVE_STATUS(gCurrentMove) && GetBattlerAbility(gBattlerTarget) == ABILITY_MAGIC_BOUNCE)) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(gBattleMoves[gCurrentMove].target & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) + CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected + gBattleScripting.battler = gBattlerAbility = gBattlerTarget; + gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; + effect = 1; + } gBattleStruct->atkCancellerTracker++; break; case CANCELLER_END: @@ -9236,6 +9234,7 @@ void DoBurmyFormChange(u32 monId) bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef) { + #if B_PRANKSTER_DARK_TYPES >= GEN_7 if (gProtectStructs[battlerPrankster].pranksterElevated && GetBattlerSide(battlerPrankster) != GetBattlerSide(battlerDef) && !(gBattleMoves[gCurrentMove].target & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_DEPENDS)) // Don't block hazards, assist-type moves @@ -9243,5 +9242,6 @@ bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef) && !(gStatuses3[battlerDef] & STATUS3_SEMI_INVULNERABLE)) return TRUE; else + #endif return FALSE; }