@pkmn/mods 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/gen1stadium/index.js +18 -23
- package/build/gen1stadium/index.js.map +1 -1
- package/build/gen1stadium/index.mjs +18 -23
- package/build/gen1stadium/index.mjs.map +1 -1
- package/build/gen2stadium2/index.js +2 -0
- package/build/gen2stadium2/index.js.map +1 -1
- package/build/gen2stadium2/index.mjs +2 -0
- package/build/gen2stadium2/index.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -393,7 +393,7 @@ var Moves = {
|
|
|
393
393
|
}
|
|
394
394
|
if (target.volatiles["substitute"]) {
|
|
395
395
|
if (move.recoil) {
|
|
396
|
-
this.damage(Math.
|
|
396
|
+
this.damage(this.clampIntRange(Math.floor(damage * move.recoil[0] / move.recoil[1]), 1), source, target, "recoil");
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
this.runEvent("AfterSubDamage", target, source, move, damage);
|
|
@@ -508,8 +508,6 @@ var Scripts = {
|
|
|
508
508
|
lockedMove = false;
|
|
509
509
|
if (!lockedMove && (!pokemon.volatiles["partialtrappinglock"] || pokemon.volatiles["partialtrappinglock"].locked !== target)) {
|
|
510
510
|
pokemon.deductPP(move, null, target);
|
|
511
|
-
pokemon.side.lastMove = move;
|
|
512
|
-
pokemon.lastMove = move;
|
|
513
511
|
} else {
|
|
514
512
|
sourceEffect = move;
|
|
515
513
|
}
|
|
@@ -539,11 +537,11 @@ var Scripts = {
|
|
|
539
537
|
}
|
|
540
538
|
if (move.id !== "metronome") {
|
|
541
539
|
if (move.id !== "mirrormove" || (!((_a = pokemon.side.foe.active[0]) == null ? void 0 : _a.lastMove) || ((_b = pokemon.side.foe.active[0].lastMove) == null ? void 0 : _b.id) === "mirrormove")) {
|
|
540
|
+
pokemon.side.lastMove = move;
|
|
541
|
+
pokemon.lastMove = move;
|
|
542
542
|
this.battle.singleEvent("AfterMove", move, null, pokemon, target, move);
|
|
543
543
|
if (target && target.hp <= 0) {
|
|
544
544
|
delete pokemon.volatiles["partialtrappinglock"];
|
|
545
|
-
target.side.removeSideCondition("reflect");
|
|
546
|
-
target.side.removeSideCondition("lightscreen");
|
|
547
545
|
} else {
|
|
548
546
|
this.battle.runEvent("AfterMoveSelf", pokemon, target, move);
|
|
549
547
|
}
|
|
@@ -587,8 +585,6 @@ var Scripts = {
|
|
|
587
585
|
return false;
|
|
588
586
|
let attrs = "";
|
|
589
587
|
if (pokemon.fainted) {
|
|
590
|
-
pokemon.side.removeSideCondition("reflect");
|
|
591
|
-
pokemon.side.removeSideCondition("lightscreen");
|
|
592
588
|
return false;
|
|
593
589
|
}
|
|
594
590
|
if (sourceEffect)
|
|
@@ -873,10 +869,10 @@ var Scripts = {
|
|
|
873
869
|
if (pokemon.volatiles["partialtrappinglock"]) {
|
|
874
870
|
pokemon.volatiles["partialtrappinglock"].damage = pokemon.lastDamage;
|
|
875
871
|
}
|
|
876
|
-
if (moveData.secondaries) {
|
|
872
|
+
if (moveData.secondaries && target && target.hp > 0) {
|
|
877
873
|
for (const secondary of moveData.secondaries) {
|
|
878
874
|
if (!move.multihit || move.lastHit) {
|
|
879
|
-
if (!(secondary.status && ["par", "brn", "frz"].includes(secondary.status) && target
|
|
875
|
+
if (!(secondary.status && ["par", "brn", "frz"].includes(secondary.status) && target.hasType(move.type))) {
|
|
880
876
|
const effectChance = Math.floor((secondary.chance || 100) * 255 / 100);
|
|
881
877
|
if (typeof secondary.chance === "undefined" || this.battle.randomChance(effectChance + 1, 256)) {
|
|
882
878
|
this.moveHit(target, pokemon, move, secondary, true, isSelf);
|
|
@@ -1011,31 +1007,30 @@ var Scripts = {
|
|
|
1011
1007
|
damage *= basePower;
|
|
1012
1008
|
damage *= attack;
|
|
1013
1009
|
damage = Math.floor(damage / defense);
|
|
1014
|
-
damage = this.battle.clampIntRange(Math.floor(damage / 50),
|
|
1010
|
+
damage = this.battle.clampIntRange(Math.floor(damage / 50), 0, 997);
|
|
1015
1011
|
damage += 2;
|
|
1016
1012
|
if (type !== "???" && source.hasType(type)) {
|
|
1017
1013
|
damage += Math.floor(damage / 2);
|
|
1018
1014
|
}
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
if (
|
|
1022
|
-
this.battle.add("-supereffective", target);
|
|
1023
|
-
damage *= 20;
|
|
1024
|
-
damage = Math.floor(damage / 10);
|
|
1025
|
-
if (totalTypeMod >= 2) {
|
|
1015
|
+
for (const targetType of target.types) {
|
|
1016
|
+
const typeMod = this.battle.dex.getEffectiveness(type, targetType);
|
|
1017
|
+
if (typeMod > 0) {
|
|
1026
1018
|
damage *= 20;
|
|
1027
1019
|
damage = Math.floor(damage / 10);
|
|
1028
1020
|
}
|
|
1021
|
+
if (typeMod < 0) {
|
|
1022
|
+
damage *= 5;
|
|
1023
|
+
damage = Math.floor(damage / 10);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
const totalTypeMod = target.runEffectiveness(move);
|
|
1027
|
+
if (totalTypeMod > 0) {
|
|
1028
|
+
if (!suppressMessages)
|
|
1029
|
+
this.battle.add("-supereffective", target);
|
|
1029
1030
|
}
|
|
1030
1031
|
if (totalTypeMod < 0) {
|
|
1031
1032
|
if (!suppressMessages)
|
|
1032
1033
|
this.battle.add("-resisted", target);
|
|
1033
|
-
damage *= 5;
|
|
1034
|
-
damage = Math.floor(damage / 10);
|
|
1035
|
-
if (totalTypeMod <= -2) {
|
|
1036
|
-
damage *= 5;
|
|
1037
|
-
damage = Math.floor(damage / 10);
|
|
1038
|
-
}
|
|
1039
1034
|
}
|
|
1040
1035
|
if (damage === 0)
|
|
1041
1036
|
return damage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/gen1stadium/conditions.ts","../../src/gen1stadium/rulesets.ts","../../src/gen1stadium/moves.ts","../../src/gen1stadium/scripts.ts"],"names":[],"mappings":";AAEO,IAAM,aAAiD;AAAA,EAC7D,KAAK;AAAA,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AG;AACrC,iBAAS,KAAK,MAAM,SAAS,GAAG;AAChC,YAAI,SAAS,OAAO,MAAM,CAAC,OAAO,UAAU;AAAe,mBAAS,OAAO;AAC3E,YAAI,OAAO,UAAU,iBAAiB,SAAS,OAAO,UAAU,cAAc,IAAI;AACjF,mBAAS,OAAO,UAAU,cAAc;AAAA,QACzC;AAAA,MACD;AAGA,aAAO,KAAK,MAAM,MAAM;AAAA,IACzB;AAAA,EACD;AACD","sourcesContent":["import type {ModdedConditionData} from '@pkmn/sim';\n\nexport const Conditions: {[k: string]: ModdedConditionData} = {\n\tbrn: {\n\t\tname: 'brn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'brn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tpar: {\n\t\tname: 'par',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'par');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.randomChance(63, 256)) {\n\t\t\t\tthis.add('cant', pokemon, 'par');\n\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\tpokemon.removeVolatile('lockedmovee');\n\t\t\t\tpokemon.removeVolatile('twoturnmove');\n\t\t\t\tpokemon.removeVolatile('fly');\n\t\t\t\tpokemon.removeVolatile('dig');\n\t\t\t\tpokemon.removeVolatile('solarbeam');\n\t\t\t\tpokemon.removeVolatile('skullbash');\n\t\t\t\tpokemon.removeVolatile('partialtrappinglock');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n\tslp: {\n\t\tname: 'slp',\n\t\teffectType: 'Status',\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.effectType === 'Move') {\n\t\t\t\tthis.add('-status', target, 'slp', '[from] move: ' + sourceEffect.name);\n\t\t\t} else {\n\t\t\t\tthis.add('-status', target, 'slp');\n\t\t\t}\n\t\t\t// 1-3 turns\n\t\t\tthis.effectState.startTime = this.random(1, 4);\n\t\t\tthis.effectState.time = this.effectState.startTime;\n\n\t\t\tif (target.removeVolatile('nightmare')) {\n\t\t\t\tthis.add('-end', target, 'Nightmare', '[silent]');\n\t\t\t}\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.statusState.time--;\n\t\t\tthis.add('cant', pokemon, 'slp');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tif (pokemon.statusState.time <= 0) pokemon.cureStatus();\n\t\t},\n\t},\n\tfrz: {\n\t\tname: 'frz',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'frz');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tthis.add('cant', pokemon, 'frz');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonHit(target, source, move) {\n\t\t\tif (move.type === 'Fire' && move.category !== 'Status') {\n\t\t\t\ttarget.cureStatus();\n\t\t\t}\n\t\t},\n\t},\n\tpsn: {\n\t\tname: 'psn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'psn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tconfusion: {\n\t\tinherit: true,\n\t\tonStart(target) {\n\t\t\tthis.add('-start', target, 'confusion');\n\t\t\tthis.effectState.time = this.random(2, 6);\n\t\t},\n\t},\n\tflinch: {\n\t\tinherit: true,\n\t\tonStart() {},\n\t},\n\tpartiallytrapped: {\n\t\tname: 'partiallytrapped',\n\t\tduration: 2,\n\t\tonBeforeMovePriority: 1,\n\t\tonStart(target, source, effect) {\n\t\t\tthis.add('-activate', target, 'move: ' + effect, '[of] ' + source);\n\t\t},\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.effectState.source && (!this.effectState.source.isActive || this.effectState.source.hp <= 0)) {\n\t\t\t\tpokemon.removeVolatile('partiallytrapped');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('cant', pokemon, 'partiallytrapped');\n\t\t\treturn false;\n\t\t},\n\t\tonEnd(pokemon) {\n\t\t\tthis.add('-end', pokemon, this.effectState.sourceEffect, '[partiallytrapped]');\n\t\t},\n\t},\n};\n","import type {ModdedFormatData} from '@pkmn/sim';\n\nexport const Rulesets: {[k: string]: ModdedFormatData} = {\n\tstandard: {\n\t\teffectType: 'ValidatorRule',\n\t\tname: 'Standard',\n\t\truleset: ['Obtainable', 'Stadium Sleep Clause', 'Freeze Clause Mod', 'Species Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Exact HP Mod', 'Cancel Mod'],\n\t},\n};\n","import type {ActiveMove, ModdedMoveData} from '@pkmn/sim';\n\nexport const Moves: {[k: string]: ModdedMoveData} = {\n\tbide: {\n\t\tinherit: true,\n\t\tpriority: 0,\n\t\taccuracy: true,\n\t\tignoreEvasion: true,\n\t\tcondition: {\n\t\t\tduration: 2,\n\t\t\tdurationCallback(target, source, effect) {\n\t\t\t\treturn this.random(3, 5);\n\t\t\t},\n\t\t\tonStart(pokemon) {\n\t\t\t\tthis.effectState.totalDamage = 0;\n\t\t\t\tthis.effectState.lastDamage = 0;\n\t\t\t\tthis.add('-start', pokemon, 'Bide');\n\t\t\t},\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (source && source !== target && move.category !== 'Physical' && move.category !== 'Special') {\n\t\t\t\t\tconst damage = this.effectState.totalDamage;\n\t\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t\t}\n\t\t\t},\n\t\t\tonDamage(damage, target, source, move) {\n\t\t\t\tif (!source || source.isAlly(target)) return;\n\t\t\t\tif (!move || move.effectType !== 'Move') return;\n\t\t\t\tif (!damage && this.effectState.lastDamage > 0) {\n\t\t\t\t\tdamage = this.effectState.totalDamage;\n\t\t\t\t}\n\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t},\n\t\t\tonAfterSetStatus(status, pokemon) {\n\t\t\t\t// Sleep, freeze, and partial trap will just pause duration.\n\t\t\t\tif (pokemon.volatiles['flinch']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else if (pokemon.volatiles['partiallytrapped']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else {\n\t\t\t\t\tswitch (status.id) {\n\t\t\t\t\tcase 'slp':\n\t\t\t\t\tcase 'frz':\n\t\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tonBeforeMove(pokemon, t, move) {\n\t\t\t\tif (this.effectState.duration === 1) {\n\t\t\t\t\tthis.add('-end', pokemon, 'Bide');\n\t\t\t\t\tif (!this.effectState.totalDamage) {\n\t\t\t\t\t\tthis.debug(\"Bide failed because no damage was taken\");\n\t\t\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.getAtSlot(this.effectState.sourceSlot);\n\t\t\t\t\tif (target.isSemiInvulnerable()) {\n\t\t\t\t\t\tthis.add('-message', 'The foe ' + target.name + ' can\\'t be hit while flying!');\n\t\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.actions.moveHit(target, pokemon, move, {damage: this.effectState.totalDamage * 2} as ActiveMove);\n\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.add('-activate', pokemon, 'Bide');\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tonDisableMove(pokemon) {\n\t\t\t\tif (!pokemon.hasMove('bide')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const moveSlot of pokemon.moveSlots) {\n\t\t\t\t\tif (moveSlot.id !== 'bide') {\n\t\t\t\t\t\tpokemon.disableMove(moveSlot.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttype: \"???\", // Will look as Normal but it's STAB-less\n\t},\n\tbind: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tclamp: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tcounter: {\n\t\tinherit: true,\n\t\tignoreImmunity: true,\n\t\twillCrit: false,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon, target) {\n\t\t\t// Counter mechanics in Stadium 1:\n\t\t\t// - a move is Counterable if it is Normal or Fighting type, has nonzero Base Power, and is not Counter\n\t\t\t// - Counter succeeds if the target used a Counterable move earlier this turn\n\n\t\t\tconst lastMoveThisTurn = target.side.lastMove && target.side.lastMove.id === target.side.lastSelectedMove &&\n\t\t\t\t!this.queue.willMove(target) && this.dex.moves.get(target.side.lastMove.id);\n\t\t\tif (!lastMoveThisTurn) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: last move was not this turn\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst lastMoveThisTurnIsCounterable = lastMoveThisTurn && lastMoveThisTurn.basePower > 0 &&\n\t\t\t\t['Normal', 'Fighting'].includes(lastMoveThisTurn.type) && lastMoveThisTurn.id !== 'counter';\n\t\t\tif (!lastMoveThisTurnIsCounterable) {\n\t\t\t\tthis.debug(`Stadium 1 Counter: last move ${lastMoveThisTurn.name} was not Counterable`);\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (this.lastDamage <= 0) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: no previous damage exists\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn 2 * this.lastDamage;\n\t\t},\n\t},\n\tfirespin: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\thaze: {\n\t\tinherit: true,\n\t\tonHit(target, source) {\n\t\t\tthis.add('-activate', target, 'move: Haze');\n\t\t\tthis.add('-clearallboost', '[silent]');\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tpokemon.clearBoosts();\n\t\t\t\tpokemon.cureStatus(true);\n\t\t\t\tfor (const id of Object.keys(pokemon.volatiles)) {\n\t\t\t\t\tpokemon.removeVolatile(id);\n\t\t\t\t\tthis.add('-end', pokemon, id, '[silent]');\n\t\t\t\t}\n\t\t\t\tpokemon.recalculateStats!();\n\t\t\t}\n\t\t},\n\t},\n\thyperbeam: {\n\t\tinherit: true,\n\t\tonMoveFail(target, source, move) {\n\t\t\tsource.addVolatile('mustrecharge');\n\t\t},\n\t},\n\tpsywave: {\n\t\tinherit: true,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon) {\n\t\t\treturn this.random(1, this.trunc(1.5 * pokemon.level));\n\t\t},\n\t},\n\trage: {\n\t\tinherit: true,\n\t\tself: {\n\t\t\tvolatileStatus: 'rage',\n\t\t},\n\t\tcondition: {\n\t\t\t// Rage lock\n\t\t\tduration: 255,\n\t\t\tonStart(target, source, effect) {\n\t\t\t\tthis.effectState.move = 'rage';\n\t\t\t},\n\t\t\tonLockMove: 'rage',\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (target.boosts.atk < 6 && (move.category !== 'Status' || move.id === 'disable')) {\n\t\t\t\t\tthis.boost({atk: 1});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\trecover: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\trest: {\n\t\tinherit: true,\n\t\tonHit(target, source, move) {\n\t\t\t// Fails if the difference between\n\t\t\t// max HP and current HP is 0, 255, or 511\n\t\t\tif (target.hp >= target.maxhp) return false;\n\t\t\tif (!target.setStatus('slp', source, move)) return false;\n\t\t\ttarget.statusState.time = 2;\n\t\t\ttarget.statusState.startTime = 2;\n\t\t\ttarget.recalculateStats!(); // Stadium Rest removes statdrops given by Major Status Conditions.\n\t\t\tthis.heal(target.maxhp); // Aesthetic only as the healing happens after you fall asleep in-game\n\t\t},\n\t},\n\tsoftboiled: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\t// Fail when health is 255 or 511 less than max\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\tsubstitute: {\n\t\tinherit: true,\n\t\tonTryHit(target) {\n\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Stadium fixes the 25% = you die gag\n\t\t\tif (target.hp <= target.maxhp / 4) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute', '[weak]');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tcondition: {\n\t\t\tonStart(target) {\n\t\t\t\tthis.add('-start', target, 'Substitute');\n\t\t\t\tthis.effectState.hp = Math.floor(target.maxhp / 4);\n\t\t\t\tdelete target.volatiles['partiallytrapped'];\n\t\t\t},\n\t\t\tonTryHitPriority: -1,\n\t\t\tonTryHit(target, source, move) {\n\t\t\t\tif (target === source) {\n\t\t\t\t\tthis.debug('sub bypass: self hit');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.drain) {\n\t\t\t\t\tthis.add('-miss', source);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tif (move.category === 'Status') {\n\t\t\t\t\tconst SubBlocked = ['leechseed', 'lockon', 'mindreader', 'nightmare'];\n\t\t\t\t\tif (move.status || move.boosts || move.volatileStatus === 'confusion' || SubBlocked.includes(move.id)) {\n\t\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[block] ' + move.name);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.volatileStatus && target === source) return;\n\t\t\t\tlet damage = this.actions.getDamage(source, target, move);\n\t\t\t\tif (!damage && damage !== 0) return null;\n\t\t\t\tdamage = this.runEvent('SubDamage', target, source, move, damage);\n\t\t\t\tif (!damage && damage !== 0) return damage;\n\t\t\t\ttarget.volatiles['substitute'].hp -= damage;\n\t\t\t\tsource.lastDamage = damage;\n\t\t\t\tthis.lastDamage = damage;\n\t\t\t\tif (target.volatiles['substitute'].hp <= 0) {\n\t\t\t\t\tthis.debug('Substitute broke');\n\t\t\t\t\ttarget.removeVolatile('substitute');\n\t\t\t\t\ttarget.subFainted = true;\n\t\t\t\t} else {\n\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[damage]');\n\t\t\t\t}\n\t\t\t\t// Drain/recoil does not happen if the substitute breaks\n\t\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\t\tif (move.recoil) {\n\t\t\t\t\t\tthis.damage(Math.round(damage * move.recoil[0] / move.recoil[1]), source, target, 'recoil');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.runEvent('AfterSubDamage', target, source, move, damage);\n\t\t\t\t// Add here counter damage\n\t\t\t\tconst lastAttackedBy = target.getLastAttackedBy();\n\t\t\t\tif (!lastAttackedBy) {\n\t\t\t\t\ttarget.attackedBy.push({source: source, move: move.id, damage: damage, slot: source.getSlot(), thisTurn: true});\n\t\t\t\t} else {\n\t\t\t\t\tlastAttackedBy.move = move.id;\n\t\t\t\t\tlastAttackedBy.damage = damage;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t},\n\t\t\tonEnd(target) {\n\t\t\t\tthis.add('-end', target, 'Substitute');\n\t\t\t},\n\t\t},\n\t\tsecondary: null,\n\t\ttarget: \"self\",\n\t\ttype: \"Normal\",\n\t},\n\tstruggle: {\n\t\tinherit: true,\n\t\tignoreImmunity: {'Normal': true},\n\t},\n\twrap: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n};\n","import type {ActiveMove, BoostID, ModdedBattleScriptsData, StatIDExceptHP} from '@pkmn/sim';\n\n/**\n * Stadium mechanics inherit from gen 1 mechanics, but fixes some stuff.\n */\nexport const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen1',\n\tgen: 1,\n\t// BattlePokemon scripts. Stadium shares gen 1 code but it fixes some problems with it.\n\tpokemon: {\n\t\tinherit: true,\n\t\t// This is run on Stadium after boosts and status changes.\n\t\trecalculateStats() {\n\t\t\tlet statName: StatIDExceptHP;\n\t\t\tfor (statName in this.storedStats) {\n\t\t\t\tlet stat = this.species.baseStats[statName];\n\t\t\t\tstat = Math.floor(\n\t\t\t\t\tMath.floor(\n\t\t\t\t\t\t2 * stat + this.set.ivs[statName] + Math.floor(this.set.evs[statName] / 4)\n\t\t\t\t\t) * this.level / 100 + 5\n\t\t\t\t);\n\t\t\t\tthis.baseStoredStats[statName] = this.storedStats[statName] = Math.floor(stat);\n\t\t\t\tthis.modifiedStats![statName] = Math.floor(stat);\n\t\t\t\t// Re-apply drops, if necessary.\n\t\t\t\tif (this.status === 'par' && statName === 'spe') this.modifyStat!('spe', 0.25);\n\t\t\t\tif (this.status === 'brn' && statName === 'atk') this.modifyStat!('atk', 0.5);\n\t\t\t\tif (this.boosts[statName] !== 0) {\n\t\t\t\t\tif (this.boosts[statName] >= 0) {\n\t\t\t\t\t\tthis.modifyStat!(statName, [1, 1.5, 2, 2.5, 3, 3.5, 4][this.boosts[statName]]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.modifyStat!(statName, [100, 66, 50, 40, 33, 28, 25][-this.boosts[statName]] / 100);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Stadium's fixed boosting function.\n\t\tboostBy(boost) {\n\t\t\tlet changed = false;\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in boost) {\n\t\t\t\tlet delta = boost[i];\n\t\t\t\tif (delta === undefined) continue;\n\t\t\t\tthis.boosts[i] += delta;\n\t\t\t\tif (this.boosts[i] > 6) {\n\t\t\t\t\tdelta -= this.boosts[i] - 6;\n\t\t\t\t\tthis.boosts[i] = 6;\n\t\t\t\t}\n\t\t\t\tif (this.boosts[i] < -6) {\n\t\t\t\t\tdelta -= this.boosts[i] - (-6);\n\t\t\t\t\tthis.boosts[i] = -6;\n\t\t\t\t}\n\t\t\t\tif (delta) changed = true;\n\t\t\t}\n\t\t\tthis.recalculateStats!();\n\t\t\treturn changed;\n\t\t},\n\t\t// Remove stat recalculation logic from gen 1\n\t\tclearBoosts() {\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in this.boosts) {\n\t\t\t\tthis.boosts[i] = 0;\n\t\t\t}\n\t\t},\n\t},\n\tactions: {\n\t\tinherit: true,\n\t\trunMove(moveOrMoveName, pokemon, targetLoc, sourceEffect) {\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\t\t\tconst target = this.battle.getTarget(pokemon, move, targetLoc);\n\t\t\tif (target?.subFainted) target.subFainted = null;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tif (pokemon.moveThisTurn || !this.battle.runEvent('BeforeMove', pokemon, target, move)) {\n\t\t\t\tthis.battle.debug('' + pokemon.fullname + ' move interrupted; movedThisTurn: ' + pokemon.moveThisTurn);\n\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t// This is only run for sleep\n\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (move.beforeMoveCallback) {\n\t\t\t\tif (move.beforeMoveCallback.call(this.battle, pokemon, target, move)) {\n\t\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpokemon.lastDamage = 0;\n\t\t\tlet lockedMove = this.battle.runEvent('LockMove', pokemon);\n\t\t\tif (lockedMove === true) lockedMove = false;\n\t\t\tif (\n\t\t\t\t!lockedMove &&\n\t\t\t\t(!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].locked !== target)\n\t\t\t) {\n\t\t\t\tpokemon.deductPP(move, null, target);\n\t\t\t\tpokemon.side.lastMove = move;\n\t\t\t\tpokemon.lastMove = move;\n\t\t\t} else {\n\t\t\t\tsourceEffect = move;\n\t\t\t}\n\t\t\tthis.battle.actions.useMove(move, pokemon, target, sourceEffect);\n\t\t},\n\t\t// This function deals with AfterMoveSelf events.\n\t\t// This leads with partial trapping moves shenanigans after the move has been used.\n\t\tuseMove(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tconst moveResult = this.useMoveInner(moveOrMoveName, pokemon, target, sourceEffect);\n\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\n\t\t\tif (move.id !== 'metronome') {\n\t\t\t\tif (move.id !== 'mirrormove' ||\n\t\t\t\t\t(!pokemon.side.foe.active[0]?.lastMove || pokemon.side.foe.active[0].lastMove?.id === 'mirrormove')) {\n\t\t\t\t\t// The move is our 'final' move (a failed Mirror Move, or any move that isn't Metronome or Mirror Move).\n\t\t\t\t\tthis.battle.singleEvent('AfterMove', move, null, pokemon, target, move);\n\n\t\t\t\t\t// If target fainted\n\t\t\t\t\tif (target && target.hp <= 0) {\n\t\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\t\t// We remove screens\n\t\t\t\t\t\ttarget.side.removeSideCondition('reflect');\n\t\t\t\t\t\ttarget.side.removeSideCondition('lightscreen');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\t\t}\n\t\t\t\t\tif (pokemon.volatiles['mustrecharge']) this.battle.add('-mustrecharge', pokemon);\n\n\t\t\t\t\t// For partial trapping moves, we are saving the target.\n\t\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target && target.hp > 0) {\n\t\t\t\t\t\t// It hit, so let's remove must recharge volatile. Yup, this happens on Stadium.\n\t\t\t\t\t\ttarget.removeVolatile('mustrecharge');\n\t\t\t\t\t\t// Let's check if the lock exists\n\t\t\t\t\t\tif (pokemon.volatiles['partialtrappinglock'] && target.volatiles['partiallytrapped']) {\n\t\t\t\t\t\t\t// Here the partialtrappinglock volatile has been already applied\n\t\t\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\t\t\t\t// If it's the first hit, we save the target\n\t\t\t\t\t\t\t\tpokemon.volatiles['partialtrappinglock'].locked = target;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // If we move to here, the move failed and there's no partial trapping lock\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn moveResult;\n\t\t},\n\t\t// This is the function that actually uses the move, running ModifyMove events.\n\t\t// It uses the move and then deals with the effects after the move.\n\t\tuseMoveInner(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t\tthis.battle.debug('not a gen 1 mechanic');\n\t\t\t}\n\t\t\tif (!move) return false;\n\n\t\t\tlet attrs = '';\n\t\t\tif (pokemon.fainted) {\n\t\t\t\t// Removing screens upon faint.\n\t\t\t\tpokemon.side.removeSideCondition('reflect');\n\t\t\t\tpokemon.side.removeSideCondition('lightscreen');\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (sourceEffect) attrs += '|[from]' + this.battle.dex.conditions.get(sourceEffect);\n\t\t\tthis.battle.addMove('move', pokemon, move.name, target + attrs);\n\n\t\t\tif (!this.battle.singleEvent('Try', move, null, pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!this.battle.singleEvent('TryMove', move, null, pokemon, target, move) ||\n\t\t\t\t!this.battle.runEvent('TryMove', pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tlet damage: number | undefined | false | '' = false;\n\t\t\tif (!target || target.fainted) {\n\t\t\t\tthis.battle.attrLastMove('[notarget]');\n\t\t\t\tthis.battle.add('-notarget');\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tdamage = this.tryMoveHit(target, pokemon, move);\n\n\t\t\t// Store 0 damage for last damage if move failed.\n\t\t\t// This only happens on moves that don't deal damage but call GetDamageVarsForPlayerAttack (disassembly).\n\t\t\tconst neverDamageMoves = [\n\t\t\t\t'conversion', 'haze', 'mist', 'focusenergy', 'confuseray', 'supersonic', 'transform', 'lightscreen', 'reflect', 'substitute', 'mimic', 'leechseed', 'splash', 'softboiled', 'recover', 'rest',\n\t\t\t];\n\t\t\tif (\n\t\t\t\t!damage && damage !== 0 &&\n\t\t\t\t(move.category !== 'Status' || (move.status && !['psn', 'tox', 'par'].includes(move.status))) &&\n\t\t\t\t!neverDamageMoves.includes(move.id)\n\t\t\t) {\n\t\t\t\tthis.battle.lastDamage = 0;\n\t\t\t}\n\n\t\t\t// Go ahead with results of the used move.\n\t\t\tif (damage === false) {\n\t\t\t\tthis.battle.singleEvent('MoveFail', move, null, target, pokemon, move);\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondarySelf', move, null, pokemon, target, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondarySelf', pokemon, target, move);\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\ttryMoveHit(target, pokemon, move) {\n\t\t\tlet damage: number | false | undefined = 0;\n\n\t\t\t// First, check if the target is semi-invulnerable\n\t\t\tlet hitResult = this.battle.runEvent('Invulnerability', target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Then, check if the Pokemon is immune to this move.\n\t\t\tif (\n\t\t\t\t(!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) &&\n\t\t\t\t!target.runImmunity(move.type, true)\n\t\t\t) {\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thitResult = this.battle.singleEvent('TryImmunity', move, null, target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.add('-immune', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Now, let's calculate the accuracy.\n\t\t\tlet accuracy = move.accuracy;\n\n\t\t\t// Partial trapping moves: true accuracy while it lasts\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target === pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\taccuracy = true;\n\t\t\t\t} else if (pokemon.volatiles['partialtrappinglock'].locked !== target) {\n\t\t\t\t\t// The target switched, therefor, you fail using wrap.\n\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// OHKO moves only have a chance to hit if the user is at least as fast as the target\n\t\t\tif (move.ohko) {\n\t\t\t\tif (target.speed > pokemon.speed) {\n\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Calculate true accuracy for gen 1, which uses 0-255.\n\t\t\t// Stadium uses the Gen 2 boost table for accuracy and evasiveness, except for 1/3 instead of 0.33\n\t\t\tconst boostTable = [1 / 3, 0.36, 0.43, 0.5, 0.66, 0.75, 1, 1.33, 1.66, 2, 2.33, 2.66, 3];\n\t\t\tif (accuracy !== true) {\n\t\t\t\taccuracy = Math.floor(accuracy * 255 / 100);\n\t\t\t\t// Check also for accuracy modifiers.\n\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[pokemon.boosts.accuracy + 6]);\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[-target.boosts.evasion + 6]);\n\t\t\t\t}\n\t\t\t\taccuracy = Math.min(accuracy, 255);\n\t\t\t}\n\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\n\t\t\t// Stadium fixes the 1/256 accuracy bug.\n\t\t\tif (accuracy !== true && !this.battle.randomChance(accuracy + 1, 256)) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tdamage = false;\n\t\t\t}\n\n\t\t\t// If damage is 0 and not false it means it didn't miss, let's calc.\n\t\t\tif (damage !== false) {\n\t\t\t\tpokemon.lastDamage = 0;\n\t\t\t\tif (move.multihit) {\n\t\t\t\t\tlet hits = move.multihit;\n\t\t\t\t\tif (Array.isArray(hits)) {\n\t\t\t\t\t\t// Yes, it's hardcoded... meh\n\t\t\t\t\t\tif (hits[0] === 2 && hits[1] === 5) {\n\t\t\t\t\t\t\thits = this.battle.sample([2, 2, 2, 3, 3, 3, 4, 5]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\thits = this.battle.random(hits[0], hits[1] + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thits = Math.floor(hits);\n\t\t\t\t\t// In gen 1, all the hits have the same damage for multihits move\n\t\t\t\t\tlet moveDamage: number | false | undefined = 0;\n\t\t\t\t\tlet i: number;\n\t\t\t\t\tfor (i = 0; i < hits && target.hp && pokemon.hp; i++) {\n\t\t\t\t\t\tmove.hit = i + 1;\n\t\t\t\t\t\tif (move.hit === hits) move.lastHit = true;\n\t\t\t\t\t\tmoveDamage = this.moveHit(target, pokemon, move);\n\t\t\t\t\t\tif (moveDamage === false) break;\n\t\t\t\t\t\tdamage = (moveDamage || 0);\n\t\t\t\t\t\t// Move damage is fixed to be the first move's damage\n\t\t\t\t\t\tif (i === 0) move.damage = damage;\n\t\t\t\t\t\tif (target.subFainted) {\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmove.damage = null;\n\t\t\t\t\tif (i === 0) return 1;\n\t\t\t\t\tthis.battle.add('-hitcount', target, i);\n\t\t\t\t} else {\n\t\t\t\t\tdamage = this.moveHit(target, pokemon, move);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (move.category !== 'Status') target.gotAttacked(move, damage, pokemon);\n\n\t\t\tif (move.selfdestruct) {\n\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t}\n\n\t\t\t// The move missed.\n\t\t\tif (damage === false) {\n\t\t\t\t// Delete the partial trap lock if necessary.\n\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.ohko) this.battle.add('-ohko');\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondary', target, pokemon, move);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tmoveHit(target, pokemon, moveOrMoveName, moveData, isSecondary, isSelf) {\n\t\t\tlet damage: number | false | null | undefined = 0;\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\n\t\t\tif (!isSecondary && !isSelf) this.battle.setActiveMove(move, pokemon, target);\n\t\t\tlet hitResult: number | boolean = true;\n\t\t\tif (!moveData) moveData = move;\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\thitResult = this.battle.singleEvent('TryHit', moveData, {}, target, pokemon, move);\n\n\t\t\t\t// Partial trapping moves still apply their volatile to Pokémon behind a Sub\n\t\t\t\tconst targetHadSub = !!target.volatiles['substitute'];\n\t\t\t\tif (targetHadSub && moveData.volatileStatus && moveData.volatileStatus === 'partiallytrapped') {\n\t\t\t\t\ttarget.addVolatile(moveData.volatileStatus, pokemon, move);\n\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].duration > 1) {\n\t\t\t\t\t\ttarget.volatiles[moveData.volatileStatus].duration = 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Only run the hit events for the hit itself, not the secondary or self hits\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHit', target, pokemon, move);\n\t\t\t\t\tif (!hitResult) {\n\t\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\t\t// Special Substitute hit flag\n\t\t\t\t\t\tif (hitResult !== 0) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!this.battle.runEvent('TryFieldHit', target, pokemon, move)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else if (isSecondary && !moveData.self) {\n\t\t\t\t\thitResult = this.battle.runEvent('TrySecondaryHit', target, pokemon, moveData);\n\t\t\t\t}\n\n\t\t\t\tif (hitResult === 0) {\n\t\t\t\t\ttarget = null;\n\t\t\t\t} else if (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\tlet didSomething = false;\n\n\t\t\t\tdamage = this.getDamage(pokemon, target, moveData);\n\t\t\t\tif ((damage || damage === 0) && !target.fainted) {\n\t\t\t\t\tdamage = this.battle.damage(damage, target, pokemon, move);\n\t\t\t\t\tif (!(damage || damage === 0)) return false;\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t} else if (damage === false && typeof hitResult === 'undefined') {\n\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t}\n\t\t\t\tif (damage === false || damage === null) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (moveData.boosts && !target.fainted) {\n\t\t\t\t\tthis.battle.boost(moveData.boosts, target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (moveData.heal && !target.fainted) {\n\t\t\t\t\tconst d = target.heal(Math.floor(target.maxhp * moveData.heal[0] / moveData.heal[1]));\n\t\t\t\t\tif (!d) {\n\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.battle.add('-heal', target, target.getHealth);\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.status) {\n\t\t\t\t\tif (!target.status) {\n\t\t\t\t\t\ttarget.setStatus(moveData.status, pokemon, move);\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t} else if (!isSecondary) {\n\t\t\t\t\t\tif (target.status === moveData.status) {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target, target.status);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.forceStatus) {\n\t\t\t\t\tif (target.setStatus(moveData.forceStatus, pokemon, move)) {\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.volatileStatus) {\n\t\t\t\t\tif (target.addVolatile(moveData.volatileStatus, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.sideCondition) {\n\t\t\t\t\tif (target.side.addSideCondition(moveData.sideCondition, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.pseudoWeather) {\n\t\t\t\t\tif (this.battle.field.addPseudoWeather(moveData.pseudoWeather, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Hit events\n\t\t\t\thitResult = this.battle.singleEvent('Hit', moveData, {}, target, pokemon, move);\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\tthis.battle.runEvent('Hit', target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (!hitResult && !didSomething) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Here's where self effects are applied.\n\t\t\tif (moveData.self) {\n\t\t\t\tthis.moveHit(pokemon, pokemon, move, moveData.self, isSecondary, true);\n\t\t\t}\n\n\t\t\t// Now we can save the partial trapping damage.\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tpokemon.volatiles['partialtrappinglock'].damage = pokemon.lastDamage;\n\t\t\t}\n\n\t\t\t// Apply move secondaries.\n\t\t\tif (moveData.secondaries) {\n\t\t\t\tfor (const secondary of moveData.secondaries) {\n\t\t\t\t\t// Multi-hit moves only roll for status once\n\t\t\t\t\tif (!move.multihit || move.lastHit) {\n\t\t\t\t\t\t// We check here whether to negate the probable secondary status if it's para, burn, or freeze.\n\t\t\t\t\t\t// In the game, this is checked and if true, the random number generator is not called.\n\t\t\t\t\t\t// That means that a move that does not share the type of the target can status it.\n\t\t\t\t\t\t// If a move that was not fire-type would exist on Gen 1, it could burn a Pokémon.\n\t\t\t\t\t\tif (!(secondary.status && ['par', 'brn', 'frz'].includes(secondary.status) && target && target.hasType(move.type))) {\n\t\t\t\t\t\t\tconst effectChance = Math.floor((secondary.chance || 100) * 255 / 100);\n\t\t\t\t\t\t\tif (typeof secondary.chance === 'undefined' || this.battle.randomChance(effectChance + 1, 256)) {\n\t\t\t\t\t\t\t\tthis.moveHit(target, pokemon, move, secondary, true, isSelf);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (move.selfSwitch && pokemon.hp) {\n\t\t\t\tpokemon.switchFlag = move.selfSwitch === true ? true : this.dex.toID(move.selfSwitch);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tgetDamage(source, target, move, suppressMessages) {\n\t\t\t// First of all, we get the move.\n\t\t\tif (typeof move === 'string') {\n\t\t\t\tmove = this.dex.getActiveMove(move);\n\t\t\t} else if (typeof move === 'number') {\n\t\t\t\tmove = {\n\t\t\t\t\tbasePower: move,\n\t\t\t\t\ttype: '???',\n\t\t\t\t\tcategory: 'Physical',\n\t\t\t\t\twillCrit: false,\n\t\t\t\t\tflags: {},\n\t\t\t\t} as ActiveMove;\n\t\t\t}\n\n\t\t\t// Let's see if the target is immune to the move.\n\t\t\tif (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {\n\t\t\t\tif (!target.runImmunity(move.type, true)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Is it an OHKO move?\n\t\t\tif (move.ohko) {\n\t\t\t\treturn target.maxhp;\n\t\t\t}\n\n\t\t\t// We edit the damage through move's damage callback if necessary.\n\t\t\tif (move.damageCallback) {\n\t\t\t\treturn move.damageCallback.call(this.battle, source, target);\n\t\t\t}\n\n\t\t\t// We take damage from damage=level moves (seismic toss).\n\t\t\tif (move.damage === 'level') {\n\t\t\t\treturn source.level;\n\t\t\t}\n\n\t\t\t// If there's a fix move damage, we return that.\n\t\t\tif (move.damage) {\n\t\t\t\treturn move.damage;\n\t\t\t}\n\n\t\t\t// If it's the first hit on a Normal-type partially trap move, it hits Ghosts anyways but damage is 0.\n\t\t\tif (move.volatileStatus === 'partiallytrapped' && move.type === 'Normal' && target.hasType('Ghost')) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Let's check if we are in middle of a partial trap sequence to return the previous damage.\n\t\t\tif (source.volatiles['partialtrappinglock'] && (target === source.volatiles['partialtrappinglock'].locked)) {\n\t\t\t\treturn source.volatiles['partialtrappinglock'].damage;\n\t\t\t}\n\n\t\t\t// We check the category and typing to calculate later on the damage.\n\t\t\tif (!move.category) move.category = 'Physical';\n\t\t\t// '???' is typeless damage: used for Struggle and Confusion etc\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// We get the base power and apply basePowerCallback if necessary.\n\t\t\tlet basePower: number | false | null = move.basePower;\n\t\t\tif (move.basePowerCallback) {\n\t\t\t\tbasePower = move.basePowerCallback.call(this.battle, source, target, move);\n\t\t\t}\n\t\t\tif (!basePower) {\n\t\t\t\treturn basePower === 0 ? undefined : basePower;\n\t\t\t}\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// Checking for the move's Critical Hit possibility. We check if it's a 100% crit move, otherwise we calculate the chance.\n\t\t\tlet isCrit = move.willCrit || false;\n\t\t\tif (!isCrit) {\n\t\t\t\t// In Stadium, the critical chance is based on speed.\n\t\t\t\t// First, we get the base speed and store it. Then we add 76. This is our current crit chance.\n\t\t\t\tlet critChance = source.species.baseStats['spe'] + 76;\n\n\t\t\t\t// Now we right logical shift it two places, essentially dividing by 4 and flooring it.\n\t\t\t\tcritChance = critChance >> 2;\n\n\t\t\t\t// Now we check for focus energy volatile.\n\t\t\t\tif (source.volatiles['focusenergy']) {\n\t\t\t\t\t// If it exists, crit chance is multiplied by 4 and floored with a logical left shift.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t\t// Then we add 160.\n\t\t\t\t\tcritChance += 160;\n\t\t\t\t} else {\n\t\t\t\t\t// If it is not active, we left shift it by 1.\n\t\t\t\t\tcritChance = critChance << 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we check for the move's critical hit ratio.\n\t\t\t\tif (move.critRatio === 2) {\n\t\t\t\t\t// High crit ratio, we multiply the result so far by 4.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t} else if (move.critRatio === 1) {\n\t\t\t\t\t// Normal hit ratio, we divide the crit chance by 2 and floor the result again.\n\t\t\t\t\tcritChance = critChance >> 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we make sure it's a number between 1 and 255.\n\t\t\t\tcritChance = this.battle.clampIntRange(critChance, 1, 255);\n\n\t\t\t\t// Last, we check deppending on ratio if the move critical hits or not.\n\t\t\t\t// We compare our critical hit chance against a random number between 0 and 255.\n\t\t\t\t// If the random number is lower, we get a critical hit. This means there is always a 1/255 chance of not hitting critically.\n\t\t\t\tif (critChance > 0) {\n\t\t\t\t\tisCrit = this.battle.randomChance(critChance, 256);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// There is a critical hit.\n\t\t\tif (isCrit && this.battle.runEvent('CriticalHit', target, null, move)) {\n\t\t\t\ttarget.getMoveHitData(move).crit = true;\n\t\t\t}\n\n\t\t\t// Happens after crit calculation.\n\t\t\tif (basePower) {\n\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower);\n\t\t\t\tif (basePower && move.basePowerModifier) {\n\t\t\t\t\tbasePower *= move.basePowerModifier;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!basePower) return 0;\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// We now check attacker's and defender's stats.\n\t\t\tlet level = source.level;\n\t\t\tconst attacker = move.overrideOffensivePokemon === 'target' ? target : source;\n\t\t\tconst defender = move.overrideDefensivePokemon === 'source' ? source : target;\n\n\t\t\tconst isPhysical = move.category === 'Physical';\n\t\t\tconst atkType: StatIDExceptHP = move.overrideOffensiveStat || (isPhysical ? 'atk' : 'spa');\n\t\t\tconst defType: StatIDExceptHP = move.overrideDefensiveStat || (isPhysical ? 'def' : 'spd');\n\n\t\t\tlet attack = attacker.getStat(atkType);\n\t\t\tlet defense = defender.getStat(defType);\n\n\t\t\t// In gen 1, screen effect is applied here.\n\t\t\tif ((defType === 'def' && defender.volatiles['reflect']) || (defType === 'spd' && defender.volatiles['lightscreen'])) {\n\t\t\t\tthis.battle.debug('Screen doubling (Sp)Def');\n\t\t\t\tdefense *= 2;\n\t\t\t\tdefense = this.battle.clampIntRange(defense, 1, 1998);\n\t\t\t}\n\n\t\t\t// In the event of a critical hit, the offense and defense changes are ignored.\n\t\t\t// This includes both boosts and screens.\n\t\t\t// Also, level is doubled in damage calculation.\n\t\t\tif (isCrit) {\n\t\t\t\tmove.ignoreOffensive = true;\n\t\t\t\tmove.ignoreDefensive = true;\n\t\t\t\tlevel *= 2;\n\t\t\t\tif (!suppressMessages) this.battle.add('-crit', target);\n\t\t\t}\n\n\t\t\tif (move.ignoreOffensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)atk boost/penalty.');\n\t\t\t\tattack = attacker.getStat(atkType, true);\n\t\t\t}\n\n\t\t\tif (move.ignoreDefensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)def boost/penalty.');\n\t\t\t\tdefense = target.getStat(defType, true);\n\t\t\t}\n\n\t\t\t// When either attack or defense are higher than 256, they are both divided by 4 and moded by 256.\n\t\t\t// This is what cuases the roll over bugs.\n\t\t\tif (attack >= 256 || defense >= 256) {\n\t\t\t\tattack = this.battle.clampIntRange(Math.floor(attack / 4) % 256, 1);\n\t\t\t\t// Defense isn't checked on the cartridge, but we don't want those / 0 bugs on the sim.\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 4) % 256, 1);\n\t\t\t}\n\n\t\t\t// Self destruct moves halve defense at this point.\n\t\t\tif (move.selfdestruct && defType === 'def') {\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 2), 1);\n\t\t\t}\n\n\t\t\t// Let's go with the calculation now that we have what we need.\n\t\t\t// We do it step by step just like the game does.\n\t\t\tlet damage = level * 2;\n\t\t\tdamage = Math.floor(damage / 5);\n\t\t\tdamage += 2;\n\t\t\tdamage *= basePower;\n\t\t\tdamage *= attack;\n\t\t\tdamage = Math.floor(damage / defense);\n\t\t\tdamage = this.battle.clampIntRange(Math.floor(damage / 50), 1, 997);\n\t\t\tdamage += 2;\n\n\t\t\t// STAB damage bonus, the \"???\" type never gets STAB\n\t\t\tif (type !== '???' && source.hasType(type)) {\n\t\t\t\tdamage += Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// Type effectiveness.\n\t\t\t// The order here is not correct, must change to check the move versus each type.\n\t\t\tconst totalTypeMod = this.dex.getEffectiveness(type, target);\n\t\t\t// Super effective attack\n\t\t\tif (totalTypeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\t\t\t\tdamage *= 20;\n\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\tif (totalTypeMod >= 2) {\n\t\t\t\t\tdamage *= 20;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (totalTypeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\t\t\t\tdamage *= 5;\n\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\tif (totalTypeMod <= -2) {\n\t\t\t\t\tdamage *= 5;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If damage becomes 0, the move is made to miss.\n\t\t\t// This occurs when damage was either 2 or 3 prior to applying STAB/Type matchup, and target is 4x resistant to the move.\n\t\t\tif (damage === 0) return damage;\n\n\t\t\t// Apply random factor if damage is greater than 1\n\t\t\tif (damage > 1) {\n\t\t\t\tdamage *= this.battle.random(217, 256);\n\t\t\t\tdamage = Math.floor(damage / 255);\n\t\t\t\tif (damage > target.hp && !target.volatiles['substitute']) damage = target.hp;\n\t\t\t\tif (target.volatiles['substitute'] && damage > target.volatiles['substitute'].hp) {\n\t\t\t\t\tdamage = target.volatiles['substitute'].hp;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We are done, this is the final damage.\n\t\t\treturn Math.floor(damage);\n\t\t},\n\t},\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/gen1stadium/conditions.ts","../../src/gen1stadium/rulesets.ts","../../src/gen1stadium/moves.ts","../../src/gen1stadium/scripts.ts"],"names":[],"mappings":";AAEO,IAAM,aAAiD;AAAA,EAC7D,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ;AACf,WAAK,IAAI,WAAW,QAAQ,KAAK;AAAA,IAClC;AAAA,IACA,yBAAyB;AAAA,IACzB,gBAAgB,SAAS;AACxB,WAAK,OAAO,KAAK,cAAc,KAAK,MAAM,QAAQ,QAAQ,EAAE,GAAG,CAAC,CAAC;AAAA,IAClE;AAAA,IACA,oBAAoB,SAAS;AAC5B,WAAK,OAAO,KAAK,cAAc,KAAK,MA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V,eAAS,KAAK,MAAM,SAAS,OAAO;AACpC,eAAS,KAAK,OAAO,cAAc,KAAK,MAAM,SAAS,EAAE,GAAG,GAAG,GAAG;AAClE,gBAAU;AAGV,UAAI,SAAS,SAAS,OAAO,QAAQ,IAAI,GAAG;AAC3C,kBAAU,KAAK,MAAM,SAAS,CAAC;AAAA,MAChC;AAIA,iBAAW,cAAc,OAAO,OAAO;AACtC,cAAM,UAAU,KAAK,OAAO,IAAI,iBAAiB,MAAM,UAAU;AACjE,YAAI,UAAU,GAAG;AAEhB,oBAAU;AACV,mBAAS,KAAK,MAAM,SAAS,EAAE;AAAA,QAChC;AACA,YAAI,UAAU,GAAG;AAEhB,oBAAU;AACV,mBAAS,KAAK,MAAM,SAAS,EAAE;AAAA,QAChC;AAAA,MACD;AACA,YAAM,eAAe,OAAO,iBAAiB,IAAI;AACjD,UAAI,eAAe,GAAG;AACrB,YAAI,CAAC;AAAkB,eAAK,OAAO,IAAI,mBAAmB,MAAM;AAAA,MACjE;AACA,UAAI,eAAe,GAAG;AACrB,YAAI,CAAC;AAAkB,eAAK,OAAO,IAAI,aAAa,MAAM;AAAA,MAC3D;AAIA,UAAI,WAAW;AAAG,eAAO;AAGzB,UAAI,SAAS,GAAG;AACf,kBAAU,KAAK,OAAO,OAAO,KAAK,GAAG;AACrC,iBAAS,KAAK,MAAM,SAAS,GAAG;AAChC,YAAI,SAAS,OAAO,MAAM,CAAC,OAAO,UAAU;AAAe,mBAAS,OAAO;AAC3E,YAAI,OAAO,UAAU,iBAAiB,SAAS,OAAO,UAAU,cAAc,IAAI;AACjF,mBAAS,OAAO,UAAU,cAAc;AAAA,QACzC;AAAA,MACD;AAGA,aAAO,KAAK,MAAM,MAAM;AAAA,IACzB;AAAA,EACD;AACD","sourcesContent":["import type {ModdedConditionData} from '@pkmn/sim';\n\nexport const Conditions: {[k: string]: ModdedConditionData} = {\n\tbrn: {\n\t\tname: 'brn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'brn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tpar: {\n\t\tname: 'par',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'par');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.randomChance(63, 256)) {\n\t\t\t\tthis.add('cant', pokemon, 'par');\n\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\tpokemon.removeVolatile('lockedmovee');\n\t\t\t\tpokemon.removeVolatile('twoturnmove');\n\t\t\t\tpokemon.removeVolatile('fly');\n\t\t\t\tpokemon.removeVolatile('dig');\n\t\t\t\tpokemon.removeVolatile('solarbeam');\n\t\t\t\tpokemon.removeVolatile('skullbash');\n\t\t\t\tpokemon.removeVolatile('partialtrappinglock');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n\tslp: {\n\t\tname: 'slp',\n\t\teffectType: 'Status',\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.effectType === 'Move') {\n\t\t\t\tthis.add('-status', target, 'slp', '[from] move: ' + sourceEffect.name);\n\t\t\t} else {\n\t\t\t\tthis.add('-status', target, 'slp');\n\t\t\t}\n\t\t\t// 1-3 turns\n\t\t\tthis.effectState.startTime = this.random(1, 4);\n\t\t\tthis.effectState.time = this.effectState.startTime;\n\n\t\t\tif (target.removeVolatile('nightmare')) {\n\t\t\t\tthis.add('-end', target, 'Nightmare', '[silent]');\n\t\t\t}\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.statusState.time--;\n\t\t\tthis.add('cant', pokemon, 'slp');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tif (pokemon.statusState.time <= 0) pokemon.cureStatus();\n\t\t},\n\t},\n\tfrz: {\n\t\tname: 'frz',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'frz');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tthis.add('cant', pokemon, 'frz');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonHit(target, source, move) {\n\t\t\tif (move.type === 'Fire' && move.category !== 'Status') {\n\t\t\t\ttarget.cureStatus();\n\t\t\t}\n\t\t},\n\t},\n\tpsn: {\n\t\tname: 'psn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'psn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tconfusion: {\n\t\tinherit: true,\n\t\tonStart(target) {\n\t\t\tthis.add('-start', target, 'confusion');\n\t\t\tthis.effectState.time = this.random(2, 6);\n\t\t},\n\t},\n\tflinch: {\n\t\tinherit: true,\n\t\tonStart() {},\n\t},\n\tpartiallytrapped: {\n\t\tname: 'partiallytrapped',\n\t\tduration: 2,\n\t\tonBeforeMovePriority: 1,\n\t\tonStart(target, source, effect) {\n\t\t\tthis.add('-activate', target, 'move: ' + effect, '[of] ' + source);\n\t\t},\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.effectState.source && (!this.effectState.source.isActive || this.effectState.source.hp <= 0)) {\n\t\t\t\tpokemon.removeVolatile('partiallytrapped');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('cant', pokemon, 'partiallytrapped');\n\t\t\treturn false;\n\t\t},\n\t\tonEnd(pokemon) {\n\t\t\tthis.add('-end', pokemon, this.effectState.sourceEffect, '[partiallytrapped]');\n\t\t},\n\t},\n};\n","import type {ModdedFormatData} from '@pkmn/sim';\n\nexport const Rulesets: {[k: string]: ModdedFormatData} = {\n\tstandard: {\n\t\teffectType: 'ValidatorRule',\n\t\tname: 'Standard',\n\t\truleset: ['Obtainable', 'Stadium Sleep Clause', 'Freeze Clause Mod', 'Species Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Exact HP Mod', 'Cancel Mod'],\n\t},\n};\n","import type {ActiveMove, ModdedMoveData} from '@pkmn/sim';\n\nexport const Moves: {[k: string]: ModdedMoveData} = {\n\tbide: {\n\t\tinherit: true,\n\t\tpriority: 0,\n\t\taccuracy: true,\n\t\tignoreEvasion: true,\n\t\tcondition: {\n\t\t\tduration: 2,\n\t\t\tdurationCallback(target, source, effect) {\n\t\t\t\treturn this.random(3, 5);\n\t\t\t},\n\t\t\tonStart(pokemon) {\n\t\t\t\tthis.effectState.totalDamage = 0;\n\t\t\t\tthis.effectState.lastDamage = 0;\n\t\t\t\tthis.add('-start', pokemon, 'Bide');\n\t\t\t},\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (source && source !== target && move.category !== 'Physical' && move.category !== 'Special') {\n\t\t\t\t\tconst damage = this.effectState.totalDamage;\n\t\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t\t}\n\t\t\t},\n\t\t\tonDamage(damage, target, source, move) {\n\t\t\t\tif (!source || source.isAlly(target)) return;\n\t\t\t\tif (!move || move.effectType !== 'Move') return;\n\t\t\t\tif (!damage && this.effectState.lastDamage > 0) {\n\t\t\t\t\tdamage = this.effectState.totalDamage;\n\t\t\t\t}\n\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t},\n\t\t\tonAfterSetStatus(status, pokemon) {\n\t\t\t\t// Sleep, freeze, and partial trap will just pause duration.\n\t\t\t\tif (pokemon.volatiles['flinch']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else if (pokemon.volatiles['partiallytrapped']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else {\n\t\t\t\t\tswitch (status.id) {\n\t\t\t\t\tcase 'slp':\n\t\t\t\t\tcase 'frz':\n\t\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tonBeforeMove(pokemon, t, move) {\n\t\t\t\tif (this.effectState.duration === 1) {\n\t\t\t\t\tthis.add('-end', pokemon, 'Bide');\n\t\t\t\t\tif (!this.effectState.totalDamage) {\n\t\t\t\t\t\tthis.debug(\"Bide failed because no damage was taken\");\n\t\t\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.getAtSlot(this.effectState.sourceSlot);\n\t\t\t\t\tif (target.isSemiInvulnerable()) {\n\t\t\t\t\t\tthis.add('-message', 'The foe ' + target.name + ' can\\'t be hit while flying!');\n\t\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.actions.moveHit(target, pokemon, move, {damage: this.effectState.totalDamage * 2} as ActiveMove);\n\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.add('-activate', pokemon, 'Bide');\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tonDisableMove(pokemon) {\n\t\t\t\tif (!pokemon.hasMove('bide')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const moveSlot of pokemon.moveSlots) {\n\t\t\t\t\tif (moveSlot.id !== 'bide') {\n\t\t\t\t\t\tpokemon.disableMove(moveSlot.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttype: \"???\", // Will look as Normal but it's STAB-less\n\t},\n\tbind: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tclamp: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tcounter: {\n\t\tinherit: true,\n\t\tignoreImmunity: true,\n\t\twillCrit: false,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon, target) {\n\t\t\t// Counter mechanics in Stadium 1:\n\t\t\t// - a move is Counterable if it is Normal or Fighting type, has nonzero Base Power, and is not Counter\n\t\t\t// - Counter succeeds if the target used a Counterable move earlier this turn\n\n\t\t\tconst lastMoveThisTurn = target.side.lastMove && target.side.lastMove.id === target.side.lastSelectedMove &&\n\t\t\t\t!this.queue.willMove(target) && this.dex.moves.get(target.side.lastMove.id);\n\t\t\tif (!lastMoveThisTurn) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: last move was not this turn\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst lastMoveThisTurnIsCounterable = lastMoveThisTurn && lastMoveThisTurn.basePower > 0 &&\n\t\t\t\t['Normal', 'Fighting'].includes(lastMoveThisTurn.type) && lastMoveThisTurn.id !== 'counter';\n\t\t\tif (!lastMoveThisTurnIsCounterable) {\n\t\t\t\tthis.debug(`Stadium 1 Counter: last move ${lastMoveThisTurn.name} was not Counterable`);\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (this.lastDamage <= 0) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: no previous damage exists\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn 2 * this.lastDamage;\n\t\t},\n\t},\n\tfirespin: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\thaze: {\n\t\tinherit: true,\n\t\tonHit(target, source) {\n\t\t\tthis.add('-activate', target, 'move: Haze');\n\t\t\tthis.add('-clearallboost', '[silent]');\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tpokemon.clearBoosts();\n\t\t\t\tpokemon.cureStatus(true);\n\t\t\t\tfor (const id of Object.keys(pokemon.volatiles)) {\n\t\t\t\t\tpokemon.removeVolatile(id);\n\t\t\t\t\tthis.add('-end', pokemon, id, '[silent]');\n\t\t\t\t}\n\t\t\t\tpokemon.recalculateStats!();\n\t\t\t}\n\t\t},\n\t},\n\thyperbeam: {\n\t\tinherit: true,\n\t\tonMoveFail(target, source, move) {\n\t\t\tsource.addVolatile('mustrecharge');\n\t\t},\n\t},\n\tpsywave: {\n\t\tinherit: true,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon) {\n\t\t\treturn this.random(1, this.trunc(1.5 * pokemon.level));\n\t\t},\n\t},\n\trage: {\n\t\tinherit: true,\n\t\tself: {\n\t\t\tvolatileStatus: 'rage',\n\t\t},\n\t\tcondition: {\n\t\t\t// Rage lock\n\t\t\tduration: 255,\n\t\t\tonStart(target, source, effect) {\n\t\t\t\tthis.effectState.move = 'rage';\n\t\t\t},\n\t\t\tonLockMove: 'rage',\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (target.boosts.atk < 6 && (move.category !== 'Status' || move.id === 'disable')) {\n\t\t\t\t\tthis.boost({atk: 1});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\trecover: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\trest: {\n\t\tinherit: true,\n\t\tonHit(target, source, move) {\n\t\t\t// Fails if the difference between\n\t\t\t// max HP and current HP is 0, 255, or 511\n\t\t\tif (target.hp >= target.maxhp) return false;\n\t\t\tif (!target.setStatus('slp', source, move)) return false;\n\t\t\ttarget.statusState.time = 2;\n\t\t\ttarget.statusState.startTime = 2;\n\t\t\ttarget.recalculateStats!(); // Stadium Rest removes statdrops given by Major Status Conditions.\n\t\t\tthis.heal(target.maxhp); // Aesthetic only as the healing happens after you fall asleep in-game\n\t\t},\n\t},\n\tsoftboiled: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\t// Fail when health is 255 or 511 less than max\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\tsubstitute: {\n\t\tinherit: true,\n\t\tonTryHit(target) {\n\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Stadium fixes the 25% = you die gag\n\t\t\tif (target.hp <= target.maxhp / 4) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute', '[weak]');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tcondition: {\n\t\t\tonStart(target) {\n\t\t\t\tthis.add('-start', target, 'Substitute');\n\t\t\t\tthis.effectState.hp = Math.floor(target.maxhp / 4);\n\t\t\t\tdelete target.volatiles['partiallytrapped'];\n\t\t\t},\n\t\t\tonTryHitPriority: -1,\n\t\t\tonTryHit(target, source, move) {\n\t\t\t\tif (target === source) {\n\t\t\t\t\tthis.debug('sub bypass: self hit');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.drain) {\n\t\t\t\t\tthis.add('-miss', source);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tif (move.category === 'Status') {\n\t\t\t\t\tconst SubBlocked = ['leechseed', 'lockon', 'mindreader', 'nightmare'];\n\t\t\t\t\tif (move.status || move.boosts || move.volatileStatus === 'confusion' || SubBlocked.includes(move.id)) {\n\t\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[block] ' + move.name);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.volatileStatus && target === source) return;\n\t\t\t\tlet damage = this.actions.getDamage(source, target, move);\n\t\t\t\tif (!damage && damage !== 0) return null;\n\t\t\t\tdamage = this.runEvent('SubDamage', target, source, move, damage);\n\t\t\t\tif (!damage && damage !== 0) return damage;\n\t\t\t\ttarget.volatiles['substitute'].hp -= damage;\n\t\t\t\tsource.lastDamage = damage;\n\t\t\t\tthis.lastDamage = damage;\n\t\t\t\tif (target.volatiles['substitute'].hp <= 0) {\n\t\t\t\t\tthis.debug('Substitute broke');\n\t\t\t\t\ttarget.removeVolatile('substitute');\n\t\t\t\t\ttarget.subFainted = true;\n\t\t\t\t} else {\n\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[damage]');\n\t\t\t\t}\n\t\t\t\t// Drain/recoil does not happen if the substitute breaks\n\t\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\t\tif (move.recoil) {\n\t\t\t\t\t\tthis.damage(this.clampIntRange(Math.floor(damage * move.recoil[0] / move.recoil[1]), 1), source, target, 'recoil');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.runEvent('AfterSubDamage', target, source, move, damage);\n\t\t\t\t// Add here counter damage\n\t\t\t\tconst lastAttackedBy = target.getLastAttackedBy();\n\t\t\t\tif (!lastAttackedBy) {\n\t\t\t\t\ttarget.attackedBy.push({source: source, move: move.id, damage: damage, slot: source.getSlot(), thisTurn: true});\n\t\t\t\t} else {\n\t\t\t\t\tlastAttackedBy.move = move.id;\n\t\t\t\t\tlastAttackedBy.damage = damage;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t},\n\t\t\tonEnd(target) {\n\t\t\t\tthis.add('-end', target, 'Substitute');\n\t\t\t},\n\t\t},\n\t\tsecondary: null,\n\t\ttarget: \"self\",\n\t\ttype: \"Normal\",\n\t},\n\tstruggle: {\n\t\tinherit: true,\n\t\tignoreImmunity: {'Normal': true},\n\t},\n\twrap: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n};\n","import type {ActiveMove, BoostID, ModdedBattleScriptsData, StatIDExceptHP} from '@pkmn/sim';\n\n/**\n * Stadium mechanics inherit from gen 1 mechanics, but fixes some stuff.\n */\nexport const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen1',\n\tgen: 1,\n\t// BattlePokemon scripts. Stadium shares gen 1 code but it fixes some problems with it.\n\tpokemon: {\n\t\tinherit: true,\n\t\t// This is run on Stadium after boosts and status changes.\n\t\trecalculateStats() {\n\t\t\tlet statName: StatIDExceptHP;\n\t\t\tfor (statName in this.storedStats) {\n\t\t\t\tlet stat = this.species.baseStats[statName];\n\t\t\t\tstat = Math.floor(\n\t\t\t\t\tMath.floor(\n\t\t\t\t\t\t2 * stat + this.set.ivs[statName] + Math.floor(this.set.evs[statName] / 4)\n\t\t\t\t\t) * this.level / 100 + 5\n\t\t\t\t);\n\t\t\t\tthis.baseStoredStats[statName] = this.storedStats[statName] = Math.floor(stat);\n\t\t\t\tthis.modifiedStats![statName] = Math.floor(stat);\n\t\t\t\t// Re-apply drops, if necessary.\n\t\t\t\tif (this.status === 'par' && statName === 'spe') this.modifyStat!('spe', 0.25);\n\t\t\t\tif (this.status === 'brn' && statName === 'atk') this.modifyStat!('atk', 0.5);\n\t\t\t\tif (this.boosts[statName] !== 0) {\n\t\t\t\t\tif (this.boosts[statName] >= 0) {\n\t\t\t\t\t\tthis.modifyStat!(statName, [1, 1.5, 2, 2.5, 3, 3.5, 4][this.boosts[statName]]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.modifyStat!(statName, [100, 66, 50, 40, 33, 28, 25][-this.boosts[statName]] / 100);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Stadium's fixed boosting function.\n\t\tboostBy(boost) {\n\t\t\tlet changed = false;\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in boost) {\n\t\t\t\tlet delta = boost[i];\n\t\t\t\tif (delta === undefined) continue;\n\t\t\t\tthis.boosts[i] += delta;\n\t\t\t\tif (this.boosts[i] > 6) {\n\t\t\t\t\tdelta -= this.boosts[i] - 6;\n\t\t\t\t\tthis.boosts[i] = 6;\n\t\t\t\t}\n\t\t\t\tif (this.boosts[i] < -6) {\n\t\t\t\t\tdelta -= this.boosts[i] - (-6);\n\t\t\t\t\tthis.boosts[i] = -6;\n\t\t\t\t}\n\t\t\t\tif (delta) changed = true;\n\t\t\t}\n\t\t\tthis.recalculateStats!();\n\t\t\treturn changed;\n\t\t},\n\t\t// Remove stat recalculation logic from gen 1\n\t\tclearBoosts() {\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in this.boosts) {\n\t\t\t\tthis.boosts[i] = 0;\n\t\t\t}\n\t\t},\n\t},\n\tactions: {\n\t\tinherit: true,\n\t\trunMove(moveOrMoveName, pokemon, targetLoc, sourceEffect) {\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\t\t\tconst target = this.battle.getTarget(pokemon, move, targetLoc);\n\t\t\tif (target?.subFainted) target.subFainted = null;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tif (pokemon.moveThisTurn || !this.battle.runEvent('BeforeMove', pokemon, target, move)) {\n\t\t\t\tthis.battle.debug('' + pokemon.fullname + ' move interrupted; movedThisTurn: ' + pokemon.moveThisTurn);\n\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t// This is only run for sleep\n\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (move.beforeMoveCallback) {\n\t\t\t\tif (move.beforeMoveCallback.call(this.battle, pokemon, target, move)) {\n\t\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpokemon.lastDamage = 0;\n\t\t\tlet lockedMove = this.battle.runEvent('LockMove', pokemon);\n\t\t\tif (lockedMove === true) lockedMove = false;\n\t\t\tif (\n\t\t\t\t!lockedMove &&\n\t\t\t\t(!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].locked !== target)\n\t\t\t) {\n\t\t\t\tpokemon.deductPP(move, null, target);\n\t\t\t} else {\n\t\t\t\tsourceEffect = move;\n\t\t\t}\n\t\t\tthis.battle.actions.useMove(move, pokemon, target, sourceEffect);\n\t\t},\n\t\t// This function deals with AfterMoveSelf events.\n\t\t// This leads with partial trapping moves shenanigans after the move has been used.\n\t\tuseMove(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tconst moveResult = this.useMoveInner(moveOrMoveName, pokemon, target, sourceEffect);\n\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\n\t\t\tif (move.id !== 'metronome') {\n\t\t\t\tif (move.id !== 'mirrormove' ||\n\t\t\t\t\t(!pokemon.side.foe.active[0]?.lastMove || pokemon.side.foe.active[0].lastMove?.id === 'mirrormove')) {\n\t\t\t\t\t// The move is our 'final' move (a failed Mirror Move, or any move that isn't Metronome or Mirror Move).\n\t\t\t\t\tpokemon.side.lastMove = move;\n\t\t\t\t\tpokemon.lastMove = move;\n\t\t\t\t\tthis.battle.singleEvent('AfterMove', move, null, pokemon, target, move);\n\n\t\t\t\t\t// If target fainted\n\t\t\t\t\tif (target && target.hp <= 0) {\n\t\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\t\t}\n\t\t\t\t\tif (pokemon.volatiles['mustrecharge']) this.battle.add('-mustrecharge', pokemon);\n\n\t\t\t\t\t// For partial trapping moves, we are saving the target.\n\t\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target && target.hp > 0) {\n\t\t\t\t\t\t// It hit, so let's remove must recharge volatile. Yup, this happens on Stadium.\n\t\t\t\t\t\ttarget.removeVolatile('mustrecharge');\n\t\t\t\t\t\t// Let's check if the lock exists\n\t\t\t\t\t\tif (pokemon.volatiles['partialtrappinglock'] && target.volatiles['partiallytrapped']) {\n\t\t\t\t\t\t\t// Here the partialtrappinglock volatile has been already applied\n\t\t\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\t\t\t\t// If it's the first hit, we save the target\n\t\t\t\t\t\t\t\tpokemon.volatiles['partialtrappinglock'].locked = target;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // If we move to here, the move failed and there's no partial trapping lock\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn moveResult;\n\t\t},\n\t\t// This is the function that actually uses the move, running ModifyMove events.\n\t\t// It uses the move and then deals with the effects after the move.\n\t\tuseMoveInner(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t\tthis.battle.debug('not a gen 1 mechanic');\n\t\t\t}\n\t\t\tif (!move) return false;\n\n\t\t\tlet attrs = '';\n\t\t\tif (pokemon.fainted) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (sourceEffect) attrs += '|[from]' + this.battle.dex.conditions.get(sourceEffect);\n\t\t\tthis.battle.addMove('move', pokemon, move.name, target + attrs);\n\n\t\t\tif (!this.battle.singleEvent('Try', move, null, pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!this.battle.singleEvent('TryMove', move, null, pokemon, target, move) ||\n\t\t\t\t!this.battle.runEvent('TryMove', pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tlet damage: number | undefined | false | '' = false;\n\t\t\tif (!target || target.fainted) {\n\t\t\t\tthis.battle.attrLastMove('[notarget]');\n\t\t\t\tthis.battle.add('-notarget');\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tdamage = this.tryMoveHit(target, pokemon, move);\n\n\t\t\t// Store 0 damage for last damage if move failed.\n\t\t\t// This only happens on moves that don't deal damage but call GetDamageVarsForPlayerAttack (disassembly).\n\t\t\tconst neverDamageMoves = [\n\t\t\t\t'conversion', 'haze', 'mist', 'focusenergy', 'confuseray', 'supersonic', 'transform', 'lightscreen', 'reflect', 'substitute', 'mimic', 'leechseed', 'splash', 'softboiled', 'recover', 'rest',\n\t\t\t];\n\t\t\tif (\n\t\t\t\t!damage && damage !== 0 &&\n\t\t\t\t(move.category !== 'Status' || (move.status && !['psn', 'tox', 'par'].includes(move.status))) &&\n\t\t\t\t!neverDamageMoves.includes(move.id)\n\t\t\t) {\n\t\t\t\tthis.battle.lastDamage = 0;\n\t\t\t}\n\n\t\t\t// Go ahead with results of the used move.\n\t\t\tif (damage === false) {\n\t\t\t\tthis.battle.singleEvent('MoveFail', move, null, target, pokemon, move);\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondarySelf', move, null, pokemon, target, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondarySelf', pokemon, target, move);\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\ttryMoveHit(target, pokemon, move) {\n\t\t\tlet damage: number | false | undefined = 0;\n\n\t\t\t// First, check if the target is semi-invulnerable\n\t\t\tlet hitResult = this.battle.runEvent('Invulnerability', target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Then, check if the Pokemon is immune to this move.\n\t\t\tif (\n\t\t\t\t(!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) &&\n\t\t\t\t!target.runImmunity(move.type, true)\n\t\t\t) {\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thitResult = this.battle.singleEvent('TryImmunity', move, null, target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.add('-immune', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Now, let's calculate the accuracy.\n\t\t\tlet accuracy = move.accuracy;\n\n\t\t\t// Partial trapping moves: true accuracy while it lasts\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target === pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\taccuracy = true;\n\t\t\t\t} else if (pokemon.volatiles['partialtrappinglock'].locked !== target) {\n\t\t\t\t\t// The target switched, therefor, you fail using wrap.\n\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// OHKO moves only have a chance to hit if the user is at least as fast as the target\n\t\t\tif (move.ohko) {\n\t\t\t\tif (target.speed > pokemon.speed) {\n\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Calculate true accuracy for gen 1, which uses 0-255.\n\t\t\t// Stadium uses the Gen 2 boost table for accuracy and evasiveness, except for 1/3 instead of 0.33\n\t\t\tconst boostTable = [1 / 3, 0.36, 0.43, 0.5, 0.66, 0.75, 1, 1.33, 1.66, 2, 2.33, 2.66, 3];\n\t\t\tif (accuracy !== true) {\n\t\t\t\taccuracy = Math.floor(accuracy * 255 / 100);\n\t\t\t\t// Check also for accuracy modifiers.\n\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[pokemon.boosts.accuracy + 6]);\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[-target.boosts.evasion + 6]);\n\t\t\t\t}\n\t\t\t\taccuracy = Math.min(accuracy, 255);\n\t\t\t}\n\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\n\t\t\t// Stadium fixes the 1/256 accuracy bug.\n\t\t\tif (accuracy !== true && !this.battle.randomChance(accuracy + 1, 256)) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tdamage = false;\n\t\t\t}\n\n\t\t\t// If damage is 0 and not false it means it didn't miss, let's calc.\n\t\t\tif (damage !== false) {\n\t\t\t\tpokemon.lastDamage = 0;\n\t\t\t\tif (move.multihit) {\n\t\t\t\t\tlet hits = move.multihit;\n\t\t\t\t\tif (Array.isArray(hits)) {\n\t\t\t\t\t\t// Yes, it's hardcoded... meh\n\t\t\t\t\t\tif (hits[0] === 2 && hits[1] === 5) {\n\t\t\t\t\t\t\thits = this.battle.sample([2, 2, 2, 3, 3, 3, 4, 5]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\thits = this.battle.random(hits[0], hits[1] + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thits = Math.floor(hits);\n\t\t\t\t\t// In gen 1, all the hits have the same damage for multihits move\n\t\t\t\t\tlet moveDamage: number | false | undefined = 0;\n\t\t\t\t\tlet i: number;\n\t\t\t\t\tfor (i = 0; i < hits && target.hp && pokemon.hp; i++) {\n\t\t\t\t\t\tmove.hit = i + 1;\n\t\t\t\t\t\tif (move.hit === hits) move.lastHit = true;\n\t\t\t\t\t\tmoveDamage = this.moveHit(target, pokemon, move);\n\t\t\t\t\t\tif (moveDamage === false) break;\n\t\t\t\t\t\tdamage = (moveDamage || 0);\n\t\t\t\t\t\t// Move damage is fixed to be the first move's damage\n\t\t\t\t\t\tif (i === 0) move.damage = damage;\n\t\t\t\t\t\tif (target.subFainted) {\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmove.damage = null;\n\t\t\t\t\tif (i === 0) return 1;\n\t\t\t\t\tthis.battle.add('-hitcount', target, i);\n\t\t\t\t} else {\n\t\t\t\t\tdamage = this.moveHit(target, pokemon, move);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (move.category !== 'Status') target.gotAttacked(move, damage, pokemon);\n\n\t\t\tif (move.selfdestruct) {\n\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t}\n\n\t\t\t// The move missed.\n\t\t\tif (damage === false) {\n\t\t\t\t// Delete the partial trap lock if necessary.\n\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.ohko) this.battle.add('-ohko');\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondary', target, pokemon, move);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tmoveHit(target, pokemon, moveOrMoveName, moveData, isSecondary, isSelf) {\n\t\t\tlet damage: number | false | null | undefined = 0;\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\n\t\t\tif (!isSecondary && !isSelf) this.battle.setActiveMove(move, pokemon, target);\n\t\t\tlet hitResult: number | boolean = true;\n\t\t\tif (!moveData) moveData = move;\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\thitResult = this.battle.singleEvent('TryHit', moveData, {}, target, pokemon, move);\n\n\t\t\t\t// Partial trapping moves still apply their volatile to Pokémon behind a Sub\n\t\t\t\tconst targetHadSub = !!target.volatiles['substitute'];\n\t\t\t\tif (targetHadSub && moveData.volatileStatus && moveData.volatileStatus === 'partiallytrapped') {\n\t\t\t\t\ttarget.addVolatile(moveData.volatileStatus, pokemon, move);\n\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].duration > 1) {\n\t\t\t\t\t\ttarget.volatiles[moveData.volatileStatus].duration = 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Only run the hit events for the hit itself, not the secondary or self hits\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHit', target, pokemon, move);\n\t\t\t\t\tif (!hitResult) {\n\t\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\t\t// Special Substitute hit flag\n\t\t\t\t\t\tif (hitResult !== 0) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!this.battle.runEvent('TryFieldHit', target, pokemon, move)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else if (isSecondary && !moveData.self) {\n\t\t\t\t\thitResult = this.battle.runEvent('TrySecondaryHit', target, pokemon, moveData);\n\t\t\t\t}\n\n\t\t\t\tif (hitResult === 0) {\n\t\t\t\t\ttarget = null;\n\t\t\t\t} else if (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\tlet didSomething = false;\n\n\t\t\t\tdamage = this.getDamage(pokemon, target, moveData);\n\t\t\t\tif ((damage || damage === 0) && !target.fainted) {\n\t\t\t\t\tdamage = this.battle.damage(damage, target, pokemon, move);\n\t\t\t\t\tif (!(damage || damage === 0)) return false;\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t} else if (damage === false && typeof hitResult === 'undefined') {\n\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t}\n\t\t\t\tif (damage === false || damage === null) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (moveData.boosts && !target.fainted) {\n\t\t\t\t\tthis.battle.boost(moveData.boosts, target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (moveData.heal && !target.fainted) {\n\t\t\t\t\tconst d = target.heal(Math.floor(target.maxhp * moveData.heal[0] / moveData.heal[1]));\n\t\t\t\t\tif (!d) {\n\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.battle.add('-heal', target, target.getHealth);\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.status) {\n\t\t\t\t\tif (!target.status) {\n\t\t\t\t\t\ttarget.setStatus(moveData.status, pokemon, move);\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t} else if (!isSecondary) {\n\t\t\t\t\t\tif (target.status === moveData.status) {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target, target.status);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.forceStatus) {\n\t\t\t\t\tif (target.setStatus(moveData.forceStatus, pokemon, move)) {\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.volatileStatus) {\n\t\t\t\t\tif (target.addVolatile(moveData.volatileStatus, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.sideCondition) {\n\t\t\t\t\tif (target.side.addSideCondition(moveData.sideCondition, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.pseudoWeather) {\n\t\t\t\t\tif (this.battle.field.addPseudoWeather(moveData.pseudoWeather, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Hit events\n\t\t\t\thitResult = this.battle.singleEvent('Hit', moveData, {}, target, pokemon, move);\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\tthis.battle.runEvent('Hit', target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (!hitResult && !didSomething) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Here's where self effects are applied.\n\t\t\tif (moveData.self) {\n\t\t\t\tthis.moveHit(pokemon, pokemon, move, moveData.self, isSecondary, true);\n\t\t\t}\n\n\t\t\t// Now we can save the partial trapping damage.\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tpokemon.volatiles['partialtrappinglock'].damage = pokemon.lastDamage;\n\t\t\t}\n\n\t\t\t// Apply move secondaries.\n\t\t\tif (moveData.secondaries && target && target.hp > 0) {\n\t\t\t\tfor (const secondary of moveData.secondaries) {\n\t\t\t\t\t// Multi-hit moves only roll for status once\n\t\t\t\t\tif (!move.multihit || move.lastHit) {\n\t\t\t\t\t\t// We check here whether to negate the probable secondary status if it's para, burn, or freeze.\n\t\t\t\t\t\t// In the game, this is checked and if true, the random number generator is not called.\n\t\t\t\t\t\t// That means that a move that does not share the type of the target can status it.\n\t\t\t\t\t\t// If a move that was not fire-type would exist on Gen 1, it could burn a Pokémon.\n\t\t\t\t\t\tif (!(secondary.status && ['par', 'brn', 'frz'].includes(secondary.status) && target.hasType(move.type))) {\n\t\t\t\t\t\t\tconst effectChance = Math.floor((secondary.chance || 100) * 255 / 100);\n\t\t\t\t\t\t\tif (typeof secondary.chance === 'undefined' || this.battle.randomChance(effectChance + 1, 256)) {\n\t\t\t\t\t\t\t\tthis.moveHit(target, pokemon, move, secondary, true, isSelf);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (move.selfSwitch && pokemon.hp) {\n\t\t\t\tpokemon.switchFlag = move.selfSwitch === true ? true : this.dex.toID(move.selfSwitch);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tgetDamage(source, target, move, suppressMessages) {\n\t\t\t// First of all, we get the move.\n\t\t\tif (typeof move === 'string') {\n\t\t\t\tmove = this.dex.getActiveMove(move);\n\t\t\t} else if (typeof move === 'number') {\n\t\t\t\tmove = {\n\t\t\t\t\tbasePower: move,\n\t\t\t\t\ttype: '???',\n\t\t\t\t\tcategory: 'Physical',\n\t\t\t\t\twillCrit: false,\n\t\t\t\t\tflags: {},\n\t\t\t\t} as ActiveMove;\n\t\t\t}\n\n\t\t\t// Let's see if the target is immune to the move.\n\t\t\tif (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {\n\t\t\t\tif (!target.runImmunity(move.type, true)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Is it an OHKO move?\n\t\t\tif (move.ohko) {\n\t\t\t\treturn target.maxhp;\n\t\t\t}\n\n\t\t\t// We edit the damage through move's damage callback if necessary.\n\t\t\tif (move.damageCallback) {\n\t\t\t\treturn move.damageCallback.call(this.battle, source, target);\n\t\t\t}\n\n\t\t\t// We take damage from damage=level moves (seismic toss).\n\t\t\tif (move.damage === 'level') {\n\t\t\t\treturn source.level;\n\t\t\t}\n\n\t\t\t// If there's a fix move damage, we return that.\n\t\t\tif (move.damage) {\n\t\t\t\treturn move.damage;\n\t\t\t}\n\n\t\t\t// If it's the first hit on a Normal-type partially trap move, it hits Ghosts anyways but damage is 0.\n\t\t\tif (move.volatileStatus === 'partiallytrapped' && move.type === 'Normal' && target.hasType('Ghost')) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Let's check if we are in middle of a partial trap sequence to return the previous damage.\n\t\t\tif (source.volatiles['partialtrappinglock'] && (target === source.volatiles['partialtrappinglock'].locked)) {\n\t\t\t\treturn source.volatiles['partialtrappinglock'].damage;\n\t\t\t}\n\n\t\t\t// We check the category and typing to calculate later on the damage.\n\t\t\tif (!move.category) move.category = 'Physical';\n\t\t\t// '???' is typeless damage: used for Struggle and Confusion etc\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// We get the base power and apply basePowerCallback if necessary.\n\t\t\tlet basePower: number | false | null = move.basePower;\n\t\t\tif (move.basePowerCallback) {\n\t\t\t\tbasePower = move.basePowerCallback.call(this.battle, source, target, move);\n\t\t\t}\n\t\t\tif (!basePower) {\n\t\t\t\treturn basePower === 0 ? undefined : basePower;\n\t\t\t}\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// Checking for the move's Critical Hit possibility. We check if it's a 100% crit move, otherwise we calculate the chance.\n\t\t\tlet isCrit = move.willCrit || false;\n\t\t\tif (!isCrit) {\n\t\t\t\t// In Stadium, the critical chance is based on speed.\n\t\t\t\t// First, we get the base speed and store it. Then we add 76. This is our current crit chance.\n\t\t\t\tlet critChance = source.species.baseStats['spe'] + 76;\n\n\t\t\t\t// Now we right logical shift it two places, essentially dividing by 4 and flooring it.\n\t\t\t\tcritChance = critChance >> 2;\n\n\t\t\t\t// Now we check for focus energy volatile.\n\t\t\t\tif (source.volatiles['focusenergy']) {\n\t\t\t\t\t// If it exists, crit chance is multiplied by 4 and floored with a logical left shift.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t\t// Then we add 160.\n\t\t\t\t\tcritChance += 160;\n\t\t\t\t} else {\n\t\t\t\t\t// If it is not active, we left shift it by 1.\n\t\t\t\t\tcritChance = critChance << 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we check for the move's critical hit ratio.\n\t\t\t\tif (move.critRatio === 2) {\n\t\t\t\t\t// High crit ratio, we multiply the result so far by 4.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t} else if (move.critRatio === 1) {\n\t\t\t\t\t// Normal hit ratio, we divide the crit chance by 2 and floor the result again.\n\t\t\t\t\tcritChance = critChance >> 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we make sure it's a number between 1 and 255.\n\t\t\t\tcritChance = this.battle.clampIntRange(critChance, 1, 255);\n\n\t\t\t\t// Last, we check deppending on ratio if the move critical hits or not.\n\t\t\t\t// We compare our critical hit chance against a random number between 0 and 255.\n\t\t\t\t// If the random number is lower, we get a critical hit. This means there is always a 1/255 chance of not hitting critically.\n\t\t\t\tif (critChance > 0) {\n\t\t\t\t\tisCrit = this.battle.randomChance(critChance, 256);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// There is a critical hit.\n\t\t\tif (isCrit && this.battle.runEvent('CriticalHit', target, null, move)) {\n\t\t\t\ttarget.getMoveHitData(move).crit = true;\n\t\t\t}\n\n\t\t\t// Happens after crit calculation.\n\t\t\tif (basePower) {\n\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower);\n\t\t\t\tif (basePower && move.basePowerModifier) {\n\t\t\t\t\tbasePower *= move.basePowerModifier;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!basePower) return 0;\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// We now check attacker's and defender's stats.\n\t\t\tlet level = source.level;\n\t\t\tconst attacker = move.overrideOffensivePokemon === 'target' ? target : source;\n\t\t\tconst defender = move.overrideDefensivePokemon === 'source' ? source : target;\n\n\t\t\tconst isPhysical = move.category === 'Physical';\n\t\t\tconst atkType: StatIDExceptHP = move.overrideOffensiveStat || (isPhysical ? 'atk' : 'spa');\n\t\t\tconst defType: StatIDExceptHP = move.overrideDefensiveStat || (isPhysical ? 'def' : 'spd');\n\n\t\t\tlet attack = attacker.getStat(atkType);\n\t\t\tlet defense = defender.getStat(defType);\n\n\t\t\t// In gen 1, screen effect is applied here.\n\t\t\tif ((defType === 'def' && defender.volatiles['reflect']) || (defType === 'spd' && defender.volatiles['lightscreen'])) {\n\t\t\t\tthis.battle.debug('Screen doubling (Sp)Def');\n\t\t\t\tdefense *= 2;\n\t\t\t\tdefense = this.battle.clampIntRange(defense, 1, 1998);\n\t\t\t}\n\n\t\t\t// In the event of a critical hit, the offense and defense changes are ignored.\n\t\t\t// This includes both boosts and screens.\n\t\t\t// Also, level is doubled in damage calculation.\n\t\t\tif (isCrit) {\n\t\t\t\tmove.ignoreOffensive = true;\n\t\t\t\tmove.ignoreDefensive = true;\n\t\t\t\tlevel *= 2;\n\t\t\t\tif (!suppressMessages) this.battle.add('-crit', target);\n\t\t\t}\n\n\t\t\tif (move.ignoreOffensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)atk boost/penalty.');\n\t\t\t\tattack = attacker.getStat(atkType, true);\n\t\t\t}\n\n\t\t\tif (move.ignoreDefensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)def boost/penalty.');\n\t\t\t\tdefense = target.getStat(defType, true);\n\t\t\t}\n\n\t\t\t// When either attack or defense are higher than 256, they are both divided by 4 and moded by 256.\n\t\t\t// This is what cuases the roll over bugs.\n\t\t\tif (attack >= 256 || defense >= 256) {\n\t\t\t\tattack = this.battle.clampIntRange(Math.floor(attack / 4) % 256, 1);\n\t\t\t\t// Defense isn't checked on the cartridge, but we don't want those / 0 bugs on the sim.\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 4) % 256, 1);\n\t\t\t}\n\n\t\t\t// Self destruct moves halve defense at this point.\n\t\t\tif (move.selfdestruct && defType === 'def') {\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 2), 1);\n\t\t\t}\n\n\t\t\t// Let's go with the calculation now that we have what we need.\n\t\t\t// We do it step by step just like the game does.\n\t\t\tlet damage = level * 2;\n\t\t\tdamage = Math.floor(damage / 5);\n\t\t\tdamage += 2;\n\t\t\tdamage *= basePower;\n\t\t\tdamage *= attack;\n\t\t\tdamage = Math.floor(damage / defense);\n\t\t\tdamage = this.battle.clampIntRange(Math.floor(damage / 50), 0, 997);\n\t\t\tdamage += 2;\n\n\t\t\t// STAB damage bonus, the \"???\" type never gets STAB\n\t\t\tif (type !== '???' && source.hasType(type)) {\n\t\t\t\tdamage += Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// Type effectiveness.\n\t\t\t// In Gen 1, type effectiveness is applied against each of the target's types.\n\t\t\tfor (const targetType of target.types) {\n\t\t\t\tconst typeMod = this.battle.dex.getEffectiveness(type, targetType);\n\t\t\t\tif (typeMod > 0) {\n\t\t\t\t\t// Super effective against targetType\n\t\t\t\t\tdamage *= 20;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t\tif (typeMod < 0) {\n\t\t\t\t\t// Not very effective against targetType\n\t\t\t\t\tdamage *= 5;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst totalTypeMod = target.runEffectiveness(move);\n\t\t\tif (totalTypeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\t\t\t}\n\t\t\tif (totalTypeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\t\t\t}\n\n\t\t\t// If damage becomes 0, the move is made to miss.\n\t\t\t// This occurs when damage was either 2 or 3 prior to applying STAB/Type matchup, and target is 4x resistant to the move.\n\t\t\tif (damage === 0) return damage;\n\n\t\t\t// Apply random factor if damage is greater than 1\n\t\t\tif (damage > 1) {\n\t\t\t\tdamage *= this.battle.random(217, 256);\n\t\t\t\tdamage = Math.floor(damage / 255);\n\t\t\t\tif (damage > target.hp && !target.volatiles['substitute']) damage = target.hp;\n\t\t\t\tif (target.volatiles['substitute'] && damage > target.volatiles['substitute'].hp) {\n\t\t\t\t\tdamage = target.volatiles['substitute'].hp;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We are done, this is the final damage.\n\t\t\treturn Math.floor(damage);\n\t\t},\n\t},\n};\n"]}
|
|
@@ -393,7 +393,7 @@ var Moves = {
|
|
|
393
393
|
}
|
|
394
394
|
if (target.volatiles["substitute"]) {
|
|
395
395
|
if (move.recoil) {
|
|
396
|
-
this.damage(Math.
|
|
396
|
+
this.damage(this.clampIntRange(Math.floor(damage * move.recoil[0] / move.recoil[1]), 1), source, target, "recoil");
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
this.runEvent("AfterSubDamage", target, source, move, damage);
|
|
@@ -508,8 +508,6 @@ var Scripts = {
|
|
|
508
508
|
lockedMove = false;
|
|
509
509
|
if (!lockedMove && (!pokemon.volatiles["partialtrappinglock"] || pokemon.volatiles["partialtrappinglock"].locked !== target)) {
|
|
510
510
|
pokemon.deductPP(move, null, target);
|
|
511
|
-
pokemon.side.lastMove = move;
|
|
512
|
-
pokemon.lastMove = move;
|
|
513
511
|
} else {
|
|
514
512
|
sourceEffect = move;
|
|
515
513
|
}
|
|
@@ -539,11 +537,11 @@ var Scripts = {
|
|
|
539
537
|
}
|
|
540
538
|
if (move.id !== "metronome") {
|
|
541
539
|
if (move.id !== "mirrormove" || (!((_a = pokemon.side.foe.active[0]) == null ? void 0 : _a.lastMove) || ((_b = pokemon.side.foe.active[0].lastMove) == null ? void 0 : _b.id) === "mirrormove")) {
|
|
540
|
+
pokemon.side.lastMove = move;
|
|
541
|
+
pokemon.lastMove = move;
|
|
542
542
|
this.battle.singleEvent("AfterMove", move, null, pokemon, target, move);
|
|
543
543
|
if (target && target.hp <= 0) {
|
|
544
544
|
delete pokemon.volatiles["partialtrappinglock"];
|
|
545
|
-
target.side.removeSideCondition("reflect");
|
|
546
|
-
target.side.removeSideCondition("lightscreen");
|
|
547
545
|
} else {
|
|
548
546
|
this.battle.runEvent("AfterMoveSelf", pokemon, target, move);
|
|
549
547
|
}
|
|
@@ -587,8 +585,6 @@ var Scripts = {
|
|
|
587
585
|
return false;
|
|
588
586
|
let attrs = "";
|
|
589
587
|
if (pokemon.fainted) {
|
|
590
|
-
pokemon.side.removeSideCondition("reflect");
|
|
591
|
-
pokemon.side.removeSideCondition("lightscreen");
|
|
592
588
|
return false;
|
|
593
589
|
}
|
|
594
590
|
if (sourceEffect)
|
|
@@ -873,10 +869,10 @@ var Scripts = {
|
|
|
873
869
|
if (pokemon.volatiles["partialtrappinglock"]) {
|
|
874
870
|
pokemon.volatiles["partialtrappinglock"].damage = pokemon.lastDamage;
|
|
875
871
|
}
|
|
876
|
-
if (moveData.secondaries) {
|
|
872
|
+
if (moveData.secondaries && target && target.hp > 0) {
|
|
877
873
|
for (const secondary of moveData.secondaries) {
|
|
878
874
|
if (!move.multihit || move.lastHit) {
|
|
879
|
-
if (!(secondary.status && ["par", "brn", "frz"].includes(secondary.status) && target
|
|
875
|
+
if (!(secondary.status && ["par", "brn", "frz"].includes(secondary.status) && target.hasType(move.type))) {
|
|
880
876
|
const effectChance = Math.floor((secondary.chance || 100) * 255 / 100);
|
|
881
877
|
if (typeof secondary.chance === "undefined" || this.battle.randomChance(effectChance + 1, 256)) {
|
|
882
878
|
this.moveHit(target, pokemon, move, secondary, true, isSelf);
|
|
@@ -1011,31 +1007,30 @@ var Scripts = {
|
|
|
1011
1007
|
damage *= basePower;
|
|
1012
1008
|
damage *= attack;
|
|
1013
1009
|
damage = Math.floor(damage / defense);
|
|
1014
|
-
damage = this.battle.clampIntRange(Math.floor(damage / 50),
|
|
1010
|
+
damage = this.battle.clampIntRange(Math.floor(damage / 50), 0, 997);
|
|
1015
1011
|
damage += 2;
|
|
1016
1012
|
if (type !== "???" && source.hasType(type)) {
|
|
1017
1013
|
damage += Math.floor(damage / 2);
|
|
1018
1014
|
}
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
if (
|
|
1022
|
-
this.battle.add("-supereffective", target);
|
|
1023
|
-
damage *= 20;
|
|
1024
|
-
damage = Math.floor(damage / 10);
|
|
1025
|
-
if (totalTypeMod >= 2) {
|
|
1015
|
+
for (const targetType of target.types) {
|
|
1016
|
+
const typeMod = this.battle.dex.getEffectiveness(type, targetType);
|
|
1017
|
+
if (typeMod > 0) {
|
|
1026
1018
|
damage *= 20;
|
|
1027
1019
|
damage = Math.floor(damage / 10);
|
|
1028
1020
|
}
|
|
1021
|
+
if (typeMod < 0) {
|
|
1022
|
+
damage *= 5;
|
|
1023
|
+
damage = Math.floor(damage / 10);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
const totalTypeMod = target.runEffectiveness(move);
|
|
1027
|
+
if (totalTypeMod > 0) {
|
|
1028
|
+
if (!suppressMessages)
|
|
1029
|
+
this.battle.add("-supereffective", target);
|
|
1029
1030
|
}
|
|
1030
1031
|
if (totalTypeMod < 0) {
|
|
1031
1032
|
if (!suppressMessages)
|
|
1032
1033
|
this.battle.add("-resisted", target);
|
|
1033
|
-
damage *= 5;
|
|
1034
|
-
damage = Math.floor(damage / 10);
|
|
1035
|
-
if (totalTypeMod <= -2) {
|
|
1036
|
-
damage *= 5;
|
|
1037
|
-
damage = Math.floor(damage / 10);
|
|
1038
|
-
}
|
|
1039
1034
|
}
|
|
1040
1035
|
if (damage === 0)
|
|
1041
1036
|
return damage;
|