diff --git a/src/battle-animations.ts b/src/battle-animations.ts
index 70bad46b4..616082d25 100644
--- a/src/battle-animations.ts
+++ b/src/battle-animations.ts
@@ -825,8 +825,11 @@ export class BattleScene implements BattleSceneStub {
if (textBuf) textBuf += ' / ';
textBuf += pokemon.speciesForme;
let url = spriteData.url;
+ var placeholderSprite = spriteData.isFrontSprite // Pet Mods placeholder sprites
+ ? "https://play.pokemonshowdown.com/sprites/gen5/substitute.png"
+ : "https://play.pokemonshowdown.com/sprites/gen5-back/substitute.png";
// if (this.paused) url.replace('/xyani', '/xy').replace('.gif', '.png');
- buf += '';
+ buf += '';
buf2 += '
';
const gender = pokemon.gender;
if (gender === 'M' || gender === 'F') {
diff --git a/src/battle-dex.ts b/src/battle-dex.ts
index 1d0124ccd..3594836a0 100644
--- a/src/battle-dex.ts
+++ b/src/battle-dex.ts
@@ -722,7 +722,15 @@ const Dex = new class implements ModdedDex {
spriteData.h *= 1.5;
spriteData.y += -11;
}
-
+ // Placeholder sprites for Pet Mods Fakemons with no sprite data
+ checkSpriteExists(spriteData.url, function(exists: any) {
+ if (!exists) {
+ spriteData = Dex.getSpriteData('substitute', spriteData.isFrontSprite, {
+ gen: options.gen,
+ mod: options.mod,
+ })
+ }
+ });
return spriteData;
}
@@ -1147,3 +1155,16 @@ if (typeof require === 'function') {
(global as any).Dex = Dex;
(global as any).toID = toID;
}
+
+function checkSpriteExists(url: string, callback: any) {
+ var img = new Image();
+ img.onload = function() {
+ // The image exists
+ callback(true);
+ };
+ img.onerror = function() {
+ // The image does not exist or could not be loaded
+ callback(false);
+ };
+ img.src = url;
+}