From f3fef6cd5d25ae4c83983505f39e74a74f9ac926 Mon Sep 17 00:00:00 2001 From: muscode13 Date: Mon, 21 Oct 2024 21:51:27 -0600 Subject: [PATCH] fixed weather bug --- src/data/ability.ts | 18 +++++++++--------- src/test/abilities/wimp_out.test.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 01b36310098..27f53ab5bce 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -3117,7 +3117,7 @@ function getHealthKnockedBelowHalf(): AbAttrCondition { // Helper function to check if health has dropped below half const isHealthBelowHalf = (initialHealth: number, currentHealth: number) => - initialHealth > maxPokemonHealth / 2 && currentHealth < maxPokemonHealth / 2; + initialHealth >= maxPokemonHealth / 2 && currentHealth < maxPokemonHealth / 2; // PostSummonPhase /** @@ -5267,7 +5267,6 @@ export class PostWeatherForceSwitchOutAttr extends PostWeatherLapseAbAttr { */ applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: Weather, args: any[]): boolean { - const scene = pokemon.scene; if (pokemon.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { return false; } @@ -5280,16 +5279,17 @@ export class PostWeatherForceSwitchOutAttr extends PostWeatherLapseAbAttr { pokemon.removeTag(BattlerTagType.TRAPPED); } const damageAmount = Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.damageFactor)); - if (pokemon.getHpRatio() > 0.5 && (pokemon.hp - damageAmount) / 2 < pokemon.getMaxHp()) { - if (getWeatherCondition(WeatherType.HAIL)) { - scene.queueMessage(i18next.t("weather:hailDamageMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); - } else { - scene.queueMessage(i18next.t("weather:sandstormDamageMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + if (pokemon.hp + damageAmount >= pokemon.getMaxHp() / 2) { + if (pokemon.hp < pokemon.getMaxHp() / 2) { + return this.helper.switchOutLogic(pokemon); + } else { + return false; } - pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER); + } else { + return false; } - return this.helper.switchOutLogic(pokemon); + } getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null { diff --git a/src/test/abilities/wimp_out.test.ts b/src/test/abilities/wimp_out.test.ts index 470fb7d53a8..3e5ebcc3b70 100644 --- a/src/test/abilities/wimp_out.test.ts +++ b/src/test/abilities/wimp_out.test.ts @@ -67,7 +67,7 @@ describe("Abilities - Wimp Out", () => { // arrange game.override .enemyMoveset(Moves.SLUDGE_BOMB) - .startingLevel(95); + .startingLevel(85); await game.startBattle([ Species.WIMPOD, Species.TYRUNT