From 28522f3ffb46350e9b12c884995d1402b670aec6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 28 Oct 2021 10:39:52 -0300 Subject: [PATCH] Fixed Hyperspace Fury not breaking through protections Also repositioned VARIOUS_JUMP_IF_SPECIES. --- asm/macros/battle_script.inc | 5 ++ data/battle_scripts_1.s | 74 +++++++++++++++++++++- include/battle.h | 10 +++ include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 + src/battle_script_commands.c | 18 ++++-- 7 files changed, 105 insertions(+), 8 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 04f6e04dc..906eb1ede 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1864,6 +1864,11 @@ .4byte \ptr .endm + .macro jumpifprotected battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_PROTECTED + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3fcaf1024..b68363d5d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -394,7 +394,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHyperspaceFury @ EFFECT_HYPERSPACE_FURY BattleScript_EffectHyperspaceFury: - jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectAttackerDefenseDownHit + jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectHyperspaceFuryUnbound jumpifspecies BS_ATTACKER, SPECIES_HOOPA, BattleScript_ButHoopaCantUseIt printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE waitmessage B_WAIT_TIME_LONG @@ -403,6 +403,78 @@ BattleScript_ButHoopaCantUseIt: printstring STRINGID_BUTHOOPACANTUSEIT waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd +BattleScript_EffectHyperspaceFuryUnbound: + attackcanceler + jumpifprotected BS_TARGET, BattleScript_HyperspaceFuryBrokeThroughProtection + argumenttomoveeffect + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + seteffectwithchance + tryfaintmon BS_TARGET, FALSE, NULL + swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler + setstatchanger STAT_DEF, 1, TRUE + statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_HyperspaceFuryTargetDefenseCantGoLower + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatDownStringIds + waitmessage B_WAIT_TIME_LONG + swapattackerwithtarget @ restore the battlers, just in case + goto BattleScript_MoveEnd + +BattleScript_HyperspaceFuryBrokeThroughProtection:: + argumenttomoveeffect + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + pause B_WAIT_TIME_LONG + printstring STRINGID_BROKETHROUGHPROTECTION + waitmessage B_WAIT_TIME_LONG + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + seteffectwithchance + tryfaintmon BS_TARGET, FALSE, NULL + swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler + setstatchanger STAT_DEF, 1, TRUE + statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_HyperspaceFuryTargetDefenseCantGoLower + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatDownStringIds + waitmessage B_WAIT_TIME_LONG + swapattackerwithtarget @ restore the battlers, just in case + goto BattleScript_MoveEnd + return + +BattleScript_HyperspaceFuryTargetDefenseCantGoLower: + printstring STRINGID_STATSWONTDECREASE + waitmessage B_WAIT_TIME_LONG + return BattleScript_EffectPlasmaFists: attackcanceler diff --git a/include/battle.h b/include/battle.h index c1ac57686..5077053e3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -638,6 +638,16 @@ struct BattleStruct gBattleMons[battlerId].type3 = TYPE_MYSTERY; \ } +#define IS_BATTLER_PROTECTED(battlerId)(gProtectStructs[battlerId].protected \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_WIDE_GUARD \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_QUICK_GUARD \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_CRAFTY_SHIELD \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_MAT_BLOCK \ + || gProtectStructs[battlerId].spikyShielded \ + || gProtectStructs[battlerId].kingsShielded \ + || gProtectStructs[battlerId].banefulBunkered \ + || gProtectStructs[battlerId].obstructed) \ + #define GET_STAT_BUFF_ID(n)((n & 7)) // first three bits 0x1, 0x2, 0x4 #define GET_STAT_BUFF_VALUE_WITH_SIGN(n)((n & 0xF8)) #define GET_STAT_BUFF_VALUE(n)(((n >> 3) & 0xF)) // 0x8, 0x10, 0x20, 0x40 diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index f00695276..abce5f9bf 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -194,6 +194,7 @@ #define VARIOUS_HANDLE_PRIMAL_REVERSION 121 #define VARIOUS_APPLY_PLASMA_FISTS 122 #define VARIOUS_JUMP_IF_SPECIES 123 +#define VARIOUS_JUMP_IF_PROTECTED 124 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 05bee80a8..1d461e2a0 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -596,8 +596,9 @@ #define STRINGID_PKMNREVERTEDTOPRIMAL 593 #define STRINGID_BUTPOKEMONCANTUSETHEMOVE 594 #define STRINGID_BUTHOOPACANTUSEIT 595 +#define STRINGID_BROKETHROUGHPROTECTION 596 -#define BATTLESTRINGS_COUNT 596 +#define BATTLESTRINGS_COUNT 597 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/src/battle_message.c b/src/battle_message.c index bdc7f25fd..f26726a69 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -722,9 +722,11 @@ static const u8 sText_StuffCheeksCantSelect[] = _("Stuff Cheeks cannot be\nselec static const u8 sText_PkmnRevertedToPrimal[] = _("{B_ATK_NAME_WITH_PREFIX}'s Primal Reversion!\nIt reverted to its primal form!"); static const u8 sText_ButPokemonCantUseTheMove[] = _("But {B_ATK_NAME_WITH_PREFIX} can't\nuse the move!"); static const u8 sText_ButHoopaCantUseIt[] = _("But Hoopa can't use it\nthe way it is now!"); +static const u8 sText_BrokeThroughProtection[] = _("It broke through the\n{B_DEF_NAME_WITH_PREFIX}'s protection!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_BROKETHROUGHPROTECTION - 12] = sText_BrokeThroughProtection, [STRINGID_BUTPOKEMONCANTUSETHEMOVE - 12] = sText_ButPokemonCantUseTheMove, [STRINGID_BUTHOOPACANTUSEIT - 12] = sText_ButHoopaCantUseIt, [STRINGID_PKMNREVERTEDTOPRIMAL - 12] = sText_PkmnRevertedToPrimal, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 828e628aa..f99aec129 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8698,12 +8698,6 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe) } return; - case VARIOUS_JUMP_IF_SPECIES: - if (gBattleMons[gActiveBattler].species == T1_READ_16(gBattlescriptCurrInstr + 3)) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5); - else - gBattlescriptCurrInstr += 9; - return; case VARIOUS_MOVEEND_ITEM_EFFECTS: if (ItemBattleEffects(1, gActiveBattler, FALSE)) return; @@ -8983,6 +8977,18 @@ static void Cmd_various(void) for (i = 0; i < gBattlersCount; i++) gStatuses4[i] |= STATUS4_PLASMA_FISTS; break; + case VARIOUS_JUMP_IF_SPECIES: + if (gBattleMons[gActiveBattler].species == T1_READ_16(gBattlescriptCurrInstr + 3)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5); + else + gBattlescriptCurrInstr += 9; + return; + case VARIOUS_JUMP_IF_PROTECTED: + if (IS_BATTLER_PROTECTED(gActiveBattler)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; } gBattlescriptCurrInstr += 3;