From 8b8caad5de083b09f38ceb8c0aa2cd01c59d6779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?In=C3=AAs=20Sim=C3=B5es?= Date: Wed, 19 Mar 2025 14:19:05 +0000 Subject: [PATCH] Fixes #5085: Updated my proposed fix Changed the move.ts file: In the StatusEffectAttr class updated the "apply()" function so that when a status isn't inflicted to the opposing pokemon it checks if the cause of that failure is Type immunity or immunity provided by an ability. --- src/data/moves/move.ts | 41 ++++++++++++++++++----------------------- src/field/pokemon.ts | 2 +- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index ac0d97f5d85..18d218ab502 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -323,7 +323,7 @@ export default class Move implements Localizable { * @param {PokemonType} type the type of the move's target * @returns boolean */ - isTypeImmune(user: Pokemon, target: Pokemon, type: PokemonType, move: Move): boolean { + isTypeImmune(user: Pokemon, target: Pokemon, type: PokemonType): boolean { if (this.moveTarget === MoveTarget.USER) { return false; } @@ -339,26 +339,6 @@ export default class Move implements Localizable { return true; } break; - case PokemonType.FIRE: - if (move.id === Moves.WILL_O_WISP) { - return true; - } - break; - case PokemonType.ELECTRIC: - if (move.id === Moves.THUNDER_WAVE) { - return true; - } - break; - case PokemonType.POISON: - if (move.id === Moves.TOXIC) { - return true; - } - break; - case PokemonType.STEEL: - if (move.id === Moves.POISON_GAS) { - return true; - } - break; } return false; } @@ -2457,8 +2437,23 @@ export class StatusEffectAttr extends MoveEffectAttr { } return false; } - if ((!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0)) - && pokemon.trySetStatus(this.effect, true, user, this.turnsRemaining)) { + 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; + } applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, false, this.effect); return true; } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 1f89cb91822..890c6bab0d6 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2459,7 +2459,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { typeMultiplier, ); if ( - this.getTypes(true, true).find(t => move.isTypeImmune(source, this, t, move)) + this.getTypes(true, true).find(t => move.isTypeImmune(source, this, t)) ) { typeMultiplier.value = 0; }