From 0cdab790dc53d9202442263a8f7a58a5e59bc280 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 6 Jan 2021 15:40:20 -0700 Subject: [PATCH] add blunder policy --- include/battle.h | 1 + src/battle_script_commands.c | 3 +++ src/battle_util.c | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/battle.h b/include/battle.h index 488e0fc51..15658fdb5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -542,6 +542,7 @@ struct BattleStruct u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used. u16 moveEffect2; // For Knock Off u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. + bool8 blunderPolicy; }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b846e81ec..4d98390d6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1595,6 +1595,9 @@ static void Cmd_accuracycheck(void) if ((Random() % 100 + 1) > GetTotalAccuracy(gBattlerAttacker, gBattlerTarget, move)) { gMoveResultFlags |= MOVE_RESULT_MISSED; + if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_BLUNDER_POLICY) + gBattleStruct->blunderPolicy = TRUE; // only activates from missing through acc/evasion checks + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && (gBattleMoves[move].target == MOVE_TARGET_BOTH || gBattleMoves[move].target == MOVE_TARGET_FOES_AND_ALLY)) gBattleCommunication[6] = 2; diff --git a/src/battle_util.c b/src/battle_util.c index dba898693..bc5e6b992 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5778,7 +5778,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) case HOLD_EFFECT_THROAT_SPRAY: // doesn't need to be a damaging move if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBattlerAttacker].hp != 0 - && gBattleMoves[gCurrentMove].flags & FLAG_SOUND) + && gBattleMoves[gCurrentMove].flags & FLAG_SOUND + && gBattleMons[gBattlerAttacker].statStages[STAT_SPATK] < MAX_STAT_STAGE) { gLastUsedItem = atkItem; gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE); @@ -5787,6 +5788,19 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gBattlescriptCurrInstr = BattleScript_AttackerItemStatRaise; } break; + case HOLD_EFFECT_BLUNDER_POLICY: + if (gBattleStruct->blunderPolicy + && gBattleMons[gBattlerAttacker].hp != 0 + && gBattleMons[gBattlerAttacker].statStages[STAT_SPEED] < MAX_STAT_STAGE) + { + gBattleStruct->blunderPolicy = FALSE; + gLastUsedItem = atkItem; + gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPEED, 2, FALSE); + effect = ITEM_STATS_CHANGE; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_AttackerItemStatRaise; + } + break; } break; case ITEMEFFECT_TARGET: