From 17724c59f0ee8e14d89d09897546f219ded38b77 Mon Sep 17 00:00:00 2001 From: Kevin Lau Date: Thu, 21 May 2015 13:51:36 -0700 Subject: [PATCH] Un-hardcode Rock Head in favor of an onDamage handler Instead of having a hardcode in scripts.js that people needed to reference, it seemed more intuitive to take advantage of the Damage event instead, and have Rock Head negate damage within the event. Fixed a bug in Gen-NEXT Rock Head exhibiting the same behavior that was causing the original Rock Head + Mummy glitch. --- data/abilities.js | 4 +++- data/moves.js | 2 +- data/scripts.js | 2 +- mods/gen5/moves.js | 2 +- mods/gennext/abilities.js | 5 +---- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/data/abilities.js b/data/abilities.js index 33888d271d..4ef686f26d 100644 --- a/data/abilities.js +++ b/data/abilities.js @@ -2151,7 +2151,9 @@ exports.BattleAbilities = { "rockhead": { desc: "This Pokemon does not take recoil damage besides Struggle, Life Orb, and crash damage.", shortDesc: "This Pokemon does not take recoil damage besides Struggle/Life Orb/crash damage.", - // Implemented in scripts.js + onDamage: function (damage, target, source, effect) { + if (effect.id === 'recoil' && this.activeMove.id !== 'struggle') return null; + }, id: "rockhead", name: "Rock Head", rating: 3, diff --git a/data/moves.js b/data/moves.js index 242b3be5ee..19e8c7b5b1 100644 --- a/data/moves.js +++ b/data/moves.js @@ -13486,7 +13486,7 @@ exports.BattleMovedex = { } else { this.add('-activate', target, 'Substitute', '[damage]'); } - if (move.recoil && (!source.hasAbility('rockhead') || move.id === 'struggle')) { + if (move.recoil) { this.damage(Math.round(damage * move.recoil[0] / move.recoil[1]), source, target, 'recoil'); } if (move.drain) { diff --git a/data/scripts.js b/data/scripts.js index 1088d71e44..5e4996d63b 100644 --- a/data/scripts.js +++ b/data/scripts.js @@ -314,7 +314,7 @@ exports.BattleScripts = { totalDamage = damage; } - if (move.recoil && (!pokemon.hasAbility('rockhead') || move.id === 'struggle')) { + if (move.recoil) { this.damage(this.clampIntRange(Math.round(totalDamage * move.recoil[0] / move.recoil[1]), 1), pokemon, target, 'recoil'); } diff --git a/mods/gen5/moves.js b/mods/gen5/moves.js index 7bd3d6efd3..706adafce5 100644 --- a/mods/gen5/moves.js +++ b/mods/gen5/moves.js @@ -869,7 +869,7 @@ exports.BattleMovedex = { } else { this.add('-activate', target, 'Substitute', '[damage]'); } - if (move.recoil && (!source.hasAbility('rockhead') || move.id === 'struggle')) { + if (move.recoil) { this.damage(Math.round(damage * move.recoil[0] / move.recoil[1]), source, target, 'recoil'); } if (move.drain) { diff --git a/mods/gennext/abilities.js b/mods/gennext/abilities.js index dd9ae50ec1..4c267d9b28 100644 --- a/mods/gennext/abilities.js +++ b/mods/gennext/abilities.js @@ -314,11 +314,8 @@ exports.BattleAbilities = { }, "rockhead": { inherit: true, - onModifyMove: function (move) { - delete move.recoil; - }, onDamage: function (damage, target, source, effect) { - if (effect && effect.id === 'lifeorb') return false; + if (effect && effect.id in {lifeorb: 1, recoil: 1}) return false; } }, "download": {