diff --git a/src/data/ability.ts b/src/data/ability.ts index 131b7d0ff7a..8de0c68a8e7 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -266,6 +266,52 @@ export class PostTeraFormChangeStatChangeAbAttr extends AbAttr { } } +/** + * Clears a specified weather whenever this attribute is called. + */ +export class ClearWeatherAbAttr extends AbAttr { + private weather: WeatherType[]; + + /** + * @param weather {@linkcode WeatherType[]} - the weather to be removed + */ + constructor(weather: WeatherType[]) { + super(true); + + this.weather = weather; + } + + apply(pokemon: Pokemon, passive: boolean, simulated:boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (!simulated) { + globalScene.arena.trySetWeather(WeatherType.NONE, true); + } + return true; + } +} + +/** + * Clears a specified terrain whenever this attribute is called. + */ +export class ClearTerrainAbAttr extends AbAttr { + private terrain: TerrainType[]; + + /** + * @param terrain {@linkcode TerrainType[]} - the terrain to be removed + */ + constructor(terrain: TerrainType[]) { + super(true); + + this.terrain = terrain; + } + + apply(pokemon: Pokemon, passive: boolean, simulated:boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (!simulated) { + globalScene.arena.trySetTerrain(TerrainType.NONE, true, true); + } + return true; + } +} + type PreDefendAbAttrCondition = (pokemon: Pokemon, attacker: Pokemon, move: Move) => boolean; export class PreDefendAbAttr extends AbAttr { @@ -6993,9 +7039,11 @@ export function initAbilities() { .attr(UnswappableAbilityAbAttr) .ignorable(), new Ability(Abilities.TERAFORM_ZERO, 9) + .attr(ClearWeatherAbAttr, [ WeatherType.SUNNY, WeatherType.RAIN, WeatherType.SANDSTORM, WeatherType.HAIL, WeatherType.SNOW, WeatherType.FOG, WeatherType.HEAVY_RAIN, WeatherType.HARSH_SUN, WeatherType.STRONG_WINDS ]) + .attr(ClearTerrainAbAttr, [ TerrainType.MISTY, TerrainType.ELECTRIC, TerrainType.GRASSY, TerrainType.PSYCHIC ]) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) - .unimplemented(), + .condition(getOncePerBattleCondition(Abilities.TERAFORM_ZERO)), new Ability(Abilities.POISON_PUPPETEER, 9) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) diff --git a/src/phases/quiet-form-change-phase.ts b/src/phases/quiet-form-change-phase.ts index 6cd1129d318..81a39f53a76 100644 --- a/src/phases/quiet-form-change-phase.ts +++ b/src/phases/quiet-form-change-phase.ts @@ -11,7 +11,7 @@ import { getPokemonNameWithAffix } from "#app/messages"; import { BattlePhase } from "./battle-phase"; import { MovePhase } from "./move-phase"; import { PokemonHealPhase } from "./pokemon-heal-phase"; -import { applyAbAttrs, PostTeraFormChangeStatChangeAbAttr } from "#app/data/ability"; +import { applyAbAttrs, ClearTerrainAbAttr, ClearWeatherAbAttr, PostTeraFormChangeStatChangeAbAttr } from "#app/data/ability"; export class QuietFormChangePhase extends BattlePhase { protected pokemon: Pokemon; @@ -148,6 +148,8 @@ export class QuietFormChangePhase extends BattlePhase { } if (this.formChange.trigger instanceof SpeciesFormChangeTeraTrigger) { applyAbAttrs(PostTeraFormChangeStatChangeAbAttr, this.pokemon, null); + applyAbAttrs(ClearWeatherAbAttr, this.pokemon, null); + applyAbAttrs(ClearTerrainAbAttr, this.pokemon, null); } super.end();