From a9a4ac4f9d76ab9652c84366e13a2f759a579d99 Mon Sep 17 00:00:00 2001 From: gMak64 <46451004+gMak64@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:24:10 -0400 Subject: [PATCH 1/2] Update harsh sun, heavy rain, and heavy winds to turn off if their respective abilities are no longer on the field --- src/data/ability.ts | 13 +++++++++++++ src/data/weather.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/data/ability.ts b/src/data/ability.ts index e0bd24b4e..c93a6ef35 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1436,6 +1436,16 @@ export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr { } } +export class PreSwitchOutWeatherChangeAbAttr extends PreSwitchOutAbAttr { + applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + if (pokemon.scene.arena.weather?.isImmutable()) { + return pokemon.scene.arena.weather?.isAbilityOnField(pokemon.scene) ? false : pokemon.scene.arena.trySetWeather(WeatherType.NONE, true); + } + + return false; + } +} + export class PreStatChangeAbAttr extends AbAttr { applyPreStatChange(pokemon: Pokemon, passive: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; @@ -2896,12 +2906,15 @@ export function initAbilities() { .ignorable(), new Ability(Abilities.PRIMORDIAL_SEA, "Primordial Sea", "The Pokémon changes the weather to nullify Fire-type attacks.", 6) .attr(PostSummonWeatherChangeAbAttr, WeatherType.HEAVY_RAIN) + .attr(PreSwitchOutWeatherChangeAbAttr) .attr(PostBiomeChangeWeatherChangeAbAttr, WeatherType.HEAVY_RAIN), new Ability(Abilities.DESOLATE_LAND, "Desolate Land", "The Pokémon changes the weather to nullify Water-type attacks.", 6) .attr(PostSummonWeatherChangeAbAttr, WeatherType.HARSH_SUN) + .attr(PreSwitchOutWeatherChangeAbAttr) .attr(PostBiomeChangeWeatherChangeAbAttr, WeatherType.HARSH_SUN), new Ability(Abilities.DELTA_STREAM, "Delta Stream", "The Pokémon changes the weather to eliminate all of the Flying type's weaknesses.", 6) .attr(PostSummonWeatherChangeAbAttr, WeatherType.STRONG_WINDS) + .attr(PreSwitchOutWeatherChangeAbAttr) .attr(PostBiomeChangeWeatherChangeAbAttr, WeatherType.STRONG_WINDS), new Ability(Abilities.STAMINA, "Stamina", "Boosts the Defense stat when hit by an attack.", 7) .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.category !== MoveCategory.STATUS, BattleStat.DEF, 1), diff --git a/src/data/weather.ts b/src/data/weather.ts index 1409920a1..14d78e649 100644 --- a/src/data/weather.ts +++ b/src/data/weather.ts @@ -7,6 +7,7 @@ import * as Utils from "../utils"; import BattleScene from "../battle-scene"; import { SuppressWeatherEffectAbAttr } from "./ability"; import { TerrainType } from "./terrain"; +import { Abilities } from "./enums/abilities"; export enum WeatherType { NONE, @@ -116,6 +117,39 @@ export class Weather { return false; } + + isAbilityOnField(scene: BattleScene): boolean { + const field = scene.getField(true); + let abilitiesOnField = 0; + + for (let pokemon of field) { + let ability = pokemon.getAbility(); + switch (this.weatherType) { + case WeatherType.HARSH_SUN: + if (ability.id === Abilities.DESOLATE_LAND) + abilitiesOnField++ + if (pokemon.hasPassive() && pokemon.getPassiveAbility().id === Abilities.DESOLATE_LAND) + abilitiesOnField++ + break; + case WeatherType.HEAVY_RAIN: + if (ability.id === Abilities.PRIMORDIAL_SEA) + abilitiesOnField++ + if (pokemon.hasPassive() && pokemon.getPassiveAbility().id === Abilities.PRIMORDIAL_SEA) + abilitiesOnField++ + break; + case WeatherType.STRONG_WINDS: + if (ability.id === Abilities.DELTA_STREAM) + abilitiesOnField++ + if (pokemon.hasPassive() && pokemon.getPassiveAbility().id === Abilities.DELTA_STREAM) + abilitiesOnField++ + break; + default: + break; + } + } + + return abilitiesOnField > 1; + } } export function getWeatherStartMessage(weatherType: WeatherType): string { From 60ecc91dfcca9f83ef61107e3c37aed8ef6632a0 Mon Sep 17 00:00:00 2001 From: gMak64 <46451004+gMak64@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:55:13 -0400 Subject: [PATCH 2/2] harsh weather can override harsh weather --- src/data/ability.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/data/ability.ts b/src/data/ability.ts index c93a6ef35..641a3e81d 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1309,6 +1309,14 @@ export class PostSummonWeatherChangeAbAttr extends PostSummonAbAttr { if (!pokemon.scene.arena.weather?.isImmutable()) return pokemon.scene.arena.trySetWeather(this.weatherType, true); + if (pokemon.scene.arena.weather?.isImmutable()) + switch (this.weatherType) { + case WeatherType.HEAVY_RAIN: + case WeatherType.HARSH_SUN: + case WeatherType.STRONG_WINDS: + return pokemon.scene.arena.trySetWeather(this.weatherType, true); + } + return false; } }