fix scrappy and mindseye working as passive ability (#567)

* fix scrappy and mindseye working as passive ability

* update apply for ignoretypeimmunityabattr

* simplify logic for ignoretypeimmunityabattr

---------

Co-authored-by: contra1337 <jpbastyr@gmail.com>
This commit is contained in:
Jeremy B 2024-05-08 00:32:38 -05:00 committed by GitHub
parent 118c57ba75
commit bb28d3599e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 12 deletions

View File

@ -2496,11 +2496,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) && this.allowedMoveTypes.includes(args[0] as Type)) {
cancelled.value = true;
return true;
}
return this.allowedMoveTypes.some(type => type === (args[0] as Type));
return false;
}
}
@ -3606,7 +3606,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)
.attr(PostSummonStatChangeAbAttr, BattleStat.EVA, -1)
.condition(getOncePerBattleCondition(Abilities.SUPERSWEET_SYRUP)),

View File

@ -908,14 +908,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) {
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)