From a95051cfe45a212cff4ee9fe68c4dd021dcec44b Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Mon, 6 May 2024 00:13:48 -0300 Subject: [PATCH 1/7] 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 f5fc8e3eb..7789dcd16 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 6f1ebc261..8f642048c 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 62b97e27a..e5769dfcc 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: From 7d30aab34bf231516ca65c6fc784a252bfaac05e Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Mon, 6 May 2024 00:28:00 -0300 Subject: [PATCH 2/7] Forgot a part of the code --- src/phases.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 8f642048c..257be4ea4 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2256,8 +2256,8 @@ export class MovePhase extends BattlePhase { 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(); - } + this.cancel(); + } } if (this.cancelled) { From 9eec3562e0ca55b35d94994716275536d6027879 Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Mon, 6 May 2024 10:41:37 -0300 Subject: [PATCH 3/7] Refined code on phases.ts Tested new funcs against DAMP, it's working. --- src/phases.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phases.ts b/src/phases.ts index 6e2518b59..b888fed73 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2254,7 +2254,7 @@ 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. + if (this.move.moveId === Moves.EXPLOSION || this.move.moveId === Moves.SELF_DESTRUCT || this.move.moveId === Moves.MISTY_EXPLOSION){ //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(); } From 6a3ea63254427f8d1762474eb77de9014cf5e402 Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Mon, 6 May 2024 10:53:55 -0300 Subject: [PATCH 4/7] Adding benjam1337 suggestion to refine code --- src/phases.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index b888fed73..1ca20ceb0 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2254,10 +2254,9 @@ export class MovePhase extends BattlePhase { if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) { moveQueue.shift(); - if (this.move.moveId === Moves.EXPLOSION || this.move.moveId === Moves.SELF_DESTRUCT || this.move.moveId === Moves.MISTY_EXPLOSION){ //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 { + if (!(this.move.moveId in [Moves.EXPLOSION,Moves.SELF_DESTRUCT,Moves.MISTY_EXPLOSION])){ this.cancel(); - } + } } if (this.cancelled) { From 52561abc881edd022d86d072f73bb36106faf770 Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Mon, 6 May 2024 11:08:00 -0300 Subject: [PATCH 5/7] Resolved bug on refinement, working properly now. There is a bug on fail, it display the message "BUT IT FAILED" even though DAMP message went through --- src/phases.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phases.ts b/src/phases.ts index 1ca20ceb0..cdf3ebc19 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2254,7 +2254,7 @@ export class MovePhase extends BattlePhase { if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) { moveQueue.shift(); - if (!(this.move.moveId in [Moves.EXPLOSION,Moves.SELF_DESTRUCT,Moves.MISTY_EXPLOSION])){ + if ((this.move.moveId in [Moves.SELF_DESTRUCT,Moves.EXPLOSION,Moves.MISTY_EXPLOSION])){ this.cancel(); } } From 59761dec917981b029e8368db5dcf54243d0f868 Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Tue, 7 May 2024 17:02:40 -0300 Subject: [PATCH 6/7] Added function on Explosion moves to force faint if missing explosion-like moves --- src/data/move.ts | 18 ++++-------------- src/phases.ts | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 6170a82c1..eb60fcfd5 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2557,14 +2557,7 @@ const crashDamageFunc = (user: Pokemon, move: Move) => { }; 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; - + user.damageAndUpdate(user.hp, HitResult.OTHER, false, true); // Forces the user to take damage = to it's hp return true; }; @@ -4295,8 +4288,7 @@ export function initMoves() { .makesContact(false) .condition(failIfDampCondition) .target(MoveTarget.ALL_NEAR_OTHERS) - .attr(MissEffectAttr, explosionDamageFunc) - .attr(NoEffectAttr, explosionDamageFunc), + .attr(MissEffectAttr, explosionDamageFunc), new AttackMove(Moves.EGG_BOMB, Type.NORMAL, MoveCategory.PHYSICAL, 100, 75, 10, -1, 0, 1) .makesContact(false) .ballBombMove(), @@ -4388,8 +4380,7 @@ export function initMoves() { .attr(SacrificialAttr) .makesContact(false) .target(MoveTarget.ALL_NEAR_OTHERS) - .attr(MissEffectAttr, explosionDamageFunc) - .attr(NoEffectAttr, explosionDamageFunc), + .attr(MissEffectAttr, 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) @@ -6158,8 +6149,7 @@ export function initMoves() { .target(MoveTarget.ALL_NEAR_OTHERS) .attr(MovePowerMultiplierAttr, (user, target, move) => user.scene.arena.getTerrainType() === TerrainType.MISTY && user.isGrounded() ? 1.5 : 1) .condition(failIfDampCondition) - .attr(MissEffectAttr, explosionDamageFunc) - .attr(NoEffectAttr, explosionDamageFunc), + .attr(MissEffectAttr, 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 c3c8b6ef2..99ff925dc 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2252,7 +2252,7 @@ export class MovePhase extends BattlePhase { if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) { moveQueue.shift(); - if ((this.move.moveId in [Moves.SELF_DESTRUCT,Moves.EXPLOSION,Moves.MISTY_EXPLOSION])){ + if (!(this.move.moveId in [Moves.SELF_DESTRUCT,Moves.EXPLOSION,Moves.MISTY_EXPLOSION])){ this.cancel(); } } From f9eb355778f4b55f70e97aaf628de19e1f9587ca Mon Sep 17 00:00:00 2001 From: Tiduzz Date: Tue, 7 May 2024 17:07:13 -0300 Subject: [PATCH 7/7] Making phases.ts as main pokerogue branch --- src/phases.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 2013de5f1..9ed1161f7 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2252,9 +2252,7 @@ export class MovePhase extends BattlePhase { if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) { moveQueue.shift(); - if (!(this.move.moveId in [Moves.SELF_DESTRUCT,Moves.EXPLOSION,Moves.MISTY_EXPLOSION])){ - this.cancel(); - } + this.cancel(); } if (this.cancelled) {