This commit is contained in:
33333-33333 2026-06-30 10:57:06 +09:00
commit f941200504
70 changed files with 1856 additions and 429 deletions

View file

@ -121,13 +121,16 @@
t.tempTimer += dt;
if (t.tempTimer >= 0.55) {
t.tempComfort = t.world.temperatureAt(t.x, t.y);
const felt = t.world?.temperatureAt?.(t.x, t.y) ?? (CONFIG.standardTemperature ?? 15);
t.tempComfort = felt;
t.feltTemperature = felt;
t.temperatureStatus = t.world?.temperatureStatusFor?.(felt) || null;
t.tempTimer = 0;
}
const tempComfort = t.tempComfort ?? 0.62;
const tooCold = Math.max(0, 0.48 - tempComfort);
const tempStatus = t.temperatureStatus || t.world?.temperatureStatusFor?.(t.tempComfort ?? (CONFIG.standardTemperature ?? 15)) || { discomfort: 0, stressExcess: 0, harmExcess: 0, direction: "comfort" };
const coldDiscomfort = tempStatus.direction === "cold" ? Math.max(0, tempStatus.discomfort || 0) : 0;
const hungerScale = t.metabolicHungerMultiplier ? t.metabolicHungerMultiplier() : (typeof tarinaiMetabolicHungerScale === "function" ? tarinaiMetabolicHungerScale(t) : 1);
t.hunger += CONFIG.hungerPerMinute * minute * t.trait.hunger * hungerScale * (1 + tooCold * 0.8);
t.hunger += CONFIG.hungerPerMinute * minute * t.trait.hunger * hungerScale * (1 + coldDiscomfort * 0.018);
t.loneliness += CONFIG.lonelinessPerMinute * minute * (2 - t.trait.social);
t.energy -= CONFIG.energyPerMinute * minute * t.trait.sleep * (t.state === "sleep" ? 0.025 : 1);
if (t.state === "sleep" || t.sleeping) {
@ -137,7 +140,21 @@
if (typeof applyNeedRelief === "function") applyNeedRelief(t, { sleep: -dt * (sleepBedLike ? 2.0 : 1.1) });
}
// stress is derived from needs; no independent stress decay.
if (tooCold > 0) applyNeedShock(t, { health: tooCold * dt * 4, safety: tooCold * dt * 2 });
if ((tempStatus.stressExcess || 0) > 0) {
const excess = tempStatus.stressExcess || 0;
const stressRate = excess * (0.66 + Math.min(20, excess) * 0.035);
applyNeedShock(t, { safety: stressRate * dt, health: stressRate * dt * 0.42 });
if ((t.world?.time || 0) >= (t.nextBubbleAt || 0) && detChance(t.world, "temperature-stress-bubble", dt * 0.18, t)) {
t.bubble(tempStatus.direction === "cold" ? "ぶるぶる" : "あちゅい", 2.4, "rgba(76,62,72,0.78)");
}
}
if ((tempStatus.harmExcess || 0) > 0) {
const harm = tempStatus.harmExcess || 0;
t.energy -= dt * (0.10 + harm * 0.075 + harm * harm * 0.006);
t.hurtTimer = Math.max(t.hurtTimer || 0, Math.min(1.2, 0.28 + harm * 0.035));
t.lastDamageCause = tempStatus.direction === "cold" ? "凍結" : "熱中症";
t.lastTemperatureDamageAt = t.world?.time || 0;
}
const phase = t.world.lightLevel();
if (phase < 0.25) t.energy += dt * 0.07;