Add evolution pausing and fix visual bug with evolution scene

pull/14/head
Flashfyre 2023-12-14 12:55:11 -05:00
parent fc2665b3f0
commit dad6401f67
6 changed files with 166 additions and 128 deletions

View File

@ -2642,9 +2642,11 @@ export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
for (let lm of levelMoves) for (let lm of levelMoves)
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm)); this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm));
} }
const evolution = pokemon.getEvolution(); if (!pokemon.pauseEvolutions) {
if (evolution) const evolution = pokemon.getEvolution();
this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.partyMemberIndex, evolution, this.lastLevel)); if (evolution)
this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.partyMemberIndex, evolution, this.lastLevel));
}
} }
} }

View File

@ -95,140 +95,155 @@ export class EvolutionPhase extends BattlePhase {
this.scene.ui.showText(`What?\n${preName} is evolving!`, null, () => { this.scene.ui.showText(`What?\n${preName} is evolving!`, null, () => {
pokemon.cry(); pokemon.cry();
const evolvedPokemon = pokemon.getPossibleEvolution(this.evolution); pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => {
[ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => {
sprite.play(evolvedPokemon.getSpriteKey(true)); console.log(evolvedPokemon.getSpriteKey(true))
[ 'spriteColors', 'fusionSpriteColors' ].map(k => { sprite.play(evolvedPokemon.getSpriteKey(true));
if (evolvedPokemon.summonData?.speciesForm) [ 'spriteColors', 'fusionSpriteColors' ].map(k => {
k += 'Base'; if (evolvedPokemon.summonData?.speciesForm)
sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k]; k += 'Base';
sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k];
});
}); });
});
this.scene.time.delayedCall(1000, () => { this.scene.time.delayedCall(1000, () => {
const evolutionBgm = this.scene.playSoundWithoutBgm('evolution'); const evolutionBgm = this.scene.playSoundWithoutBgm('evolution');
this.scene.tweens.add({ this.scene.tweens.add({
targets: this.evolutionBgOverlay, targets: this.evolutionBgOverlay,
alpha: 1, alpha: 1,
delay: 500, delay: 500,
duration: 1500, duration: 1500,
ease: 'Sine.easeOut', ease: 'Sine.easeOut',
onComplete: () => { onComplete: () => {
this.scene.time.delayedCall(1000, () => { this.scene.time.delayedCall(1000, () => {
this.scene.tweens.add({ this.scene.tweens.add({
targets: this.evolutionBgOverlay, targets: this.evolutionBgOverlay,
alpha: 0, alpha: 0,
duration: 250 duration: 250
});
this.evolutionBg.setVisible(true);
this.evolutionBg.play();
}); });
this.evolutionBg.setVisible(true); this.scene.playSound('charge');
this.evolutionBg.play(); this.doSpiralUpward();
}); this.scene.tweens.addCounter({
this.scene.playSound('charge'); from: 0,
this.doSpiralUpward(); to: 1,
this.scene.tweens.addCounter({ duration: 2000,
from: 0, onUpdate: t => {
to: 1, this.pokemonTintSprite.setAlpha(t.getValue());
duration: 2000, },
onUpdate: t => { onComplete: () => {
this.pokemonTintSprite.setAlpha(t.getValue()); this.pokemonSprite.setVisible(false);
}, this.scene.time.delayedCall(1100, () => {
onComplete: () => { this.scene.playSound('beam');
this.pokemonSprite.setVisible(false); this.doArcDownward();
this.scene.time.delayedCall(1100, () => { this.scene.time.delayedCall(1500, () => {
this.scene.playSound('beam'); this.pokemonEvoTintSprite.setScale(0.25);
this.doArcDownward(); this.pokemonEvoTintSprite.setVisible(true);
this.scene.time.delayedCall(1500, () => { evolutionHandler.canCancel = true;
this.pokemonEvoTintSprite.setScale(0.25); this.doCycle(1).then(success => {
this.pokemonEvoTintSprite.setVisible(true); if (!success) {
evolutionHandler.canCancel = true;
this.doCycle(1).then(success => {
if (!success) {
this.pokemonSprite.setVisible(true); this.pokemonSprite.setVisible(true);
this.pokemonTintSprite.setScale(1); this.pokemonTintSprite.setScale(1);
this.scene.tweens.add({ this.scene.tweens.add({
targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ], targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ],
alpha: 0, alpha: 0,
duration: 250, duration: 250,
onComplete: () => { onComplete: () => {
this.evolutionBg.setVisible(false); 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.unshiftPhase(new EndEvolutionPhase(this.scene));
this.scene.playSound('shine'); this.scene.ui.showText(`${preName} stopped evolving.`, null, () => {
this.doSpray(); this.scene.ui.showText(`Would you like to pause evolutions for ${preName}?\nEvolutions can be re-enabled from the party screen.`, null, () => {
this.scene.tweens.add({ const end = () => {
targets: this.evolutionOverlay, this.scene.ui.showText(null, 0);
alpha: 1, this.scene.playBgm();
duration: 250, evolvedPokemon.destroy();
easing: 'Sine.easeIn', this.end();
onComplete: () => { };
this.evolutionBgOverlay.setAlpha(1); this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
this.evolutionBg.setVisible(false); this.scene.ui.revertMode();
this.scene.tweens.add({ pokemon.pauseEvolutions = true;
targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ], this.scene.ui.showText(`Evolutions have been paused for ${preName}.`, null, end, 3000);
alpha: 0, }, () => {
duration: 2000, this.scene.ui.revertMode();
delay: 150, this.scene.time.delayedCall(3000, end);
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());
});
});
}
});
}
}); });
} });
}, 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); }, 1000);

View File

@ -515,7 +515,7 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator {
if (pregenArgs) if (pregenArgs)
return new EvolutionItemModifierType(pregenArgs[0] as EvolutionItem); 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]; 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))); 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); }).flat().filter(e => (e.item >= 100) === mega).flatMap(e => e.item);

View File

@ -65,6 +65,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
public moveset: PokemonMove[]; public moveset: PokemonMove[];
public status: Status; public status: Status;
public winCount: integer; public winCount: integer;
public pauseEvolutions: boolean;
public pokerus: boolean; public pokerus: boolean;
public fusionSpecies: PokemonSpecies; public fusionSpecies: PokemonSpecies;
@ -120,6 +121,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.moveset = dataSource.moveset; this.moveset = dataSource.moveset;
this.status = dataSource.status; this.status = dataSource.status;
this.winCount = dataSource.winCount; this.winCount = dataSource.winCount;
this.pauseEvolutions = dataSource.pauseEvolutions;
this.pokerus = !!dataSource.pokerus; this.pokerus = !!dataSource.pokerus;
this.fusionSpecies = dataSource.fusionSpecies instanceof PokemonSpecies ? dataSource.fusionSpecies : getPokemonSpecies(dataSource.fusionSpecies); this.fusionSpecies = dataSource.fusionSpecies instanceof PokemonSpecies ? dataSource.fusionSpecies : getPokemonSpecies(dataSource.fusionSpecies);
this.fusionFormIndex = dataSource.fusionFormIndex; this.fusionFormIndex = dataSource.fusionFormIndex;
@ -1716,14 +1718,18 @@ export class PlayerPokemon extends Pokemon {
}); });
} }
getPossibleEvolution(evolution: SpeciesEvolution): Pokemon { getPossibleEvolution(evolution: SpeciesEvolution): Promise<Pokemon> {
const species = getPokemonSpecies(evolution.speciesId); return new Promise(resolve => {
const formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0); const species = getPokemonSpecies(evolution.speciesId);
return new PlayerPokemon(this.scene, species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.ivs, this); 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<void> { evolve(evolution: SpeciesEvolution): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
this.pauseEvolutions = false;
this.handleSpecialEvolutions(evolution); this.handleSpecialEvolutions(evolution);
this.species = getPokemonSpecies(evolution.speciesId); this.species = getPokemonSpecies(evolution.speciesId);
if (evolution.preFormKey !== null) if (evolution.preFormKey !== null)

View File

@ -25,6 +25,7 @@ export default class PokemonData {
public moveset: PokemonMove[]; public moveset: PokemonMove[];
public status: Status; public status: Status;
public winCount: integer; public winCount: integer;
public pauseEvolutions: boolean;
public pokerus: boolean; public pokerus: boolean;
public fusionSpecies: Species; public fusionSpecies: Species;
@ -52,6 +53,7 @@ export default class PokemonData {
this.stats = source.stats; this.stats = source.stats;
this.ivs = source.ivs; this.ivs = source.ivs;
this.winCount = source.winCount; this.winCount = source.winCount;
this.pauseEvolutions = !!source.pauseEvolutions;
this.pokerus = !!source.pokerus; this.pokerus = !!source.pokerus;
this.fusionSpecies = sourcePokemon ? sourcePokemon.fusionSpecies?.speciesId : source.fusionSpecies; this.fusionSpecies = sourcePokemon ? sourcePokemon.fusionSpecies?.speciesId : source.fusionSpecies;

View File

@ -11,6 +11,7 @@ import { Moves, allMoves } from "../data/move";
import { getGenderColor, getGenderSymbol } from "../data/gender"; import { getGenderColor, getGenderSymbol } from "../data/gender";
import { StatusEffect } from "../data/status-effect"; import { StatusEffect } from "../data/status-effect";
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
import { pokemonEvolutions } from "../data/pokemon-evolutions";
const defaultMessage = 'Choose a Pokémon.'; const defaultMessage = 'Choose a Pokémon.';
@ -36,6 +37,7 @@ export enum PartyOption {
TRANSFER, TRANSFER,
SPLICE, SPLICE,
SUMMARY, SUMMARY,
UNPAUSE_EVO,
RELEASE, RELEASE,
SCROLL_UP = 1000, SCROLL_UP = 1000,
SCROLL_DOWN = 1001, SCROLL_DOWN = 1001,
@ -223,7 +225,7 @@ export default class PartyUiHandler extends MessageUiHandler {
} }
ui.playSelect(); ui.playSelect();
return true; 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)) { || (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) {
let filterResult: string; let filterResult: string;
if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) { if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) {
@ -270,6 +272,11 @@ export default class PartyUiHandler extends MessageUiHandler {
ui.playSelect(); ui.playSelect();
ui.setModeWithoutClear(Mode.SUMMARY, pokemon).then(() => this.clearOptions()); ui.setModeWithoutClear(Mode.SUMMARY, pokemon).then(() => this.clearOptions());
return true; 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) { } else if (option === PartyOption.RELEASE) {
this.clearOptions(); this.clearOptions();
ui.playSelect(); ui.playSelect();
@ -538,6 +545,9 @@ export default class PartyUiHandler extends MessageUiHandler {
this.options.push(PartyOption.SUMMARY); this.options.push(PartyOption.SUMMARY);
if (pokemon.pauseEvolutions && pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId))
this.options.push(PartyOption.UNPAUSE_EVO);
if (this.partyUiMode === PartyUiMode.SWITCH) if (this.partyUiMode === PartyUiMode.SWITCH)
this.options.push(PartyOption.RELEASE); this.options.push(PartyOption.RELEASE);
} else if (this.partyUiMode === PartyUiMode.MOVE_MODIFIER) { } else if (this.partyUiMode === PartyUiMode.MOVE_MODIFIER) {
@ -589,6 +599,9 @@ export default class PartyUiHandler extends MessageUiHandler {
case PartyOption.MOVE_4: case PartyOption.MOVE_4:
optionName = pokemon.moveset[option - PartyOption.MOVE_1].getName(); optionName = pokemon.moveset[option - PartyOption.MOVE_1].getName();
break; break;
case PartyOption.UNPAUSE_EVO:
optionName = 'Unpause Evo.';
break;
default: default:
optionName = Utils.toReadableString(PartyOption[option]); optionName = Utils.toReadableString(PartyOption[option]);
break; break;