hm
This commit is contained in:
parent
7455d630fc
commit
4d3fc2cd47
84 changed files with 3429 additions and 3480 deletions
37
js/ants.js
37
js/ants.js
|
|
@ -23,6 +23,8 @@ function buildAntWorkerPool(count = ANT_NEST_START_COUNT) {
|
|||
return Array.from({ length: n }, () => ANT_WORKER_HP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sanitizeAntWorkerPool(list, fallbackCount = 0) {
|
||||
if (!Array.isArray(list)) return buildAntWorkerPool(fallbackCount);
|
||||
const out = list.map(v => clampAntHp(v)).filter(v => v > 0.01);
|
||||
|
|
@ -127,13 +129,16 @@ class AntActor {
|
|||
this.extinguishFire("natural");
|
||||
return true;
|
||||
}
|
||||
this.burnTurnTimer = Math.max(0, Number(this.burnTurnTimer || 0) - dt);
|
||||
if (this.burnTurnTimer <= 0) {
|
||||
this.burnWanderAngle = deterministicAngle(this.world, "ant-burn-angle", this, Math.floor((this.world?.time || 0) * 6));
|
||||
this.burnTurnTimer = deterministicRange(this.world, "ant-burn-turn", 0.08, 0.28, this);
|
||||
} else {
|
||||
this.burnWanderAngle += deterministicRange(this.world, "ant-burn-jitter", -9.0, 9.0, this) * dt;
|
||||
}
|
||||
globalThis.TarinaiBurnMotionUtil.updateBurnWanderAngle(this, dt, {
|
||||
angleKey: "ant-burn-angle",
|
||||
turnKey: "ant-burn-turn",
|
||||
jitterKey: "ant-burn-jitter",
|
||||
bucketScale: 6,
|
||||
turnMin: 0.08,
|
||||
turnMax: 0.28,
|
||||
jitterMin: -9.0,
|
||||
jitterMax: 9.0,
|
||||
});
|
||||
const speed = this.kind === "queen" ? ANT_QUEEN_SPEED * 3.0 : ANT_WORKER_RETURN_SPEED * 3.3;
|
||||
this.vx = Math.cos(this.burnWanderAngle || 0) * speed;
|
||||
this.vy = Math.sin(this.burnWanderAngle || 0) * speed;
|
||||
|
|
@ -153,7 +158,7 @@ class AntActor {
|
|||
if (distXY(this.x, this.y, it.x, it.y) <= contactRadius + Math.max(it.r || 16, 12)) globalThis.TarinaiItemDynamicToolSystem?.igniteGrassByFire?.(it, this, this.world, dt);
|
||||
}
|
||||
if (deterministicChance(this.world, "ant-fire-effect", dt * 2.0, this)) {
|
||||
this.world?.effects?.push(new Effect("fight", this.x, this.y - this.r, { vx: rand(-6, 6), vy: rand(-22, -8), size: Math.max(5, this.r * 1.8), life: 0.28, color: "rgba(255,118,35,0.72)" }));
|
||||
this.world?.effects?.push(new Effect("flame", this.x, this.y - this.r, { vx: rand(-2, 2), vy: rand(-14, -6), size: Math.max(4, this.r * 1.0), life: 0.22, color: "rgba(236,46,24,0.72)" }));
|
||||
}
|
||||
if (this.burnTimer <= 0.01) this.extinguishFire("timeout");
|
||||
return true;
|
||||
|
|
@ -413,7 +418,6 @@ class AntActor {
|
|||
this.world?.emit?.("ant:died", { ant: this, home, reason: "hp" });
|
||||
const corpse = new Item("ant_corpse", this.x, this.y);
|
||||
corpse.amount = 24;
|
||||
corpse.workerSprite = this.workerSpriteId();
|
||||
this.world.addItem?.(corpse, "ant-corpse") || this.world.items.push(corpse);
|
||||
this.world.effects?.push(new Effect("zunchi_miasma", this.x, this.y - 4, { size: 10, life: 0.44, color: "rgba(82,61,42,0.28)" }));
|
||||
if (home) syncAntNestCount(this.world, home);
|
||||
|
|
@ -523,15 +527,16 @@ class AntActor {
|
|||
ctx.fill();
|
||||
}
|
||||
if (this.burning || (this.burnTimer || 0) > 0.02) {
|
||||
ctx.fillStyle = "rgba(255,112,34,0.82)";
|
||||
ctx.strokeStyle = "rgba(255,226,92,0.70)";
|
||||
ctx.lineWidth = Math.max(0.8, this.r * 0.16);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const a = this.seed + this.age * 8 + i * 2.1;
|
||||
const drawFire = typeof drawSimpleFireShape === "function" ? drawSimpleFireShape : null;
|
||||
if (drawFire) {
|
||||
const phase = this.seed + this.age * 8.0;
|
||||
drawFire(ctx, -this.r * 0.10, -this.r * 0.86, Math.max(5, this.r * 1.05), { phase, alpha: 0.86, shadow: false });
|
||||
drawFire(ctx, this.r * 0.54, -this.r * 0.48, Math.max(4, this.r * 0.78), { phase: phase + 1.5, alpha: 0.72, shadow: false });
|
||||
} else {
|
||||
ctx.fillStyle = "rgba(236,46,24,0.78)";
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(Math.cos(a) * this.r * 0.34, -this.r * (0.8 + i * 0.32), this.r * (0.45 - i * 0.05), this.r * (0.75 - i * 0.08), a * 0.25, 0, Math.PI * 2);
|
||||
ctx.ellipse(0, -this.r * 0.8, this.r * 0.42, this.r * 0.86, 0, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
ctx.restore();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue