From 6be3548e2fc1ae672e3fb9cc877f6412164f9c49 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sun, 17 Nov 2024 17:39:37 -0800 Subject: [PATCH 1/3] Prevent crash if enemy Future Sight user is caught --- src/field/pokemon.ts | 7 +++++-- src/phases/move-effect-phase.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 1dc4972af790..217d5fa699b0 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3243,11 +3243,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return null; } - getMoveHistory(): TurnMove[] { + public getMoveHistory(): TurnMove[] { return this.battleSummonData.moveHistory; } - pushMoveHistory(turnMove: TurnMove) { + public pushMoveHistory(turnMove: TurnMove): void { + if (!this.isOnField()) { + return; + } turnMove.turn = this.scene.currentBattle?.turn; this.getMoveHistory().push(turnMove); } diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index afc8dd0475d6..3a609f850c6a 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -92,8 +92,12 @@ export class MoveEffectPhase extends PokemonPhase { const isDelayedAttack = this.move.getMove().hasAttr(DelayedAttackAttr); /** If the user was somehow removed from the field and it's not a delayed attack, end this phase */ - if (!user.isOnField() && !isDelayedAttack) { - return super.end(); + if (!user.isOnField()) { + if (!isDelayedAttack) { + return super.end(); + } else { + user.resetTurnData(); + } } /** @@ -174,7 +178,7 @@ export class MoveEffectPhase extends PokemonPhase { const playOnEmptyField = this.scene.currentBattle?.mysteryEncounter?.hasBattleAnimationsWithoutTargets ?? false; // Move animation only needs one target - new MoveAnim(move.id as Moves, user, this.getFirstTarget()!.getBattlerIndex()!, playOnEmptyField).play(this.scene, move.hitsSubstitute(user, this.getFirstTarget()!), () => { + new MoveAnim(move.id as Moves, user, this.getFirstTarget()!.getBattlerIndex(), playOnEmptyField).play(this.scene, move.hitsSubstitute(user, this.getFirstTarget()!), () => { /** Has the move successfully hit a target (for damage) yet? */ let hasHit: boolean = false; for (const target of targets) { From cb2ae7ec334b8898f2766a07fbaf3c825bb1faa6 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sun, 17 Nov 2024 17:39:37 -0800 Subject: [PATCH 2/3] Prevent crash if enemy Future Sight user is caught --- src/field/pokemon.ts | 7 +++++-- src/phases/move-effect-phase.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 1dc4972af790..217d5fa699b0 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3243,11 +3243,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return null; } - getMoveHistory(): TurnMove[] { + public getMoveHistory(): TurnMove[] { return this.battleSummonData.moveHistory; } - pushMoveHistory(turnMove: TurnMove) { + public pushMoveHistory(turnMove: TurnMove): void { + if (!this.isOnField()) { + return; + } turnMove.turn = this.scene.currentBattle?.turn; this.getMoveHistory().push(turnMove); } diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index afc8dd0475d6..3a609f850c6a 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -92,8 +92,12 @@ export class MoveEffectPhase extends PokemonPhase { const isDelayedAttack = this.move.getMove().hasAttr(DelayedAttackAttr); /** If the user was somehow removed from the field and it's not a delayed attack, end this phase */ - if (!user.isOnField() && !isDelayedAttack) { - return super.end(); + if (!user.isOnField()) { + if (!isDelayedAttack) { + return super.end(); + } else { + user.resetTurnData(); + } } /** @@ -174,7 +178,7 @@ export class MoveEffectPhase extends PokemonPhase { const playOnEmptyField = this.scene.currentBattle?.mysteryEncounter?.hasBattleAnimationsWithoutTargets ?? false; // Move animation only needs one target - new MoveAnim(move.id as Moves, user, this.getFirstTarget()!.getBattlerIndex()!, playOnEmptyField).play(this.scene, move.hitsSubstitute(user, this.getFirstTarget()!), () => { + new MoveAnim(move.id as Moves, user, this.getFirstTarget()!.getBattlerIndex(), playOnEmptyField).play(this.scene, move.hitsSubstitute(user, this.getFirstTarget()!), () => { /** Has the move successfully hit a target (for damage) yet? */ let hasHit: boolean = false; for (const target of targets) { From 090ffa105f4b5b10749bbdc1080994e609f0938d Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sun, 17 Nov 2024 17:58:35 -0800 Subject: [PATCH 3/3] Update patch version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 792720200a9c..22a55cdfa282 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pokemon-rogue-battle", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pokemon-rogue-battle", - "version": "1.2.0", + "version": "1.2.1", "hasInstallScript": true, "dependencies": { "@material/material-color-utilities": "^0.2.7", diff --git a/package.json b/package.json index 3c65fe1a8b97..5aaffc59de1a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pokemon-rogue-battle", "private": true, - "version": "1.2.0", + "version": "1.2.1", "type": "module", "scripts": { "start": "vite",