From b99b781e0cf5999bbd1f104ec151821e12627ad7 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 3 Apr 2024 12:14:26 -0400 Subject: [PATCH] Fix Baton Pass logic and enemy multi hit AI hitting ally --- src/data/move.ts | 15 ++++++++++----- src/phases.ts | 7 +------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index adb4c750d..cc8925eb2 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -865,8 +865,8 @@ export class MultiHitAttr extends MoveAttr { return true; } - getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): number { - return 5; + getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number { + return -5; } } @@ -2290,9 +2290,14 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { } getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { - if (this.batonPass) - return -100; // Overridden in switch logic - return this.user ? Math.floor(user.getHpRatio() * 20) : super.getUserBenefitScore(user, target, move); + if (!user.scene.getEnemyParty().find(p => p.isActive() && !p.isOnField())) + return -20; + let ret = this.user ? Math.floor((1 - user.getHpRatio()) * 20) : super.getUserBenefitScore(user, target, move); + if (this.user && this.batonPass) { + const battleStatTotal = user.summonData.battleStats.reduce((bs: integer, total: integer) => total += bs, 0); + ret = ret / 2 + (Phaser.Tweens.Builders.GetEaseFunction('Sine.easeOut')(Math.min(Math.abs(battleStatTotal), 10) / 10) * (battleStatTotal >= 0 ? 10 : -10)); + } + return ret; } } diff --git a/src/phases.ts b/src/phases.ts index 2e93813ec..d8d96bb28 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1666,12 +1666,7 @@ export class EnemyCommandPhase extends FieldPhase { const trapTag = enemyPokemon.findTag(t => t instanceof TrappedTag) as TrappedTag; const trapped = new Utils.BooleanHolder(false); opponents.forEach(playerPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, playerPokemon, trapped)); - if (enemyPokemon.moveset.find(m => m.moveId === Moves.BATON_PASS && m.isUsable(enemyPokemon)) && (enemyPokemon.summonData.battleStats.reduce((total, stat) => total += stat, 0) >= 0 || trapTag || trapped.value)) { - this.scene.currentBattle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = - { command: Command.FIGHT, move: { move: Moves.BATON_PASS, targets: enemyPokemon.getNextTargets(Moves.BATON_PASS) } }; - - return this.end(); - } else if (!trapTag && !trapped.value) { + if (!trapTag && !trapped.value) { const partyMemberScores = trainer.getPartyMemberMatchupScores(enemyPokemon.trainerSlot, true); if (partyMemberScores.length) {