diff --git a/src/data/ability.ts b/src/data/ability.ts index a257525ef..004614357 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1736,6 +1736,30 @@ export class PreSetStatusAbAttr extends AbAttr { } } +/** + * Ignores the type immunity to Status Effects of the defender if the defender is of a certain type + */ +export class IgnoreTypeStatusEffectImmunityAbAttr extends PreSetStatusAbAttr { + private statusEffect: StatusEffect[]; + private defenderType: Type[]; + + constructor(statusEffect: StatusEffect[], defenderType: Type[]) { + super(true); + + this.statusEffect = statusEffect; + this.defenderType = defenderType; + } + + applyPreSetStatus(pokemon: Pokemon, passive: boolean, effect: StatusEffect,cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (this.statusEffect.includes(effect) && this.defenderType.includes(args[1] as Type)) { + cancelled.value = true; + return true; + } + + return false; + } +} + export class StatusEffectImmunityAbAttr extends PreSetStatusAbAttr { private immuneEffects: StatusEffect[]; @@ -2666,30 +2690,6 @@ export class IgnoreTypeImmunityAbAttr extends AbAttr { } } -/** - * Ignores the type immunity to Status Effects of the defender if the defender is of a certain type - */ -export class IgnoreTypeStatusEffectImmunityAbAttr extends AbAttr { - private statusEffect: StatusEffect[]; - private defenderType: Type[]; - - constructor(statusEffect: StatusEffect[], defenderType: Type[]) { - super(true); - - this.statusEffect = statusEffect; - this.defenderType = defenderType; - } - - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - if (this.statusEffect.includes(args[0] as StatusEffect) && this.defenderType.includes(args[1] as Type)) { - cancelled.value = true; - return true; - } - - return false; - } -} - function applyAbAttrsInternal(attrType: { new(...args: any[]): TAttr }, pokemon: Pokemon, applyFunc: AbAttrApplyFunc, args: any[], isAsync: boolean = false, showAbilityInstant: boolean = false, quiet: boolean = false, passive: boolean = false): Promise { return new Promise(resolve => { @@ -2824,8 +2824,8 @@ export function applyPostStatChangeAbAttrs(attrType: { new(...args: any[]): Post export function applyPreSetStatusAbAttrs(attrType: { new(...args: any[]): PreSetStatusAbAttr }, pokemon: Pokemon, effect: StatusEffect, cancelled: Utils.BooleanHolder, ...args: any[]): Promise { - const simulated = args.length > 1 && args[1]; - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreSetStatus(pokemon, passive, effect, cancelled, args), args, false, false, !simulated); + const simulated = args[0]; + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreSetStatus(pokemon, passive, effect, cancelled, args), args, false, false, simulated); } export function applyPreApplyBattlerTagAbAttrs(attrType: { new(...args: any[]): PreApplyBattlerTagAbAttr }, diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index eb08af3da..9c163ee26 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2052,6 +2052,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { switch (effect) { case StatusEffect.POISON: case StatusEffect.TOXIC: + console.log('checking poison immunity', this.name, types, sourcePokemon?.name, sourcePokemon?.id) // Check if the Pokemon is immune to Poison/Toxic or if the source pokemon is canceling the immunity let poisonImmunity = types.map(defType => { // Check if the Pokemon is not immune to Poison/Toxic @@ -2061,7 +2062,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Check if the source Pokemon has an ability that cancels the Poison/Toxic immunity const cancelImmunity = new Utils.BooleanHolder(false); if (sourcePokemon) { - applyAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, sourcePokemon, cancelImmunity, effect, defType); + applyPreSetStatusAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, sourcePokemon, effect, cancelImmunity, quiet, defType); if (cancelImmunity.value) return false; }