This commit is contained in:
33333-33333 2026-07-15 14:44:29 +09:00
commit 63e10af865
86 changed files with 5400 additions and 1209 deletions

View file

@ -290,7 +290,7 @@ const HEALTH = (() => {
}
return true;
}
function applyDamage(t, amount, reason = "") {
function applyDamage(t, amount, reason = "", options = {}) {
const maxEnergy = typeof tarinaiMaxEnergy === "function" ? tarinaiMaxEnergy(t) : (Number(t.maxEnergy) || 100);
t.maxEnergy = maxEnergy;
const before = clamp(Number(t.energy) || 0, 0, maxEnergy);
@ -299,6 +299,7 @@ const HEALTH = (() => {
const actualLoss = Math.max(0, before - t.energy);
let cause = "";
if (actualLoss > 0.01) {
globalThis.TarinaiAchievements?.recordDamageSource?.(t, options.source || null, { world: t.world, amount: actualLoss, reason });
cause = rememberDamage(t, actualLoss, reason);
const plushie = (t.world?.ownedItemsFor?.(t.id) || t.world?.itemsOfType?.("plushie") || t.world?.items || []).find(item => item && !item.dead && item.isStructure && item.type === "plushie" && item.ownerId === t.id && item.carriedById === t.id);
if (plushie && actualLoss >= 1) plushie.damage(actualLoss, t.world, null);