mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-17 10:46:53 -05:00
This is the change that renames: - `Dex.getMove` -> `Dex.moves.get` - `Dex.getAbility` -> `Dex.abilities.get` - `Dex.getItem` -> `Dex.items.get` - `Dex.getSpecies` -> `Dex.species.get` - `Dex.getEffect` -> `Dex.conditions.get` - `Dex.getNature` -> `Dex.natures.get` - `Dex.getType` -> `Dex.types.get` - `Dex.getFormat` -> `Dex.formats.get` In addition, some other APIs have been updated: - `getByID` methods have also been added to every other table. - `Dex.moves.all()` now gets an array of all moves - Plus equivalent methods for `abilities`, `items`, `species`, `formats`, `natures`, `types` - Note: there's no `Dex.conditions.all()` - new API: `Dex.stats` for naming/iterating stats - `Dex.getEffectByID` -> `Dex.conditions.getByID` - `Dex.getType` -> `Dex.types.get` - `Dex.data.Formats` -> `Dex.data.Rulesets` - `Dex.formats` -> now an array `Dex.formats.all()` - `Dex.getRuleTable` -> `Dex.formats.getRuleTable` - `Dex.validateFormat` -> `Dex.formats.validate` Team functions have been split off into a new `sim/teams` package: - `Dex.packTeam` -> `Teams.pack` - `Dex.fastUnpackTeam` -> `Teams.unpack` - `Dex.generateTeam` -> `Teams.generate` - `Dex.stringifyTeam` -> `Teams.export` `Teams.export` has also been rewritten to better match how it works in client. This implements #8178
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
export const Scripts: ModdedBattleScriptsData = {
|
|
inherit: 'gen7',
|
|
init() {
|
|
this.modData('Abilities', 'noability').isNonstandard = null;
|
|
for (const i in this.data.Pokedex) {
|
|
this.modData('Pokedex', i).abilities = {0: 'No Ability'};
|
|
}
|
|
},
|
|
/**
|
|
* Given a table of base stats and a pokemon set, return the actual stats.
|
|
*/
|
|
spreadModify(baseStats, set) {
|
|
const modStats: StatsTable = {hp: 10, atk: 10, def: 10, spa: 10, spd: 10, spe: 10};
|
|
let statName: StatID;
|
|
for (statName in modStats) {
|
|
const stat = baseStats[statName];
|
|
modStats[statName] = Math.floor((Math.floor(2 * stat + set.ivs[statName]) * set.level / 100 + 5));
|
|
}
|
|
if ('hp' in baseStats) {
|
|
const stat = baseStats['hp'];
|
|
modStats['hp'] = Math.floor(Math.floor(2 * stat + set.ivs['hp'] + 100) * set.level / 100 + 10);
|
|
}
|
|
return this.natureModify(modStats, set);
|
|
},
|
|
|
|
/**
|
|
* @param {StatsTable} stats
|
|
* @param {PokemonSet} set
|
|
* @return {StatsTable}
|
|
*/
|
|
natureModify(stats, set) {
|
|
const nature = this.dex.natures.get(set.nature);
|
|
if (nature.plus) stats[nature.plus] = Math.floor(stats[nature.plus] * 1.1);
|
|
if (nature.minus) stats[nature.minus] = Math.floor(stats[nature.minus] * 0.9);
|
|
set.happiness = 70;
|
|
const friendshipValue = Math.floor((set.happiness / 255 / 10 + 1) * 100);
|
|
let stat: StatID;
|
|
for (stat in stats) {
|
|
if (stat !== 'hp') {
|
|
stats[stat] = Math.floor(stats[stat] * friendshipValue / 100);
|
|
}
|
|
stats[stat] += set.evs[stat];
|
|
}
|
|
return stats;
|
|
},
|
|
|
|
pokemon: {
|
|
getWeight() {
|
|
let weighthg = this.battle.runEvent('ModifyWeight', this, null, null, this.weighthg);
|
|
if (weighthg < 1) weighthg = 1;
|
|
const weightModifierFinal = 20 * Math.random() * 0.01;
|
|
return weighthg + (weighthg * (this.battle.random(2) === 1 ? 1 : -1) * weightModifierFinal);
|
|
},
|
|
},
|
|
};
|