diff --git a/src/data/ability.ts b/src/data/ability.ts index 4128f22e2..6396a8593 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -324,6 +324,13 @@ export class PreDefendMovePowerToOneAbAttr extends ReceivedMoveDamageMultiplierA } } +/** + * Makes the user immune to moves of a specific type. Works regardless + * of move category. Does not affect moves that target the field (ex. spikes) + * @param immuneType The {@link Type} that the user is immune to + * @param condition N/A + * @returns if the ability successfully activates + */ export class TypeImmunityAbAttr extends PreDefendAbAttr { private immuneType: Type; private condition: AbAttrCondition; @@ -336,7 +343,11 @@ export class TypeImmunityAbAttr extends PreDefendAbAttr { } applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean { - if ((move.getMove() instanceof AttackMove || move.getMove().getAttrs(StatusMoveTypeImmunityAttr).find(attr => (attr as StatusMoveTypeImmunityAttr).immuneType === this.immuneType)) && move.getMove().type === this.immuneType) { + + const target = move.getMove().moveTarget; + const targetsField = target === MoveTarget.ENEMY_SIDE || target === MoveTarget.USER_SIDE || target === MoveTarget.BOTH_SIDES; // should not activate on moves like spikes or grassy terrain + + if ((!targetsField || move.getMove().getAttrs(StatusMoveTypeImmunityAttr).find(attr => (attr as StatusMoveTypeImmunityAttr).immuneType === this.immuneType)) && move.getMove().type === this.immuneType) { (args[0] as Utils.NumberHolder).value = 0; return true; }