add blunder policy

This commit is contained in:
Evan 2021-01-06 15:40:20 -07:00
parent db6f9d05ec
commit 0cdab790dc
3 changed files with 19 additions and 1 deletions

View file

@ -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) \

View file

@ -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;

View file

@ -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: