From 0f5c735609d909ea4d52e20f57e85b6dea31b0ec Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 10 Jan 2024 10:38:00 -0500 Subject: [PATCH] Improve handling of boss bar thresholds --- src/pokemon.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pokemon.ts b/src/pokemon.ts index 14a64cb5d..074cf5fd5 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -2223,10 +2223,12 @@ export class EnemyPokemon extends Pokemon { if (!ignoreSegments && this.isBoss()) { const segmentSize = this.getMaxHp() / this.bossSegments; for (let s = this.bossSegments - 1; s > 0; s--) { - const hpThreshold = Math.round(segmentSize * s); - if (this.hp > hpThreshold) { - if (this.hp - damage < hpThreshold) { - damage = this.hp - hpThreshold; + const hpThreshold = segmentSize * s; + const roundedHpThreshold = Math.round(hpThreshold); + if (this.hp > roundedHpThreshold) { + if (this.hp - damage < roundedHpThreshold) { + const bypassSegment = (this.hp - roundedHpThreshold) / damage < 0.1; + damage = this.hp - (bypassSegment ? Math.round(hpThreshold - segmentSize) : roundedHpThreshold); this.handleBossSegmentCleared(s); } break; @@ -2285,8 +2287,8 @@ export class EnemyPokemon extends Pokemon { let segmentBypassCount = Math.floor(amountRatio / (1 / this.bossSegments)); const segmentSize = this.getMaxHp() / this.bossSegments; for (let s = 1; s < this.bossSegments; s++) { - const hpThreshold = Math.round(segmentSize * s); - if (this.hp <= hpThreshold) { + const hpThreshold = segmentSize * s; + if (this.hp <= Math.round(hpThreshold)) { const healAmount = Math.min(amount, this.getMaxHp() - this.hp, Math.round(hpThreshold + (segmentSize * segmentBypassCount) - this.hp)); this.hp += healAmount; return healAmount;