fixed weather bug

This commit is contained in:
muscode13 2024-10-21 21:51:27 -06:00
parent a677a71e51
commit f3fef6cd5d
2 changed files with 10 additions and 10 deletions

View File

@ -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) }));
}
pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER);
}
if (pokemon.hp + damageAmount >= pokemon.getMaxHp() / 2) {
if (pokemon.hp < pokemon.getMaxHp() / 2) {
return this.helper.switchOutLogic(pokemon);
} else {
return false;
}
} else {
return false;
}
}
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {

View File

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