aa
This commit is contained in:
parent
f941200504
commit
ad2cc76429
34 changed files with 616 additions and 365 deletions
|
|
@ -351,7 +351,7 @@
|
|||
if (id === "athletic") return "ice";
|
||||
if (id === "war") return "foot_massage";
|
||||
if (id === "happy") return "blanket";
|
||||
return "";
|
||||
return "soil";
|
||||
}
|
||||
|
||||
global.TarinaiResetPresets = Object.freeze({ ids: Object.keys(RESET_PRESETS), meta: RESET_PRESETS, normalize: normalizeResetPresetId });
|
||||
|
|
@ -525,7 +525,12 @@
|
|||
if (Math.abs((Number(entry.scale) || 0) - nextScale) > 0.002) changed = true;
|
||||
if (Math.abs((Number(entry.adultScale) || 0) - nextAdultScale) > 0.002) changed = true;
|
||||
if (Math.abs((Number(entry.growth) || 0) - nextGrowth) > 0.02) changed = true;
|
||||
for (const key of ["lifeSpanMul", "attackMul", "speedMul", "sizeMul"]) if (Math.abs((Number(entry.genetics?.[key]) || 1) - (Number(nextGenetics?.[key]) || 1)) > 0.002) changed = true;
|
||||
for (const key of ["lifeSpanMul", "attackMul", "speedMul", "sizeMul", "temperatureOffset"]) {
|
||||
const fallback = key === "temperatureOffset" ? 0 : 1;
|
||||
const prevGene = Number.isFinite(Number(entry.genetics?.[key])) ? Number(entry.genetics?.[key]) : fallback;
|
||||
const nextGene = Number.isFinite(Number(nextGenetics?.[key])) ? Number(nextGenetics?.[key]) : fallback;
|
||||
if (Math.abs(prevGene - nextGene) > 0.002) changed = true;
|
||||
}
|
||||
if (Math.abs((Number(entry.lifeSpan) || 0) - (Number(t.lifeSpan) || 0)) > 1) changed = true;
|
||||
if ((Number(entry.totalFightWins) || 0) !== nextFightWins) changed = true;
|
||||
if ((Number(entry.totalFightLosses) || 0) !== nextFightLosses) changed = true;
|
||||
|
|
@ -618,7 +623,12 @@
|
|||
const b = next[key];
|
||||
let equal = false;
|
||||
if (key === "genetics") {
|
||||
equal = ["lifeSpanMul", "attackMul", "speedMul", "sizeMul"].every(gk => Math.abs((Number(a?.[gk]) || 1) - (Number(b?.[gk]) || 1)) <= 0.002);
|
||||
equal = ["lifeSpanMul", "attackMul", "speedMul", "sizeMul", "temperatureOffset"].every(gk => {
|
||||
const fallback = gk === "temperatureOffset" ? 0 : 1;
|
||||
const av = Number.isFinite(Number(a?.[gk])) ? Number(a?.[gk]) : fallback;
|
||||
const bv = Number.isFinite(Number(b?.[gk])) ? Number(b?.[gk]) : fallback;
|
||||
return Math.abs(av - bv) <= 0.002;
|
||||
});
|
||||
} else {
|
||||
equal = Array.isArray(a) && Array.isArray(b) ? sameList(a, b) : a === b;
|
||||
}
|
||||
|
|
@ -1179,6 +1189,7 @@
|
|||
if ((a.fightMochiTimer || 0) > 0.04 || (b.fightMochiTimer || 0) > 0.04) return this.startForcedFight(a, b);
|
||||
if (this.areParentChild(a, b) || this.areCoParents?.(a, b)) return false;
|
||||
if ((a.postBirthPeaceTimer || 0) > 0 || (b.postBirthPeaceTimer || 0) > 0) return false;
|
||||
if ((a.postConflictPeaceTimer || 0) > 0.04 || (b.postConflictPeaceTimer || 0) > 0.04) return false;
|
||||
if (this.fightPairCooldownRemaining?.(a, b) > 0.04) return false;
|
||||
if (a.fightTimer > 0.04 || b.fightTimer > 0.04 || a.intimidateTimer > 0.04 || b.intimidateTimer > 0.04) return false;
|
||||
const aAggressiveIntent = a.shouldApplyPersonalityBehavior?.("aggression", 1) ? 1 : 0;
|
||||
|
|
@ -1266,6 +1277,7 @@
|
|||
if (!a || !b || a.dead || b.dead) return false;
|
||||
if (!this.canFightPair(a, b) && !this.canFightPair(b, a)) return false;
|
||||
if ((a.postBirthPeaceTimer || 0) > 0 || (b.postBirthPeaceTimer || 0) > 0) return false;
|
||||
if ((a.postConflictPeaceTimer || 0) > 0.04 || (b.postConflictPeaceTimer || 0) > 0.04) return false;
|
||||
if (this.isAlreadyFightingPair?.(a, b)) return true;
|
||||
const allowForcedStart = Boolean(opts?.forced);
|
||||
if (!allowForcedStart && ((a.fightTimer || 0) > 0.04 || (b.fightTimer || 0) > 0.04 || (a.intimidateTimer || 0) > 0.04 || (b.intimidateTimer || 0) > 0.04)) return false;
|
||||
|
|
@ -1305,14 +1317,8 @@
|
|||
b.fightTargetId = b.fightTargetIds[0];
|
||||
if (a.addStress) a.addStress(deterministicRange(this, "fight-start-stress-a", 8, 18, a, b), { threshold: 8 });
|
||||
if (b.addStress) b.addStress(deterministicRange(this, "fight-start-stress-b", 8, 18, a, b), { threshold: 8 });
|
||||
const rawDamageToA = deterministicRange(this, "fight-pulse-damage-a", 2, 7, a, b);
|
||||
const rawDamageToB = deterministicRange(this, "fight-pulse-damage-b", 2, 7, a, b);
|
||||
const damageToA = b.outgoingDamage ? b.outgoingDamage(rawDamageToA) : rawDamageToA;
|
||||
const damageToB = a.outgoingDamage ? a.outgoingDamage(rawDamageToB) : rawDamageToB;
|
||||
a.damage(damageToA, "\u55a7\u5629");
|
||||
b.damage(damageToB, "\u55a7\u5629");
|
||||
this.maybeDefeatFromFightDamage?.(a, b, damageToA);
|
||||
this.maybeDefeatFromFightDamage?.(b, a, damageToB);
|
||||
// Damage is applied by repeated headbutt pulses while the fight is active.
|
||||
// Do not front-load or end-load a lump sum when the fight state starts/settles.
|
||||
const dx = b.x - a.x, dy = b.y - a.y;
|
||||
const d = Math.hypot(dx, dy) || 1;
|
||||
a.vx -= dx / d * deterministicRange(this, "fight-pulse-knockback-ax", 32, 62, a, b); a.vy -= dy / d * deterministicRange(this, "fight-pulse-knockback-ay", 32, 62, a, b);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue