From 8a744891722bf66b844b1a645744ace70397bb47 Mon Sep 17 00:00:00 2001 From: Shiva Devarajan Date: Thu, 17 Oct 2024 09:59:42 -0700 Subject: [PATCH] Add Disabled Item field that is used to check knock off damage during Magic Room --- calc/src/mechanics/gen789.ts | 38 ++++++++++++++++++------------------ calc/src/mechanics/util.ts | 1 + calc/src/pokemon.ts | 1 + 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/calc/src/mechanics/gen789.ts b/calc/src/mechanics/gen789.ts index ad1ac5603..25e20fded 100644 --- a/calc/src/mechanics/gen789.ts +++ b/calc/src/mechanics/gen789.ts @@ -1003,30 +1003,30 @@ export function calculateBPModsSMSSSV( const bpMods = []; // Move effects - + let defenderItem = (defender.item && defender.item !== "") ? defender.item : defender.disabledItem; let resistedKnockOffDamage = - (!defender.item || isQPActive(defender, field)) || - (defender.named('Dialga-Origin') && defender.hasItem('Adamant Crystal')) || - (defender.named('Palkia-Origin') && defender.hasItem('Lustrous Globe')) || + (!defenderItem || isQPActive(defender, field)) || + (defender.named('Dialga-Origin') && defenderItem === 'Adamant Crystal') || + (defender.named('Palkia-Origin') && defenderItem === 'Lustrous Globe') || // Griseous Core for gen 9, Griseous Orb otherwise - (defender.name.includes('Giratina-Origin') && defender.item.includes('Griseous')) || - (defender.name.includes('Arceus') && defender.item.includes('Plate')) || - (defender.name.includes('Genesect') && defender.item.includes('Drive')) || - (defender.named('Groudon', 'Groudon-Primal') && defender.hasItem('Red Orb')) || - (defender.named('Kyogre', 'Kyogre-Primal') && defender.hasItem('Blue Orb')) || - (defender.name.includes('Silvally') && defender.item.includes('Memory')) || - defender.item.includes(' Z') || - (defender.named('Zacian') && defender.hasItem('Rusted Sword')) || - (defender.named('Zamazenta') && defender.hasItem('Rusted Shield')) || - (defender.name.includes('Ogerpon-Cornerstone') && defender.hasItem('Cornerstone Mask')) || - (defender.name.includes('Ogerpon-Hearthflame') && defender.hasItem('Hearthflame Mask')) || - (defender.name.includes('Ogerpon-Wellspring') && defender.hasItem('Wellspring Mask')) || - (defender.named('Venomicon-Epilogue') && defender.hasItem('Vile Vial')); + (defender.name.includes('Giratina-Origin') && defenderItem.includes('Griseous')) || + (defender.name.includes('Arceus') && defenderItem.includes('Plate')) || + (defender.name.includes('Genesect') && defenderItem.includes('Drive')) || + (defender.named('Groudon', 'Groudon-Primal') && defenderItem === 'Red Orb') || + (defender.named('Kyogre', 'Kyogre-Primal') && defenderItem === 'Blue Orb') || + (defender.name.includes('Silvally') && defenderItem.includes('Memory')) || + defenderItem.includes(' Z') || + (defender.named('Zacian') && defenderItem === 'Rusted Sword') || + (defender.named('Zamazenta') && defenderItem === 'Rusted Shield') || + (defender.name.includes('Ogerpon-Cornerstone') && defenderItem === 'Cornerstone Mask') || + (defender.name.includes('Ogerpon-Hearthflame') && defenderItem === 'Hearthflame Mask') || + (defender.name.includes('Ogerpon-Wellspring') && defenderItem === 'Wellspring Mask') || + (defender.named('Venomicon-Epilogue') && defenderItem === 'Vile Vial'); // The last case only applies when the Pokemon has the Mega Stone that matches its species // (or when it's already a Mega-Evolution) - if (!resistedKnockOffDamage && defender.item) { - const item = gen.items.get(toID(defender.item))!; + if (!resistedKnockOffDamage && defenderItem) { + const item = gen.items.get(toID(defenderItem))!; resistedKnockOffDamage = !!item.megaEvolves && defender.name.includes(item.megaEvolves); } diff --git a/calc/src/mechanics/util.ts b/calc/src/mechanics/util.ts index 1f29a2b9d..d8fe1bc78 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -200,6 +200,7 @@ export function checkItem(pokemon: Pokemon, magicRoomActive?: boolean) { pokemon.hasAbility('Klutz') && !EV_ITEMS.includes(pokemon.item!) || magicRoomActive ) { + pokemon.disabledItem = pokemon.item; pokemon.item = '' as ItemName; } } diff --git a/calc/src/pokemon.ts b/calc/src/pokemon.ts index f34610701..721f4dcbe 100644 --- a/calc/src/pokemon.ts +++ b/calc/src/pokemon.ts @@ -25,6 +25,7 @@ export class Pokemon implements State.Pokemon { alliesFainted?: number; boostedStat?: I.StatIDExceptHP | 'auto'; item?: I.ItemName; + disabledItem?: I.ItemName; teraType?: I.TypeName; nature: I.NatureName;