Skip to content

Commit

Permalink
Add King's Rock flags for Gens 2-4 (#4916)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgsamm authored and Zarel committed Oct 23, 2018
1 parent d7d40c2 commit b502236
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 16 deletions.
2 changes: 2 additions & 0 deletions dev-tools/globals.ts
Expand Up @@ -143,6 +143,7 @@ interface SecondaryEffect {
ability?: Ability
boosts?: SparseBoostsTable
dustproof?: boolean
kingsrock?: boolean
self?: SelfEffect
status?: string
volatileStatus?: string
Expand Down Expand Up @@ -538,6 +539,7 @@ interface ActiveMove extends Effect, MoveData {
hasSheerForce?: boolean
hasSTAB?: boolean
isExternal?: boolean
lastHit?: boolean
magnitude?: number
negateSecondary?: boolean
normalizeBoosted?: boolean
Expand Down
36 changes: 26 additions & 10 deletions mods/gen2/items.js
Expand Up @@ -2,6 +2,10 @@

/**@type {{[k: string]: ModdedItemData}} */
let BattleItems = {
berryjuice: {
inherit: true,
isUnreleased: false,
},
brightpowder: {
inherit: true,
desc: "An attack against the holder has its accuracy out of 255 lowered by 20.",
Expand All @@ -11,10 +15,6 @@ let BattleItems = {
return accuracy - 20;
},
},
berryjuice: {
inherit: true,
isUnreleased: false,
},
dragonfang: {
inherit: true,
desc: "No competitive use.",
Expand All @@ -39,12 +39,21 @@ let BattleItems = {
}
},
},
metalpowder: {
inherit: true,
desc: "If held by a Ditto, its Defense and Sp. Def are 1.5x, even while Transformed.",
// In Gen 2 this happens in stat calculation directly.
onModifyDef: function () {},
onModifySpD: function () {},
kingsrock: {
inherit: true,
onModifyMove: function (move) {
let affectedByKingsRock = ['absorb', 'aeroblast', 'barrage', 'beatup', 'bide', 'bonerush', 'bonemerang', 'cometpunch', 'counter', 'crabhammer', 'crosschop', 'cut', 'dig', 'doublekick', 'doubleslap', 'doubleedge', 'dragonrage', 'drillpeck', 'eggbomb', 'explosion', 'extremespeed', 'falseswipe', 'feintattack', 'flail', 'fly', 'frustration', 'furyattack', 'furycutter', 'furyswipes', 'gigadrain', 'hiddenpower', 'highjumpkick', 'hornattack', 'hydropump', 'jumpkick', 'karatechop', 'leechlife', 'machpunch', 'magnitude', 'megadrain', 'megakick', 'megapunch', 'megahorn', 'mirrorcoat', 'nightshade', 'outrage', 'payday', 'peck', 'petaldance', 'pinmissile', 'pound', 'present', 'pursuit', 'psywave', 'quickattack', 'rage', 'rapidspin', 'razorleaf', 'razorwind', 'return', 'reversal', 'rockthrow', 'rollout', 'scratch', 'seismictoss', 'selfdestruct', 'skullbash', 'skyattack', 'slam', 'slash', 'snore', 'solarbeam', 'sonicboom', 'spikecannon', 'strength', 'struggle', 'submission', 'superfang', 'surf', 'swift', 'tackle', 'takedown', 'thief', 'thrash', 'triplekick', 'twineedle', 'vicegrip', 'vinewhip', 'vitalthrow', 'watergun', 'waterfall', 'wingattack'];
if (affectedByKingsRock.includes(move.id)) {
if (!move.secondaries) move.secondaries = [];
// The kingsrock flag allows for differentiation from Snore,
// which can flinch and is also affected by King's Rock
move.secondaries.push({
chance: 12,
volatileStatus: 'flinch',
kingsrock: true,
});
}
},
},
lightball: {
inherit: true,
Expand All @@ -61,6 +70,13 @@ let BattleItems = {
}
},
},
metalpowder: {
inherit: true,
desc: "If held by a Ditto, its Defense and Sp. Def are 1.5x, even while Transformed.",
// In Gen 2 this happens in stat calculation directly.
onModifyDef: function () {},
onModifySpD: function () {},
},
quickclaw: {
inherit: true,
desc: "Each turn, holder has a ~23.4% chance to move first in its priority bracket.",
Expand Down
5 changes: 4 additions & 1 deletion mods/gen2/moves.js
Expand Up @@ -842,7 +842,10 @@ let BattleMovedex = {
this.debug('sub bypass: self hit');
return;
}
if (move.id === 'twineedle') delete move.secondaries;
if (move.id === 'twineedle') {
// @ts-ignore: Twineedle has move.secondaries defined
move.secondaries = move.secondaries.filter(p => !p.kingsrock);
}
if (move.drain) {
this.add('-hint', "In Gold/Silver/Crystal, draining moves always miss against Substitute.");
this.add('-miss', source);
Expand Down
13 changes: 12 additions & 1 deletion mods/gen2/scripts.js
Expand Up @@ -231,6 +231,7 @@ let BattleScripts = {
for (i = 0; i < hits && target.hp && pokemon.hp; i++) {
if (pokemon.status === 'slp' && !isSleepUsable) break;
move.hit = i + 1;
if (move.hit === hits) move.lastHit = true;
moveDamage = this.moveHit(target, pokemon, move);
if (moveDamage === false) break;
if (nullDamage && (moveDamage || moveDamage === 0 || moveDamage === undefined)) nullDamage = false;
Expand Down Expand Up @@ -409,7 +410,17 @@ let BattleScripts = {
// That means that a move that does not share the type of the target can status it.
// This means tri-attack can burn fire-types and freeze ice-types.
// Unlike gen 1, though, paralysis works for all unless the target is immune to direct move (ie. ground-types and t-wave).
if (!(secondary.status && ['brn', 'frz'].includes(secondary.status) && target && target.hasType(move.type))) {
if (secondary.status && ['brn', 'frz'].includes(secondary.status) && target && target.hasType(move.type)) {
this.debug('Target immune to [' + secondary.status + ']');
continue;
}
// A sleeping or frozen target cannot be flinched in Gen 2; King's Rock is exempt
if (secondary.volatileStatus === 'flinch' && target && ['slp', 'frz'].includes(target.status) && !secondary.kingsrock) {
this.debug('Cannot flinch a sleeping or frozen target');
continue;
}
// Multi-hit moves only roll for status once
if (!move.multihit || move.lastHit) {
let effectChance = Math.floor((secondary.chance || 100) * 255 / 100);
if (typeof secondary.chance === 'undefined' || this.randomChance(effectChance, 256)) {
this.moveHit(target, pokemon, move, secondary, true, isSelf);
Expand Down
9 changes: 5 additions & 4 deletions mods/gen3/items.js
Expand Up @@ -123,12 +123,13 @@ let BattleItems = {
"kingsrock": {
inherit: true,
onModifyMove: function (move) {
if (move.category !== "Status") {
if (move.secondaries && move.secondaries.length) return;
move.secondaries = [{
let affectedByKingsRock = ['aerialace', 'aeroblast', 'aircutter', 'armthrust', 'barrage', 'beatup', 'bide', 'bind', 'blastburn', 'bonerush', 'bonemerang', 'bounce', 'brickbreak', 'bulletseed', 'clamp', 'cometpunch', 'crabhammer', 'crosschop', 'cut', 'dig', 'dive', 'doublekick', 'doubleslap', 'doubleedge', 'dragonbreath', 'dragonclaw', 'dragonrage', 'drillpeck', 'earthquake', 'eggbomb', 'endeavor', 'eruption', 'explosion', 'extremespeed', 'falseswipe', 'feintattack', 'firespin', 'flail', 'fly', 'frenzyplant', 'frustration', 'furyattack', 'furycutter', 'furyswipes', 'gust', 'hiddenpower', 'highjumpkick', 'hornattack', 'hydrocannon', 'hydropump', 'hyperbeam', 'iceball', 'iciclespear', 'jumpkick', 'karatechop', 'leafblade', 'lowkick', 'machpunch', 'magicalleaf', 'magnitude', 'megakick', 'megapunch', 'megahorn', 'meteormash', 'mudshot', 'muddywater', 'nightshade', 'outrage', 'overheat', 'payday', 'peck', 'petaldance', 'pinmissile', 'poisontail', 'pound', 'psychoboost', 'psywave', 'quickattack', 'rage', 'rapidspin', 'razorleaf', 'razorwind', 'return', 'revenge', 'reversal', 'rockblast', 'rockthrow', 'rollingkick', 'rollout', 'sandtomb', 'scratch', 'seismictoss', 'selfdestruct', 'shadowpunch', 'shockwave', 'signalbeam', 'silverwind', 'skullbash', 'skyattack', 'skyuppercut', 'slam', 'slash', 'snore', 'solarbeam', 'sonicboom', 'spikecannon', 'spitup', 'steelwing', 'strength', 'struggle', 'submission', 'surf', 'swift', 'tackle', 'takedown', 'thrash', 'tickle', 'triplekick', 'twister', 'uproar', 'vicegrip', 'vinewhip', 'vitalthrow', 'volttackle', 'watergun', 'waterpulse', 'waterfall', 'weatherball', 'whirlpool', 'wingattack', 'wrap'];
if (affectedByKingsRock.includes(move.id)) {
if (!move.secondaries) move.secondaries = [];
move.secondaries.push({
chance: 10,
volatileStatus: 'flinch',
}];
});
}
},
},
Expand Down
26 changes: 26 additions & 0 deletions mods/gen4/items.js
Expand Up @@ -126,6 +126,19 @@ let BattleItems = {
}
},
},
"kingsrock": {
inherit: true,
onModifyMove: function (move) {
let affectedByKingsRock = ['aerialace', 'aeroblast', 'aircutter', 'airslash', 'aquajet', 'aquatail', 'armthrust', 'assurance', 'attackorder', 'aurasphere', 'avalanche', 'barrage', 'beatup', 'bide', 'bind', 'blastburn', 'bonerush', 'bonemerang', 'bounce', 'bravebird', 'brickbreak', 'brine', 'bugbite', 'bulletpunch', 'bulletseed', 'chargebeam', 'clamp', 'closecombat', 'cometpunch', 'crabhammer', 'crosschop', 'crosspoison', 'crushgrip', 'cut', 'darkpulse', 'dig', 'discharge', 'dive', 'doublehit', 'doublekick', 'doubleslap', 'doubleedge', 'dracometeor', 'dragonbreath', 'dragonclaw', 'dragonpulse', 'dragonrage', 'dragonrush', 'drainpunch', 'drillpeck', 'earthpower', 'earthquake', 'eggbomb', 'endeavor', 'eruption', 'explosion', 'extremespeed', 'falseswipe', 'feintattack', 'firefang', 'firespin', 'flail', 'flashcannon', 'fly', 'forcepalm', 'frenzyplant', 'frustration', 'furyattack', 'furycutter', 'furyswipes', 'gigaimpact', 'grassknot', 'gunkshot', 'gust', 'gyroball', 'hammerarm', 'headsmash', 'hiddenpower', 'highjumpkick', 'hornattack', 'hydrocannon', 'hydropump', 'hyperbeam', 'iceball', 'icefang', 'iceshard', 'iciclespear', 'ironhead', 'judgment', 'jumpkick', 'karatechop', 'lastresort', 'lavaplume', 'leafblade', 'leafstorm', 'lowkick', 'machpunch', 'magicalleaf', 'magmastorm', 'magnetbomb', 'magnitude', 'megakick', 'megapunch', 'megahorn', 'meteormash', 'mirrorshot', 'mudbomb', 'mudshot', 'muddywater', 'nightshade', 'nightslash', 'ominouswind', 'outrage', 'overheat', 'payday', 'payback', 'peck', 'petaldance', 'pinmissile', 'pluck', 'poisonjab', 'poisontail', 'pound', 'powergem', 'powerwhip', 'psychoboost', 'psychocut', 'psywave', 'punishment', 'quickattack', 'rage', 'rapidspin', 'razorleaf', 'razorwind', 'return', 'revenge', 'reversal', 'roaroftime', 'rockblast', 'rockclimb', 'rockthrow', 'rockwrecker', 'rollingkick', 'rollout', 'sandtomb', 'scratch', 'seedbomb', 'seedflare', 'seismictoss', 'selfdestruct', 'shadowclaw', 'shadowforce', 'shadowpunch', 'shadowsneak', 'shockwave', 'signalbeam', 'silverwind', 'skullbash', 'skyattack', 'skyuppercut', 'slam', 'slash', 'snore', 'solarbeam', 'sonicboom', 'spacialrend', 'spikecannon', 'spitup', 'steelwing', 'stoneedge', 'strength', 'struggle', 'submission', 'suckerpunch', 'surf', 'swift', 'tackle', 'takedown', 'thrash', 'thunderfang', 'triplekick', 'trumpcard', 'twister', 'uturn', 'uproar', 'vacuumwave', 'vicegrip', 'vinewhip', 'vitalthrow', 'volttackle', 'wakeupslap', 'watergun', 'waterpulse', 'waterfall', 'weatherball', 'whirlpool', 'wingattack', 'woodhammer', 'wrap', 'wringout', 'xscissor', 'zenheadbutt'];
if (affectedByKingsRock.includes(move.id)) {
if (!move.secondaries) move.secondaries = [];
move.secondaries.push({
chance: 10,
volatileStatus: 'flinch',
});
}
},
},
"lifeorb": {
inherit: true,
onModifyDamage: function () {},
Expand Down Expand Up @@ -222,6 +235,19 @@ let BattleItems = {
},
},
},
"razorfang": {
inherit: true,
onModifyMove: function (move) {
let affectedByRazorFang = ['aerialace', 'aeroblast', 'aircutter', 'airslash', 'aquajet', 'aquatail', 'armthrust', 'assurance', 'attackorder', 'aurasphere', 'avalanche', 'barrage', 'beatup', 'bide', 'bind', 'blastburn', 'bonerush', 'bonemerang', 'bounce', 'bravebird', 'brickbreak', 'brine', 'bugbite', 'bulletpunch', 'bulletseed', 'chargebeam', 'clamp', 'closecombat', 'cometpunch', 'crabhammer', 'crosschop', 'crosspoison', 'crushgrip', 'cut', 'darkpulse', 'dig', 'discharge', 'dive', 'doublehit', 'doublekick', 'doubleslap', 'doubleedge', 'dracometeor', 'dragonbreath', 'dragonclaw', 'dragonpulse', 'dragonrage', 'dragonrush', 'drainpunch', 'drillpeck', 'earthpower', 'earthquake', 'eggbomb', 'endeavor', 'eruption', 'explosion', 'extremespeed', 'falseswipe', 'feintattack', 'firefang', 'firespin', 'flail', 'flashcannon', 'fly', 'forcepalm', 'frenzyplant', 'frustration', 'furyattack', 'furycutter', 'furyswipes', 'gigaimpact', 'grassknot', 'gunkshot', 'gust', 'gyroball', 'hammerarm', 'headsmash', 'hiddenpower', 'highjumpkick', 'hornattack', 'hydrocannon', 'hydropump', 'hyperbeam', 'iceball', 'icefang', 'iceshard', 'iciclespear', 'ironhead', 'judgment', 'jumpkick', 'karatechop', 'lastresort', 'lavaplume', 'leafblade', 'leafstorm', 'lowkick', 'machpunch', 'magicalleaf', 'magmastorm', 'magnetbomb', 'magnitude', 'megakick', 'megapunch', 'megahorn', 'meteormash', 'mirrorshot', 'mudbomb', 'mudshot', 'muddywater', 'nightshade', 'nightslash', 'ominouswind', 'outrage', 'overheat', 'payday', 'payback', 'peck', 'petaldance', 'pinmissile', 'pluck', 'poisonjab', 'poisontail', 'pound', 'powergem', 'powerwhip', 'psychoboost', 'psychocut', 'psywave', 'punishment', 'quickattack', 'rage', 'rapidspin', 'razorleaf', 'razorwind', 'return', 'revenge', 'reversal', 'roaroftime', 'rockblast', 'rockclimb', 'rockthrow', 'rockwrecker', 'rollingkick', 'rollout', 'sandtomb', 'scratch', 'seedbomb', 'seedflare', 'seismictoss', 'selfdestruct', 'shadowclaw', 'shadowforce', 'shadowpunch', 'shadowsneak', 'shockwave', 'signalbeam', 'silverwind', 'skullbash', 'skyattack', 'skyuppercut', 'slam', 'slash', 'snore', 'solarbeam', 'sonicboom', 'spacialrend', 'spikecannon', 'spitup', 'steelwing', 'stoneedge', 'strength', 'struggle', 'submission', 'suckerpunch', 'surf', 'swift', 'tackle', 'takedown', 'thrash', 'thunderfang', 'triplekick', 'trumpcard', 'twister', 'uturn', 'uproar', 'vacuumwave', 'vicegrip', 'vinewhip', 'vitalthrow', 'volttackle', 'wakeupslap', 'watergun', 'waterpulse', 'waterfall', 'weatherball', 'whirlpool', 'wingattack', 'woodhammer', 'wrap', 'wringout', 'xscissor', 'zenheadbutt'];
if (affectedByRazorFang.includes(move.id)) {
if (!move.secondaries) move.secondaries = [];
move.secondaries.push({
chance: 10,
volatileStatus: 'flinch',
});
}
},
},
"rowapberry": {
inherit: true,
onAfterDamage: function () {},
Expand Down

0 comments on commit b502236

Please sign in to comment.