Implement Mirror Move correctly for gens 1 and 2

Also fixed lastMove not being an id.
This commit is contained in:
The Immortal 2015-03-25 03:27:20 +04:00
parent bf3898273e
commit cca9688b2a
3 changed files with 17 additions and 5 deletions

View File

@ -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: {

View File

@ -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);

View File

@ -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) {