From 09b51fcc7c91402cbe579e21d7955e40c9cf0cb9 Mon Sep 17 00:00:00 2001 From: AJ Fontaine Date: Thu, 25 Apr 2024 14:22:23 -0400 Subject: [PATCH] Add Aftermath and Magic Guard interactions --- src/data/ability.ts | 5 +++++ src/data/move.ts | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 545262a9564..299f97c6343 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2063,6 +2063,11 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr { applyPostFaint(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) { + const cancelled = new Utils.BooleanHolder(false); + pokemon.scene.getField(true).map(p=>applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled)) + if (cancelled) { + return false; + } attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); return true; } diff --git a/src/data/move.ts b/src/data/move.ts index 76cce603402..79e2e9cfa75 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -734,8 +734,11 @@ export class HalfSacrificialAttr extends MoveEffectAttr { if (!super.apply(user, target, move, args)) return false; - user.damageAndUpdate(Math.ceil(user.getMaxHp()/2), HitResult.OTHER, false, true, true); - + const cancelled = new Utils.BooleanHolder(false); + applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); + if (!cancelled){ + user.damageAndUpdate(Math.ceil(user.getMaxHp()/2), HitResult.OTHER, false, true, true); + } return true; }