Fix Charge Move Infinites

Fixed an issue where two turn charge moves could be paused by status or Truant causing some infinite sequences if not careful.
This commit is contained in:
Benjamin Odom 2024-05-11 06:05:13 -05:00
parent 28c75e4377
commit 623fcfea2f
2 changed files with 22 additions and 18 deletions

View File

@ -731,7 +731,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const overrideArray: Array<Moves> = this.isPlayer() ? Overrides.MOVESET_OVERRIDE : Overrides.OPP_MOVESET_OVERRIDE;
if (overrideArray.length > 0) {
overrideArray.forEach((move: Moves, index: number) => {
const ppUsed = this.moveset[index]?.ppUp || 0;
const ppUsed = this.moveset[index]?.ppUsed || 0;
this.moveset[index] = new PokemonMove(move, Math.min(ppUsed, allMoves[move].pp))
});
}

View File

@ -2211,7 +2211,7 @@ export class MovePhase extends BattlePhase {
}
// Move redirection abilities (ie. Storm Drain) only support single target moves
const moveTarget = this.targets.length === 1
const moveTarget = this.targets.length === 1
? new Utils.IntegerHolder(this.targets[0])
: null;
if (moveTarget) {
@ -2226,7 +2226,7 @@ const moveTarget = this.targets.length === 1
moveTarget.value = oldTarget;
}
this.targets[0] = moveTarget.value;
}
}
if (this.targets.length === 1 && this.targets[0] === BattlerIndex.ATTACKER) {
if (this.pokemon.turnData.attacksReceived.length) {
@ -2269,16 +2269,20 @@ const moveTarget = this.targets.length === 1
if (!this.followUp && this.canMove() && !this.cancelled) {
this.pokemon.lapseTags(BattlerTagLapseType.MOVE);
}
const moveQueue = this.pokemon.getMoveQueue();
if (this.cancelled || this.failed) {
if (this.failed)
this.move.usePp(ppUsed); // Only use PP if the move failed
// Record a failed move so Abilities like Truant don't trigger next turn and soft-lock
this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL });
this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT); // Remove any tags from moves like Fly/Dive/etc.
moveQueue.shift(); // Remove the second turn of charge moves
return this.end();
}
const moveQueue = this.pokemon.getMoveQueue();
this.scene.triggerPokemonFormChange(this.pokemon, SpeciesFormChangePreMoveTrigger);
if (this.move.moveId)