0.2.5-dev: merge PR #524 by xcdoge — 敌方血条偏高:头顶高度按"原点以上的高度"ç
This commit is contained in:
commit
c438323596
3 files changed
+119
-11
No files matched your search
@@ -228,6 +228,38 @@ export const ALIAS_TINT = Object.freeze({ enemy_1305_mhslim: 0xffc48a, enemy_130
|
||||
* between `pulse` and 1 at `pulseHz` (real time).
|
||||
*/
|
||||
export const EL_BAR = Object.freeze({ icon: 0.15, min: 8, max: 15, enemy: 0.8, gap: 1, pulse: 0.45, pulseHz: 1.5 });
|
||||
|
||||
/** The share of a model's height a bar is placed above (the head is not the very top of the silhouette). */
|
||||
export const HEAD_TOP_K = 0.92;
|
||||
/** Enemies whose model is taller than this many tiles keep their bar at the cap — a bar must stay on screen. */
|
||||
export const HEAD_TILES_CAP = 2.2;
|
||||
export const HEAD_TILES_CAP_BOSS = 3.2;
|
||||
|
||||
/**
|
||||
* Tiles above the feet where a unit's HP bar / name tag sits.
|
||||
*
|
||||
* Operators and tokens are uniform chibis (UNIT.headroom). Enemies vary: with a known model they use **how far the model
|
||||
* reaches above its own origin** (spine.js `top` = `bounds.y + bounds.height`, not the box's raw height — a body whose
|
||||
* origin sits mid-model, 逐腐兽, would otherwise push its bar ~a tile too high), scaled by the official model factor and
|
||||
* the vertical-stretch quirk; without bounds they fall back to the chibi headroom × that factor.
|
||||
* @param {{ isEnemy:boolean, isBoss:boolean, spineShown:boolean, bounds?:{y?:number,height?:number}|null, modelK:number, modelKY:number }} o
|
||||
* @returns {number} tiles
|
||||
*/
|
||||
export function headTilesForUnit(o) {
|
||||
const k = (Number.isFinite(o.modelK) ? o.modelK : 1) * (Number.isFinite(o.modelKY) ? o.modelKY : 1);
|
||||
if (!o.isEnemy) return UNIT.headroom;
|
||||
const cap = o.isBoss ? HEAD_TILES_CAP_BOSS : HEAD_TILES_CAP;
|
||||
const b = o.spineShown ? o.bounds : null;
|
||||
if (b && Number.isFinite(b.height) && b.height > 20) {
|
||||
// how far the box reaches *above the origin*: 猎狗pro −3.7, 大鲍勃 −2.6 (feet-anchored, ≈ height), 逐腐兽 −404.7 of
|
||||
// 722.6 and 锏 −798 of 1183 (origin mid-body). Using the raw height there put the bar about a tile too high.
|
||||
const top = Number.isFinite(b.y) ? b.y + b.height : b.height;
|
||||
return clamp(Math.min(Math.max(top, 20), 900) * UNIT.modelScale * k * HEAD_TOP_K, 0.55, cap);
|
||||
}
|
||||
if (o.isBoss) return HEAD_TILES_CAP;
|
||||
if (o.spineShown) return clamp(UNIT.headroom * k, 0.55, HEAD_TILES_CAP);
|
||||
return UNIT.headroom;
|
||||
}
|
||||
/**
|
||||
* The HP-bar readouts under the bars (b.snap `ammo`, `wolves`, `neg`; render/interp.js header):
|
||||
* - AMMO_BAR — the ammo skill's segmented bar replaces the SP bar: a cell per round, `height` of the HP bar's thickness
|
||||
@@ -1297,13 +1329,14 @@ export class UnitView {
|
||||
this.aura.scale.set((s * 1.3) / 128, (s * 1.9) / 128);
|
||||
}
|
||||
|
||||
// head height: operators/tokens are uniform chibis; enemies vary (setup-pose bounds, when known; else the chibi
|
||||
// headroom × their official model factor)
|
||||
let headTiles = UNIT.headroom;
|
||||
if (this.isEnemy && spineShown && this.actor.entry.bounds) headTiles = clamp(this.actor.height * UNIT.modelScale * this.modelK * this.modelKY * 0.92, 0.55, this.isBoss ? 3.2 : 2.2);
|
||||
else if (this.isEnemy && this.isBoss) headTiles = 2.2;
|
||||
else if (this.isEnemy && spineShown) headTiles = clamp(UNIT.headroom * this.modelK * this.modelKY, 0.55, 2.2);
|
||||
this._headTiles = headTiles;
|
||||
// keep the original short-circuit: many views never build an actor (prep chips, diamonds, tests), so the model
|
||||
// only counts when a spine is actually shown
|
||||
const actor = spineShown ? this.actor : null;
|
||||
const headTiles = this._headTiles = headTilesForUnit({
|
||||
isEnemy: this.isEnemy, isBoss: this.isBoss, spineShown,
|
||||
bounds: actor && actor.entry ? actor.entry.bounds : null,
|
||||
modelK: this.modelK, modelKY: this.modelKY,
|
||||
});
|
||||
this.screen.top = by - headTiles * s;
|
||||
this._updateHud(dt, s, bx, by - headTiles * s, alpha, t);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user