diff --git a/data/mods/gen1/moves.ts b/data/mods/gen1/moves.ts index 9bb9510f3f..11f8d8f6e9 100644 --- a/data/mods/gen1/moves.ts +++ b/data/mods/gen1/moves.ts @@ -482,9 +482,8 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = { inherit: true, onHit(pokemon) { const foe = pokemon.side.foe.active[0]; - if (!foe?.lastMove || foe.lastMove.id === 'mirrormove') { - return false; - } + // only Mirror Move isn't mirrorable + if (!foe?.lastMove?.flags['mirror']) return false; pokemon.side.lastSelectedMove = foe.lastMove.id; this.actions.useMove(foe.lastMove.id, pokemon); }, diff --git a/data/mods/gen1/scripts.ts b/data/mods/gen1/scripts.ts index 83812bfa95..6e9cc33f16 100644 --- a/data/mods/gen1/scripts.ts +++ b/data/mods/gen1/scripts.ts @@ -21,6 +21,16 @@ export const Scripts: ModdedBattleScriptsData = { poke.gender = 'N'; poke.eggGroups = null; } + for (const i in this.data.Moves) { + const move = this.data.Moves[i]; + if (i === 'mirrormove') { + const flags = { ...move.flags }; + delete flags['mirror']; + this.modData('Moves', i).flags = flags; + } else { + this.modData('Moves', i).flags = { mirror: 1, ...move.flags }; + } + } }, // BattlePokemon scripts. pokemon: { diff --git a/data/mods/gen2/moves.ts b/data/mods/gen2/moves.ts index c75e5a214f..2f5ccd8892 100644 --- a/data/mods/gen2/moves.ts +++ b/data/mods/gen2/moves.ts @@ -343,13 +343,10 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = { inherit: true, flags: { metronome: 1, failencore: 1, nosketch: 1 }, onHit(pokemon) { - const noMirror = ['metronome', 'mimic', 'mirrormove', 'sketch', 'sleeptalk', 'transform']; const target = pokemon.side.foe.active[0]; - const lastMove = target?.lastMove && target?.lastMove.id; - if (!lastMove || (!pokemon.activeTurns && !target.moveThisTurn)) { - return false; - } - if (noMirror.includes(lastMove) || pokemon.moves.includes(lastMove)) { + const lastMove = target?.lastMove; + if (!lastMove?.flags['mirror'] || pokemon.moves.includes(lastMove.id) || + (!pokemon.activeTurns && !target.moveThisTurn)) { return false; } this.actions.useMove(lastMove, pokemon); diff --git a/data/mods/gen2/scripts.ts b/data/mods/gen2/scripts.ts index 5bb79245ba..c66fef1c0d 100644 --- a/data/mods/gen2/scripts.ts +++ b/data/mods/gen2/scripts.ts @@ -5,6 +5,19 @@ export const Scripts: ModdedBattleScriptsData = { inherit: 'gen3', gen: 2, + init() { + const noMirror = ['metronome', 'mimic', 'mirrormove', 'sketch', 'sleeptalk', 'transform']; + for (const i in this.data.Moves) { + const move = this.data.Moves[i]; + if (noMirror.includes(i)) { + const flags = { ...move.flags }; + delete flags['mirror']; + this.modData('Moves', i).flags = flags; + } else { + this.modData('Moves', i).flags = { mirror: 1, ...move.flags }; + } + } + }, pokemon: { inherit: true, getStat(statName, unboosted, unmodified, fastReturn) { diff --git a/data/mods/gen3/moves.ts b/data/mods/gen3/moves.ts index 06cdde7a04..99f0667882 100644 --- a/data/mods/gen3/moves.ts +++ b/data/mods/gen3/moves.ts @@ -428,21 +428,6 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = { mirrormove: { inherit: true, flags: { metronome: 1, failencore: 1, nosleeptalk: 1, noassist: 1 }, - onTryHit: undefined, // no inherit - onHit(pokemon) { - const noMirror = [ - 'assist', 'curse', 'doomdesire', 'focuspunch', 'futuresight', 'magiccoat', 'metronome', 'mimic', 'mirrormove', 'naturepower', 'psychup', 'roleplay', 'sketch', 'sleeptalk', 'spikes', 'spitup', 'taunt', 'teeterdance', 'transform', - ]; - const lastAttackedBy = pokemon.getLastAttackedBy(); - if (!lastAttackedBy?.source.lastMove || !lastAttackedBy.move) { - return false; - } - if (noMirror.includes(lastAttackedBy.move) || !lastAttackedBy.source.hasMove(lastAttackedBy.move)) { - return false; - } - this.actions.useMove(lastAttackedBy.move, pokemon); - }, - target: "self", }, naturepower: { inherit: true, diff --git a/data/mods/gen3/scripts.ts b/data/mods/gen3/scripts.ts index 75d9dd50ee..f7c6c5c4bd 100644 --- a/data/mods/gen3/scripts.ts +++ b/data/mods/gen3/scripts.ts @@ -3,14 +3,25 @@ export const Scripts: ModdedBattleScriptsData = { gen: 3, init() { const specialTypes = ['Fire', 'Water', 'Grass', 'Ice', 'Electric', 'Dark', 'Psychic', 'Dragon']; + const noMirror = [ + 'assist', 'curse', 'doomdesire', 'focuspunch', 'futuresight', 'magiccoat', 'metronome', 'mimic', 'mirrormove', 'naturepower', 'psychup', 'roleplay', 'sketch', 'sleeptalk', 'spikes', 'spitup', 'taunt', 'teeterdance', 'transform', + ]; let newCategory = ''; for (const i in this.data.Moves) { - if (!this.data.Moves[i]) console.log(i); - if (this.data.Moves[i].category === 'Status') continue; - newCategory = specialTypes.includes(this.data.Moves[i].type) ? 'Special' : 'Physical'; - if (newCategory !== this.data.Moves[i].category) { + const move = this.data.Moves[i]; + if (!move) console.log(i); + if (move.category === 'Status') continue; + newCategory = specialTypes.includes(move.type) ? 'Special' : 'Physical'; + if (newCategory !== move.category) { this.modData('Moves', i).category = newCategory; } + if (noMirror.includes(i)) { + const flags = { ...move.flags }; + delete flags['mirror']; + this.modData('Moves', i).flags = flags; + } else { + this.modData('Moves', i).flags = { mirror: 1, ...move.flags }; + } } }, pokemon: { diff --git a/data/mods/gen4/moves.ts b/data/mods/gen4/moves.ts index 795aa6e7c8..0d8259149b 100644 --- a/data/mods/gen4/moves.ts +++ b/data/mods/gen4/moves.ts @@ -895,13 +895,11 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = { if (!lastAttackedBy?.source.lastMove || !lastAttackedBy.move) { return false; } - const noMirror = [ - 'acupressure', 'aromatherapy', 'assist', 'chatter', 'copycat', 'counter', 'curse', 'doomdesire', 'feint', 'focuspunch', 'futuresight', 'gravity', 'hail', 'haze', 'healbell', 'helpinghand', 'lightscreen', 'luckychant', 'magiccoat', 'mefirst', 'metronome', 'mimic', 'mirrorcoat', 'mirrormove', 'mist', 'mudsport', 'naturepower', 'perishsong', 'psychup', 'raindance', 'reflect', 'roleplay', 'safeguard', 'sandstorm', 'sketch', 'sleeptalk', 'snatch', 'spikes', 'spitup', 'stealthrock', 'struggle', 'sunnyday', 'tailwind', 'toxicspikes', 'transform', 'watersport', - ]; - if (noMirror.includes(lastAttackedBy.move) || !lastAttackedBy.source.hasMove(lastAttackedBy.move)) { + const move = this.dex.moves.get(lastAttackedBy.move); + if (!move.flags['mirror'] || !lastAttackedBy.source.hasMove(move.id)) { return false; } - this.actions.useMove(lastAttackedBy.move, pokemon); + this.actions.useMove(move, pokemon); }, target: "self", }, diff --git a/data/mods/gen4/scripts.ts b/data/mods/gen4/scripts.ts index c28929177d..002f91955a 100644 --- a/data/mods/gen4/scripts.ts +++ b/data/mods/gen4/scripts.ts @@ -1,6 +1,21 @@ export const Scripts: ModdedBattleScriptsData = { inherit: 'gen5', gen: 4, + init() { + const noMirror = [ + 'acupressure', 'aromatherapy', 'assist', 'chatter', 'copycat', 'counter', 'curse', 'doomdesire', 'feint', 'focuspunch', 'futuresight', 'gravity', 'hail', 'haze', 'healbell', 'helpinghand', 'lightscreen', 'luckychant', 'magiccoat', 'mefirst', 'metronome', 'mimic', 'mirrorcoat', 'mirrormove', 'mist', 'mudsport', 'naturepower', 'perishsong', 'psychup', 'raindance', 'reflect', 'roleplay', 'safeguard', 'sandstorm', 'sketch', 'sleeptalk', 'snatch', 'spikes', 'spitup', 'stealthrock', 'struggle', 'sunnyday', 'tailwind', 'toxicspikes', 'transform', 'watersport', + ]; + for (const i in this.data.Moves) { + const move = this.data.Moves[i]; + if (noMirror.includes(i)) { + const flags = { ...move.flags }; + delete flags['mirror']; + this.modData('Moves', i).flags = flags; + } else { + this.modData('Moves', i).flags = { mirror: 1, ...move.flags }; + } + } + }, pokemon: { inherit: true, getActionSpeed() { diff --git a/sim/dex-species.ts b/sim/dex-species.ts index 688891f42b..c066675eba 100644 --- a/sim/dex-species.ts +++ b/sim/dex-species.ts @@ -594,11 +594,12 @@ export class DexSpecies { species.canHatch = species.canHatch || (!['Ditto', 'Undiscovered'].includes(species.eggGroups[0]) && !species.prevo && species.name !== 'Manaphy'); if (this.dex.gen === 1) species.bst -= species.baseStats.spd; - if (this.dex.gen < 5) { + if (this.dex.gen <= 2) species.abilities = { 0: 'No Ability' }; + else if (this.dex.gen < 5) { species.abilities = this.dex.deepClone(species.abilities); delete species.abilities['H']; + if (this.dex.gen === 3 && this.dex.abilities.get(species.abilities['1']).gen === 4) delete species.abilities['1']; } - if (this.dex.gen === 3 && this.dex.abilities.get(species.abilities['1']).gen === 4) delete species.abilities['1']; if (this.dex.parentMod) { // if this species is exactly identical to parentMod's species, reuse parentMod's copy