mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-21 14:59:50 -05:00
147 lines
4.9 KiB
TypeScript
147 lines
4.9 KiB
TypeScript
export const Scripts: ModdedBattleScriptsData = {
|
|
gen: 8,
|
|
field: {
|
|
suppressingWeather() {
|
|
for (const pokemon of this.battle.getAllActive()) {
|
|
if (pokemon && !pokemon.fainted && !pokemon.ignoringAbility() &&
|
|
(pokemon.getAbility().suppressWeather ||
|
|
pokemon.m.innates?.some((k: string) => this.battle.dex.abilities.get(k).suppressWeather))) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
},
|
|
pokemon: {
|
|
ignoringAbility() {
|
|
// Check if any active pokemon have the ability Neutralizing Gas
|
|
let neutralizinggas = false;
|
|
for (const pokemon of this.battle.getAllActive()) {
|
|
// can't use hasAbility because it would lead to infinite recursion
|
|
if (
|
|
(pokemon.ability === ('neutralizinggas' as ID) || pokemon.m.innates?.some((k: string) => k === 'neutralizinggas')) &&
|
|
!pokemon.volatiles['gastroacid'] && !pokemon.abilityState.ending
|
|
) {
|
|
neutralizinggas = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return !!(
|
|
(this.battle.gen >= 5 && !this.isActive) ||
|
|
((this.volatiles['gastroacid'] ||
|
|
(neutralizinggas && (this.ability !== ('neutralizinggas' as ID) ||
|
|
this.m.innates?.some((k: string) => k === 'neutralizinggas'))
|
|
)) && !this.getAbility().isPermanent
|
|
)
|
|
);
|
|
},
|
|
hasAbility(ability) {
|
|
if (this.ignoringAbility()) return false;
|
|
if (Array.isArray(ability)) return ability.some(abil => this.hasAbility(abil));
|
|
ability = this.battle.toID(ability);
|
|
return this.ability === ability || !!this.volatiles['ability:' + ability];
|
|
},
|
|
transformInto(pokemon, effect) {
|
|
const species = pokemon.species;
|
|
if (pokemon.fainted || pokemon.illusion || (pokemon.volatiles['substitute'] && this.battle.gen >= 5) ||
|
|
(pokemon.transformed && this.battle.gen >= 2) || (this.transformed && this.battle.gen >= 5) ||
|
|
species.name === 'Eternatus-Eternamax') {
|
|
return false;
|
|
}
|
|
|
|
if (!this.setSpecies(species, effect, true)) return false;
|
|
|
|
this.transformed = true;
|
|
this.weighthg = pokemon.weighthg;
|
|
|
|
const types = pokemon.getTypes(true);
|
|
this.setType(pokemon.volatiles['roost'] ? pokemon.volatiles['roost'].typeWas : types, true);
|
|
this.addedType = pokemon.addedType;
|
|
this.knownType = this.isAlly(pokemon) && pokemon.knownType;
|
|
this.apparentType = pokemon.apparentType;
|
|
|
|
let statName: StatIDExceptHP;
|
|
for (statName in this.storedStats) {
|
|
this.storedStats[statName] = pokemon.storedStats[statName];
|
|
}
|
|
this.moveSlots = [];
|
|
this.set.ivs = (this.battle.gen >= 5 ? this.set.ivs : pokemon.set.ivs);
|
|
this.hpType = (this.battle.gen >= 5 ? this.hpType : pokemon.hpType);
|
|
this.hpPower = (this.battle.gen >= 5 ? this.hpPower : pokemon.hpPower);
|
|
for (const moveSlot of pokemon.moveSlots) {
|
|
let moveName = moveSlot.move;
|
|
if (moveSlot.id === 'hiddenpower') {
|
|
moveName = 'Hidden Power ' + this.hpType;
|
|
}
|
|
this.moveSlots.push({
|
|
move: moveName,
|
|
id: moveSlot.id,
|
|
pp: moveSlot.maxpp === 1 ? 1 : 5,
|
|
maxpp: this.battle.gen >= 5 ? (moveSlot.maxpp === 1 ? 1 : 5) : moveSlot.maxpp,
|
|
target: moveSlot.target,
|
|
disabled: false,
|
|
used: false,
|
|
virtual: true,
|
|
});
|
|
}
|
|
let boostName: BoostID;
|
|
for (boostName in pokemon.boosts) {
|
|
this.boosts[boostName] = pokemon.boosts[boostName]!;
|
|
}
|
|
if (this.battle.gen >= 6) {
|
|
const volatilesToCopy = ['focusenergy', 'gmaxchistrike', 'laserfocus'];
|
|
for (const volatile of volatilesToCopy) {
|
|
if (pokemon.volatiles[volatile]) {
|
|
this.addVolatile(volatile);
|
|
if (volatile === 'gmaxchistrike') this.volatiles[volatile].layers = pokemon.volatiles[volatile].layers;
|
|
} else {
|
|
this.removeVolatile(volatile);
|
|
}
|
|
}
|
|
}
|
|
if (effect) {
|
|
this.battle.add('-transform', this, pokemon, '[from] ' + effect.fullname);
|
|
} else {
|
|
this.battle.add('-transform', this, pokemon);
|
|
}
|
|
if (this.battle.gen > 2) {
|
|
this.setAbility(pokemon.ability, this, true);
|
|
if (this.m.innates) {
|
|
for (const innate of this.m.innates) {
|
|
this.removeVolatile('ability:' + innate);
|
|
}
|
|
}
|
|
if (pokemon.m.innates) {
|
|
for (const innate of pokemon.m.innates) {
|
|
this.addVolatile('ability:' + innate, this);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Change formes based on held items (for Transform)
|
|
// Only ever relevant in Generation 4 since Generation 3 didn't have item-based forme changes
|
|
if (this.battle.gen === 4) {
|
|
if (this.species.num === 487) {
|
|
// Giratina formes
|
|
if (this.species.name === 'Giratina' && this.item === 'griseousorb') {
|
|
this.formeChange('Giratina-Origin');
|
|
} else if (this.species.name === 'Giratina-Origin' && this.item !== 'griseousorb') {
|
|
this.formeChange('Giratina');
|
|
}
|
|
}
|
|
if (this.species.num === 493) {
|
|
// Arceus formes
|
|
const item = this.getItem();
|
|
const targetForme = (item?.onPlate ? 'Arceus-' + item.onPlate : 'Arceus');
|
|
if (this.species.name !== targetForme) {
|
|
this.formeChange(targetForme);
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
},
|
|
},
|
|
};
|