From a95051cfe45a212cff4ee9fe68c4dd021dcec44b Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Mon, 6 May 2024 00:13:48 -0300 Subject: [PATCH] Added a new function for explosion attacks "explosionDamageFunc" Added an exception for explosion moves on 2257 phases.ts, probably can be done in a better way. Removed debugger on settings.ts 154 --- src/data/move.ts | 24 +++++++++++++++++++++--- src/phases.ts | 3 +++ src/system/settings.ts | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index f5fc8e3ebcb..7789dcd16e3 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2506,6 +2506,18 @@ const crashDamageFunc = (user: Pokemon, move: Move) => { return true; }; +const explosionDamageFunc = (user: Pokemon, move: Move) => { + const cancelled = new Utils.BooleanHolder(false); + applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); + if (cancelled.value) + return false; + + user.damageAndUpdate(user.hp, HitResult.OTHER, false, true); + user.turnData.damageTaken += user.hp; + + return true; +}; + export class TypelessAttr extends MoveAttr { } export class DisableMoveAttr extends MoveEffectAttr { @@ -4229,7 +4241,9 @@ export function initMoves() { .attr(SacrificialAttr) .makesContact(false) .condition(failIfDampCondition) - .target(MoveTarget.ALL_NEAR_OTHERS), + .target(MoveTarget.ALL_NEAR_OTHERS) + .attr(MissEffectAttr, explosionDamageFunc) + .attr(NoEffectAttr, explosionDamageFunc), new AttackMove(Moves.EGG_BOMB, Type.NORMAL, MoveCategory.PHYSICAL, 100, 75, 10, -1, 0, 1) .makesContact(false) .ballBombMove(), @@ -4320,7 +4334,9 @@ export function initMoves() { .condition(failIfDampCondition) .attr(SacrificialAttr) .makesContact(false) - .target(MoveTarget.ALL_NEAR_OTHERS), + .target(MoveTarget.ALL_NEAR_OTHERS) + .attr(MissEffectAttr, explosionDamageFunc) + .attr(NoEffectAttr, explosionDamageFunc), new AttackMove(Moves.FURY_SWIPES, Type.NORMAL, MoveCategory.PHYSICAL, 18, 80, 15, -1, 0, 1) .attr(MultiHitAttr), new AttackMove(Moves.BONEMERANG, Type.GROUND, MoveCategory.PHYSICAL, 50, 90, 10, -1, 0, 1) @@ -6090,7 +6106,9 @@ export function initMoves() { .attr(SacrificialAttr) .target(MoveTarget.ALL_NEAR_OTHERS) .attr(MovePowerMultiplierAttr, (user, target, move) => user.scene.arena.getTerrainType() === TerrainType.MISTY && user.isGrounded() ? 1.5 : 1) - .condition(failIfDampCondition), + .condition(failIfDampCondition) + .attr(MissEffectAttr, explosionDamageFunc) + .attr(NoEffectAttr, explosionDamageFunc), new AttackMove(Moves.GRASSY_GLIDE, Type.GRASS, MoveCategory.PHYSICAL, 55, 100, 20, -1, 0, 8) .partial(), new AttackMove(Moves.RISING_VOLTAGE, Type.ELECTRIC, MoveCategory.SPECIAL, 70, 100, 20, -1, 0, 8) diff --git a/src/phases.ts b/src/phases.ts index 6f1ebc261da..8f642048c80 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2254,8 +2254,11 @@ export class MovePhase extends BattlePhase { if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) { moveQueue.shift(); + if (this.move.moveId === 153 || this.move.moveId === 120 || this.move.moveId === 802){ //Currently all explosions, AKA, kamikaze-attacks. There might be a better way to do it except to hardcode it, but i haven't found how yet. + } else { this.cancel(); } + } if (this.cancelled) { this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL }); diff --git a/src/system/settings.ts b/src/system/settings.ts index 62b97e27a58..e5769dfcce9 100644 --- a/src/system/settings.ts +++ b/src/system/settings.ts @@ -151,7 +151,7 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer) case Setting.Gamepad_Support: scene.gamepadSupport = settingOptions[setting][value] !== 'Disabled'; break; - case Setting.Swap_A_and_B:debugger; + case Setting.Swap_A_and_B: scene.setGamepadConfirm(settingOptions[setting][value] !== 'Enabled'); break; case Setting.Touch_Controls: