From cca9688b2a800604a8d8c0999dfe46596478bbb0 Mon Sep 17 00:00:00 2001 From: The Immortal Date: Wed, 25 Mar 2015 03:27:20 +0400 Subject: [PATCH] Implement Mirror Move correctly for gens 1 and 2 Also fixed lastMove not being an id. --- mods/gen1/moves.js | 7 ++++--- mods/gen1/scripts.js | 4 ++-- mods/gen2/moves.js | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/mods/gen1/moves.js b/mods/gen1/moves.js index 589358d919..82a2a58233 100644 --- a/mods/gen1/moves.js +++ b/mods/gen1/moves.js @@ -564,11 +564,12 @@ exports.BattleMovedex = { }, mirrormove: { inherit: true, - onTryHit: function (target) { - var noMirrorMove = {mirrormove: 1, struggle: 1}; - if (!target.lastMove || noMirrorMove[target.lastMove]) { + onHit: function (pokemon) { + var foe = pokemon.side.foe.active[0]; + if (!foe || !foe.lastMove || foe.lastMove === 'mirrormove') { return false; } + this.useMove(foe.lastMove, pokemon); } }, nightshade: { diff --git a/mods/gen1/scripts.js b/mods/gen1/scripts.js index 6788866fd0..cd0a4bbcfa 100644 --- a/mods/gen1/scripts.js +++ b/mods/gen1/scripts.js @@ -104,8 +104,8 @@ exports.BattleScripts = { if (!lockedMove && (!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].locked !== target)) { pokemon.deductPP(move, null, target); // On gen 1 moves are stored when they are chosen and a PP is deducted. - pokemon.side.lastMove = move; - pokemon.lastMove = move; + pokemon.side.lastMove = move.id; + pokemon.lastMove = move.id; } this.useMove(move, pokemon, target, sourceEffect); this.runEvent('AfterMove', target, pokemon, move); diff --git a/mods/gen2/moves.js b/mods/gen2/moves.js index 8fb0163d96..3b6fc7d888 100644 --- a/mods/gen2/moves.js +++ b/mods/gen2/moves.js @@ -178,6 +178,17 @@ exports.BattleMovedex = { } } }, + mirrormove: { + inherit: true, + onHit: function (pokemon) { + var noMirror = {metronome: 1, mimic: 1, mirrormove: 1, sketch: 1, sleeptalk: 1, transform: 1}; + var foe = pokemon.side.foe.active[0]; + if (!foe || !foe.lastMove || (!pokemon.activeTurns && !foe.moveThisTurn) || noMirror[foe.lastMove] || pokemon.moves.indexOf(foe.lastMove) !== -1) { + return false; + } + this.useMove(foe.lastMove, pokemon); + } + }, moonlight: { inherit: true, onHit: function (pokemon) {