Add experimental animated sprites

This commit is contained in:
Flashfyre committed 2024-02-24 21:16:19 -05:00
1 parent 10ff9c4775
commit d72dd93212
4662 files changed
+1966555 -3031

No files matched your search

+33 -1
View File
@@ -2,7 +2,7 @@ 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, MovePhase } from './phases';
import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon';
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species';
import PokemonSpecies, { PokemonSpeciesFilter, SpeciesFormKey, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species';
import * as Utils from './utils';
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier } from './modifier/modifier';
import { PokeballType } from './data/pokeball';
@@ -61,6 +61,8 @@ export const startingWave = 1;
export const startingBiome = Biome.TOWN;
export const startingMoney = 1000;
const expSpriteKeys: string[] = [];
export enum Button {
UP,
DOWN,
@@ -99,6 +101,7 @@ export default class BattleScene extends Phaser.Scene {
public showLevelUpStats: boolean = true;
public enableTutorials: boolean = true;
public windowType: integer = 1;
public experimentalSprites: boolean = false;
public enableTouchControls: boolean = false;
public enableVibration: boolean = false;
public quickStart: boolean = quickStart;
@@ -185,6 +188,26 @@ export default class BattleScene extends Phaser.Scene {
this.load.atlas(key, `images/${folder}${filenameRoot}.png`, `images/${folder}/${filenameRoot}.json`);
}
loadPokemonAtlas(key: string, atlasPath: string, experimental?: boolean) {
if (experimental === undefined)
experimental = this.experimentalSprites;
if (experimental) {
const keyMatch = /^pkmn__(back__)?(shiny__)?(female__)?(\d+)(\-.*?)?$/g.exec(key);
let k = keyMatch[4];
if (keyMatch[2])
k += 's';
if (keyMatch[1])
k += 'b';
if (keyMatch[3])
k += 'f';
if (keyMatch[5])
k += keyMatch[5];
if (expSpriteKeys.indexOf(k) === -1)
experimental = false;
}
this.load.atlas(key, `images/pokemon/${experimental ? 'exp/' : ''}${atlasPath}.png`, `images/pokemon/${experimental ? 'exp/' : ''}${atlasPath}.json`);
}
loadSpritesheet(key: string, folder: string, size: integer, filename?: string) {
if (!filename)
filename = `${key}.png`;
@@ -631,6 +654,15 @@ export default class BattleScene extends Phaser.Scene {
this.updateMoneyText();
}
initExpSprites(): void {
if (expSpriteKeys.length)
return;
fetch('./exp_sprites.json').then(res => res.json()).then(keys => {
if (Array.isArray(keys))
expSpriteKeys.push(...keys);
});
}
setupControls() {
const keyCodes = Phaser.Input.Keyboard.KeyCodes;
const keyConfig = {
+8 -4
View File
@@ -274,8 +274,9 @@ export abstract class PokemonSpeciesForm {
loadAssets(scene: BattleScene, female: boolean, formIndex?: integer, shiny?: boolean, startLoad?: boolean): Promise<void> {
return new Promise(resolve => {
const spriteKey = this.getSpriteKey(female, formIndex, shiny);
scene.load.audio(this.getCryKey(formIndex), `audio/cry/${this.getCryKey(formIndex)}.ogg`);
scene.loadAtlas(this.getSpriteKey(female, formIndex, shiny), 'pokemon', this.getSpriteAtlasPath(female, formIndex, shiny));
scene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny));
scene.load.once(Phaser.Loader.Events.COMPLETE, () => {
const originalWarn = console.warn;
// Ignore warnings for missing frames, because there will be a lot
@@ -1689,8 +1690,8 @@ export function initSpecies() {
new PokemonSpecies(Species.NOIBAT, "Noibat", 6, false, false, false, "Sound Wave Pokémon", Type.FLYING, Type.DRAGON, 0.5, 8, Abilities.FRISK, Abilities.INFILTRATOR, Abilities.TELEPATHY, 245, 40, 30, 35, 45, 40, 55, 190, 50, 49, GrowthRate.MEDIUM_FAST, 50, false),
new PokemonSpecies(Species.NOIVERN, "Noivern", 6, false, false, false, "Sound Wave Pokémon", Type.FLYING, Type.DRAGON, 1.5, 85, Abilities.FRISK, Abilities.INFILTRATOR, Abilities.TELEPATHY, 535, 85, 70, 80, 97, 80, 123, 45, 50, 187, GrowthRate.MEDIUM_FAST, 50, false),
new PokemonSpecies(Species.XERNEAS, "Xerneas", 6, false, true, false, "Life Pokémon", Type.FAIRY, null, 3, 215, Abilities.FAIRY_AURA, Abilities.NONE, Abilities.NONE, 680, 126, 131, 95, 131, 98, 99, 45, 0, 340, GrowthRate.SLOW, null, false, true,
new PokemonForm("Active Mode", "active", Type.FAIRY, null, 3, 215, Abilities.FAIRY_AURA, Abilities.NONE, Abilities.NONE, 680, 126, 131, 95, 131, 98, 99, 45, 0, 340, false, ""),
new PokemonForm("Neutral Mode", "neutral", Type.FAIRY, null, 3, 215, Abilities.FAIRY_AURA, Abilities.NONE, Abilities.NONE, 680, 126, 131, 95, 131, 98, 99, 45, 0, 340, false, ""),
new PokemonForm("Neutral Mode", "neutral", Type.FAIRY, null, 3, 215, Abilities.FAIRY_AURA, Abilities.NONE, Abilities.NONE, 680, 126, 131, 95, 131, 98, 99, 45, 0, 340),
new PokemonForm("Active Mode", "active", Type.FAIRY, null, 3, 215, Abilities.FAIRY_AURA, Abilities.NONE, Abilities.NONE, 680, 126, 131, 95, 131, 98, 99, 45, 0, 340)
),
new PokemonSpecies(Species.YVELTAL, "Yveltal", 6, false, true, false, "Destruction Pokémon", Type.DARK, Type.FLYING, 5.8, 203, Abilities.DARK_AURA, Abilities.NONE, Abilities.NONE, 680, 126, 131, 95, 131, 98, 99, 45, 0, 340, GrowthRate.SLOW, null, false),
new PokemonSpecies(Species.ZYGARDE, "Zygarde", 6, true, false, false, "Order Pokémon", Type.DRAGON, Type.GROUND, 5, 305, Abilities.AURA_BREAK, Abilities.NONE, Abilities.NONE, 600, 108, 100, 121, 81, 95, 95, 3, 0, 300, GrowthRate.SLOW, null, false, false,
@@ -1849,7 +1850,10 @@ export function initSpecies() {
new PokemonForm("Normal", "", Type.STEEL, Type.FAIRY, 1, 80.5, Abilities.SOUL_HEART, Abilities.NONE, Abilities.NONE, 600, 80, 95, 115, 130, 115, 65, 3, 0, 300),
new PokemonForm("Original", "original", Type.STEEL, Type.FAIRY, 1, 80.5, Abilities.SOUL_HEART, Abilities.NONE, Abilities.NONE, 600, 80, 95, 115, 130, 115, 65, 3, 0, 300),
),
new PokemonSpecies(Species.MARSHADOW, "Marshadow", 7, true, false, true, "Gloomdweller Pokémon", Type.FIGHTING, Type.GHOST, 0.7, 22.2, Abilities.TECHNICIAN, Abilities.NONE, Abilities.NONE, 600, 90, 125, 80, 90, 90, 125, 3, 0, 300, GrowthRate.SLOW, null, false),
new PokemonSpecies(Species.MARSHADOW, "Marshadow", 7, true, false, true, "Gloomdweller Pokémon", Type.FIGHTING, Type.GHOST, 0.7, 22.2, Abilities.TECHNICIAN, Abilities.NONE, Abilities.NONE, 600, 90, 125, 80, 90, 90, 125, 3, 0, 300, GrowthRate.SLOW, null, false, true,
new PokemonForm("Normal", "", Type.FIGHTING, Type.GHOST, 0.7, 22.2, Abilities.TECHNICIAN, Abilities.NONE, Abilities.NONE, 600, 90, 125, 80, 90, 90, 125, 3, 0, 300),
new PokemonForm("Zenith", "zenith", Type.FIGHTING, Type.GHOST, 0.7, 22.2, Abilities.TECHNICIAN, Abilities.NONE, Abilities.NONE, 600, 90, 125, 80, 90, 90, 125, 3, 0, 300)
),
new PokemonSpecies(Species.POIPOLE, "Poipole", 7, true, false, false, "Poison Pin Pokémon", Type.POISON, null, 0.6, 1.8, Abilities.BEAST_BOOST, Abilities.NONE, Abilities.NONE, 420, 67, 73, 67, 73, 67, 73, 45, 0, 210, GrowthRate.SLOW, null, false),
new PokemonSpecies(Species.NAGANADEL, "Naganadel", 7, true, false, false, "Poison Pin Pokémon", Type.POISON, Type.DRAGON, 3.6, 150, Abilities.BEAST_BOOST, Abilities.NONE, Abilities.NONE, 540, 73, 73, 73, 127, 73, 121, 45, 0, 270, GrowthRate.SLOW, null, false),
new PokemonSpecies(Species.STAKATAKA, "Stakataka", 7, true, false, false, "Rampart Pokémon", Type.ROCK, Type.STEEL, 5.5, 820, Abilities.BEAST_BOOST, Abilities.NONE, Abilities.NONE, 570, 61, 131, 211, 53, 101, 13, 30, 0, 285, GrowthRate.SLOW, null, false),
+2 -2
View File
@@ -276,10 +276,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
loadMoveAnimAssets(this.scene, moveIds);
this.getSpeciesForm().loadAssets(this.scene, this.getGender() === Gender.FEMALE, this.formIndex, this.shiny);
if (this.isPlayer() || this.getFusionSpeciesForm())
this.scene.loadAtlas(this.getBattleSpriteKey(true), 'pokemon', this.getBattleSpriteAtlasPath(true));
this.scene.loadPokemonAtlas(this.getBattleSpriteKey(true, true), this.getBattleSpriteAtlasPath(true, true));
if (this.getFusionSpeciesForm()) {
this.getFusionSpeciesForm().loadAssets(this.scene, this.getFusionGender() === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny);
this.scene.loadAtlas(this.getFusionBattleSpriteKey(true), 'pokemon', this.getFusionBattleSpriteAtlasPath(true));
this.scene.loadPokemonAtlas(this.getFusionBattleSpriteKey(true, true), this.getFusionBattleSpriteAtlasPath(true, true));
}
this.scene.load.once(Phaser.Loader.Events.COMPLETE, () => {
if (this.isPlayer()) {
+8
View File
@@ -10,6 +10,7 @@ export enum Setting {
Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS",
Window_Type = "WINDOW_TYPE",
Tutorials = "TUTORIALS",
Sprite_Set = "SPRITE_SET",
Player_Gender = "PLAYER_GENDER",
Touch_Controls = "TOUCH_CONTROLS",
Vibration = "VIBRATION"
@@ -31,6 +32,7 @@ export const settingOptions: SettingOptions = {
[Setting.Show_Stats_on_Level_Up]: [ 'Off', 'On' ],
[Setting.Window_Type]: new Array(4).fill(null).map((_, i) => (i + 1).toString()),
[Setting.Tutorials]: [ 'Off', 'On' ],
[Setting.Sprite_Set]: [ 'Consistent', 'Prioritize Animation' ],
[Setting.Player_Gender]: [ 'Boy', 'Girl' ],
[Setting.Touch_Controls]: [ 'Auto', 'Disabled' ],
[Setting.Vibration]: [ 'Auto', 'Disabled' ]
@@ -44,6 +46,7 @@ export const settingDefaults: SettingDefaults = {
[Setting.Show_Stats_on_Level_Up]: 1,
[Setting.Window_Type]: 0,
[Setting.Tutorials]: 1,
[Setting.Sprite_Set]: 0,
[Setting.Player_Gender]: 0,
[Setting.Touch_Controls]: 0,
[Setting.Vibration]: 0
@@ -75,6 +78,11 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
case Setting.Tutorials:
scene.enableTutorials = settingOptions[setting][value] === 'On';
break;
case Setting.Sprite_Set:
scene.experimentalSprites = !!value;
if (value)
scene.initExpSprites();
break;
case Setting.Player_Gender:
if (scene.gameData) {
const female = settingOptions[setting][value] === 'Girl';
+2 -1
View File
@@ -1,4 +1,5 @@
import BattleScene from "../battle-scene";
import * as Utils from "../utils";
export default class CharSprite extends Phaser.GameObjects.Container {
private sprite: Phaser.GameObjects.Sprite;
@@ -53,7 +54,7 @@ export default class CharSprite extends Phaser.GameObjects.Container {
}
});
this.setVisible(this.scene.textures.get(key).key !== '__MISSING');
this.setVisible(this.scene.textures.get(key).key !== Utils.MissingTextureKey);
this.shown = true;
this.key = key;
+2
View File
@@ -1,3 +1,5 @@
export const MissingTextureKey = '__MISSING';
export function toReadableString(str: string): string {
return str.replace(/\_/g, ' ').split(' ').map(s => `${s.slice(0, 1)}${s.slice(1).toLowerCase()}`).join(' ');
}