From 00ab9eb22567890a19699be0fb99f94eaa380651 Mon Sep 17 00:00:00 2001 From: Jimmybald1 <147992650+IBBCalc@users.noreply.github.com> Date: Sat, 24 May 2025 09:58:18 +0200 Subject: [PATCH] Protect rng now resets on new waves and fixed to look at all turns in the same wave. --- src/data/moves/move.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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; }); }