From 2cc0ac90f88ac6cc1e79a439a4cdf4392d1a650a Mon Sep 17 00:00:00 2001 From: Dean <69436131+emdeann@users.noreply.github.com> Date: Tue, 25 Feb 2025 17:22:32 -0800 Subject: [PATCH] [Bug] Fix canApplyAbility check #5413 --- src/data/ability.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 5f19af8cea4..dcbaa4026f4 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -5152,6 +5152,10 @@ function applySingleAbAttrs( showAbilityInstant: boolean = false, messages: string[] = [] ) { + if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id))) { + return; + } + const ability = passive ? pokemon.getPassiveAbility() : pokemon.getAbility(); if (gainedMidTurn && ability.getAttrs(attrType).some(attr => attr instanceof PostSummonAbAttr && !attr.shouldActivateOnGain())) { return; @@ -5445,12 +5449,10 @@ function applyAbAttrsInternal( gainedMidTurn: boolean = false ) { for (const passive of [ false, true ]) { - if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id))) { - continue; + if (pokemon) { + applySingleAbAttrs(pokemon, passive, attrType, applyFunc, args, gainedMidTurn, simulated, showAbilityInstant, messages); + globalScene.clearPhaseQueueSplice(); } - - applySingleAbAttrs(pokemon, passive, attrType, applyFunc, args, gainedMidTurn, simulated, showAbilityInstant, messages); - globalScene.clearPhaseQueueSplice(); } }