Fix boss immunity and ally fainting

This commit is contained in:
Jakub Hanko 2024-05-19 20:34:43 +02:00
parent 8343426110
commit 678c0de2ec
No known key found for this signature in database
GPG Key ID: 775D427937A306CC
2 changed files with 19 additions and 12 deletions

View File

@ -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;
}
}

View File

@ -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;