From c428d1bdbbff34858304a13d2c70ddeabc3cd38b Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 17:59:14 -0700 Subject: [PATCH 1/9] Coded Hyperspace Fury --- data/battle_scripts_1.s | 11 +++++++++++ include/battle_scripts.h | 1 + src/battle_script_commands.c | 7 ++++++- src/data/battle_moves.h | 10 +++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 77eddc8ab..3c59041b6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6058,6 +6058,17 @@ BattleScript_AtkDefDownTryDef: BattleScript_AtkDefDownRet: return +BattleScript_DefDown:: + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_DEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE + setstatchanger STAT_DEF, 1, TRUE + statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_DefDownRet + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_DefDownRet + printfromtable gStatDownStringIds + waitmessage 0x40 +BattleScript_DefDownRet: + return + BattleScript_DefSpDefDown:: setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE | STAT_CHANGE_MULTIPLE_STATS diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 0b94a6ae7..196383dc3 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -90,6 +90,7 @@ extern const u8 BattleScript_SelectingNotAllowedMoveTauntInPalace[]; extern const u8 BattleScript_WishComesTrue[]; extern const u8 BattleScript_IngrainTurnHeal[]; extern const u8 BattleScript_AtkDefDown[]; +extern const u8 BattleScript_DefDown[]; // Hyperspace Fury extern const u8 BattleScript_DefSpDefDown[]; extern const u8 BattleScript_KnockedOff[]; extern const u8 BattleScript_MoveUsedIsImprisoned[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index fc0eedcbc..b990f7d7d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3148,7 +3148,12 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } - } + } + if (gCurrentMove == MOVE_HYPERSPACE_FURY) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_DefDown; + } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 61050e44f..fa1d54c39 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9581,15 +9581,15 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HYPERSPACE_FURY] = { - .effect = EFFECT_PLACEHOLDER, - .power = 0, + .effect = EFFECT_FEINT, + .power = 100, .type = TYPE_DARK, .accuracy = 0, - .pp = 0, - .secondaryEffectChance = 0, + .pp = 5, + .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = 0, + .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, }, From 0d47269798452d1fa05fde08e25323f0c605b003 Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 18:11:53 -0700 Subject: [PATCH 2/9] Spaces instead of tabs --- src/battle_script_commands.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b990f7d7d..ede3d16a3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3149,11 +3149,11 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } } - if (gCurrentMove == MOVE_HYPERSPACE_FURY) - { - BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = BattleScript_DefDown; - } + if (gCurrentMove == MOVE_HYPERSPACE_FURY) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_DefDown; + } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. From 07a9674d22dc60fb2f5f059573ec48a950803d0c Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 18:30:22 -0700 Subject: [PATCH 3/9] Fixed --- data/battle_scripts_1.s | 11 ----------- include/battle_scripts.h | 1 - src/battle_script_commands.c | 5 ----- src/data/battle_moves.h | 3 ++- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3c59041b6..77eddc8ab 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6058,17 +6058,6 @@ BattleScript_AtkDefDownTryDef: BattleScript_AtkDefDownRet: return -BattleScript_DefDown:: - setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_ATTACKER, BIT_DEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE - setstatchanger STAT_DEF, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_DefDownRet - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_DefDownRet - printfromtable gStatDownStringIds - waitmessage 0x40 -BattleScript_DefDownRet: - return - BattleScript_DefSpDefDown:: setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE | STAT_CHANGE_MULTIPLE_STATS diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 196383dc3..0b94a6ae7 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -90,7 +90,6 @@ extern const u8 BattleScript_SelectingNotAllowedMoveTauntInPalace[]; extern const u8 BattleScript_WishComesTrue[]; extern const u8 BattleScript_IngrainTurnHeal[]; extern const u8 BattleScript_AtkDefDown[]; -extern const u8 BattleScript_DefDown[]; // Hyperspace Fury extern const u8 BattleScript_DefSpDefDown[]; extern const u8 BattleScript_KnockedOff[]; extern const u8 BattleScript_MoveUsedIsImprisoned[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ede3d16a3..e9fce3ac6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3149,11 +3149,6 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } } - if (gCurrentMove == MOVE_HYPERSPACE_FURY) - { - BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = BattleScript_DefDown; - } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index fa1d54c39..5a9de6b9e 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9581,7 +9581,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HYPERSPACE_FURY] = { - .effect = EFFECT_FEINT, + .effect = EFFECT_ATTACKER_DEFENSE_DOWN_HIT, .power = 100, .type = TYPE_DARK, .accuracy = 0, @@ -9591,6 +9591,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, + .argument = MOVE_EFFECT_FEINT, }, [MOVE_SHORE_UP] = From 031504cd1217c3a0358b3e3466a09ecf02da7118 Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 18:31:49 -0700 Subject: [PATCH 4/9] Spaces instead of tabs --- src/battle_script_commands.c | 2 +- src/data/battle_moves.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e9fce3ac6..fc0eedcbc 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3148,7 +3148,7 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } - } + } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 5a9de6b9e..689218c3a 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9591,7 +9591,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, - .argument = MOVE_EFFECT_FEINT, + .argument = MOVE_EFFECT_FEINT, }, [MOVE_SHORE_UP] = From bfc66a21cc6a03ea34e3f1dd4d8647a7943b54fd Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 6 Jun 2021 19:14:11 -0700 Subject: [PATCH 5/9] `gBattlescriptCurrInstr[3]` is not reading `species` parameter --- asm/macros/battle_script.inc | 6 ++++++ data/battle_scripts_1.s | 13 +++++++++++++ include/constants/battle_config.h | 2 ++ include/constants/battle_move_effects.h | 3 ++- include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 4 +++- include/constants/pokemon.h | 1 + src/battle_message.c | 4 ++++ src/battle_script_commands.c | 8 ++++++++ src/data/battle_moves.h | 4 ++-- 10 files changed, 42 insertions(+), 4 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9fa3fe0c3..9d624195b 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1769,6 +1769,12 @@ various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH .endm + .macro jumpifspecies battler:req, species:req, ptr:req + various \battler, VARIOUS_JUMP_IF_SPECIES + .byte \species + .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 b5dc673a0..6fb81c9ac 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -11,6 +11,7 @@ #include "constants/game_stat.h" #include "constants/trainers.h" #include "constants/battle_config.h" +#include "constants/species.h" .include "asm/macros.inc" .include "asm/macros/battle_script.inc" .include "constants/constants.inc" @@ -369,6 +370,18 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectSleepHit .4byte BattleScript_EffectAttackerDefenseDownHit .4byte BattleScript_EffectBodyPress + .4byte BattleScript_EffectHyperspaceFury + +BattleScript_EffectHyperspaceFury: + jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectAttackerDefenseDownHit + jumpifspecies BS_ATTACKER, SPECIES_HOOPA, BattleScript_ButHoopaCantUseIt + printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd +BattleScript_ButHoopaCantUseIt: + printstring STRINGID_BUTHOOPACANTUSEIT + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd BattleScript_EffectAttackerDefenseDownHit: setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index fe376da8d..9e610b43c 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -35,6 +35,8 @@ #define SPECIES_ZYGARDE 0 // 50% #define SPECIES_ZYGARDE_10 10011 // 10 % #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % + #define SPECIES_HOOPA 0 + #define SPECIES_HOOPA_UNBOUND 10013 #endif // Items with peculiar battle effects. diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 6174ca496..0fa6dea89 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -353,7 +353,8 @@ #define EFFECT_SLEEP_HIT 347 // Relic Song #define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 348 #define EFFECT_BODY_PRESS 349 +#define EFFECT_HYPERSPACE_FURY 350 -#define NUM_BATTLE_MOVE_EFFECTS 350 +#define NUM_BATTLE_MOVE_EFFECTS 351 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index faaf8f17e..87139bbe0 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -173,6 +173,7 @@ #define VARIOUS_DESTROY_ABILITY_POPUP 102 #define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 +#define VARIOUS_JUMP_IF_SPECIES 105 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 266aef147..9e3941324 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -570,8 +570,10 @@ #define STRINGID_MICLEBERRYACTIVATES 566 #define STRINGID_PKMNSHOOKOFFTHETAUNT 567 #define STRINGID_PKMNGOTOVERITSINFATUATION 568 +#define STRINGID_BUTPOKEMONCANTUSETHEMOVE 569 +#define STRINGID_BUTHOOPACANTUSEIT 570 -#define BATTLESTRINGS_COUNT 569 +#define BATTLESTRINGS_COUNT 571 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 322bee706..39157a53b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -315,6 +315,7 @@ #define FLAG_DMG_2X_IN_AIR (1 << 22) // If target is in the air, can hit and deal double damage. #define FLAG_DMG_IN_AIR (1 << 23) // If target is in the air, can hit. #define FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING (1 << 24) // Makes a Ground type move do 1x damage to flying and levitating targets +#define FLAG_HIT_IN_SUBSTITUTE (1 << 25) // Hyperspace Fury // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/battle_message.c b/src/battle_message.c index d4d5756f9..9f4de13d9 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -696,6 +696,8 @@ static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faste static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); static const u8 sText_PkmnShookOffTheTaunt[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} shook off\nthe taunt!"); static const u8 sText_PkmnGotOverItsInfatuation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} got over\nits infatuation!"); +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!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1256,6 +1258,8 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_AURABREAKENTERS - 12] = sText_AuraBreakActivates, [STRINGID_COMATOSEENTERS - 12] = sText_ComatoseActivates, [STRINGID_SCREENCLEANERENTERS - 12] = sText_ScreenCleanerActivates, + [STRINGID_BUTPOKEMONCANTUSETHEMOVE - 12] = sText_ButPokemonCantUseTheMove, + [STRINGID_BUTHOOPACANTUSEIT - 12] = sText_ButHoopaCantUseIt, }; const u16 gTerrainStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4c95ecb63..2a4b2e347 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8426,6 +8426,12 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe) } return; + case VARIOUS_JUMP_IF_SPECIES: + if (gBattleMons[gBattlerAttacker].species == gBattlescriptCurrInstr[3]) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4); + else + gBattlescriptCurrInstr += 8; + return; } gBattlescriptCurrInstr += 3; @@ -11862,6 +11868,8 @@ bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move) return FALSE; else if (GetBattlerAbility(battlerAtk) == ABILITY_INFILTRATOR) return FALSE; + else if (gBattleMoves[move].flags & FLAG_HIT_IN_SUBSTITUTE) + return FALSE; else return TRUE; } diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 7746b1196..ecc0f907b 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9678,7 +9678,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HYPERSPACE_FURY] = { - .effect = EFFECT_ATTACKER_DEFENSE_DOWN_HIT, + .effect = EFFECT_HYPERSPACE_FURY, .power = 100, .type = TYPE_DARK, .accuracy = 0, @@ -9686,7 +9686,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIT_IN_SUBSTITUTE, .split = SPLIT_PHYSICAL, .argument = MOVE_EFFECT_FEINT, }, From dcea8e45ed0bb72f67ef2f78513450dfb6133d70 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 17 Oct 2021 10:51:22 -0300 Subject: [PATCH 6/9] Fixed jumpifspecies --- asm/macros/battle_script.inc | 2 +- src/battle_script_commands.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9d624195b..fd20478d2 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1771,7 +1771,7 @@ .macro jumpifspecies battler:req, species:req, ptr:req various \battler, VARIOUS_JUMP_IF_SPECIES - .byte \species + .2byte \species .4byte \ptr .endm diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2a4b2e347..7b5e782c2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8427,10 +8427,10 @@ static void Cmd_various(void) } return; case VARIOUS_JUMP_IF_SPECIES: - if (gBattleMons[gBattlerAttacker].species == gBattlescriptCurrInstr[3]) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4); + if (gBattleMons[gActiveBattler].species == T1_READ_16(gBattlescriptCurrInstr + 3)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5); else - gBattlescriptCurrInstr += 8; + gBattlescriptCurrInstr += 9; return; } From 28522f3ffb46350e9b12c884995d1402b670aec6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 28 Oct 2021 10:39:52 -0300 Subject: [PATCH 7/9] 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; From 2803b840e50fb47ea50256db6727859bd3084d42 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 28 Oct 2021 13:52:35 -0300 Subject: [PATCH 8/9] Updated Shadow Force's move data --- src/data/battle_moves.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 1079cd608..cdb3ba0d1 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -7415,6 +7415,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .target = MOVE_TARGET_SELECTED, .priority = 0, .split = SPLIT_PHYSICAL, + .argument = MOVE_EFFECT_FEINT, }, [MOVE_HONE_CLAWS] = From 82101d3581a736fcaf6b46c37c1678d102b2fdfe Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 28 Oct 2021 13:59:59 -0300 Subject: [PATCH 9/9] Optimizations --- asm/macros/battle_script.inc | 5 -- data/battle_scripts_1.s | 85 ++++------------------ include/battle_scripts.h | 1 + include/constants/battle_script_commands.h | 1 - src/battle_script_commands.c | 21 ++---- src/data/battle_moves.h | 1 - 6 files changed, 22 insertions(+), 92 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 906eb1ede..04f6e04dc 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1864,11 +1864,6 @@ .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 b68363d5d..e17fd8450 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -394,86 +394,31 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHyperspaceFury @ EFFECT_HYPERSPACE_FURY BattleScript_EffectHyperspaceFury: - jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectHyperspaceFuryUnbound - jumpifspecies BS_ATTACKER, SPECIES_HOOPA, BattleScript_ButHoopaCantUseIt + jumpifspecies BS_ATTACKER, SPECIES_TREECKO, BattleScript_EffectHyperspaceFuryUnbound + jumpifspecies BS_ATTACKER, SPECIES_MUDKIP, BattleScript_ButHoopaCantUseIt printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd + +BattleScript_EffectHyperspaceFuryUnbound:: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + pause B_WAIT_TIME_LONG + ppreduce + setmoveeffect MOVE_EFFECT_FEINT + seteffectwithchance + setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN + goto BattleScript_HitFromCritCalc + 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 +BattleScript_HyperspaceFuryRemoveProtect:: 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: diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 1994aef50..ec95a4549 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -401,5 +401,6 @@ extern const u8 BattleScript_AttackWeakenedByStrongWinds[]; extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[]; extern const u8 BattleScript_BlockedByPrimalWeatherRet[]; extern const u8 BattleScript_PrimalReversion[]; +extern const u8 BattleScript_HyperspaceFuryRemoveProtect[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index abce5f9bf..f00695276 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -194,7 +194,6 @@ #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/src/battle_script_commands.c b/src/battle_script_commands.c index f99aec129..e41f0982a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3278,15 +3278,7 @@ void SetMoveEffect(bool32 primary, u32 certain) } break; case MOVE_EFFECT_FEINT: - if (gProtectStructs[gBattlerTarget].protected - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_WIDE_GUARD - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_QUICK_GUARD - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_CRAFTY_SHIELD - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_MAT_BLOCK - || gProtectStructs[gBattlerTarget].spikyShielded - || gProtectStructs[gBattlerTarget].kingsShielded - || gProtectStructs[gBattlerTarget].banefulBunkered - || gProtectStructs[gBattlerTarget].obstructed) + if (IS_BATTLER_PROTECTED(gBattlerTarget)) { gProtectStructs[gBattlerTarget].protected = 0; gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD); @@ -3302,6 +3294,11 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } + else if (gCurrentMove == MOVE_HYPERSPACE_FURY) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_HyperspaceFuryRemoveProtect; + } } break; case MOVE_EFFECT_SPECTRAL_THIEF: @@ -8983,12 +8980,6 @@ static void Cmd_various(void) 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; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 41f577a5b..93d8fcda9 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9701,7 +9701,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIT_IN_SUBSTITUTE, .split = SPLIT_PHYSICAL, - .argument = MOVE_EFFECT_FEINT, }, [MOVE_SHORE_UP] =