From 5879724ead7e46c30206afa1d50c7333579d9dba Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 20 Feb 2024 13:15:53 -0500 Subject: [PATCH] Fix Beak Blast not working in same turn --- src/battle-phases.ts | 2 +- src/battle-scene.ts | 11 ++++++++++- src/data/move.ts | 15 ++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 5b7a8ac54..e1f445c21 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -1755,8 +1755,8 @@ export class CommonAnimPhase extends PokemonPhase { export class MovePhase extends BattlePhase { public pokemon: Pokemon; + public move: PokemonMove; protected targets: BattlerIndex[]; - protected move: PokemonMove; protected followUp: boolean; protected ignorePp: boolean; protected cancelled: boolean; diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 4b8751ab4..f0d18dc30 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1,6 +1,6 @@ import Phaser from 'phaser'; import UI, { Mode } from './ui/ui'; -import { EncounterPhase, SummonPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, CheckLoadPhase, TurnInitPhase, ReturnPhase, LevelCapPhase, TestMessagePhase, ShowTrainerPhase, TrainerMessageTestPhase, LoginPhase, ConsolidateDataPhase, SelectGenderPhase } from './battle-phases'; +import { EncounterPhase, SummonPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, CheckLoadPhase, TurnInitPhase, ReturnPhase, LevelCapPhase, TestMessagePhase, ShowTrainerPhase, TrainerMessageTestPhase, LoginPhase, ConsolidateDataPhase, SelectGenderPhase, MovePhase } from './battle-phases'; import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon'; import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species'; import * as Utils from './utils'; @@ -1467,6 +1467,15 @@ export default class BattleScene extends Phaser.Scene { return this.phaseQueue.find(phaseFilter); } + pushMovePhase(movePhase: MovePhase, priorityOverride?: integer): void { + const priority = priorityOverride !== undefined ? priorityOverride : movePhase.move.getMove().priority; + const lowerPriorityPhase = this.phaseQueue.find(p => p instanceof MovePhase && p.move.getMove().priority < priority); + if (lowerPriorityPhase) + this.phaseQueue.splice(this.phaseQueue.indexOf(lowerPriorityPhase), 0, movePhase); + else + this.pushPhase(movePhase); + } + queueMessage(message: string, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer, defer?: boolean) { const phase = new MessagePhase(this, message, callbackDelay, prompt, promptDelay); if (!defer) diff --git a/src/data/move.ts b/src/data/move.ts index b9a02fd7a..1605bb7d9 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -916,14 +916,18 @@ export class ChargeAttr extends OverrideMoveEffectAttr { private chargeText: string; private tagType: BattlerTagType; public chargeEffect: boolean; + public sameTurn: boolean; + public followUpPriority: integer; - constructor(chargeAnim: ChargeAnim, chargeText: string, tagType?: BattlerTagType, chargeEffect?: boolean) { + constructor(chargeAnim: ChargeAnim, chargeText: string, tagType?: BattlerTagType, chargeEffect: boolean = false, sameTurn: boolean = false, followUpPriority?: integer) { super(); this.chargeAnim = chargeAnim; this.chargeText = chargeText; this.tagType = tagType; - this.chargeEffect = !!chargeEffect; + this.chargeEffect = chargeEffect; + this.sameTurn = sameTurn; + this.followUpPriority = followUpPriority; } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { @@ -939,6 +943,8 @@ export class ChargeAttr extends OverrideMoveEffectAttr { applyMoveAttrs(MoveEffectAttr, user, target, move); user.pushMoveHistory({ move: move.id, targets: [ target.getBattlerIndex() ], result: MoveResult.OTHER }); user.getMoveQueue().push({ move: move.id, targets: [ target.getBattlerIndex() ], ignorePP: true }); + if (this.sameTurn) + user.scene.pushMovePhase(new MovePhase(user.scene, user, [ target.getBattlerIndex() ], user.moveset.find(m => m.moveId === move.id), true), this.followUpPriority); resolve(true); }); } else @@ -1595,7 +1601,6 @@ export class LapseBattlerTagAttr extends MoveEffectAttr { } } - export class RemoveBattlerTagAttr extends MoveEffectAttr { public tagTypes: BattlerTagType[]; @@ -3754,8 +3759,8 @@ export function initMoves() { new AttackMove(Moves.TROP_KICK, "Trop Kick", Type.GRASS, MoveCategory.PHYSICAL, 70, 100, 15, -1, "The user lands an intense kick of tropical origins on the target. This also lowers the target's Attack stat.", 100, 0, 7) .attr(StatChangeAttr, BattleStat.ATK, -1), new StatusMove(Moves.INSTRUCT, "Instruct (N)", Type.PSYCHIC, -1, 15, -1, "The user instructs the target to use the target's last move again.", -1, 0, 7), - new AttackMove(Moves.BEAK_BLAST, "Beak Blast", Type.FLYING, MoveCategory.PHYSICAL, 100, 100, 15, -1, "The user first heats up its beak, and then it attacks the target. Making direct contact with the Pokémon while it's heating up its beak results in a burn.", -1, -3, 7) - .attr(ChargeAttr, ChargeAnim.BEAK_BLAST_CHARGING, "started\nheating up its beak!") + new AttackMove(Moves.BEAK_BLAST, "Beak Blast (P)", Type.FLYING, MoveCategory.PHYSICAL, 100, 100, 15, -1, "The user first heats up its beak, and then it attacks the target. Making direct contact with the Pokémon while it's heating up its beak results in a burn.", -1, 5, 7) + .attr(ChargeAttr, ChargeAnim.BEAK_BLAST_CHARGING, "started\nheating up its beak!", undefined, false, true, -3) .ballBombMove(), new AttackMove(Moves.CLANGING_SCALES, "Clanging Scales", Type.DRAGON, MoveCategory.SPECIAL, 110, 100, 5, -1, "The user rubs the scales on its entire body and makes a huge noise to attack opposing Pokémon. The user's Defense stat goes down after the attack.", 100, 0, 7) .attr(StatChangeAttr, BattleStat.DEF, -1, true)