fixed issues
This commit is contained in:
parent
46258a83eb
commit
aea08dc3fb
25 changed files with 1625 additions and 513 deletions
|
|
@ -96,6 +96,7 @@ class Tarinai {
|
|||
this.zunchiDiseaseSeverity = opts.zunchiDiseaseSeverity ?? (this.zunchiDisease ? 1 : 0);
|
||||
this.zunchiDiseaseCooldown = opts.zunchiDiseaseCooldown ?? 0;
|
||||
this.totalFightLosses = opts.totalFightLosses || 0;
|
||||
this.totalFightWins = opts.totalFightWins || 0;
|
||||
this.isZunchiSlave = Boolean(opts.isZunchiSlave);
|
||||
this.formerName = opts.formerName || null;
|
||||
this.loveMochiTimer = opts.loveMochiTimer ?? 0;
|
||||
|
|
@ -165,7 +166,7 @@ class Tarinai {
|
|||
birthRitualTimer: this.birthRitualTimer, birthRitualMax: this.birthRitualMax, birthPartnerId: this.birthPartnerId,
|
||||
birthRitualRole: this.birthRitualRole, birthRitualLeader: this.birthRitualLeader,
|
||||
pokeFlashTimer: this.pokeFlashTimer, zunchiStain: this.zunchiStain, zunchiStainSeed: this.zunchiStainSeed,
|
||||
totalFightLosses: this.totalFightLosses, isZunchiSlave: this.isZunchiSlave, formerName: this.formerName, loveMochiTimer: this.loveMochiTimer, fightMochiTimer: this.fightMochiTimer,
|
||||
totalFightLosses: this.totalFightLosses, totalFightWins: this.totalFightWins, isZunchiSlave: this.isZunchiSlave, formerName: this.formerName, loveMochiTimer: this.loveMochiTimer, fightMochiTimer: this.fightMochiTimer,
|
||||
sleepDisease: this.sleepDisease, sleepDiseaseCooldown: this.sleepDiseaseCooldown, explosionDisease: this.explosionDisease, explosionDiseaseTimer: this.explosionDiseaseTimer, fightDisease: this.fightDisease, fightDiseaseCooldown: this.fightDiseaseCooldown, lastBleedAt: this.lastBleedAt, favorite: this.favorite, insideNestBoxId: this.insideNestBoxId || null, nestFade: this.nestFade || 0, sleepDiseaseAnchorX: this.sleepDiseaseAnchorX, sleepDiseaseAnchorY: this.sleepDiseaseAnchorY, records: this.records ? this.records.slice(0, 42) : [],
|
||||
zunchiDisease: this.zunchiDisease, zunchiDiseaseSeverity: this.zunchiDiseaseSeverity, zunchiDiseaseCooldown: this.zunchiDiseaseCooldown,
|
||||
tempComfort: this.tempComfort, tempTimer: this.tempTimer,
|
||||
|
|
@ -226,6 +227,7 @@ class Tarinai {
|
|||
|
||||
addRecord(text, kind = "note") {
|
||||
if (!text) return;
|
||||
if (this.world?.shouldHideFromObservationRecords?.(text)) return;
|
||||
if (!Array.isArray(this.records)) this.records = [];
|
||||
const entry = { time: this.world?.time || 0, text: String(text), kind: kind || "note" };
|
||||
const head = this.records[0];
|
||||
|
|
@ -242,6 +244,28 @@ class Tarinai {
|
|||
return this.personalityProfile().label || this.personality || "\u4e0d\u660e";
|
||||
}
|
||||
|
||||
fightWinCount() {
|
||||
return this.totalFightWins || 0;
|
||||
}
|
||||
|
||||
fightLossCount() {
|
||||
return this.totalFightLosses || 0;
|
||||
}
|
||||
|
||||
maybeBecomeTimidAfterDamage(cause = "") {
|
||||
if (this.dead || this.personality === "timid") return false;
|
||||
const losses = this.totalFightLosses || 0;
|
||||
const wins = this.totalFightWins || 0;
|
||||
if (losses <= wins) return false;
|
||||
if (Math.random() >= 0.05) return false;
|
||||
this.personality = "timid";
|
||||
this.fearTimer = Math.max(this.fearTimer || 0, 1.2);
|
||||
this.stress = clamp((this.stress || 0) + 5, 0, 130);
|
||||
this.world?.spawnBubble?.(this.x, this.y - this.radius * 1.35, "こわい…", "rgba(90,80,120,0.78)");
|
||||
this.addRecord?.(`${this.name}は痛みで臆病になった。`, "health");
|
||||
return true;
|
||||
}
|
||||
|
||||
relationTo(id) {
|
||||
if (!id) return relationDefaults();
|
||||
if (!this.relationships) this.relationships = {};
|
||||
|
|
@ -623,9 +647,9 @@ class Tarinai {
|
|||
this.fightDisease = true;
|
||||
this.fightDiseaseCooldown = 18;
|
||||
this.fearTimer = Math.max(this.fearTimer || 0, 0.35);
|
||||
this.thought = "\u55a7\u5629\u50b7\u75c5\u3067\u5f53\u3066\u3082\u306a\u304f\u5f77\u5fa8\u3063\u3066\u3044\u308b";
|
||||
this.thought = "きずつき病\u3067\u5f53\u3066\u3082\u306a\u304f\u5f77\u5fa8\u3063\u3066\u3044\u308b";
|
||||
this.world?.spawnBubble?.(this.x, this.y - this.radius * 1.20, "?", "rgba(150,78,44,0.80)");
|
||||
this.world?.log?.(`${this.name}\u306f\u55a7\u5629\u50b7\u75c5\u3092\u767a\u75c7\u3057\u305f\u3002`, "fight");
|
||||
this.world?.log?.(`${this.name}\u306fきずつき病\u3092\u767a\u75c7\u3057\u305f\u3002`, "fight");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -633,10 +657,10 @@ class Tarinai {
|
|||
if (!this.fightDisease) return false;
|
||||
this.fightDisease = false;
|
||||
this.fightDiseaseCooldown = 20;
|
||||
this.thought = reason || "\u55a7\u5629\u50b7\u75c5\u304c\u6cbb\u3063\u305f";
|
||||
this.thought = reason || "きずつき病\u304c\u6cbb\u3063\u305f";
|
||||
this.stress = clamp(this.stress - 12, 0, 130);
|
||||
this.world?.spawnBubble?.(this.x, this.y - this.radius * 1.18, "\u306f\u3046", "rgba(82,126,88,0.76)");
|
||||
this.world?.log?.(`${this.name}\u306e\u55a7\u5629\u50b7\u75c5\u304c\u6cbb\u3063\u305f\u3002`, "fight");
|
||||
this.world?.log?.(`${this.name}\u306eきずつき病\u304c\u6cbb\u3063\u305f\u3002`, "fight");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -671,7 +695,11 @@ class Tarinai {
|
|||
return null;
|
||||
}
|
||||
const d = distXY(this.x, this.y, box.x, box.y);
|
||||
const canEnter = (this.state === "sleep" || this.state === "seek_bed") && d <= Math.max(18, box.r * 0.58);
|
||||
const occupants = this.world?.nestBoxOccupants ? this.world.nestBoxOccupants(box, Infinity) : [];
|
||||
const capacity = this.world?.nestBoxCapacity ? this.world.nestBoxCapacity(box) : 5;
|
||||
const occupantIndex = occupants.indexOf(this);
|
||||
const hasRoom = occupantIndex >= 0 ? occupantIndex < capacity : occupants.length < capacity;
|
||||
const canEnter = hasRoom && (this.state === "sleep" || this.state === "seek_bed") && d <= Math.max(18, box.r * 0.58);
|
||||
if (canEnter) {
|
||||
this.insideNestBoxId = box.id;
|
||||
this.nestFade = clamp((this.nestFade || 0) + dt * 2.4, 0, 1);
|
||||
|
|
@ -728,7 +756,7 @@ class Tarinai {
|
|||
if (this.recoverZunchiDisease("\u81ea\u7136\u306b\u305a\u3093\u3061\u75c5\u304c\u6cbb\u307e\u3063\u305f")) this.world?.log?.(`${this.name}\u306e\u305a\u3093\u3061\u75c5\u304c\u81ea\u7136\u306b\u6cbb\u3063\u305f\u3002`, "accident");
|
||||
}
|
||||
if (this.fightDisease && Math.random() < dt * 0.00070 * (this.energy > 58 ? 1.4 : 1.0)) {
|
||||
this.recoverFightDisease("\u81ea\u7136\u306b\u55a7\u5629\u50b7\u75c5\u304c\u6cbb\u3063\u305f");
|
||||
this.recoverFightDisease("\u81ea\u7136\u306bきずつき病\u304c\u6cbb\u3063\u305f");
|
||||
}
|
||||
if (this.fightDisease) {
|
||||
this.stress = clamp(this.stress + dt * 0.16, 0, 130);
|
||||
|
|
@ -848,6 +876,8 @@ class Tarinai {
|
|||
|
||||
update(dt) {
|
||||
if (this.dead) return;
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
|
||||
const minute = dt / 60;
|
||||
this.age += dt;
|
||||
|
|
@ -1166,8 +1196,8 @@ class Tarinai {
|
|||
? dayP >= this.sleepStart && dayP < this.sleepEnd
|
||||
: dayP >= this.sleepStart || dayP < this.sleepEnd;
|
||||
|
||||
if (this.hasFightMochiEffect() && this.fightTimer <= 0.04 && this.intimidateTimer <= 0.04 && this.defeatedTimer <= 0.04) {
|
||||
const opponent = this.world.nearestOther(this, 320);
|
||||
if (this.world.canStartFight?.(this) && this.hasFightMochiEffect() && this.fightTimer <= 0.04 && this.intimidateTimer <= 0.04 && this.defeatedTimer <= 0.04) {
|
||||
const opponent = this.world.nearestOther(this, 320, o => this.world.canBeFightTarget?.(o));
|
||||
if (opponent) {
|
||||
const d = dist(this, opponent);
|
||||
if (d <= Math.max(48, this.radius + opponent.radius + 18)) {
|
||||
|
|
@ -1191,7 +1221,7 @@ class Tarinai {
|
|||
this.target = this.panicDestination(rival);
|
||||
this.fearTimer = Math.max(this.fearTimer, 0.35 * this.personalityProfile().fear);
|
||||
this.thought = `${rival.name}\u3092\u907f\u3051\u3066\u9060\u56de\u308a\u3057\u3066\u3044\u308b`;
|
||||
if (this.world.relationNotice(this.id, rival.id, "avoid", 22)) this.world.log(`${this.name}\u306f\u4ee5\u524d\u306e\u55a7\u5629\u5f8c\u3001${rival.name}\u3092\u907f\u3051\u305f\u3002`, "relation");
|
||||
this.world.relationNotice(this.id, rival.id, "avoid", 22);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1219,7 +1249,7 @@ class Tarinai {
|
|||
this.state = "seek_food";
|
||||
this.target = cureFood;
|
||||
this.foodReactTimer = Math.max(this.foodReactTimer, 0.42);
|
||||
this.thought = this.fightDisease ? "\u55a7\u5629\u50b7\u75c5\u3067\u305a\u3093\u3060\u9905\u3092\u63a2\u3057\u3066\u3044\u308b" : "\u7206\u767a\u75c5\u3067\u305a\u3093\u3060\u9905\u3092\u63a2\u3057\u3066\u3044\u308b";
|
||||
this.thought = this.fightDisease ? "きずつき病\u3067\u305a\u3093\u3060\u9905\u3092\u63a2\u3057\u3066\u3044\u308b" : "\u7206\u767a\u75c5\u3067\u305a\u3093\u3060\u9905\u3092\u63a2\u3057\u3066\u3044\u308b";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1227,7 +1257,7 @@ class Tarinai {
|
|||
if (this.fightDisease && this.fightTimer <= 0.04 && this.birthRitualTimer <= 0.04 && this.defeatedTimer <= 0.04) {
|
||||
this.state = "fight_sick";
|
||||
this.target = null;
|
||||
this.thought = "\u55a7\u5629\u50b7\u75c5\u3067\u5f53\u3066\u3082\u306a\u304f\u5f77\u5fa8\u3063\u3066\u3044\u308b";
|
||||
this.thought = "きずつき病\u3067\u5f53\u3066\u3082\u306a\u304f\u5f77\u5fa8\u3063\u3066\u3044\u308b";
|
||||
if (Math.random() < dt * 0.45) this.wanderAngle += rand(-3.4, 3.4);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1431,7 +1461,7 @@ class Tarinai {
|
|||
this.stress = clamp(this.stress - eating * 0.42, 0, 130);
|
||||
this.fearTimer = Math.max(0, this.fearTimer - eating * 0.035);
|
||||
if (this.explosionDisease) this.recoverExplosionDisease("\u305a\u3093\u3060\u9905\u3067\u7206\u767a\u75c5\u304c\u6cbb\u3063\u305f");
|
||||
if (this.fightDisease) this.recoverFightDisease("\u305a\u3093\u3060\u9905\u3067\u55a7\u5629\u50b7\u75c5\u304c\u6cbb\u3063\u305f");
|
||||
if (this.fightDisease) this.recoverFightDisease("\u305a\u3093\u3060\u9905\u3067きずつき病\u304c\u6cbb\u3063\u305f");
|
||||
}
|
||||
this.eatTimer = Math.max(this.eatTimer, 0.32);
|
||||
this.eatCooldown = it.type === "sweet" ? rand(0.34, 0.62) : rand(0.44, 0.78);
|
||||
|
|
@ -1602,7 +1632,7 @@ class Tarinai {
|
|||
if (d < 0.01 || d > 74) continue;
|
||||
closeCount += 1;
|
||||
|
||||
const fightMochiContact = this.hasFightMochiEffect() || o.hasFightMochiEffect();
|
||||
const fightMochiContact = this.world.canFightPair?.(this, o) && (this.hasFightMochiEffect() || o.hasFightMochiEffect());
|
||||
if (fightMochiContact && d <= Math.max(42, this.radius + o.radius + 16)) {
|
||||
if (this.world.startForcedFight?.(this, o)) continue;
|
||||
}
|
||||
|
|
@ -1689,7 +1719,7 @@ class Tarinai {
|
|||
const birthPeace = (this.postBirthPeaceTimer || 0) > 0 || (o.postBirthPeaceTimer || 0) > 0;
|
||||
const familyFightBlocked = this.world.areParentChild ? this.world.areParentChild(this, o) : false;
|
||||
const pairFightBlocked = this.world.areCoParents ? this.world.areCoParents(this, o) : false;
|
||||
if (d < 56 && !familyFightBlocked && !pairFightBlocked && !birthPeace && fightRisk && this.fightCooldown <= 0 && o.fightCooldown <= 0 && Math.random() < dt * 0.23 * personalityRisk * fearBrake * friendBrake * conflictBias) {
|
||||
if (this.world.canFightPair?.(this, o) && d < 56 && !familyFightBlocked && !pairFightBlocked && !birthPeace && fightRisk && this.fightCooldown <= 0 && o.fightCooldown <= 0 && Math.random() < dt * 0.23 * personalityRisk * fearBrake * friendBrake * conflictBias) {
|
||||
this.world.startConflict(this, o);
|
||||
}
|
||||
|
||||
|
|
@ -1884,7 +1914,7 @@ class Tarinai {
|
|||
reason = this.dominantDeathCause("", { lowHealth: true }) || "\u4e8b\u6545";
|
||||
}
|
||||
else if (this.hunger >= 108) reason = "\u98e2\u9913";
|
||||
else if (this.age >= this.lifeSpan) reason = "\u5bff\u547d";
|
||||
else if (this.age >= this.lifeSpan) reason = "天寿を全うした";
|
||||
else if (this.stress >= 124) {
|
||||
reason = this.dominantDeathCause("\u30b9\u30c8\u30ec\u30b9\u904e\u591a", { stressDeath: true }) || "\u30b9\u30c8\u30ec\u30b9\u904e\u591a";
|
||||
}
|
||||
|
|
@ -1970,7 +2000,8 @@ class Tarinai {
|
|||
? this.sleepFacing > 0
|
||||
: this.facingDir() > 0;
|
||||
const angle = (faceRight ? 1 : -1) * (Math.PI / 12) + motionTilt;
|
||||
const nestHideAlpha = this.nestFade ? clamp(1 - this.nestFade * 0.92, 0.08, 1) : 1;
|
||||
const nestHideAlpha = this.nestFade ? clamp(1 - this.nestFade, 0, 1) : 1;
|
||||
if (nestHideAlpha <= 0.01) return;
|
||||
|
||||
const shadow = projectedShadowParams(lightState, 0.95 + this.scale * 0.8);
|
||||
const shadowContactY = this.y + bob + (drawH / squish) * 0.30;
|
||||
|
|
@ -1996,9 +2027,6 @@ class Tarinai {
|
|||
|
||||
ctx.save();
|
||||
ctx.translate(this.x + intimidateShake, this.y + bob + fearShakeY);
|
||||
ctx.rotate(angle);
|
||||
if (insideCardboard) ctx.globalAlpha *= 0.58;
|
||||
|
||||
const observeKind = this.world.observeHighlightKind ? this.world.observeHighlightKind(this) : "";
|
||||
if (observeKind && this.world.selected !== this) {
|
||||
const style = {
|
||||
|
|
@ -2008,7 +2036,7 @@ class Tarinai {
|
|||
enemy: { color: "rgba(214,82,66,0.90)", label: "\u6575\u5bfe" },
|
||||
}[observeKind] || { color: "rgba(255,250,220,0.78)", label: "" };
|
||||
ctx.save();
|
||||
ctx.globalAlpha = 0.96;
|
||||
ctx.globalAlpha = 0.96 * nestHideAlpha;
|
||||
ctx.shadowColor = style.color;
|
||||
ctx.shadowBlur = 16;
|
||||
ctx.strokeStyle = style.color;
|
||||
|
|
@ -2042,6 +2070,12 @@ class Tarinai {
|
|||
ctx.restore();
|
||||
}
|
||||
|
||||
|
||||
ctx.rotate(angle);
|
||||
ctx.globalAlpha *= nestHideAlpha;
|
||||
if (insideCardboard) ctx.globalAlpha *= 0.58;
|
||||
|
||||
|
||||
if (this.world.selected === this) {
|
||||
ctx.save();
|
||||
ctx.globalAlpha = 0.85;
|
||||
|
|
@ -2112,7 +2146,6 @@ class Tarinai {
|
|||
ctx.restore();
|
||||
}
|
||||
|
||||
ctx.globalAlpha *= nestHideAlpha;
|
||||
if (faceRight) ctx.scale(-1, 1);
|
||||
const dw = drawW * squish;
|
||||
const dh = drawH / squish;
|
||||
|
|
@ -2162,7 +2195,7 @@ class Tarinai {
|
|||
|
||||
if (this.favorite) {
|
||||
ctx.save();
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.globalAlpha = nestHideAlpha;
|
||||
const starSize = Math.max(18, this.radius * 0.88);
|
||||
const sx = this.x;
|
||||
const sy = this.y - drawH * 0.64 - 20;
|
||||
|
|
@ -2216,4 +2249,3 @@ class Tarinai {
|
|||
return distXY(this.x, this.y, x, y) < hit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue