hmm
This commit is contained in:
parent
e8f1d1db1e
commit
54aff02658
27 changed files with 1700 additions and 1034 deletions
|
|
@ -58,18 +58,30 @@
|
|||
const profile = this.personalityProfile ? this.personalityProfile() : { fear: 1 };
|
||||
const fearMul = opts.fearMultiplier ?? profile.fear ?? 1;
|
||||
const threat = opts.threat ?? opts.target ?? null;
|
||||
let target = null;
|
||||
if ("target" in opts) target = opts.target;
|
||||
else if (opts.destination) target = opts.destination;
|
||||
else if (this.panicDestination) target = this.panicDestination(threat, !!opts.forceDestination);
|
||||
this.setActionState("panic", {
|
||||
target,
|
||||
reason: opts.reason || this.thought || "パニックになっている",
|
||||
wake: opts.wake !== false,
|
||||
sleeping: false,
|
||||
});
|
||||
if (Number.isFinite(opts.fearTimer)) this.fearTimer = Math.max(this.fearTimer || 0, opts.fearTimer * fearMul);
|
||||
else this.fearTimer = Math.max(this.fearTimer || 0, (opts.fear ?? 0.55) * fearMul);
|
||||
const safetyShock = Math.max(40, (opts.fearTimer ?? opts.fear ?? 0.55) * 32 * fearMul, Number(opts.stress || 0) * 1.8);
|
||||
const healthShock = Math.max(0, Number(opts.hurtTimer || 0) > 0 ? 45 : 0);
|
||||
if (typeof applyNeedShock === "function") {
|
||||
applyNeedShock(this, { safety: safetyShock, health: healthShock }, threat);
|
||||
} else {
|
||||
this.needShock = this.needShock || {};
|
||||
this.needShock.safety = Math.max(this.needShock.safety || 0, safetyShock);
|
||||
if (healthShock > 0) this.needShock.health = Math.max(this.needShock.health || 0, healthShock);
|
||||
}
|
||||
let handled = false;
|
||||
if (typeof triggerNeedShockReaction === "function") handled = triggerNeedShockReaction(this, threat, opts.reason || "パニックになっている");
|
||||
if (!handled) {
|
||||
let target = null;
|
||||
if ("target" in opts) target = opts.target;
|
||||
else if (opts.destination) target = opts.destination;
|
||||
else if (this.panicDestination) target = this.panicDestination(threat, !!opts.forceDestination);
|
||||
this.setActionState("panic", {
|
||||
target,
|
||||
reason: opts.reason || this.thought || "パニックになっている",
|
||||
wake: opts.wake !== false,
|
||||
sleeping: false,
|
||||
});
|
||||
this.fearTimer = Math.max(this.fearTimer || 0, 2.4);
|
||||
}
|
||||
if (Number.isFinite(opts.surpriseTimer)) this.surpriseTimer = Math.max(this.surpriseTimer || 0, opts.surpriseTimer);
|
||||
if (Number.isFinite(opts.hurtTimer)) this.hurtTimer = Math.max(this.hurtTimer || 0, opts.hurtTimer);
|
||||
if (Number.isFinite(opts.awakeLockTimer)) this.awakeLockTimer = Math.max(this.awakeLockTimer || 0, opts.awakeLockTimer);
|
||||
|
|
@ -77,10 +89,6 @@
|
|||
this.fallTimer = Math.max(this.fallTimer || 0, opts.fallTimer);
|
||||
this.fallMax = Math.max(this.fallMax || 0, this.fallTimer);
|
||||
}
|
||||
if (Number.isFinite(opts.stress) && opts.stress > 0) {
|
||||
if (this.addStress) this.addStress(opts.stress, { threshold: opts.stressThreshold ?? 8, duration: opts.stressDuration ?? 4.2 });
|
||||
else this.stress = clamp((this.stress || 0) + opts.stress, 0, 130);
|
||||
}
|
||||
if (opts.bubble) this.bubble?.(opts.bubble, opts.bubbleCooldown ?? 0.9, opts.bubbleColor || "rgba(84,66,86,0.80)");
|
||||
this.lastPanicCause = opts.cause || opts.reason || this.thought || "panic";
|
||||
this.lastPanicAt = this.world?.time || 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue