From 17eef20bcf5dc556c60970eb3da2d8230334e3a1 Mon Sep 17 00:00:00 2001 From: Karthik <32044378+Karthik99999@users.noreply.github.com> Date: Mon, 8 Jan 2024 17:10:58 -0700 Subject: [PATCH] Support new ability flags (#2210) --- build-tools/build-indexes | 2 +- .../src/battle-dex-data.ts | 23 +++++++++++++++++-- play.pokemonshowdown.com/src/battle.ts | 15 ++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/build-tools/build-indexes b/build-tools/build-indexes index 7ab6a55af..01e935a45 100755 --- a/build-tools/build-indexes +++ b/build-tools/build-indexes @@ -1063,7 +1063,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); // Client relevant data that should be overriden by past gens and mods const overrideSpeciesKeys = ['abilities', 'baseStats', 'cosmeticFormes', 'isNonstandard', 'requiredItems', 'types', 'unreleasedHidden']; const overrideMoveKeys = ['accuracy', 'basePower', 'category', 'desc', 'flags', 'isNonstandard', 'noSketch', 'pp', 'priority', 'shortDesc', 'target', 'type']; - const overrideAbilityKeys = ['desc', 'isNonstandard', 'rating', 'shortDesc']; + const overrideAbilityKeys = ['desc', 'flags', 'isNonstandard', 'rating', 'shortDesc']; // // Past gen table diff --git a/play.pokemonshowdown.com/src/battle-dex-data.ts b/play.pokemonshowdown.com/src/battle-dex-data.ts index af18f361f..b6523073a 100644 --- a/play.pokemonshowdown.com/src/battle-dex-data.ts +++ b/play.pokemonshowdown.com/src/battle-dex-data.ts @@ -1372,6 +1372,25 @@ class Move implements Effect { } } +interface AbilityFlags { + /** Can be suppressed by Mold Breaker and related effects */ + breakable?: 1; + /** Ability can't be suppressed by e.g. Gastro Acid or Neutralizing Gas */ + cantsuppress?: 1; + /** Role Play fails if target has this Ability */ + failroleplay?: 1; + /** Skill Swap fails if either the user or target has this Ability */ + failskillswap?: 1; + /** Entrainment fails if user has this Ability */ + noentrain?: 1; + /** Receiver and Power of Alchemy will not activate if an ally faints with this Ability */ + noreceiver?: 1; + /** Trace cannot copy this Ability */ + notrace?: 1; + /** Disables the Ability if the user is Transformed */ + notransform?: 1; +} + class Ability implements Effect { // effect readonly effectType = 'Ability'; @@ -1385,7 +1404,7 @@ class Ability implements Effect { readonly desc: string; readonly rating: number; - readonly isPermanent: boolean; + readonly flags: AbilityFlags; readonly isNonstandard: boolean; constructor(id: ID, name: string, data: any) { @@ -1399,7 +1418,7 @@ class Ability implements Effect { this.shortDesc = data.shortDesc || data.desc || ''; this.desc = data.desc || data.shortDesc || ''; this.rating = data.rating || 1; - this.isPermanent = !!data.isPermanent; + this.flags = data.flags || {}; this.isNonstandard = !!data.isNonstandard; if (!this.gen) { if (this.num >= 234) { diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index bf8660f5e..04ca1b915 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -521,11 +521,14 @@ export class Pokemon implements PokemonDetails, PokemonHealth { return !this.getTypeList(serverPokemon).includes('Flying'); } effectiveAbility(serverPokemon?: ServerPokemon) { - if (this.fainted || this.volatiles['gastroacid']) return ''; const ability = this.side.battle.dex.abilities.get( serverPokemon?.ability || this.ability || serverPokemon?.baseAbility || '' ); - if (this.side.battle.ngasActive() && !ability.isPermanent) { + if ( + this.fainted || + (this.volatiles['transform'] && ability.flags['notransform']) || + (!ability.flags['cantsuppress'] && (this.side.battle.ngasActive() || this.volatiles['gastroacid'])) + ) { return ''; } return ability.name; @@ -1224,6 +1227,7 @@ export class Battle { } return pokemonList; } + // Used in Pokemon#effectiveAbility over abilityActive to prevent infinite recursion ngasActive() { for (const active of this.getAllActive()) { if (active.ability === 'Neutralizing Gas' && !active.volatiles['gastroacid']) { @@ -1234,12 +1238,9 @@ export class Battle { } abilityActive(abilities: string | string[]) { if (typeof abilities === 'string') abilities = [abilities]; - if (this.ngasActive()) { - abilities = abilities.filter(a => this.dex.abilities.get(a).isPermanent); - if (!abilities.length) return false; - } + abilities = abilities.map(toID); for (const active of this.getAllActive()) { - if (abilities.includes(active.ability) && !active.volatiles['gastroacid']) { + if (abilities.includes(toID(active.effectiveAbility()))) { return true; } }