From f4d0d56cfd647c1059cf625b7d2a013ca8f24fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?In=C3=AAs=20Sim=C3=B5es?= Date: Tue, 1 Apr 2025 23:06:36 +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 queue of the message ""XXXX is protected by Safeguard!" in the class: "StatusEffectAttr" due to the Pokemon being safeguarded when a status move is used and added a call to the function canSetStatus(). In pokemon.ts: Added the function "messageIsImmune(quiet: boolean)" which displays the message "It doesn't affect XXXX" if the quiet parameter is set to false. 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. Also included the queue of the message removed from the move.ts file allowing the centralization of the messages associated with status moves. --- src/data/moves/move.ts | 24 +++------------------- src/field/pokemon.ts | 46 ++++++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 044c19e1dcf..35d629ab525 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -2431,29 +2431,11 @@ export class StatusEffectAttr extends MoveEffectAttr { } } - if (user !== target && target.isSafeguarded(user)) { - if (move.category === MoveCategory.STATUS) { - globalScene.queueMessage(i18next.t("moveTriggers:safeguard", { targetName: getPokemonNameWithAffix(target) })); - } + if (user !== target && move.category === MoveCategory.STATUS && !target.canSetStatus(this.effect, false, false, user, true)) { return false; } - if (!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0)){ - const statusApplied = pokemon.trySetStatus(this.effect, true, user, this.turnsRemaining); - if (!statusApplied) { - const isImmune = - (this.effect === StatusEffect.POISON || this.effect === StatusEffect.TOXIC) - && (pokemon.isOfType(PokemonType.POISON) || pokemon.isOfType(PokemonType.STEEL) || pokemon.hasAbility(Abilities.IMMUNITY)) - || (this.effect === StatusEffect.PARALYSIS - && (pokemon.isOfType(PokemonType.ELECTRIC) || pokemon.hasAbility(Abilities.LIMBER))) - || (this.effect === StatusEffect.BURN - && (pokemon.isOfType(PokemonType.FIRE) || pokemon.hasAbility(Abilities.WATER_VEIL))) - || (this.effect === StatusEffect.FREEZE - && (pokemon.isOfType(PokemonType.ICE) || pokemon.hasAbility(Abilities.MAGMA_ARMOR))); - if (isImmune) { - globalScene.queueMessage(i18next.t("abilityTriggers:moveImmunity", { pokemonNameWithAffix: getPokemonNameWithAffix(target) })); - } - return false; - } + if ((!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0)) + && pokemon.trySetStatus(this.effect, true, user, this.turnsRemaining)) { applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, false, this.effect); return true; } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 890c6bab0d6..5286f9fc367 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -5300,6 +5300,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ); } + messageIsImmune(quiet: boolean): boolean { + if(!quiet){ + globalScene.queueMessage( + i18next.t("abilityTriggers:moveImmunity", {pokemonNameWithAffix: getPokemonNameWithAffix(this),}) + ); + } + return false; + } + /** * Checks if a status effect can be applied to the Pokemon. * @@ -5318,24 +5327,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ): boolean { if (effect !== StatusEffect.FAINT) { if (overrideStatus ? this.status?.effect === effect : this.status) { - return false; + return this.messageIsImmune(quiet); } if ( this.isGrounded() && !ignoreField && globalScene.arena.terrain?.terrainType === TerrainType.MISTY ) { - return false; + return this.messageIsImmune(quiet); } } - if ( - sourcePokemon && - sourcePokemon !== this && - this.isSafeguarded(sourcePokemon) - ) { - return false; - } const types = this.getTypes(true, true); @@ -5361,22 +5363,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { defType, ); if (cancelImmunity.value) { - return false; + return this.messageIsImmune(quiet); } } - return true; + return true; }); if (this.isOfType(PokemonType.POISON) || this.isOfType(PokemonType.STEEL)) { if (poisonImmunity.includes(true)) { - return false; + return this.messageIsImmune(quiet); } } break; case StatusEffect.PARALYSIS: if (this.isOfType(PokemonType.ELECTRIC)) { - return false; + return this.messageIsImmune(quiet); } break; case StatusEffect.SLEEP: @@ -5384,7 +5386,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.isGrounded() && globalScene.arena.terrain?.terrainType === TerrainType.ELECTRIC ) { - return false; + return this.messageIsImmune(quiet); } break; case StatusEffect.FREEZE: @@ -5396,12 +5398,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { globalScene.arena.weather.weatherType, )) ) { - return false; + return this.messageIsImmune(quiet); } break; case StatusEffect.BURN: if (this.isOfType(PokemonType.FIRE)) { - return false; + return this.messageIsImmune(quiet); } break; } @@ -5427,6 +5429,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ); if (cancelled.value) { + return this.messageIsImmune(quiet); + } + + if ( + sourcePokemon && + sourcePokemon !== this && + this.isSafeguarded(sourcePokemon) + ) { + if(!quiet){ + globalScene.queueMessage(i18next.t("moveTriggers:safeguard", { targetName: getPokemonNameWithAffix(this) }));} return false; } @@ -5440,7 +5452,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { turnsRemaining = 0, sourceText: string | null = null, ): boolean { - if (!this.canSetStatus(effect, asPhase, false, sourcePokemon)) { + if (!this.canSetStatus(effect, false, false, sourcePokemon)) { return false; } if (this.isFainted() && effect !== StatusEffect.FAINT) {