diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 924c66277cb..c8965646957 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -211,7 +211,7 @@ export abstract class PokemonSpeciesForm { return `${/_[1-3]$/.test(spriteId) ? 'variant/' : ''}${spriteId}`; } - getSpriteId(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer): string { + getSpriteId(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer, back?: boolean): string { if (formIndex === undefined || this instanceof PokemonForm) formIndex = this.formIndex; @@ -222,10 +222,10 @@ export abstract class PokemonSpeciesForm { let variantSet: VariantSet; let config = variantData; - baseSpriteKey.split('__').map(p => config = variantData[p]); + `${back ? 'back__' : ''}${baseSpriteKey}`.split('__').map(p => config ? config = config[p] : null); variantSet = config as VariantSet; - return `${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? 'shiny__' : ''}${baseSpriteKey}${shiny && variantSet && variantSet[variant || 0] === 2 ? `_${variant + 1}` : ''}`; + return `${back ? 'back__' : ''}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? 'shiny__' : ''}${baseSpriteKey}${shiny && variantSet && variantSet[variant || 0] === 2 ? `_${variant + 1}` : ''}`; } getSpriteKey(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer): string { @@ -386,7 +386,7 @@ export abstract class PokemonSpeciesForm { spritePath = `exp/${spritePath}`; let variantSet: VariantSet; let config = variantData; - spritePath.split('/').map(p => config = variantData[p]); + spritePath.split('/').map(p => config ? config = config[p] : null); variantSet = config as VariantSet; if (variantSet && variantSet[variant] === 1) { const populateVariantColors = (key: string): Promise => { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 993d5bb41d9..6fd584d5311 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -310,7 +310,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const battleSpritePath = this.getBattleSpriteAtlasPath(back, ignoreOverride); let variantSet: VariantSet; let config = variantData; - battleSpritePath.split('/').map(p => config = variantData[p]); + battleSpritePath.split('/').map(p => config ? config = config[p] : null); variantSet = config as VariantSet; if (variantSet && variantSet[this.variant] === 1) { if (variantColorCache.hasOwnProperty(key)) @@ -367,7 +367,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getBattleSpriteId(back?: boolean, ignoreOverride?: boolean): string { if (back === undefined) back = this.isPlayer(); - return `${back ? 'back__' : ''}${this.getSpriteId(ignoreOverride)}`; + return this.getSpeciesForm(ignoreOverride).getSpriteId(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant, back); } getSpriteKey(ignoreOverride?: boolean): string { @@ -385,7 +385,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getFusionBattleSpriteId(back?: boolean, ignoreOverride?: boolean): string { if (back === undefined) back = this.isPlayer(); - return `${back ? 'back__' : ''}${this.getFusionSpriteId(ignoreOverride)}`; + return this.getFusionSpeciesForm(ignoreOverride).getSpriteId(this.getFusionGender(ignoreOverride) === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny, this.fusionVariant, back); } getFusionBattleSpriteKey(back?: boolean, ignoreOverride?: boolean): string {