Update harsh sun, heavy rain, and heavy winds to turn off if their respective abilities are no longer on the field

pull/280/head^2
gMak64 2024-04-24 18:24:10 -04:00
parent d5e462ba7d
commit a9a4ac4f9d
2 changed files with 47 additions and 0 deletions

View File

@ -1436,6 +1436,16 @@ export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr {
}
}
export class PreSwitchOutWeatherChangeAbAttr extends PreSwitchOutAbAttr {
applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
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<boolean> {
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),

View File

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