From bb843492ba4061b0d51db07a11d6f441dc6da5d1 Mon Sep 17 00:00:00 2001 From: contra1337 Date: Mon, 6 May 2024 15:15:48 -0500 Subject: [PATCH] fix scrappy and mindseye working as passive ability --- src/data/ability.ts | 9 +++++---- src/field/pokemon.ts | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 07aecbdcc91..f44908467b4 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2483,11 +2483,11 @@ export class IgnoreTypeImmunityAbAttr extends AbAttr { } apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - if (this.defenderType !== (args[1] as Type)) { - return false; + if (this.defenderType === (args[1] as Type)) { + cancelled.value = this.allowedMoveTypes.some(type => type === (args[0] as Type)); } - return this.allowedMoveTypes.some(type => type === (args[0] as Type)); + return cancelled.value; } } @@ -3588,7 +3588,8 @@ export function initAbilities() { .partial(), new Ability(Abilities.MINDS_EYE, 9) .attr(IgnoreTypeImmunityAbAttr, Type.GHOST, [Type.NORMAL, Type.FIGHTING]) - .ignorable(), // TODO: evasiveness bypass should not be ignored, but accuracy immunity should + .ignorable() // TODO: evasiveness bypass should not be ignored, but accuracy immunity should + .partial(), new Ability(Abilities.SUPERSWEET_SYRUP, 9) .unimplemented(), new Ability(Abilities.HOSPITALITY, 9) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 2242b1ee694..75d19d1755f 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -901,14 +901,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.isTerastallized() ? 2 : 1; const types = this.getTypes(true, true); - const ignorableImmunities = source?.getAbility()?.getAttrs(IgnoreTypeImmunityAbAttr) || []; - const cancelled = new Utils.BooleanHolder(false); + let multiplier = types.map(defType => { + if (source && source.hasAbilityWithAttr(IgnoreTypeImmunityAbAttr)) { + const ignoreImmunity = new Utils.BooleanHolder(false); + applyAbAttrs(IgnoreTypeImmunityAbAttr, source, ignoreImmunity, moveType, defType); + if (ignoreImmunity.value) + return 1; + } - let multiplier = types.map(defType => - ignorableImmunities.some(attr => attr.apply(source, false, cancelled, [moveType, defType])) - ? 1 - : getTypeDamageMultiplier(moveType, defType) - ).reduce((acc, cur) => acc * cur, 1) as TypeDamageMultiplier; + return getTypeDamageMultiplier(moveType, defType); + }).reduce((acc, cur) => acc * cur, 1) as TypeDamageMultiplier; // Handle strong winds lowering effectiveness of types super effective against pure flying if (this.scene.arena.weather?.weatherType === WeatherType.STRONG_WINDS && !this.scene.arena.weather.isEffectSuppressed(this.scene) && multiplier >= 2 && this.isOfType(Type.FLYING) && getTypeDamageMultiplier(moveType, Type.FLYING) === 2)