Fix some bugs and add seen Pokemon to starter screen

This commit is contained in:
Flashfyre 2024-02-18 22:21:57 -05:00
parent 22054dddd5
commit 2f8df43db8
10 changed files with 80 additions and 38 deletions

View File

@ -3191,7 +3191,11 @@ export class PokemonHealPhase extends CommonAnimPhase {
this.scene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier);
const healAmount = new Utils.NumberHolder(this.hpHealed * hpRestoreMultiplier.value);
healAmount.value = pokemon.heal(healAmount.value);
this.scene.validateAchvs(HealAchv, healAmount);
if (pokemon.isPlayer()) {
this.scene.validateAchvs(HealAchv, healAmount);
if (healAmount.value > this.scene.gameData.gameStats.highestHeal)
this.scene.gameData.gameStats.highestHeal = healAmount.value;
}
pokemon.updateInfo().then(() => super.end());
} else if (this.showFullHpMessage)
this.message = getPokemonMessage(pokemon, `'s\nHP is full!`);

View File

@ -1058,7 +1058,7 @@ export default class BattleScene extends Phaser.Scene {
addPokemonSprite(pokemon: Pokemon, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, hasShadow: boolean = false, ignoreOverride: boolean = false): Phaser.GameObjects.Sprite {
const ret = this.addFieldSprite(x, y, texture, frame);
this.initPokemonSprite(ret, pokemon);
this.initPokemonSprite(ret, pokemon, hasShadow, ignoreOverride);
return ret;
}

View File

@ -68,10 +68,10 @@ export function getTypeDamageMultiplier(attackType: integer, defType: integer):
case Type.ELECTRIC:
case Type.ICE:
case Type.DRAGON:
case Type.DARK:
return 1;
case Type.ROCK:
case Type.BUG:
case Type.DARK:
return 0.5;
default:
return 0;

View File

@ -116,11 +116,13 @@ export class FormChangePhase extends EvolutionPhase {
this.scene.time.delayedCall(250, () => {
this.pokemon.cry();
this.scene.time.delayedCall(1250, () => {
const isMega = this.formChange.formKey.indexOf(SpeciesFormKey.MEGA) > -1;
let playEvolutionFanfare = false;
if (isMega) {
if (this.formChange.formKey.indexOf(SpeciesFormKey.MEGA) > -1) {
this.scene.validateAchv(achvs.MEGA_EVOLVE);
playEvolutionFanfare = true;
} else if (this.formChange.formKey.indexOf(SpeciesFormKey.GIGANTAMAX) > -1 || this.formChange.formKey.indexOf(SpeciesFormKey.ETERNAMAX) > -1) {
this.scene.validateAchv(achvs.GIGANTAMAX);
playEvolutionFanfare = true;
}
const delay = playEvolutionFanfare ? 4000 : 1750;

View File

@ -14,7 +14,7 @@ import * as Utils from "../utils";
import { TempBattleStat } from '../data/temp-battle-stat';
import { BerryType, getBerryEffectFunc, getBerryPredicate } from '../data/berry';
import { StatusEffect, getStatusEffectDescriptor } from '../data/status-effect';
import { MoneyAchv } from '../system/achv';
import { MoneyAchv, achvs } from '../system/achv';
import { VoucherType } from '../system/voucher';
import { PreventBerryUseAbAttr, applyAbAttrs } from '../data/ability';
import { FormChangeItem, SpeciesFormChangeItemTrigger } from '../data/pokemon-forms';
@ -564,6 +564,9 @@ export class TerastallizeModifier extends LapsingPokemonHeldItemModifier {
apply(args: any[]): boolean {
const pokemon = args[0] as Pokemon;
pokemon.scene.validateAchv(achvs.TERASTALLIZE);
if (this.teraType === Type.STELLAR)
pokemon.scene.validateAchv(achvs.STELLAR_TERASTALLIZE);
pokemon.updateSpritePipelineData();
return true;
}

View File

@ -860,7 +860,7 @@ export class GameData {
} while (pokemonPrevolutions.hasOwnProperty(speciesId) && (speciesId = pokemonPrevolutions[speciesId]));
}
getSpeciesDefaultDexAttr(species: PokemonSpecies): bigint {
getSpeciesDefaultDexAttr(species: PokemonSpecies, forSeen: boolean = false): bigint {
let ret = 0n;
const dexEntry = this.dexData[species.speciesId];
const attr = dexEntry.caughtAttr;

View File

@ -10,6 +10,8 @@ export class GameStats {
public highestEndlessWave: integer;
public highestLevel: integer;
public highestMoney: integer;
public highestDamage: integer;
public highestHeal: integer;
public pokemonSeen: integer;
public pokemonDefeated: integer;
public pokemonCaught: integer;
@ -40,6 +42,8 @@ export class GameStats {
this.highestEndlessWave = source?.highestEndlessWave || 0;
this.highestLevel = source?.highestLevel || 0;
this.highestMoney = source?.highestMoney || 0;
this.highestDamage = source?.highestDamage || 0;
this.highestHeal = source?.highestHeal || 0;
this.pokemonSeen = source?.pokemonSeen || 0;
this.pokemonDefeated = source?.pokemonDefeated || 0;
this.pokemonCaught = source?.pokemonCaught || 0;

View File

@ -75,6 +75,8 @@ const displayStats: DisplayStats = {
endlessSessionsPlayed: 'Runs (Endless)?',
highestEndlessWave: 'Highest Wave (Endless)?',
highestMoney: 'Highest Money',
highestDamage: 'Highest Damage',
highestHeal: 'Highest HP Healed',
pokemonSeen: 'Pokémon Encountered',
pokemonDefeated: 'Pokémon Defeated',
pokemonCaught: 'Pokémon Caught',

View File

@ -18,7 +18,6 @@ import { Nature, getNatureName } from "../data/nature";
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
import { pokemonFormChanges } from "../data/pokemon-forms";
import { Tutorial, handleTutorial } from "../tutorial";
import PokemonSpriteSparkleHandler from "../sprite/pokemon-sprite-sparkle-handler";
export type StarterSelectCallback = (starters: Starter[]) => void;
@ -40,6 +39,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private pokemonGrowthRateLabelText: Phaser.GameObjects.Text;
private pokemonGrowthRateText: Phaser.GameObjects.Text;
private pokemonGenderText: Phaser.GameObjects.Text;
private pokemonUncaughtText: Phaser.GameObjects.Text;
private pokemonAbilityLabelText: Phaser.GameObjects.Text;
private pokemonAbilityText: Phaser.GameObjects.Text;
private pokemonNatureLabelText: Phaser.GameObjects.Text;
@ -140,6 +140,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonGenderText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonGenderText);
this.pokemonUncaughtText = addTextObject(this.scene, 6, 126, 'Uncaught', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonUncaughtText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonUncaughtText);
this.pokemonAbilityLabelText = addTextObject(this.scene, 6, 126, 'Ability:', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonAbilityLabelText.setOrigin(0, 0);
this.pokemonAbilityLabelText.setVisible(false);
@ -244,7 +248,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
icon.setScale(0.5);
icon.setOrigin(0, 0);
icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny));
icon.setTintFill(0);
icon.setTint(0);
this.starterSelectGenIconContainers[g].add(icon);
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.NONE);
s++;
@ -356,6 +360,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
const icon = this.starterSelectGenIconContainers[g].getAt(s) as Phaser.GameObjects.Sprite;
if (dexEntry.caughtAttr)
icon.clearTint();
else if (dexEntry.seenAttr)
icon.setTint(0x808080);
});
}
@ -762,56 +768,78 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.lastSpecies = species;
if (species && this.speciesStarterDexEntry?.caughtAttr) {
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr)) {
this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4));
this.pokemonNameText.setText(species.name);
this.pokemonGrowthRateText.setText(Utils.toReadableString(GrowthRate[species.growthRate]));
this.pokemonGrowthRateText.setColor(getGrowthRateColor(species.growthRate));
this.pokemonGrowthRateText.setShadowColor(getGrowthRateColor(species.growthRate, true));
this.pokemonGrowthRateLabelText.setVisible(true);
this.pokemonAbilityLabelText.setVisible(true);
this.pokemonNatureLabelText.setVisible(true);
this.pokemonCaughtCountLabelText.setVisible(true);
this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry.caughtCount}/${this.speciesStarterDexEntry.hatchedCount} (${this.speciesStarterDexEntry.caughtCount + this.speciesStarterDexEntry.hatchedCount})`);
this.pokemonCaughtCountText.setVisible(true);
this.iconAnimHandler.addOrUpdate(this.starterSelectGenIconContainers[species.generation - 1].getAt(this.genSpecies[species.generation - 1].indexOf(species)) as Phaser.GameObjects.Sprite, PokemonIconAnimMode.PASSIVE);
let starterIndex = -1;
if (this.speciesStarterDexEntry?.caughtAttr) {
this.pokemonGrowthRateText.setText(Utils.toReadableString(GrowthRate[species.growthRate]));
this.pokemonGrowthRateText.setColor(getGrowthRateColor(species.growthRate));
this.pokemonGrowthRateText.setShadowColor(getGrowthRateColor(species.growthRate, true));
this.pokemonGrowthRateLabelText.setVisible(true);
this.pokemonUncaughtText.setVisible(false);
this.pokemonAbilityLabelText.setVisible(true);
this.pokemonNatureLabelText.setVisible(true);
this.pokemonCaughtCountLabelText.setVisible(true);
this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry.caughtCount}/${this.speciesStarterDexEntry.hatchedCount} (${this.speciesStarterDexEntry.caughtCount + this.speciesStarterDexEntry.hatchedCount})`);
this.pokemonCaughtCountText.setVisible(true);
this.iconAnimHandler.addOrUpdate(this.starterSelectGenIconContainers[species.generation - 1].getAt(this.genSpecies[species.generation - 1].indexOf(species)) as Phaser.GameObjects.Sprite, PokemonIconAnimMode.PASSIVE);
this.starterGens.every((g, i) => {
const starterSpecies = this.genSpecies[g][this.starterCursors[i]];
if (starterSpecies.speciesId === species.speciesId) {
starterIndex = i;
return false;
let starterIndex = -1;
this.starterGens.every((g, i) => {
const starterSpecies = this.genSpecies[g][this.starterCursors[i]];
if (starterSpecies.speciesId === species.speciesId) {
starterIndex = i;
return false;
}
return true;
});
if (starterIndex > -1) {
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.starterAttr[starterIndex]);
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, this.starterNatures[starterIndex]);
} else {
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
const props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, defaultNature);
}
return true;
});
if (starterIndex > -1) {
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.starterAttr[starterIndex]);
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, this.starterNatures[starterIndex]);
this.pokemonSprite.clearTint();
} else {
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
this.pokemonGrowthRateText.setText('');
this.pokemonGrowthRateLabelText.setVisible(false);
this.pokemonUncaughtText.setVisible(true);
this.pokemonAbilityLabelText.setVisible(false);
this.pokemonNatureLabelText.setVisible(false);
this.pokemonCaughtCountLabelText.setVisible(false);
this.pokemonCaughtCountText.setVisible(false);
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species, true);
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
const props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, defaultNature);
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, defaultNature, true);
this.pokemonSprite.setTint(0x808080);
}
} else {
this.pokemonNumberText.setText(Utils.padInt(0, 4));
this.pokemonNameText.setText(species ? '???' : '');
this.pokemonGrowthRateText.setText('');
this.pokemonGrowthRateLabelText.setVisible(false);
this.pokemonUncaughtText.setVisible(!!species);
this.pokemonAbilityLabelText.setVisible(false);
this.pokemonNatureLabelText.setVisible(false);
this.pokemonCaughtCountLabelText.setVisible(false);
this.pokemonCaughtCountText.setVisible(false);
this.setSpeciesDetails(species, false, 0, false, 0, 0);
this.pokemonSprite.clearTint();
}
}
setSpeciesDetails(species: PokemonSpecies, shiny: boolean, formIndex: integer, female: boolean, abilityIndex: integer, natureIndex: integer): void {
setSpeciesDetails(species: PokemonSpecies, shiny: boolean, formIndex: integer, female: boolean, abilityIndex: integer, natureIndex: integer, forSeen: boolean = false): void {
const oldProps = species ? this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor) : null;
this.dexAttrCursor = 0n;
@ -836,7 +864,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
if (species) {
const dexEntry = this.scene.gameData.dexData[species.speciesId];
if (!dexEntry.caughtAttr) {
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.scene.gameData.getSpeciesDefaultDexAttr(species));
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.scene.gameData.getSpeciesDefaultDexAttr(species, forSeen));
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
if (shiny === undefined || shiny !== props.shiny)
shiny = props.shiny;
@ -850,7 +878,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
natureIndex = defaultNature;
}
if (this.speciesStarterDexEntry?.caughtAttr) {
if (forSeen ? this.speciesStarterDexEntry?.seenAttr : this.speciesStarterDexEntry?.caughtAttr) {
let starterIndex = -1;
this.starterGens.every((g, i) => {

View File

@ -2,7 +2,6 @@ import BBCodeText from "phaser3-rex-plugins/plugins/gameobjects/tagtext/bbcodete
import BattleScene from "../battle-scene";
import { Stat, getStatName } from "../data/pokemon-stat";
import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text";
import { Gender, getGenderColor } from "../data/gender";
const ivChartSize = 24;
const ivChartStatCoordMultipliers = [ [ 0, 1 ], [ 0.825, 0.5 ], [ 0.825, -0.5 ], [ 0, -1 ], [ -0.825, -0.5 ], [ -0.825, 0.5 ] ];