diff --git a/data/mods/gen4/abilities.ts b/data/mods/gen4/abilities.ts index 66a54ed3b7..d5cd0caaeb 100644 --- a/data/mods/gen4/abilities.ts +++ b/data/mods/gen4/abilities.ts @@ -190,7 +190,7 @@ export const Abilities: import('../../../sim/dex-abilities').ModdedAbilityDataTa inherit: true, onStart(pokemon) { const target = pokemon.side.randomFoe(); - if (target?.item && !target.itemState.knockedOff) { + if (target?.item && !target.itemKnockedOff) { this.add('-item', '', target.getItem().name, '[from] ability: Frisk', `[of] ${pokemon}`); } }, @@ -542,7 +542,7 @@ export const Abilities: import('../../../sim/dex-abilities').ModdedAbilityDataTa inherit: true, condition: { onModifySpe(spe, pokemon) { - if ((!pokemon.item || pokemon.itemState.knockedOff) && !pokemon.ignoringAbility()) { + if ((!pokemon.item || pokemon.itemKnockedOff) && !pokemon.ignoringAbility()) { return this.chainModify(2); } }, diff --git a/data/mods/gen4/moves.ts b/data/mods/gen4/moves.ts index a286355200..586ef6c1d8 100644 --- a/data/mods/gen4/moves.ts +++ b/data/mods/gen4/moves.ts @@ -905,11 +905,11 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = { knockoff: { inherit: true, onAfterHit(target, source, move) { - if (!target.item || target.itemState.knockedOff) return; + if (!target.item || target.itemKnockedOff) return; if (target.ability === 'multitype') return; const item = target.getItem(); if (this.runEvent('TakeItem', target, source, move, item)) { - target.itemState.knockedOff = true; + target.itemKnockedOff = true; this.add('-enditem', target, item.name, '[from] move: Knock Off', `[of] ${source}`); this.hint("In Gens 3-4, Knock Off only makes the target's item unusable; it cannot obtain a new item.", true); } diff --git a/data/mods/sharingiscaring/scripts.ts b/data/mods/sharingiscaring/scripts.ts index 2ee6c6ca8c..94fb823ecb 100644 --- a/data/mods/sharingiscaring/scripts.ts +++ b/data/mods/sharingiscaring/scripts.ts @@ -115,7 +115,7 @@ export const Scripts: ModdedBattleScriptsData = { }, setItem(item, source, effect) { if (!this.hp || !this.isActive) return false; - if (this.itemState.knockedOff) return false; + if (this.itemKnockedOff) return false; if (typeof item === 'string') item = this.battle.dex.items.get(item); const effectid = this.battle.effect ? this.battle.effect.id : ''; diff --git a/data/moves.ts b/data/moves.ts index 8f26c3e7ee..402f2f5eab 100644 --- a/data/moves.ts +++ b/data/moves.ts @@ -15364,6 +15364,7 @@ export const Moves: import('../sim/dex-moves').MoveDataTable = { if (pokemon.item || !pokemon.lastItem) return false; const item = pokemon.lastItem; pokemon.lastItem = ''; + pokemon.itemKnockedOff = false; // Gens 3-4 only this.add('-item', pokemon, this.dex.items.get(item), '[from] move: Recycle'); pokemon.setItem(item, source, move); }, diff --git a/sim/pokemon.ts b/sim/pokemon.ts index 0242257151..6156a5bb2f 100644 --- a/sim/pokemon.ts +++ b/sim/pokemon.ts @@ -123,6 +123,8 @@ export class Pokemon { lastItem: ID; usedItemThisTurn: boolean; ateBerry: boolean; + // Gens 3-4 only + itemKnockedOff: boolean; trapped: boolean | "hidden"; maybeTrapped: boolean; @@ -419,6 +421,7 @@ export class Pokemon { this.lastItem = ''; this.usedItemThisTurn = false; this.ateBerry = false; + this.itemKnockedOff = false; this.trapped = false; this.maybeTrapped = false; @@ -865,7 +868,7 @@ export class Pokemon { ignoringItem(isFling = false) { if (this.getItem().isPrimalOrb) return false; - if (this.itemState.knockedOff) return true; // Gen 3-4 + if (this.itemKnockedOff) return true; // Gen 3-4 if (this.battle.gen >= 5 && !this.isActive) return true; if (this.volatiles['embargo'] || this.battle.field.pseudoWeather['magicroom']) return true; // check Fling first to avoid infinite recursion @@ -1736,7 +1739,7 @@ export class Pokemon { } eatItem(force?: boolean, source?: Pokemon, sourceEffect?: Effect) { - if (!this.item || this.itemState.knockedOff) return false; + if (!this.item || this.itemKnockedOff) return false; if ((!this.hp && this.item !== 'jabocaberry' && this.item !== 'rowapberry') || !this.isActive) return false; if (!sourceEffect && this.battle.effect) sourceEffect = this.battle.effect; @@ -1780,7 +1783,7 @@ export class Pokemon { useItem(source?: Pokemon, sourceEffect?: Effect) { if ((!this.hp && !this.getItem().isGem) || !this.isActive) return false; - if (!this.item || this.itemState.knockedOff) return false; + if (!this.item || this.itemKnockedOff) return false; if (!sourceEffect && this.battle.effect) sourceEffect = this.battle.effect; if (!source && this.battle.event?.target) source = this.battle.event.target; @@ -1819,7 +1822,7 @@ export class Pokemon { } takeItem(source?: Pokemon) { - if (!this.item || this.itemState.knockedOff) return false; + if (!this.item || this.itemKnockedOff) return false; if (!source) source = this; if (this.battle.gen === 4) { if (toID(this.ability) === 'multitype') return false; @@ -1840,8 +1843,7 @@ export class Pokemon { setItem(item: string | Item, source?: Pokemon, effect?: Effect) { if (!this.hp || !this.isActive) return false; - if (this.itemState.knockedOff && !(effect?.id === 'recycle')) return false; - delete this.itemState.knockedOff; + if (this.itemKnockedOff) return false; if (typeof item === 'string') item = this.battle.dex.items.get(item); const effectid = this.battle.effect ? this.battle.effect.id : '';