diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 31ad3337926..85fb7b8da46 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -5780,20 +5780,35 @@ export class ProtectAttr extends AddBattlerTagAttr { getCondition(): MoveConditionFunc { return ((user, target, move): boolean => { + // Protect rng resets on new waves, it always succeeds. + if (user.tempSummonData.waveTurnCount === 1) { + return true; + } + let timesUsed = 0; - const moveHistory = user.getLastXMoves(); + const moveHistory = user.getLastXMoves(-1); let turnMove: TurnMove | undefined; while (moveHistory.length) { turnMove = moveHistory.shift(); + if (!allMoves[turnMove?.move ?? Moves.NONE].hasAttr(ProtectAttr) || turnMove?.result !== MoveResult.SUCCESS) { break; } + timesUsed++; + + // Break after first move used this wave. + // If no move was used on turn 1, then it would have broken in the attr check already. + if (turnMove?.turn === 1) { + break; + } } + if (timesUsed) { return !user.randBattleSeedInt(Math.pow(3, timesUsed)); } + return true; }); }