diff --git a/battle-engine.js b/battle-engine.js index eb1ab5a683..dc6a13e75c 100644 --- a/battle-engine.js +++ b/battle-engine.js @@ -200,7 +200,8 @@ BattlePokemon = (function () { this.baseAbility = toId(set.ability); this.ability = this.baseAbility; this.item = toId(set.item); - if (this.baseTemplate.otherFormes) var forme = this.battle.getTemplate(this.baseTemplate.otherFormes[0]); + var forme; + if (this.baseTemplate.otherFormes) forme = this.battle.getTemplate(this.baseTemplate.otherFormes[0]); this.canMegaEvo = ((this.battle.getItem(this.item).megaEvolves === this.baseTemplate.baseSpecies) || (forme && forme.isMega && forme.requiredMove && this.set.moves.indexOf(toId(forme.requiredMove)) > -1)); this.abilityData = {id: this.ability}; this.itemData = {id: this.item}; diff --git a/data/scripts.js b/data/scripts.js index d240f19319..c959975a76 100644 --- a/data/scripts.js +++ b/data/scripts.js @@ -537,14 +537,16 @@ exports.BattleScripts = { var side = pokemon.side; if (side.megaEvo) return false; - if (pokemon.baseTemplate.otherFormes) var otherForme = this.getTemplate(pokemon.baseTemplate.otherFormes[0]); + var otherForme; + var template; + if (pokemon.baseTemplate.otherFormes) otherForme = this.getTemplate(pokemon.baseTemplate.otherFormes[0]); if (otherForme && otherForme.isMega && otherForme.requiredMove) { if (pokemon.moves.indexOf(toId(otherForme.requiredMove)) < 0) return false; - var template = otherForme; + template = otherForme; } else { var item = this.getItem(pokemon.item); if (!item.megaStone) return false; - var template = this.getTemplate(item.megaStone); + template = this.getTemplate(item.megaStone); if (pokemon.baseTemplate.baseSpecies !== template.baseSpecies) return false; } if (!template.isMega) return false;