From 678c0de2ecf889d034e5239b8217c1e54062b47f Mon Sep 17 00:00:00 2001 From: Jakub Hanko <60473007+JakubHanko@users.noreply.github.com> Date: Sun, 19 May 2024 20:34:43 +0200 Subject: [PATCH] Fix boss immunity and ally fainting --- src/data/battler-tags.ts | 24 ++++++++++++++++++------ src/data/move.ts | 7 +------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 87b63386ea9..ae8fba10f6f 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -266,8 +266,8 @@ export class DestinyBondTag extends BattlerTag { /** * Destiny bond tag. * Lapses either before the user's move and does nothing - * or after receiving damage. If the damage received from foe - * is fatal, it takes down the foe as well. + * or after receiving fatal damage. When the damage is fatal, + * the attacking Pokemon is taken down as well, unless it's a boss. * * @param {Pokemon} pokemon Pokemon that is attacking the Destiny Bond user. * @param {BattlerTagLapseType} lapseType CUSTOM or PRE_MOVE @@ -278,11 +278,23 @@ export class DestinyBondTag extends BattlerTag { return super.lapse(pokemon, lapseType); } const source = pokemon.scene.getPokemonById(this.sourceId); - if (source.isFainted()) { - const targetMessage = getPokemonMessage(pokemon, ''); - pokemon.scene.queueMessage(`${getPokemonMessage(source, ` took\n${targetMessage} down with it!`)}`) - pokemon.damageAndUpdate(pokemon.hp, HitResult.ONE_HIT_KO, false, false, true); + if (!source.isFainted()) { + return true; } + + if (source.getAlly() === pokemon) { + return false; + } + + const targetMessage = getPokemonMessage(pokemon, ''); + + if (pokemon.isBossImmune()) { + pokemon.scene.queueMessage(`${targetMessage} is unaffected\nby the effects of Destiny Bond.`); + return false; + } + + pokemon.scene.queueMessage(`${getPokemonMessage(source, ` took\n${targetMessage} down with it!`)}`) + pokemon.damageAndUpdate(pokemon.hp, HitResult.ONE_HIT_KO, false, false, true); return false; } } diff --git a/src/data/move.ts b/src/data/move.ts index dbc640a5ce0..d3e677a9bd7 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4261,14 +4261,9 @@ export class DestinyBondAttr extends MoveEffectAttr { * @param {Pokemon} target N/A * @param {Move} move {@linkcode Move.DESTINY_BOND} * @param {any[]} args N/A - * @returns false in boss battle, true otherwise + * @returns true */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if (user.scene.getField().some(p => p.isBossImmune())) { - user.scene.queueMessage('But it failed!'); - return false; - } - user.scene.queueMessage(`${getPokemonMessage(user, ' is trying\nto take its foe down with it!')}`); user.addTag(BattlerTagType.DESTINY_BOND, undefined, move.id, user.id); return true;