diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 8277d88a0..596155618 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -2642,9 +2642,11 @@ export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { for (let lm of levelMoves) this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm)); } - const evolution = pokemon.getEvolution(); - if (evolution) - this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.partyMemberIndex, evolution, this.lastLevel)); + if (!pokemon.pauseEvolutions) { + const evolution = pokemon.getEvolution(); + if (evolution) + this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.partyMemberIndex, evolution, this.lastLevel)); + } } } diff --git a/src/evolution-phase.ts b/src/evolution-phase.ts index 7f9073830..5fb98e56c 100644 --- a/src/evolution-phase.ts +++ b/src/evolution-phase.ts @@ -95,140 +95,155 @@ export class EvolutionPhase extends BattlePhase { this.scene.ui.showText(`What?\n${preName} is evolving!`, null, () => { pokemon.cry(); - const evolvedPokemon = pokemon.getPossibleEvolution(this.evolution); + pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => { - [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { - sprite.play(evolvedPokemon.getSpriteKey(true)); - [ 'spriteColors', 'fusionSpriteColors' ].map(k => { - if (evolvedPokemon.summonData?.speciesForm) - k += 'Base'; - sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k]; + [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { + console.log(evolvedPokemon.getSpriteKey(true)) + sprite.play(evolvedPokemon.getSpriteKey(true)); + [ 'spriteColors', 'fusionSpriteColors' ].map(k => { + if (evolvedPokemon.summonData?.speciesForm) + k += 'Base'; + sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k]; + }); }); - }); - this.scene.time.delayedCall(1000, () => { - const evolutionBgm = this.scene.playSoundWithoutBgm('evolution'); - this.scene.tweens.add({ - targets: this.evolutionBgOverlay, - alpha: 1, - delay: 500, - duration: 1500, - ease: 'Sine.easeOut', - onComplete: () => { - this.scene.time.delayedCall(1000, () => { - this.scene.tweens.add({ - targets: this.evolutionBgOverlay, - alpha: 0, - duration: 250 + this.scene.time.delayedCall(1000, () => { + const evolutionBgm = this.scene.playSoundWithoutBgm('evolution'); + this.scene.tweens.add({ + targets: this.evolutionBgOverlay, + alpha: 1, + delay: 500, + duration: 1500, + ease: 'Sine.easeOut', + onComplete: () => { + this.scene.time.delayedCall(1000, () => { + this.scene.tweens.add({ + targets: this.evolutionBgOverlay, + alpha: 0, + duration: 250 + }); + this.evolutionBg.setVisible(true); + this.evolutionBg.play(); }); - this.evolutionBg.setVisible(true); - this.evolutionBg.play(); - }); - this.scene.playSound('charge'); - this.doSpiralUpward(); - this.scene.tweens.addCounter({ - from: 0, - to: 1, - duration: 2000, - onUpdate: t => { - this.pokemonTintSprite.setAlpha(t.getValue()); - }, - onComplete: () => { - this.pokemonSprite.setVisible(false); - this.scene.time.delayedCall(1100, () => { - this.scene.playSound('beam'); - this.doArcDownward(); - this.scene.time.delayedCall(1500, () => { - this.pokemonEvoTintSprite.setScale(0.25); - this.pokemonEvoTintSprite.setVisible(true); - evolutionHandler.canCancel = true; - this.doCycle(1).then(success => { - if (!success) { + this.scene.playSound('charge'); + this.doSpiralUpward(); + this.scene.tweens.addCounter({ + from: 0, + to: 1, + duration: 2000, + onUpdate: t => { + this.pokemonTintSprite.setAlpha(t.getValue()); + }, + onComplete: () => { + this.pokemonSprite.setVisible(false); + this.scene.time.delayedCall(1100, () => { + this.scene.playSound('beam'); + this.doArcDownward(); + this.scene.time.delayedCall(1500, () => { + this.pokemonEvoTintSprite.setScale(0.25); + this.pokemonEvoTintSprite.setVisible(true); + evolutionHandler.canCancel = true; + this.doCycle(1).then(success => { + if (!success) { - this.pokemonSprite.setVisible(true); - this.pokemonTintSprite.setScale(1); - this.scene.tweens.add({ - targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ], - alpha: 0, - duration: 250, - onComplete: () => { - this.evolutionBg.setVisible(false); - } - }); + this.pokemonSprite.setVisible(true); + this.pokemonTintSprite.setScale(1); + this.scene.tweens.add({ + targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ], + alpha: 0, + duration: 250, + onComplete: () => { + this.evolutionBg.setVisible(false); + } + }); - SoundFade.fadeOut(this.scene, evolutionBgm, 100); + SoundFade.fadeOut(this.scene, evolutionBgm, 100); - this.scene.unshiftPhase(new EndEvolutionPhase(this.scene)); - - this.scene.ui.showText(`${preName} stopped evolving.`, null, () => { - this.scene.playBgm(); - evolvedPokemon.destroy(); - this.end(); - }, null, true, 3000); - return; - } - - this.scene.playSound('sparkle'); - this.pokemonEvoSprite.setVisible(true); - this.doCircleInward(); - this.scene.time.delayedCall(900, () => { - evolutionHandler.canCancel = false; - - pokemon.evolve(this.evolution).then(() => { - const levelMoves = pokemon.getLevelMoves(this.lastLevel + 1, true); - for (let lm of levelMoves) - this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm)); this.scene.unshiftPhase(new EndEvolutionPhase(this.scene)); - this.scene.playSound('shine'); - this.doSpray(); - this.scene.tweens.add({ - targets: this.evolutionOverlay, - alpha: 1, - duration: 250, - easing: 'Sine.easeIn', - onComplete: () => { - this.evolutionBgOverlay.setAlpha(1); - this.evolutionBg.setVisible(false); - this.scene.tweens.add({ - targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ], - alpha: 0, - duration: 2000, - delay: 150, - easing: 'Sine.easeIn', - onComplete: () => { - this.scene.tweens.add({ - targets: this.evolutionBgOverlay, - alpha: 0, - duration: 250, - onComplete: () => { - SoundFade.fadeOut(this.scene, evolutionBgm, 100); - this.scene.time.delayedCall(250, () => { - pokemon.cry(); - this.scene.time.delayedCall(1250, () => { - this.scene.playSoundWithoutBgm('evolution_fanfare'); - if (this.evolution.evoFormKey && this.evolution.evoFormKey.indexOf(SpeciesFormKey.MEGA) > -1) - this.scene.validateAchv(achvs.MEGA_EVOLVE); - - evolvedPokemon.destroy(); - this.scene.ui.showText(`Congratulations! Your ${preName}\nevolved into ${pokemon.name}!`, null, () => this.end(), null, true, 3000); - this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm()); - }); - }); - } - }); - } + this.scene.ui.showText(`${preName} stopped evolving.`, null, () => { + this.scene.ui.showText(`Would you like to pause evolutions for ${preName}?\nEvolutions can be re-enabled from the party screen.`, null, () => { + const end = () => { + this.scene.ui.showText(null, 0); + this.scene.playBgm(); + evolvedPokemon.destroy(); + this.end(); + }; + this.scene.ui.setOverlayMode(Mode.CONFIRM, () => { + this.scene.ui.revertMode(); + pokemon.pauseEvolutions = true; + this.scene.ui.showText(`Evolutions have been paused for ${preName}.`, null, end, 3000); + }, () => { + this.scene.ui.revertMode(); + this.scene.time.delayedCall(3000, end); }); - } + }); + }, null, true); + return; + } + + this.scene.playSound('sparkle'); + this.pokemonEvoSprite.setVisible(true); + this.doCircleInward(); + this.scene.time.delayedCall(900, () => { + evolutionHandler.canCancel = false; + + pokemon.evolve(this.evolution).then(() => { + const levelMoves = pokemon.getLevelMoves(this.lastLevel + 1, true); + for (let lm of levelMoves) + this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm)); + this.scene.unshiftPhase(new EndEvolutionPhase(this.scene)); + + this.scene.playSound('shine'); + this.doSpray(); + this.scene.tweens.add({ + targets: this.evolutionOverlay, + alpha: 1, + duration: 250, + easing: 'Sine.easeIn', + onComplete: () => { + this.evolutionBgOverlay.setAlpha(1); + this.evolutionBg.setVisible(false); + this.scene.tweens.add({ + targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ], + alpha: 0, + duration: 2000, + delay: 150, + easing: 'Sine.easeIn', + onComplete: () => { + this.scene.tweens.add({ + targets: this.evolutionBgOverlay, + alpha: 0, + duration: 250, + onComplete: () => { + SoundFade.fadeOut(this.scene, evolutionBgm, 100); + this.scene.time.delayedCall(250, () => { + pokemon.cry(); + this.scene.time.delayedCall(1250, () => { + this.scene.playSoundWithoutBgm('evolution_fanfare'); + if (this.evolution.evoFormKey && this.evolution.evoFormKey.indexOf(SpeciesFormKey.MEGA) > -1) + this.scene.validateAchv(achvs.MEGA_EVOLVE); + + evolvedPokemon.destroy(); + this.scene.ui.showText(`Congratulations! Your ${preName}\nevolved into ${pokemon.name}!`, null, () => this.end(), null, true, 3000); + this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm()); + }); + }); + } + }); + } + }); + } + }); }); }); }); }); }); - }); - } - }) - } + } + }) + } + }); }); }); }, 1000); diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 1afbad159..c66037a19 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -515,7 +515,7 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator { if (pregenArgs) return new EvolutionItemModifierType(pregenArgs[0] as EvolutionItem); - const evolutionItemPool = party.filter(p => pokemonEvolutions.hasOwnProperty(p.species.speciesId)).map(p => { + const evolutionItemPool = party.filter(p => !p.pauseEvolutions && pokemonEvolutions.hasOwnProperty(p.species.speciesId)).map(p => { const evolutions = pokemonEvolutions[p.species.speciesId]; return evolutions.filter(e => e.item !== EvolutionItem.NONE && (e.evoFormKey === null || (e.preFormKey || '') === p.getFormKey()) && (!e.condition || e.condition.predicate(p))); }).flat().filter(e => (e.item >= 100) === mega).flatMap(e => e.item); diff --git a/src/pokemon.ts b/src/pokemon.ts index 2a077e494..f2ca00116 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -65,6 +65,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public moveset: PokemonMove[]; public status: Status; public winCount: integer; + public pauseEvolutions: boolean; public pokerus: boolean; public fusionSpecies: PokemonSpecies; @@ -120,6 +121,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.moveset = dataSource.moveset; this.status = dataSource.status; this.winCount = dataSource.winCount; + this.pauseEvolutions = dataSource.pauseEvolutions; this.pokerus = !!dataSource.pokerus; this.fusionSpecies = dataSource.fusionSpecies instanceof PokemonSpecies ? dataSource.fusionSpecies : getPokemonSpecies(dataSource.fusionSpecies); this.fusionFormIndex = dataSource.fusionFormIndex; @@ -1716,14 +1718,18 @@ export class PlayerPokemon extends Pokemon { }); } - getPossibleEvolution(evolution: SpeciesEvolution): Pokemon { - const species = getPokemonSpecies(evolution.speciesId); - const formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0); - return new PlayerPokemon(this.scene, species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.ivs, this); + getPossibleEvolution(evolution: SpeciesEvolution): Promise { + return new Promise(resolve => { + const species = getPokemonSpecies(evolution.speciesId); + const formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0); + const ret = new PlayerPokemon(this.scene, species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.ivs, this); + ret.loadAssets().then(() => resolve(ret)); + }); } evolve(evolution: SpeciesEvolution): Promise { return new Promise(resolve => { + this.pauseEvolutions = false; this.handleSpecialEvolutions(evolution); this.species = getPokemonSpecies(evolution.speciesId); if (evolution.preFormKey !== null) diff --git a/src/system/pokemon-data.ts b/src/system/pokemon-data.ts index 02de841ee..9e25a6937 100644 --- a/src/system/pokemon-data.ts +++ b/src/system/pokemon-data.ts @@ -25,6 +25,7 @@ export default class PokemonData { public moveset: PokemonMove[]; public status: Status; public winCount: integer; + public pauseEvolutions: boolean; public pokerus: boolean; public fusionSpecies: Species; @@ -52,6 +53,7 @@ export default class PokemonData { this.stats = source.stats; this.ivs = source.ivs; this.winCount = source.winCount; + this.pauseEvolutions = !!source.pauseEvolutions; this.pokerus = !!source.pokerus; this.fusionSpecies = sourcePokemon ? sourcePokemon.fusionSpecies?.speciesId : source.fusionSpecies; diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 8f5f4b815..431334419 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -11,6 +11,7 @@ import { Moves, allMoves } from "../data/move"; import { getGenderColor, getGenderSymbol } from "../data/gender"; import { StatusEffect } from "../data/status-effect"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler"; +import { pokemonEvolutions } from "../data/pokemon-evolutions"; const defaultMessage = 'Choose a Pokémon.'; @@ -36,6 +37,7 @@ export enum PartyOption { TRANSFER, SPLICE, SUMMARY, + UNPAUSE_EVO, RELEASE, SCROLL_UP = 1000, SCROLL_DOWN = 1001, @@ -223,7 +225,7 @@ export default class PartyUiHandler extends MessageUiHandler { } ui.playSelect(); return true; - } else if ((option !== PartyOption.SUMMARY && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL) + } else if ((option !== PartyOption.SUMMARY && option !== PartyOption.UNPAUSE_EVO && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL) || (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) { let filterResult: string; if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) { @@ -270,6 +272,11 @@ export default class PartyUiHandler extends MessageUiHandler { ui.playSelect(); ui.setModeWithoutClear(Mode.SUMMARY, pokemon).then(() => this.clearOptions()); return true; + } else if (option === PartyOption.UNPAUSE_EVO) { + this.clearOptions(); + ui.playSelect(); + pokemon.pauseEvolutions = false; + this.showText(`Evolutions have been unpaused for ${pokemon.name}.`, null, () => this.showText(null, 0), null, true); } else if (option === PartyOption.RELEASE) { this.clearOptions(); ui.playSelect(); @@ -538,6 +545,9 @@ export default class PartyUiHandler extends MessageUiHandler { this.options.push(PartyOption.SUMMARY); + if (pokemon.pauseEvolutions && pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId)) + this.options.push(PartyOption.UNPAUSE_EVO); + if (this.partyUiMode === PartyUiMode.SWITCH) this.options.push(PartyOption.RELEASE); } else if (this.partyUiMode === PartyUiMode.MOVE_MODIFIER) { @@ -589,6 +599,9 @@ export default class PartyUiHandler extends MessageUiHandler { case PartyOption.MOVE_4: optionName = pokemon.moveset[option - PartyOption.MOVE_1].getName(); break; + case PartyOption.UNPAUSE_EVO: + optionName = 'Unpause Evo.'; + break; default: optionName = Utils.toReadableString(PartyOption[option]); break;