[Ability] Implement Teraform Zero ability (#5359)

* Partially implement Teraform Zero ability

The functionality of the ability is all there, it just isn't limited to one use per Terastallization yet.

* Add the once per battle condition

This removes the partial from the ability.

* Make attribute names more generic

---------

Co-authored-by: damocleas <damocleas25@gmail.com>
This commit is contained in:
Madmadness65 2025-02-25 01:46:07 -06:00 committed by GitHub
parent d14f71d27a
commit 88a5c9d416
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 2 deletions

View File

@ -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)

View File

@ -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();