Fix Baton Pass logic and enemy multi hit AI hitting ally

This commit is contained in:
Flashfyre 2024-04-03 12:14:26 -04:00
parent 5759a5e5ce
commit b99b781e0c
2 changed files with 11 additions and 11 deletions

View File

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

View File

@ -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) {