From b8c8f3f64859ea69c4d33e26f0c73a6d4c470fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bastos=20Dias?= Date: Wed, 12 Feb 2025 20:38:33 +0000 Subject: [PATCH] Fix White Herb interaction with Grim Neigh --- data/items.ts | 54 ++++++++++++++++++++++++------------- test/sim/items/whiteherb.js | 2 +- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/data/items.ts b/data/items.ts index 78e6d7a9e2901..e2b9318d00129 100644 --- a/data/items.ts +++ b/data/items.ts @@ -3816,16 +3816,16 @@ export const Items: import('../sim/dex-items').ItemDataTable = { }, onAnySwitchInPriority: -3, onAnySwitchIn() { - if (!this.effectState.ready || !this.effectState.boosts) return; + if (!this.effectState.ready) return; (this.effectState.target as Pokemon).useItem(); }, onAnyAfterMove() { - if (!this.effectState.ready || !this.effectState.boosts) return; + if (!this.effectState.ready) return; (this.effectState.target as Pokemon).useItem(); }, onResidualOrder: 29, onResidual(pokemon) { - if (!this.effectState.ready || !this.effectState.boosts) return; + if (!this.effectState.ready) return; (this.effectState.target as Pokemon).useItem(); }, onUse(pokemon) { @@ -7191,27 +7191,43 @@ export const Items: import('../sim/dex-items').ItemDataTable = { } }, }, - onAnySwitchInPriority: -2, - onAnySwitchIn() { - ((this.effect as any).onUpdate as (p: Pokemon) => void).call(this, this.effectState.target); - }, - onStart(pokemon) { - ((this.effect as any).onUpdate as (p: Pokemon) => void).call(this, pokemon); - }, - onUpdate(pokemon) { - let activate = false; - const boosts: SparseBoostsTable = {}; + onAfterBoost(boost, pokemon) { + delete this.effectState.ready; + this.effectState.boosts = {} as SparseBoostsTable; let i: BoostID; for (i in pokemon.boosts) { if (pokemon.boosts[i] < 0) { - activate = true; - boosts[i] = 0; + this.effectState.ready = true; + this.effectState.boosts[i] = 0; } } - if (activate && pokemon.useItem()) { - pokemon.setBoost(boosts); - this.add('-clearnegativeboost', pokemon, '[silent]'); - } + }, + onStart(pokemon) { + ((this.effect as any).onAfterBoost as (b: SparseBoostsTable, p: Pokemon) => void).call(this, pokemon.boosts, pokemon); + if (!this.effectState.ready) return; + (this.effectState.target as Pokemon).useItem(); + }, + onAnySwitchInPriority: -2, + onAnySwitchIn() { + if (!this.effectState.ready) return; + (this.effectState.target as Pokemon).useItem(); + }, + onAnyAfterMove() { + if (!this.effectState.ready) return; + (this.effectState.target as Pokemon).useItem(); + }, + onResidualOrder: 29, + onResidual(pokemon) { + if (!this.effectState.ready) return; + (this.effectState.target as Pokemon).useItem(); + }, + onUse(pokemon) { + pokemon.setBoost(this.effectState.boosts); + this.add('-clearnegativeboost', pokemon, '[silent]'); + }, + onEnd() { + delete this.effectState.boosts; + delete this.effectState.ready; }, num: 214, gen: 3, diff --git a/test/sim/items/whiteherb.js b/test/sim/items/whiteherb.js index 73229dbe4935a..6f8599e2def2a 100644 --- a/test/sim/items/whiteherb.js +++ b/test/sim/items/whiteherb.js @@ -24,7 +24,7 @@ describe("White Herb", function () { assert.statStage(wynaut, 'spa', 0); }); - it.skip('should activate after Abilities that boost stats on KOs', function () { + it('should activate after Abilities that boost stats on KOs', function () { battle = common.createBattle([[ {species: 'litten', level: 1, ability: 'noguard', moves: ['sleeptalk']}, {species: 'torracat', moves: ['partingshot']},