From 1e8798b708d615a5e4c77b57fdcbdc031b4b2164 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 4 Jul 2023 16:47:23 -0400 Subject: [PATCH] Make type immunity abilities block status moves --- src/pokemon.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/pokemon.ts b/src/pokemon.ts index da6192387..6dfccc202 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -598,18 +598,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const move = battlerMove.getMove(); const moveCategory = move.category; let damage = 0; + + const cancelled = new Utils.BooleanHolder(false); + const typeless = !!move.getAttrs(TypelessAttr).length + const typeMultiplier = new Utils.NumberHolder(!typeless && moveCategory !== MoveCategory.STATUS + ? getTypeDamageMultiplier(move.type, this.getSpeciesForm().type1) * (this.getSpeciesForm().type2 !== null ? getTypeDamageMultiplier(move.type, this.getSpeciesForm().type2) : 1) + : 1); + if (typeless) + typeMultiplier.value = 1; + switch (moveCategory) { case MoveCategory.PHYSICAL: case MoveCategory.SPECIAL: const isPhysical = moveCategory === MoveCategory.PHYSICAL; - const typeless = !!move.getAttrs(TypelessAttr).length - const cancelled = new Utils.BooleanHolder(false); const power = new Utils.NumberHolder(move.power); - const typeMultiplier = new Utils.NumberHolder(!typeless - ? getTypeDamageMultiplier(move.type, this.getSpeciesForm().type1) * (this.getSpeciesForm().type2 !== null ? getTypeDamageMultiplier(move.type, this.getSpeciesForm().type2) : 1) - : 1); - if (typeless) - typeMultiplier.value = 1; applyPreAttackAbAttrs(VariableMovePowerAbAttr, source, this, battlerMove, power); if (!typeless) @@ -700,7 +702,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } break; case MoveCategory.STATUS: - result = HitResult.STATUS; + if (!typeless) + applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, battlerMove, cancelled, typeMultiplier); + result = cancelled.value || !typeMultiplier.value ? HitResult.NO_EFFECT : HitResult.STATUS; break; }