Spaces:
Running
Running
{ | |
"version": 3, | |
"sources": ["../../../../data/mods/gen4/scripts.ts"], | |
"sourcesContent": ["export const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen5',\n\tgen: 4,\n\n\tactions: {\n\t\tinherit: true,\n\t\trunSwitch(pokemon) {\n\t\t\tthis.battle.runEvent('EntryHazard', pokemon);\n\n\t\t\tthis.battle.runEvent('SwitchIn', pokemon);\n\n\t\t\tif (this.battle.gen <= 2) {\n\t\t\t\t// pokemon.lastMove is reset for all Pokemon on the field after a switch. This affects Mirror Move.\n\t\t\t\tfor (const poke of this.battle.getAllActive()) poke.lastMove = null;\n\t\t\t\tif (!pokemon.side.faintedThisTurn && pokemon.draggedIn !== this.battle.turn) {\n\t\t\t\t\tthis.battle.runEvent('AfterSwitchInSelf', pokemon);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!pokemon.hp) return false;\n\t\t\tpokemon.isStarted = true;\n\t\t\tif (!pokemon.fainted) {\n\t\t\t\tthis.battle.singleEvent('Start', pokemon.getAbility(), pokemon.abilityState, pokemon);\n\t\t\t\tthis.battle.singleEvent('Start', pokemon.getItem(), pokemon.itemState, pokemon);\n\t\t\t}\n\t\t\tif (this.battle.gen === 4) {\n\t\t\t\tfor (const foeActive of pokemon.foes()) {\n\t\t\t\t\tfoeActive.removeVolatile('substitutebroken');\n\t\t\t\t}\n\t\t\t}\n\t\t\tpokemon.draggedIn = null;\n\t\t\treturn true;\n\t\t},\n\t\tmodifyDamage(baseDamage, pokemon, target, move, suppressMessages = false) {\n\t\t\t// DPP divides modifiers into several mathematically important stages\n\t\t\t// The modifiers run earlier than other generations are called with ModifyDamagePhase1 and ModifyDamagePhase2\n\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// Burn\n\t\t\tif (pokemon.status === 'brn' && baseDamage && move.category === 'Physical' && !pokemon.hasAbility('guts')) {\n\t\t\t\tbaseDamage = this.battle.modify(baseDamage, 0.5);\n\t\t\t}\n\n\t\t\t// Other modifiers (Reflect/Light Screen/etc)\n\t\t\tbaseDamage = this.battle.runEvent('ModifyDamagePhase1', pokemon, target, move, baseDamage);\n\n\t\t\t// Double battle multi-hit\n\t\t\tif (move.spreadHit) {\n\t\t\t\tconst spreadModifier = move.spreadModifier || (this.battle.gameType === 'freeforall' ? 0.5 : 0.75);\n\t\t\t\tthis.battle.debug(`Spread modifier: ${spreadModifier}`);\n\t\t\t\tbaseDamage = this.battle.modify(baseDamage, spreadModifier);\n\t\t\t}\n\n\t\t\t// Weather\n\t\t\tbaseDamage = this.battle.runEvent('WeatherModifyDamage', pokemon, target, move, baseDamage);\n\n\t\t\tif (this.battle.gen === 3 && move.category === 'Physical' && !Math.floor(baseDamage)) {\n\t\t\t\tbaseDamage = 1;\n\t\t\t}\n\n\t\t\tbaseDamage += 2;\n\n\t\t\tconst isCrit = target.getMoveHitData(move).crit;\n\t\t\tif (isCrit) {\n\t\t\t\tbaseDamage = this.battle.modify(baseDamage, move.critModifier || 2);\n\t\t\t}\n\n\t\t\t// Mod 2 (Damage is floored after all multipliers are in)\n\t\t\tbaseDamage = Math.floor(this.battle.runEvent('ModifyDamagePhase2', pokemon, target, move, baseDamage));\n\n\t\t\t// this is not a modifier\n\t\t\tbaseDamage = this.battle.randomizer(baseDamage);\n\n\t\t\t// STAB\n\t\t\t// The \"???\" type never gets STAB\n\t\t\t// Not even if you Roost in Gen 4 and somehow manage to use\n\t\t\t// Struggle in the same turn.\n\t\t\t// (On second thought, it might be easier to get a MissingNo.)\n\t\t\tif (type !== '???') {\n\t\t\t\tlet stab: number | [number, number] = 1;\n\t\t\t\tif (move.forceSTAB || pokemon.hasType(type)) {\n\t\t\t\t\tstab = 1.5;\n\t\t\t\t}\n\t\t\t\tstab = this.battle.runEvent('ModifySTAB', pokemon, target, move, stab);\n\t\t\t\tbaseDamage = this.battle.modify(baseDamage, stab);\n\t\t\t}\n\t\t\t// types\n\t\t\tlet typeMod = target.runEffectiveness(move);\n\t\t\ttypeMod = this.battle.clampIntRange(typeMod, -6, 6);\n\t\t\ttarget.getMoveHitData(move).typeMod = typeMod;\n\t\t\tif (typeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\n\t\t\t\tfor (let i = 0; i < typeMod; i++) {\n\t\t\t\t\tbaseDamage *= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\n\t\t\t\tfor (let i = 0; i > typeMod; i--) {\n\t\t\t\t\tbaseDamage = Math.floor(baseDamage / 2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isCrit && !suppressMessages) this.battle.add('-crit', target);\n\n\t\t\t// Final modifier.\n\t\t\tbaseDamage = this.battle.runEvent('ModifyDamage', pokemon, target, move, baseDamage);\n\n\t\t\tif (!Math.floor(baseDamage)) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\treturn Math.floor(baseDamage);\n\t\t},\n\t\thitStepInvulnerabilityEvent(targets, pokemon, move) {\n\t\t\tconst hitResults = this.battle.runEvent('Invulnerability', targets, pokemon, move);\n\t\t\tfor (const [i, target] of targets.entries()) {\n\t\t\t\tif (hitResults[i] === false) {\n\t\t\t\t\tif (!move.spreadHit) this.battle.attrLastMove('[miss]');\n\t\t\t\t\tthis.battle.add('-miss', pokemon, target);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn hitResults;\n\t\t},\n\t\thitStepAccuracy(targets, pokemon, move) {\n\t\t\tconst hitResults = [];\n\t\t\tfor (const [i, target] of targets.entries()) {\n\t\t\t\tthis.battle.activeTarget = target;\n\t\t\t\t// calculate true accuracy\n\t\t\t\tlet accuracy = move.accuracy;\n\t\t\t\tif (move.ohko) { // bypasses accuracy modifiers\n\t\t\t\t\tif (!target.isSemiInvulnerable()) {\n\t\t\t\t\t\tif (pokemon.level < target.level) {\n\t\t\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\t\t\thitResults[i] = false;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taccuracy = 30 + pokemon.level - target.level;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst boostTable = [1, 4 / 3, 5 / 3, 2, 7 / 3, 8 / 3, 3];\n\n\t\t\t\t\tlet boosts;\n\t\t\t\t\tlet boost!: number;\n\t\t\t\t\tif (accuracy !== true) {\n\t\t\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\t\t\tboosts = this.battle.runEvent('ModifyBoost', pokemon, null, null, { ...pokemon.boosts });\n\t\t\t\t\t\t\tboost = this.battle.clampIntRange(boosts['accuracy'], -6, 6);\n\t\t\t\t\t\t\tif (boost > 0) {\n\t\t\t\t\t\t\t\taccuracy *= boostTable[boost];\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\taccuracy /= boostTable[-boost];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\t\t\tboosts = this.battle.runEvent('ModifyBoost', target, null, null, { ...target.boosts });\n\t\t\t\t\t\t\tboost = this.battle.clampIntRange(boosts['evasion'], -6, 6);\n\t\t\t\t\t\t\tif (boost > 0) {\n\t\t\t\t\t\t\t\taccuracy /= boostTable[boost];\n\t\t\t\t\t\t\t} else if (boost < 0) {\n\t\t\t\t\t\t\t\taccuracy *= boostTable[-boost];\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\taccuracy = this.battle.runEvent('ModifyAccuracy', target, pokemon, move, accuracy);\n\t\t\t\t}\n\t\t\t\tif (move.alwaysHit) {\n\t\t\t\t\taccuracy = true; // bypasses ohko accuracy modifiers\n\t\t\t\t} else {\n\t\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t\t}\n\t\t\t\tif (accuracy !== true && !this.battle.randomChance(accuracy, 100)) {\n\t\t\t\t\tif (!move.spreadHit) this.battle.attrLastMove('[miss]');\n\t\t\t\t\tthis.battle.add('-miss', pokemon, target);\n\t\t\t\t\thitResults[i] = false;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\thitResults[i] = true;\n\t\t\t}\n\t\t\treturn hitResults;\n\t\t},\n\t\tcalcRecoilDamage(damageDealt, move) {\n\t\t\treturn this.battle.clampIntRange(Math.floor(damageDealt * move.recoil![0] / move.recoil![1]), 1);\n\t\t},\n\t},\n};\n"], | |
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,UAAmC;AAAA,EAC/C,SAAS;AAAA,EACT,KAAK;AAAA,EAEL,SAAS;AAAA,IACR,SAAS;AAAA,IACT,UAAU,SAAS;AAClB,WAAK,OAAO,SAAS,eAAe,OAAO;AAE3C,WAAK,OAAO,SAAS,YAAY,OAAO;AAExC,UAAI,KAAK,OAAO,OAAO,GAAG;AAEzB,mBAAW,QAAQ,KAAK,OAAO,aAAa;AAAG,eAAK,WAAW;AAC/D,YAAI,CAAC,QAAQ,KAAK,mBAAmB,QAAQ,cAAc,KAAK,OAAO,MAAM;AAC5E,eAAK,OAAO,SAAS,qBAAqB,OAAO;AAAA,QAClD;AAAA,MACD;AACA,UAAI,CAAC,QAAQ;AAAI,eAAO;AACxB,cAAQ,YAAY;AACpB,UAAI,CAAC,QAAQ,SAAS;AACrB,aAAK,OAAO,YAAY,SAAS,QAAQ,WAAW,GAAG,QAAQ,cAAc,OAAO;AACpF,aAAK,OAAO,YAAY,SAAS,QAAQ,QAAQ,GAAG,QAAQ,WAAW,OAAO;AAAA,MAC/E;AACA,UAAI,KAAK,OAAO,QAAQ,GAAG;AAC1B,mBAAW,aAAa,QAAQ,KAAK,GAAG;AACvC,oBAAU,eAAe,kBAAkB;AAAA,QAC5C;AAAA,MACD;AACA,cAAQ,YAAY;AACpB,aAAO;AAAA,IACR;AAAA,IACA,aAAa,YAA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