Improve handling of sprite data

- Don't try to use nonexistent resources for CAP or recent Pokémon in old-gen battles.
- Don't try to play invalid cries.
- Do use Substitute old-gen sprites according to the played gen.
This also removes Substitutes' being numbered as 0, and adds to its animation data a `exists` flag set to `false`.

Fixes #562
This commit is contained in:
Ivo Julca
2015-12-01 01:03:31 -05:00
parent 10659ae202
commit c821665d02
3 changed files with 15 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ BattlePokemonSprites = {
"volkraken": {num:-18},
"plasmanta": {num:-19, front:{ani:{w:143,h:105}}, back:{ani:{w:141,h:140}}},
"naviathan": {num:-20, front:{ani:{w:142,h:119}}, back:{ani:{w:147,h:111}}},
"substitute": {num:0, front:{ani:{w:34,h:39}}, back:{ani:{w:37,h:38}}},
"substitute": {exists:false, front:{ani:{w:34,h:39}}, back:{ani:{w:37,h:38}}},
"bulbasaur": {num:1, front:{ani:{w:45,h:49}}, back:{ani:{w:52,h:50}}},
"ivysaur": {num:2, front:{ani:{w:84,h:66}}, back:{ani:{w:76,h:68}}},
"venusaur": {num:3, front:{ani:{w:106,h:77}}, back:{ani:{w:95,h:78}}},

View File

@@ -835,7 +835,10 @@ var Sprite = (function () {
}
};
Sprite.prototype.animSub = function () {
var subsp = Tools.getSpriteData('substitute', this.siden, {afd: this.battle.tier === "[Seasonal] Fools Festival"});
var subsp = Tools.getSpriteData('substitute', this.siden, {
afd: this.battle.tier === "[Seasonal] Fools Festival",
gen: this.battle.gen
});
this.subsp = subsp;
this.iw = subsp.w;
this.ih = subsp.h;

View File

@@ -966,7 +966,7 @@ var Tools = {
}
// Decide what gen sprites to use.
var gen = {1:'rby', 2:'gsc', 3:'rse', 4:'dpp', 5:'bw', 6:'xy'}[options.gen];
var gen = {1:'rby', 2:'gsc', 3:'rse', 4:'dpp', 5:'bw', 6:'xy'}[Math.max(options.gen, pokemon.gen)];
if (Tools.prefs('nopastgens')) gen = 'xy';
if (Tools.prefs('bwgfx') && gen === 'xy') gen = 'bw';
@@ -976,12 +976,12 @@ var Tools = {
} else {
animationData = BattlePokemonSprites && window.BattlePokemonSprites[pokemon.speciesid];
}
if (animationData) {
if (animationData && typeof animationData.num !== 'undefined') {
var num = '' + animationData.num;
if (num.length < 3) num = '0' + num;
if (num.length < 3) num = '0' + num;
spriteData.cryurl = 'audio/cries/' + num;
if (pokemon.forme && (pokemon.forme.substr(0, 4) === 'Mega' || pokemon.forme === 'Sky' || pokemon.forme === 'Therian' || pokemon.forme === 'Black' || pokemon.forme === 'White' || pokemon.forme === 'Super')) {
if (pokemon.isMega || pokemon.forme && (pokemon.forme === 'Sky' || pokemon.forme === 'Therian' || pokemon.forme === 'Black' || pokemon.forme === 'White' || pokemon.forme === 'Super')) {
spriteData.cryurl += pokemon.formeid;
}
spriteData.cryurl += '.wav';
@@ -1012,8 +1012,13 @@ var Tools = {
return spriteData;
}
}
// if there is no entry or enough data in pokedex-mini.js or the animations are disabled or past gen, use the proper sprites
gen = (gen === 'xy') ? 'bw' : gen;
// There is no entry or enough data in pokedex-mini.js
// Handle these in case-by-case basis; either using BW sprites or matching the played gen.
if (pokemon.speciesid !== 'substitute') {
if (pokemon.tier === 'CAP') gen = 'bw';
if (gen === 'xy') gen = 'bw';
}
dir = gen + dir;
spriteData.url += dir + '/' + name + '.png';