From ef3b4965ea49a8f11ca57602ea445a9bdd280eba Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sat, 7 Jan 2017 22:42:28 -0500 Subject: [PATCH] Fix Z-move priority interaction Priority Z-moves exist (namely, Gale Wings Supersonic Skystrike). Quick Guard now partially protects against priority Z-moves. Psychic Terrain now fully protects against priority Z-moves. --- battle-engine.js | 2 +- data/moves.js | 8 ++++++-- data/scripts.js | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/battle-engine.js b/battle-engine.js index e69b2cbde3..eda2bb14c2 100644 --- a/battle-engine.js +++ b/battle-engine.js @@ -3949,7 +3949,7 @@ class Battle extends Tools.BattleDex { baseDamage = this.runEvent('ModifyDamage', pokemon, target, move, baseDamage); // TODO: Find out where this actually goes in the damage calculation - if (move.isZ && (target.volatiles['banefulbunker'] || target.volatiles['kingsshield'] || target.side.sideConditions['matblock'] || target.volatiles['protect'] || target.volatiles['spikyshield'])) { + if (move.isZ && (move.zBrokeProtect || target.volatiles['banefulbunker'] || target.volatiles['kingsshield'] || target.side.sideConditions['matblock'] || target.volatiles['protect'] || target.volatiles['spikyshield'])) { baseDamage = this.modify(baseDamage, 0.25); this.add('-message', target.name + " couldn't fully protect itself and got hurt! (placeholder)"); } diff --git a/data/moves.js b/data/moves.js index ecffef7c66..4cc3bfedae 100644 --- a/data/moves.js +++ b/data/moves.js @@ -12710,10 +12710,14 @@ exports.BattleMovedex = { this.add('-singleturn', source, 'Quick Guard'); }, onTryHitPriority: 4, - onTryHit: function (target, source, effect) { + onTryHit: function (target, source, move) { // Quick Guard blocks moves with positive priority, even those given increased priority by Prankster or Gale Wings. // (e.g. it blocks 0 priority moves boosted by Prankster or Gale Wings; Quick Claw/Custap Berry do not count) - if (effect && (effect.id === 'feint' || effect.priority <= 0.1 || effect.target === 'self')) { + if (move.id === 'feint' || move.priority <= 0.1 || move.target === 'self') { + return; + } + if (move.isZ) { + move.zBrokeProtect = true; return; } this.add('-activate', target, 'move: Quick Guard'); diff --git a/data/scripts.js b/data/scripts.js index 8f85932f42..c582acbb4f 100644 --- a/data/scripts.js +++ b/data/scripts.js @@ -17,6 +17,9 @@ exports.BattleScripts = { move = zMove ? this.getZMoveCopy(move, pokemon) : baseMove; if (!target && target !== false) target = this.resolveTarget(pokemon, move); + // copy the priority for Quick Guard + if (zMove) move.priority = baseMove.priority; + this.setActiveMove(move, pokemon, target); /* if (pokemon.moveThisTurn) {