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