pokemon-showdown/data/mods/sharedpower/scripts.ts
Leonard Craft III 8a5bbbd255
Implement Ability flags (#10048)
* Add AbilityFlags interface

* Add flags to abilities data (Karthik's script)

* Convert isBreakable to its new flag

* Convert most of isPermanent to its new flag

* Convert Trace to its new flag

* Convert Skill Swap to its new flag

* Convert Wandering Spirit to the failskillswap flag

* Update miscelleneous descriptions that depend on cantsuppress

* Convert Entrainment to its flag

* Convert Receiver/PoA to its flag

* Convert Role Play to its flag

* Implement Doodle failure conditions

* Various cleanup

* Breakable fixes

* How did I manage to do this

* Allow LightningRod to be breakable in Gen 3

* Implement notransform flag

* Tera Shell oopsie

* Fix more things after the rebase

* And fix Teraform Zero

* Update data/abilities.ts

* Update data/abilities.ts

* Update data/abilities.ts

* Update data/mods/partnersincrime/abilities.ts

* Update data/abilities.ts

* Update data/mods/sharedpower/abilities.ts

* Update abilities.ts

---------

Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
2024-01-02 23:55:17 -07:00

48 lines
1.6 KiB
TypeScript

export const Scripts: ModdedBattleScriptsData = {
field: {
suppressingWeather() {
for (const pokemon of this.battle.getAllActive()) {
const innates = Object.keys(pokemon.volatiles).filter(x => x.startsWith('ability:'));
if (pokemon && !pokemon.ignoringAbility() &&
(pokemon.getAbility().suppressWeather || innates.some(x => (
this.battle.dex.abilities.get(x.replace('ability:', '')).suppressWeather
)))) {
return true;
}
}
return false;
},
},
pokemon: {
hasAbility(ability) {
if (this.ignoringAbility()) return false;
if (Array.isArray(ability)) return ability.some(abil => this.hasAbility(abil));
const abilityid = this.battle.toID(ability);
return this.ability === abilityid || !!this.volatiles['ability:' + abilityid];
},
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.abils?.includes('ability: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.abils?.includes('ability:neutralizinggas'))
)) && !this.getAbility().flags['cantsuppress']
)
);
},
},
};