From 80e9a28efbb55f7ee4d59ea3636ee8512e6727d1 Mon Sep 17 00:00:00 2001 From: Marty-D Date: Sat, 27 Apr 2013 13:55:26 -0400 Subject: [PATCH] Gen IV: Fix Magic Coat. --- mods/gen4/moves.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/mods/gen4/moves.js b/mods/gen4/moves.js index 116083e0d5..81587e8854 100644 --- a/mods/gen4/moves.js +++ b/mods/gen4/moves.js @@ -449,23 +449,31 @@ exports.BattleMovedex = { onStart: function(target) { this.add('-singleturn', target, 'move: Magic Coat'); }, - onAllyTryFieldHit: function(target, source, move) { + onTryHitPriority: 2, + onTryHit: function(target, source, move) { if (target === source) return; + if (move.hasBounced) return; if (typeof move.isBounceable === 'undefined') { move.isBounceable = !!(move.category === 'Status' && (move.status || move.boosts || move.volatileStatus === 'confusion' || move.forceSwitch)); } - if (move.target !== 'foeSide' && target !== this.effectData.target) { - return; + if (move.isBounceable) { + var newMove = this.getMoveCopy(move.id); + newMove.hasBounced = true; + this.useMove(newMove, target, source); + return null; } - if (move.hasBounced) { - return; + }, + onAllyTryHitSide: function(target, source, move) { + if (target.side === source.side) return; + if (move.hasBounced) return; + if (typeof move.isBounceable === 'undefined') { + move.isBounceable = !!(move.category === 'Status' && (move.status || move.boosts || move.volatileStatus === 'confusion' || move.forceSwitch)); } if (move.isBounceable) { target.removeVolatile('MagicCoat'); var newMove = this.getMoveCopy(move.id); newMove.hasBounced = true; - this.add('-activate', target, 'move: Magic Coat', newMove, '[of] '+source); - this.moveHit(source, target, newMove); + this.useMove(newMove, target, source); return null; } }