This commit is contained in:
33333-33333 2026-06-21 22:29:00 +09:00
commit 0a6148c73f
67 changed files with 2653 additions and 1519 deletions

View file

@ -30,19 +30,25 @@ class Tarinai { constructor(world, opts = {}) {
this.currentPersonality = normalizePersonality(opts.currentPersonality || opts.personalityCurrent || this.birthPersonality);
this.personalityDaily = opts.personalityDaily && typeof opts.personalityDaily === "object" ? JSON.parse(JSON.stringify(opts.personalityDaily)) : null;
ensurePersonality(this);
this.genetics = normalizeGenetics(opts.genetics, this.familyKey);
this.trait = makeTrait(this.type);
this.trait.speed *= this.genetics.speedMul || 1;
this.birthTime = opts.birthTime ?? this.world.time;
const generationOpt = opts.generation ?? 1;
const growthAtConstruct = generationOpt > 1 ? clamp(((this.world?.time || 0) - this.birthTime) / Math.max(1, CONFIG.childGrowTime || 120), 0, 1) : 1;
this.x = opts.x ?? rand(100, world.w - 100);
this.y = opts.y ?? rand(100, world.h - 100);
this.vx = opts.vx ?? rand(-12, 12);
this.vy = opts.vy ?? rand(-12, 12);
this.impulseVx = opts.impulseVx ?? 0;
this.impulseVy = opts.impulseVy ?? 0;
this.scale = opts.scale ?? rand(0.22, 0.33);
this.adultScale = Number.isFinite(opts.adultScale) ? opts.adultScale : (Number.isFinite(opts.baseAdultScale) ? opts.baseAdultScale : (Number.isFinite(opts.scale) && growthAtConstruct >= 1 ? opts.scale : adultScaleFromGenetics(this.familyKey, this.genetics)));
this.scale = Number.isFinite(opts.scale) ? opts.scale : (generationOpt > 1 ? scaleForGrowth(this.adultScale, growthAtConstruct) : this.adultScale);
this.radius = 56 * this.scale;
this.age = opts.age ?? rand(0, 20);
this.lifeSpan = opts.lifeSpan ?? rand(1400, 2200);
if (this.lifeSpan < 1200) this.lifeSpan = rand(1400, 2200);
this.generation = opts.generation ?? 1;
this.lifeSpan = opts.lifeSpan ?? rand(1400, 2200) * (this.genetics.lifeSpanMul || 1);
if (this.lifeSpan < 900) this.lifeSpan = rand(1200, 1800) * (this.genetics.lifeSpanMul || 1);
this.generation = generationOpt;
this.hasPaired = opts.hasPaired ?? false;
this.hunger = opts.hunger ?? rand(16, 45);
this.loneliness = opts.loneliness ?? rand(18, 62);
@ -104,14 +110,15 @@ class Tarinai { constructor(world, opts = {}) {
this.zunchiDiseaseCooldown = opts.zunchiDiseaseCooldown ?? 0;
this.totalFightLosses = opts.totalFightLosses || 0;
this.totalFightWins = opts.totalFightWins || 0;
this.isZunchiSlave = Boolean(opts.isZunchiSlave);
this.isZunchiSlave = Boolean(opts.isZunchiSlave || opts.zunchiSlaveLocked);
this.zunchiSlaveLocked = Boolean(opts.zunchiSlaveLocked || this.isZunchiSlave);
this.formerName = opts.formerName || null;
this.loveMochiTimer = opts.loveMochiTimer ?? 0;
this.fightMochiTimer = opts.fightMochiTimer ?? 0;
this.sleepDisease = Boolean(opts.sleepDisease);
this.sleepDiseaseCooldown = opts.sleepDiseaseCooldown ?? 0;
this.explosionDisease = Boolean(opts.explosionDisease);
this.explosionDiseaseTimer = opts.explosionDiseaseTimer ?? (this.explosionDisease ? (CONFIG.dayLength || 120) * 0.5 : 0);
this.explosionDiseaseTimer = opts.explosionDiseaseTimer ?? (this.explosionDisease ? 60 : 0);
this.fightDisease = Boolean(opts.fightDisease);
this.fightDiseaseCooldown = opts.fightDiseaseCooldown ?? 0;
this.lastBleedAt = opts.lastBleedAt ?? -999;
@ -121,13 +128,17 @@ class Tarinai { constructor(world, opts = {}) {
this.nestBoxEnteredAt = opts.nestBoxEnteredAt ?? (this.insideNestBoxId ? (world?.time || 0) : -Infinity);
this.nestBoxStayUntil = opts.nestBoxStayUntil ?? (this.insideNestBoxId ? ((world?.time || 0) + 10) : -Infinity);
this.focusPulseTimer = opts.focusPulseTimer ?? 0;
if (this.isZunchiSlave) this.name = "\u305a\u3093\u3061\u3069\u308c\u3044";
if (this.isZunchiSlave) {
this.zunchiSlaveLocked = true;
this.name = "\u305a\u3093\u3061\u3069\u308c\u3044";
applyZunchiSlavePersonality(this, { record: false, birth: false });
this.visibleSpriteId = "zunchi_slave";
}
this.tempComfort = opts.tempComfort ?? 0.62;
this.tempTimer = opts.tempTimer ?? stableUnit(this.familyKey, "temp-start") * 0.55;
this.parents = opts.parents || [];
this.parentNames = opts.parentNames || [];
this.children = opts.children || [];
this.birthTime = opts.birthTime ?? this.world.time;
this.nextEatSound = opts.nextEatSound ?? 0;
this.fightTimer = opts.fightTimer ?? 0;
this.fightCooldown = opts.fightCooldown ?? rand(0, CONFIG.fightCooldown);
@ -140,6 +151,7 @@ class Tarinai { constructor(world, opts = {}) {
this.lastMealColor = opts.lastMealColor || "#f7cf67";
this.grassEatTimer = opts.grassEatTimer ?? 0;
this.hurtTimer = opts.hurtTimer ?? 0;
this.stuckPushpinId = opts.stuckPushpinId || null;
this.defeatedTimer = opts.defeatedTimer ?? 0;
this.defeatedById = opts.defeatedById || null;
this.fightWinnerId = opts.fightWinnerId || null;
@ -161,6 +173,7 @@ class Tarinai { constructor(world, opts = {}) {
this.aiTimer = opts.aiTimer ?? stableUnit(this.familyKey, "ai-start") * 0.22;
this.envTimer = opts.envTimer ?? stableUnit(this.familyKey, "env-start") * 0.55;
this.visibleSpriteId = opts.visibleSpriteId || null;
this.zunchiSlaveSpriteVariant = opts.zunchiSlaveSpriteVariant || (opts.isZunchiSlave ? (Math.random() < 0.5 ? "zunchi_slave" : "zunchi_slave_alt") : "");
this.spriteLockUntil = opts.spriteLockUntil ?? 0;
this.entryTimer = opts.entryTimer ?? 0;
const effectTimers = opts.itemEffectTimers && typeof opts.itemEffectTimers === "object" ? opts.itemEffectTimers : {};
@ -179,6 +192,7 @@ class Tarinai { constructor(world, opts = {}) {
this.powerEffectPulse = opts.powerEffectPulse || 0;
this.powerEffectKind = opts.powerEffectKind || this.powerItemMode || this.sizeItemMode || this.lifeItemMode || "";
this.mysteryDrugHistory = Array.isArray(opts.mysteryDrugHistory) ? opts.mysteryDrugHistory.slice(-8) : [];
this.recentChangeCauses = Array.isArray(opts.recentChangeCauses) ? opts.recentChangeCauses.slice(-8) : [];
if (this.refreshEffectiveSize) this.refreshEffectiveSize();
}
}