Fix Charge Move Infinites (#741)

Fixed an issue where two turn charge moves could be paused by status or Truant causing some infinite sequences if not careful.
pull/723/head^2
Benjamin Odom 2024-05-11 08:22:26 -05:00 committed by GitHub
parent 28c75e4377
commit ae7c1ef4f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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

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