From 2eebf29d92b9e5b66a8ea540c812ed67c9dda8bb Mon Sep 17 00:00:00 2001 From: Kevin Lau Date: Sat, 21 Mar 2015 19:05:42 -0700 Subject: [PATCH] Generation 4: Fix Transform's interaction with item-based forme changes Causes Dittos transforming into Giratina-O without Griseous Orb to revert to Giratina-A in Generation 4, etc. --- battle-engine.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/battle-engine.js b/battle-engine.js index c2191fc3a5..c91309d76e 100644 --- a/battle-engine.js +++ b/battle-engine.js @@ -367,6 +367,30 @@ BattlePokemon = (function () { } if (init) return; + // Change formes based on held items (for Transform) + // Only ever relevant in Generation 4 since Generation 3 didn't have item-based forme changes + if (this.battle.gen === 4) { + if (this.template.num === 487) { + // Giratina formes + if (this.template.species === 'Giratina' && this.item === 'griseousorb') { + this.formeChange('Giratina-Origin'); + this.battle.add('-formechange', this, 'Giratina-Origin'); + } else if (this.template.species === 'Giratina-Origin' && this.item !== 'griseousorb') { + this.formeChange('Giratina'); + this.battle.add('-formechange', this, 'Giratina'); + } + } + if (this.template.num === 493) { + // Arceus formes + var item = Tools.getItem(this.item); + var targetForme = (item && item.onPlate ? 'Arceus-' + item.onPlate : 'Arceus'); + if (this.template.species !== targetForme) { + this.formeChange(targetForme); + this.battle.add('-formechange', this, targetForme); + } + } + } + if (this.runImmunity('trapped')) this.battle.runEvent('MaybeTrapPokemon', this); // Disable the faculty to cancel switches if a foe may have a trapping ability for (var i = 0; i < this.battle.sides.length; ++i) {