From ebe2dc6bbb09b55143d939640ef92f737b18eeb9 Mon Sep 17 00:00:00 2001 From: Papa Cancer Date: Sun, 31 Mar 2019 17:17:13 +0100 Subject: [PATCH] Mat Block Nothing more needs to be said --- data/battle_scripts_1.s | 7 +++++++ include/constants/battle.h | 1 + include/constants/battle_move_effects.h | 1 + src/battle_main.c | 4 ++-- src/battle_script_commands.c | 11 +++++++++++ src/data/battle_moves.h | 5 +++-- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 663ae83d9..aaff6e776 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -345,6 +345,7 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectPartingShot .4byte BattleScript_EffectSpectralThief .4byte BattleScript_EffectVCreate + .4byte BattleScript_EffectMatBlock BattleScript_EffectVCreate: setmoveeffect MOVE_EFFECT_V_CREATE | MOVE_EFFECT_AFFECTS_USER @@ -3148,9 +3149,15 @@ BattleScript_DoGhostCurse:: tryfaintmon BS_ATTACKER, FALSE, NULL goto BattleScript_MoveEnd +BattleScript_EffectMatBlock:: + attackcanceler + jumpifnotfirstturn BattleScript_ButItFailedAtkStringPpReduce + goto BattleScript_ProtectLikeAtkString + BattleScript_EffectProtect:: BattleScript_EffectEndure:: attackcanceler +BattleScript_ProtectLikeAtkString: attackstring ppreduce setprotectlike diff --git a/include/constants/battle.h b/include/constants/battle.h index c42188596..d06e01f75 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -212,6 +212,7 @@ #define SIDE_STATUS_QUICK_GUARD (1 << 18) #define SIDE_STATUS_WIDE_GUARD (1 << 19) #define SIDE_STATUS_CRAFTY_SHIELD (1 << 20) +#define SIDE_STATUS_MAT_BLOCK (1 << 21) // Field affecting statuses. #define STATUS_FIELD_MAGIC_ROOM 0x1 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 588fe9773..056518935 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -333,5 +333,6 @@ #define EFFECT_PARTING_SHOT 327 #define EFFECT_SPECTRAL_THIEF 328 #define EFFECT_V_CREATE 329 +#define EFFECT_MAT_BLOCK 330 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/battle_main.c b/src/battle_main.c index 28d8dc0ee..70f8c065b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4593,8 +4593,8 @@ static void TurnValuesCleanUp(bool8 var0) gBattleMons[gActiveBattler].status2 &= ~(STATUS2_SUBSTITUTE); } - gSideStatuses[0] &= ~(SIDE_STATUS_QUICK_GUARD | SIDE_STATUS_WIDE_GUARD | SIDE_STATUS_CRAFTY_SHIELD); - gSideStatuses[1] &= ~(SIDE_STATUS_QUICK_GUARD | SIDE_STATUS_WIDE_GUARD | SIDE_STATUS_CRAFTY_SHIELD); + gSideStatuses[0] &= ~(SIDE_STATUS_QUICK_GUARD | SIDE_STATUS_WIDE_GUARD | SIDE_STATUS_CRAFTY_SHIELD | SIDE_STATUS_MAT_BLOCK); + gSideStatuses[1] &= ~(SIDE_STATUS_QUICK_GUARD | SIDE_STATUS_WIDE_GUARD | SIDE_STATUS_CRAFTY_SHIELD | SIDE_STATUS_MAT_BLOCK); gSideTimers[0].followmeTimer = 0; gSideTimers[1].followmeTimer = 0; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index adad0eda0..e541acfe6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -906,6 +906,9 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) else if (gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_CRAFTY_SHIELD && gBattleMoves[move].power == 0) return TRUE; + else if (gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_MAT_BLOCK + && gBattleMoves[move].power != 0) + return TRUE; else return FALSE; } @@ -2723,6 +2726,7 @@ void SetMoveEffect(bool32 primary, u32 certain) || 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) @@ -2731,6 +2735,7 @@ void SetMoveEffect(bool32 primary, u32 certain) 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 = 0; gProtectStructs[gBattlerTarget].kingsShielded = 0; gProtectStructs[gBattlerTarget].banefulBunkered = 0; @@ -7379,6 +7384,12 @@ static void atk77_setprotectlike(void) gDisableStructs[gBattlerAttacker].protectUses++; fail = FALSE; } + else if (gCurrentMove == MOVE_MAT_BLOCK && !(gSideStatuses[side] & SIDE_STATUS_MAT_BLOCK)) + { + gSideStatuses[side] |= SIDE_STATUS_MAT_BLOCK; + gBattleCommunication[MULTISTRING_CHOOSER] = 3; + fail = FALSE; + } } } diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 89f499c2b..70d03d782 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -7870,16 +7870,17 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_MAT_BLOCK] = { - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_MAT_BLOCK, .power = 0, .type = TYPE_FIGHTING, .accuracy = 0, .pp = 15, .secondaryEffectChance = 0, - .target = MOVE_TARGET_SELECTED, + .target = MOVE_TARGET_USER, .priority = 0, .flags = 0, .split = SPLIT_STATUS, + .argument = TRUE, // Protects the whole side. }, [MOVE_BELCH] =