From b1f183199eebef9aae7046157ff33d079ed407bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?In=C3=AAs=20Sim=C3=B5es?= Date: Thu, 10 Apr 2025 22:44:20 +0100 Subject: [PATCH] Fix #5085 Moves dont play a No Effect Message Against Immune Type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using non-volatile status move like: Will-O-Wisp, Thunder Wave, Toxic, or Poison Gas against a Pokémon whose type is immune to that Status condition, no "It doesn't affect" message plays. My proposed fixes: In move.ts: Removed the else condition in the apply() function in StatusEffectAttr class. In pokemon.ts: Added the function "messageIsImmune(quiet: boolean, effect: StatusEffect)" which displays the message "It doesn't affect XXXX" or the " XXXX is already affected by YYY" message, depending if the effect trying to be set is already affecting the pokemon or if the pokemon is immune to the status. Updated the "canSetStatus()" function so that when it returns false (meaning the status couldn't be applied) it calls the "messageIsImmune()" function to display the message correctly. --- src/data/moves/move.ts | 2 -- src/field/pokemon.ts | 48 +++++++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 35d629ab525..4e6954fb346 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -2426,8 +2426,6 @@ export class StatusEffectAttr extends MoveEffectAttr { if (pokemon.status) { if (this.overrideStatus) { pokemon.resetStatus(); - } else { - return false; } } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 5286f9fc367..3661db7acdf 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -251,6 +251,7 @@ import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; import { CustomPokemonData } from "#app/data/custom-pokemon-data"; import { SwitchType } from "#enums/switch-type"; import { SpeciesFormKey } from "#enums/species-form-key"; +import {getStatusEffectOverlapText } from "#app/data/status-effect"; import { BASE_HIDDEN_ABILITY_CHANCE, BASE_SHINY_CHANCE, @@ -5300,13 +5301,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ); } - messageIsImmune(quiet: boolean): boolean { - if(!quiet){ - globalScene.queueMessage( - i18next.t("abilityTriggers:moveImmunity", {pokemonNameWithAffix: getPokemonNameWithAffix(this),}) - ); + messageIsImmune(quiet: boolean, effect?: StatusEffect): void { + if (!effect || quiet) { + return; } - return false; + const message = effect && this.status?.effect === effect + ? getStatusEffectOverlapText(effect ?? StatusEffect.NONE, getPokemonNameWithAffix(this)) + : i18next.t("abilityTriggers:moveImmunity", { + pokemonNameWithAffix: getPokemonNameWithAffix(this), + }); + globalScene.queueMessage(message); } /** @@ -5327,18 +5331,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ): boolean { if (effect !== StatusEffect.FAINT) { if (overrideStatus ? this.status?.effect === effect : this.status) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } if ( this.isGrounded() && !ignoreField && globalScene.arena.terrain?.terrainType === TerrainType.MISTY ) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } } - const types = this.getTypes(true, true); switch (effect) { @@ -5363,7 +5368,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { defType, ); if (cancelImmunity.value) { - return this.messageIsImmune(quiet); + return false; } } @@ -5372,13 +5377,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (this.isOfType(PokemonType.POISON) || this.isOfType(PokemonType.STEEL)) { if (poisonImmunity.includes(true)) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } } break; case StatusEffect.PARALYSIS: if (this.isOfType(PokemonType.ELECTRIC)) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } break; case StatusEffect.SLEEP: @@ -5386,7 +5393,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.isGrounded() && globalScene.arena.terrain?.terrainType === TerrainType.ELECTRIC ) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } break; case StatusEffect.FREEZE: @@ -5398,12 +5406,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { globalScene.arena.weather.weatherType, )) ) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } break; case StatusEffect.BURN: if (this.isOfType(PokemonType.FIRE)) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } break; } @@ -5429,7 +5439,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ); if (cancelled.value) { - return this.messageIsImmune(quiet); + this.messageIsImmune(quiet, effect); + return false; } if ( @@ -5438,7 +5449,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.isSafeguarded(sourcePokemon) ) { if(!quiet){ - globalScene.queueMessage(i18next.t("moveTriggers:safeguard", { targetName: getPokemonNameWithAffix(this) }));} + globalScene.queueMessage( + i18next.t("moveTriggers:safeguard", { targetName: getPokemonNameWithAffix(this) + })); + } return false; }