1.5
This commit is contained in:
parent
c9dd7182aa
commit
acf93ec6df
22 changed files with 320 additions and 261 deletions
15
js/health.js
15
js/health.js
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
const HEALTH = (() => {
|
||||
const MAJOR_DAMAGE_WINDOW = 24;
|
||||
const WEAKENED_MAJOR_DAMAGE_MIN_AGE = 3;
|
||||
const WEAKENED_MAJOR_DAMAGE_MAX_AGE = 20;
|
||||
const MAJOR_DAMAGE_REACTION_WINDOW = 1.0;
|
||||
const WEAKENED_TRACE_WINDOW = 45;
|
||||
const WEAKENED_SUFFIX = "\u3067\u8870\u5f31";
|
||||
|
|
@ -100,6 +102,12 @@ const HEALTH = (() => {
|
|||
return Boolean(t.lastMajorDamageCause && now - (t.lastMajorDamageAt || -999) <= MAJOR_DAMAGE_WINDOW);
|
||||
}
|
||||
|
||||
function hasLingeringMajorDamage(t) {
|
||||
const now = t.world?.time || 0;
|
||||
const age = now - (t.lastMajorDamageAt || -999);
|
||||
return Boolean(t.lastMajorDamageCause && age >= WEAKENED_MAJOR_DAMAGE_MIN_AGE && age < WEAKENED_MAJOR_DAMAGE_MAX_AGE);
|
||||
}
|
||||
|
||||
function isFightingContext(t, recent) {
|
||||
return Boolean(t.fightTimer > 0.04 || t.defeatedTimer > 0.04 || t.defeatedById || t.fightWinnerId || recent === CAUSES.fight);
|
||||
}
|
||||
|
|
@ -121,7 +129,7 @@ const HEALTH = (() => {
|
|||
|
||||
if (direct === CAUSES.fire || recent === CAUSES.fire || t.lastMajorDamageCause === CAUSES.fire) return CAUSES.fire;
|
||||
if (recentMajor && t.lastMajorDamageCause === CAUSES.collision && !(t.energy <= 20 || t.mood <= 16 || t.stress >= 124 || t.hunger >= 112)) return CAUSES.collision;
|
||||
if (recentMajor && (!direct || direct === t.lastMajorDamageCause || t.energy <= 18 || t.mood <= 16 || t.stress >= 124 || t.hunger >= 112)) {
|
||||
if (hasLingeringMajorDamage(t) && (!direct || direct === t.lastMajorDamageCause || t.energy <= 18 || t.mood <= 16 || t.stress >= 124 || t.hunger >= 112)) {
|
||||
return weakenedDeathReasonFor(t.lastMajorDamageCause);
|
||||
}
|
||||
const weakenedTrace = recentDamageCause(t, WEAKENED_TRACE_WINDOW);
|
||||
|
|
@ -144,7 +152,8 @@ const HEALTH = (() => {
|
|||
if (text.includes(CAUSES.lifespan) || text.includes("\u5bff\u547d")) return CAUSES.lifespan;
|
||||
if (direct) return direct;
|
||||
if (t.stress >= 118 || /\u30b9\u30c8\u30ec\u30b9|stress|\u6c17\u5206/.test(text)) return CAUSES.stress;
|
||||
if (opts.lowHealth || t.energy <= 0.5) return CAUSES.weakness;
|
||||
if ((opts.lowHealth || t.energy <= 0.5) && hasLingeringMajorDamage(t)) return weakenedDeathReasonFor(t.lastMajorDamageCause);
|
||||
if (opts.lowHealth || t.energy <= 0.5) return CAUSES.accident;
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +164,7 @@ const HEALTH = (() => {
|
|||
if (cause.includes(WEAKENED_SUFFIX)) return cause;
|
||||
if (opts.fromDamage) return cause;
|
||||
const canWeaken = cause && !cause.endsWith("\u75c5") && cause !== CAUSES.hunger && cause !== CAUSES.stress && cause !== CAUSES.lifespan && cause !== CAUSES.outOfBounds && cause !== CAUSES.collision && cause !== CAUSES.genkotsu && cause !== CAUSES.fire && cause !== CAUSES.weakness && cause !== CAUSES.freeze && cause !== CAUSES.heatstroke;
|
||||
if (canWeaken && (opts.weakened || (hasRecentMajorDamage(t) && cause === t.lastMajorDamageCause))) return weakenedDeathReasonFor(cause);
|
||||
if (canWeaken && (opts.weakened || (hasLingeringMajorDamage(t) && cause === t.lastMajorDamageCause))) return weakenedDeathReasonFor(cause);
|
||||
return cause;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue