From 2ffaf0fc77fae9033beb15974db0d25c4687c134 Mon Sep 17 00:00:00 2001 From: ascriptmaster Date: Thu, 16 Oct 2014 15:02:20 -0700 Subject: [PATCH] Sky Drop refactor and bug fixes - Changed Sky Drop to use onTryHit on its first hit as well as its second, allowing it to check for Protect and Fly naturally. - Added messages when a Pokemon is freed from Sky Drop. - Allow Flying-type Pokemon to be hit by Sky Drop if their Ground immunity has been removed. - Added BeforeMovePriority to allow Sky Drop to interact with Stance Change properly. - Prevent a Pokemon trapped by Sky Drop from Mega Evolving. - Added onRedirectTarget to allow Sky Drop to interact with Ally Switch properly. --- data/moves.js | 74 ++++++++++++++++++++++++++++++------------------- data/scripts.js | 7 +++++ 2 files changed, 52 insertions(+), 29 deletions(-) diff --git a/data/moves.js b/data/moves.js index d786f188a6..d88acb015f 100644 --- a/data/moves.js +++ b/data/moves.js @@ -5290,10 +5290,20 @@ exports.BattleMovedex = { pokemon.disabledMoves[m] = true; } var applies = false; - if (pokemon.removeVolatile('bounce') || pokemon.removeVolatile('fly') || pokemon.removeVolatile('skydrop')) { + if (pokemon.removeVolatile('bounce') || pokemon.removeVolatile('fly')) { applies = true; this.cancelMove(pokemon); } + if (pokemon.volatiles['skydrop']) { + applies = true; + this.cancelMove(pokemon); + + if (pokemon.volatiles['skydrop'].source) { + this.add('-end', pokemon.volatiles['twoturnmove'].source, 'Sky Drop', '[interrupt]'); + } + pokemon.removeVolatile('skydrop'); + pokemon.removeVolatile('twoturnmove'); + } if (pokemon.volatiles['magnetrise']) { applies = true; delete pokemon.volatiles['magnetrise']; @@ -11913,37 +11923,32 @@ exports.BattleMovedex = { pp: 10, priority: 0, isContact: true, - isTwoTurnMove: true, - onTry: function (attacker, defender, move) { - if (defender.fainted) return false; - if (attacker.removeVolatile(move.id)) { - return; - } - if (defender.volatiles['substitute'] || defender.side === attacker.side) { - return false; - } - if (defender.weightkg >= 200) { - this.add('-fail', defender, 'move: Sky Drop', '[heavy]'); + onTryHit: function (target, source, move) { + if (target.fainted) return false; + if (source.removeVolatile(move.id)) { + if (target !== source.volatiles['twoturnmove'].source) return false; + + if (target.hasType('Flying') && !target.negateImmunity['Ground']) { + this.add('-immune', target, '[msg]'); + this.add('-end', target, 'Sky Drop'); + return null; + } + } else { + if (target.volatiles['substitute'] || target.side === source.side) { + return false; + } + if (target.weightkg >= 200) { + this.add('-fail', target, 'move: Sky Drop', '[heavy]'); + return null; + } + + this.add('-prepare', source, move.name, target); + source.addVolatile('twoturnmove', target); return null; } - if (defender.volatiles['protect']) { - this.add('-activate', defender, 'Protect'); - return null; - } - if (defender.volatiles['bounce'] || defender.volatiles['dig'] || defender.volatiles['dive'] || defender.volatiles['fly'] || defender.volatiles['phantomforce'] || defender.volatiles['shadowforce'] || defender.volatiles['skydrop']) { - this.add('-miss', attacker, defender); - return null; - } - this.add('-prepare', attacker, move.name, defender); - attacker.addVolatile('twoturnmove', defender); - return null; }, - onTryHit: function (target, source) { - if (target !== source.volatiles['twoturnmove'].source) return false; - if (target.hasType('Flying')) { - this.add('-immune', target, '[msg]'); - return null; - } + onHit: function (target, source) { + this.add('-end', target, 'Sky Drop'); }, effect: { duration: 2, @@ -11953,6 +11958,7 @@ exports.BattleMovedex = { if (defender !== this.effectData.source) return; defender.trapped = true; }, + onFoeBeforeMovePriority: 11, onFoeBeforeMove: function (attacker, defender, move) { if (attacker === this.effectData.source) { this.debug('Sky drop nullifying.'); @@ -11960,6 +11966,11 @@ exports.BattleMovedex = { return null; } }, + onRedirectTarget: function (target, source, source2) { + if (source !== this.effectData.target) return; + if (this.effectData.source.fainted) return; + return this.effectData.source; + }, onAnyAccuracy: function (accuracy, target, source, move) { if (target !== this.effectData.target && target !== this.effectData.source) { return; @@ -11988,6 +11999,11 @@ exports.BattleMovedex = { if (move.id === 'gust' || move.id === 'twister') { return this.chainModify(2); } + }, + onFaint: function (target) { + if (target.volatiles['skydrop'] && target.volatiles['twoturnmove'].source) { + this.add('-end', target.volatiles['twoturnmove'].source, 'Sky Drop', '[interrupt]'); + } } }, secondary: false, diff --git a/data/scripts.js b/data/scripts.js index d4ed8c576a..64450adc6d 100644 --- a/data/scripts.js +++ b/data/scripts.js @@ -542,6 +542,13 @@ exports.BattleScripts = { if (!template.isMega) return false; if (pokemon.baseTemplate.baseSpecies !== template.baseSpecies) return false; + var foeActive = side.foe.active; + for (var i = 0; i < foeActive.length; i++) { + if (foeActive[i].volatiles['skydrop'] && foeActive[i].volatiles['skydrop'].source === pokemon) { + return false; + } + } + // okay, mega evolution is possible pokemon.formeChange(template); pokemon.baseTemplate = template; // mega evolution is permanent :o