From 0011f6033b9b789431c2aba3069125ab3c3a6b1a Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sat, 2 Mar 2024 10:23:54 -0500 Subject: [PATCH] Fix redundant item update for each transferred item when fusing --- src/battle-scene.ts | 8 ++++---- src/data/move.ts | 2 +- src/field/pokemon.ts | 14 ++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index efe6d386068..57a65d8fe7e 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1583,7 +1583,7 @@ export default class BattleScene extends Phaser.Scene { }); } - tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, transferStack: boolean, playSound: boolean, instant?: boolean): Promise { + tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, transferStack: boolean, playSound: boolean, instant?: boolean, ignoreUpdate?: boolean): Promise { return new Promise(resolve => { const source = itemModifier.getPokemon(target.scene); const cancelled = new Utils.BooleanHolder(false); @@ -1611,13 +1611,13 @@ export default class BattleScene extends Phaser.Scene { const addModifier = () => { if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) { if (target.isPlayer()) - this.addModifier(newItemModifier, false, playSound, false, instant).then(() => resolve(true)); + this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => resolve(true)); else - this.addEnemyModifier(newItemModifier, false, instant).then(() => resolve(true)); + this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => resolve(true)); } else resolve(false); }; - if (source.isPlayer() !== target.isPlayer()) + if (source.isPlayer() !== target.isPlayer() && !ignoreUpdate) this.updateModifiers(source.isPlayer(), instant).then(() => addModifier()); else addModifier(); diff --git a/src/data/move.ts b/src/data/move.ts index 24b737854d7..a1aff2d184c 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3826,7 +3826,7 @@ export function initMoves() { .attr(StatChangeAttr, BattleStat.DEF, -1), new AttackMove(Moves.PRISMATIC_LASER, "Prismatic Laser", Type.PSYCHIC, MoveCategory.SPECIAL, 160, 100, 10, -1, "The user shoots powerful lasers using the power of a prism. The user can't move on the next turn.", -1, 0, 7) .attr(RechargeAttr), - new AttackMove(Moves.SPECTRAL_THIEF, "Spectral Thief (NP)", Type.GHOST, MoveCategory.PHYSICAL, 90, 100, 10, -1, "The user hides in the target's shadow, steals the target's stat boosts, and then attacks.", -1, 0, 7), + new AttackMove(Moves.SPECTRAL_THIEF, "Spectral Thief (P)", Type.GHOST, MoveCategory.PHYSICAL, 90, 100, 10, -1, "The user hides in the target's shadow, steals the target's stat boosts, and then attacks.", -1, 0, 7), new AttackMove(Moves.SUNSTEEL_STRIKE, "Sunsteel Strike (P)", Type.STEEL, MoveCategory.PHYSICAL, 100, 100, 5, -1, "The user slams into the target with the force of a meteor. This move can be used on the target regardless of its Abilities.", -1, 0, 7), new AttackMove(Moves.MOONGEIST_BEAM, "Moongeist Beam (P)", Type.GHOST, MoveCategory.SPECIAL, 100, 100, 5, -1, "The user emits a sinister ray to attack the target. This move can be used on the target regardless of its Abilities.", -1, 0, 7), new StatusMove(Moves.TEARFUL_LOOK, "Tearful Look", Type.NORMAL, -1, 20, -1, "The user gets teary eyed to make the target lose its combative spirit. This lowers the target's Attack and Sp. Atk stats.", 100, 0, 7) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 7b3fca5bdc2..3d91e977988 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2083,13 +2083,15 @@ export class PlayerPokemon extends Pokemon { && (m as PokemonHeldItemModifier).pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; const transferModifiers: Promise[] = []; for (let modifier of fusedPartyMemberHeldModifiers) - transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, true, false)); + transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, true, false, true, true)); Promise.allSettled(transferModifiers).then(() => { - this.scene.removePartyMemberModifiers(fusedPartyMemberIndex); - this.scene.getParty().splice(fusedPartyMemberIndex, 1)[0]; - pokemon.destroy(); - this.updateFusionPalette(); - resolve(); + this.scene.updateModifiers(true, true).then(() => { + this.scene.removePartyMemberModifiers(fusedPartyMemberIndex); + this.scene.getParty().splice(fusedPartyMemberIndex, 1)[0]; + pokemon.destroy(); + this.updateFusionPalette(); + resolve(); + }); }); }); });