Improve handling of boss bar thresholds

pull/14/head
Flashfyre 2024-01-10 10:38:00 -05:00
parent 7d0393be35
commit 0f5c735609
1 changed files with 8 additions and 6 deletions

View File

@ -2223,10 +2223,12 @@ export class EnemyPokemon extends Pokemon {
if (!ignoreSegments && this.isBoss()) { if (!ignoreSegments && this.isBoss()) {
const segmentSize = this.getMaxHp() / this.bossSegments; const segmentSize = this.getMaxHp() / this.bossSegments;
for (let s = this.bossSegments - 1; s > 0; s--) { for (let s = this.bossSegments - 1; s > 0; s--) {
const hpThreshold = Math.round(segmentSize * s); const hpThreshold = segmentSize * s;
if (this.hp > hpThreshold) { const roundedHpThreshold = Math.round(hpThreshold);
if (this.hp - damage < hpThreshold) { if (this.hp > roundedHpThreshold) {
damage = this.hp - hpThreshold; 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); this.handleBossSegmentCleared(s);
} }
break; break;
@ -2285,8 +2287,8 @@ export class EnemyPokemon extends Pokemon {
let segmentBypassCount = Math.floor(amountRatio / (1 / this.bossSegments)); let segmentBypassCount = Math.floor(amountRatio / (1 / this.bossSegments));
const segmentSize = this.getMaxHp() / this.bossSegments; const segmentSize = this.getMaxHp() / this.bossSegments;
for (let s = 1; s < this.bossSegments; s++) { for (let s = 1; s < this.bossSegments; s++) {
const hpThreshold = Math.round(segmentSize * s); const hpThreshold = segmentSize * s;
if (this.hp <= hpThreshold) { if (this.hp <= Math.round(hpThreshold)) {
const healAmount = Math.min(amount, this.getMaxHp() - this.hp, Math.round(hpThreshold + (segmentSize * segmentBypassCount) - this.hp)); const healAmount = Math.min(amount, this.getMaxHp() - this.hp, Math.round(hpThreshold + (segmentSize * segmentBypassCount) - this.hp));
this.hp += healAmount; this.hp += healAmount;
return healAmount; return healAmount;