Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions e63334287a3deaa3/ironveil/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
#cross i{position:absolute;background:var(--ink);box-shadow:0 0 2px rgba(0,0,0,.9)}
#cross .u,#cross .d{width:2px;height:9px;left:-1px}#cross .l,#cross .r{width:9px;height:2px;top:-1px}
#cross .c{width:2px;height:2px;left:-1px;top:-1px;opacity:.7}
#ads{position:absolute;left:50%;top:50%;width:22px;height:22px;margin:-11px 0 0 -11px;border:1.5px solid rgba(236,228,206,.75);border-radius:50%;box-shadow:0 0 0 1px rgba(0,0,0,.55),inset 0 0 0 1px rgba(0,0,0,.4);opacity:0;transition:opacity .12s}
#ads i{position:absolute;left:50%;top:50%;width:4px;height:4px;margin:-2px 0 0 -2px;border-radius:50%;background:#ffd36b;box-shadow:0 0 0 1px rgba(0,0,0,.7),0 0 6px rgba(255,190,80,.8)}
#hitm{position:absolute;left:50%;top:50%;width:26px;height:26px;margin:-13px 0 0 -13px;opacity:0}
#hitm::before,#hitm::after{content:'';position:absolute;left:12px;top:0;width:2px;height:26px;background:linear-gradient(var(--ink) 0 32%,transparent 32% 68%,var(--ink) 68%)}
#hitm::before{transform:rotate(45deg)}#hitm::after{transform:rotate(-45deg)}
Expand Down Expand Up @@ -199,6 +201,7 @@
<div class="h-wave" id="h-wave"></div>
<div class="h-fuse" id="h-fuse"></div>
<div id="cross"><i class="u"></i><i class="d"></i><i class="l"></i><i class="r"></i><i class="c"></i></div>
<div id="ads"><i></i></div>
<div id="hitm"></div>
<div class="h-dmg"><i></i><i></i><i></i></div>
<div class="h-prompt" id="h-prompt"><span><kbd>E</kbd><em id="h-pt" style="font-style:normal"></em></span><u><s id="h-pb"></s></u></div>
Expand Down
13 changes: 9 additions & 4 deletions e63334287a3deaa3/ironveil/js/enemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
return IK.qb;
}

const hit = {}, tmp = { x: 0, z: 0 };
const hit = {}, tmp = { x: 0, z: 0 }, HV = new THREE.Vector3();
class Soldier {
constructor(kind, x, z, o) {
o = o || {}; this.kind = kind; this.x = x; this.z = z; this.h = o.face || 0; this.hp = kind === 's' ? 140 : 45; this.alive = true;
Expand All @@ -209,6 +209,7 @@
const fx = Math.sin(this.h), fz = Math.cos(this.h), dot = d > 0.01 ? (dx * fx + dz * fz) / d : 1;
const range = (this.state === 'combat' ? 70 : 34) * (P.crouchK > 0.5 ? 0.62 : 1) * (1 + 0.5 * P.noise);
this.los = P.alive && d < range && (dot > (this.state === 'combat' ? -0.3 : 0.25) || d < 2.5) && MO.phys.los(this.x, 1.55 - this.crouch * 0.5, this.z, px, P.pos.y + P.eye - 0.15, pz);
if (this.los && MO.mission.state === 'intro' && this.state !== 'combat') this.los = false; // nobody notices you during the opening title
if (this.los) { this.seen.x = px; this.seen.z = pz; this.seen.t = MO.time;
if (this.state !== 'combat') { this.aware += (0.14 + 0.06) * (2.6 / Math.max(0.35, d / 9)) * (P.crouchK > 0.5 ? 0.55 : 1) * (1 + P.noise); if (this.aware >= 1) { this.alert(px, pz, true); EN.shout(this.x, this.z, 30, px, pz); MO.emit('spotted', this); } } }
else if (this.state !== 'combat') this.aware = Math.max(0, this.aware - 0.05);
Expand Down Expand Up @@ -249,6 +250,9 @@
else if (this.tok) { this.tok = false; EN.tokens--; }
this.flinch = Math.max(0, this.flinch - dt * 4);
this.pose(dt, sp, d);
// where the head and chest really are this frame, for hit tests (the head moves forward when aiming and kneeling)
this.group.updateMatrixWorld(true); HV.set(0, 0.13, 0.02).applyMatrix4(this.b.head.matrixWorld); this.hx = HV.x; this.hy = HV.y; this.hz = HV.z;
HV.set(0, 0, 0).applyMatrix4(this.b.chest.matrixWorld); this.cx = HV.x; this.cz = HV.z; this.ctop = Math.max(0.9, this.hy - 0.2);
}
shoot(d) {
const P = MO.player, A = MO.audio, my = 1.42 - this.crouch * 0.45, mx = this.x + Math.sin(this.h) * 0.7, mz = this.z + Math.cos(this.h) * 0.7;
Expand Down Expand Up @@ -378,9 +382,10 @@
EN.rayHit = (ox, oy, oz, dx, dy, dz, max) => {
let best = max, be = null, head = false;
for (const s of EN.list) { if (!s.alive) continue; const ex = s.x - ox, ez = s.z - oz; if (ex * dx + ez * dz < -1) continue;
const k = 1 - s.crouch * 0.3, hy = 1.66 * k - s.crouch * 0.1;
let t = segRay(ox, oy, oz, dx, dy, dz, s.x, 0.1, 1.42 * k, s.z, 0.25, best); if (t >= 0) { best = t; be = s; head = false; }
const cx = s.x - ox, cy = hy - oy, cz = s.z - oz, tc = cx * dx + cy * dy + cz * dz; if (tc > 0 && tc < best + 0.3) { const px = cx - dx * tc, py = cy - dy * tc, pz = cz - dz * tc, d2 = px * px + py * py + pz * pz; if (d2 < 0.0256) { const th = tc - Math.sqrt(0.0256 - d2); if (th < best + 0.25) { best = Math.min(best, th); be = s; head = true; } } } }
const k = 1 - s.crouch * 0.3, hx = s.hx === undefined ? s.x : s.hx, hy = s.hy === undefined ? 1.66 * k - s.crouch * 0.1 : s.hy, hz = s.hz === undefined ? s.z : s.hz;
const bx = s.cx === undefined ? s.x : (s.x + s.cx) / 2, bz = s.cz === undefined ? s.z : (s.z + s.cz) / 2;
let t = segRay(ox, oy, oz, dx, dy, dz, bx, 0.1, s.ctop || 1.42 * k, bz, 0.25, best); if (t >= 0) { best = t; be = s; head = false; }
const cx = hx - ox, cy = hy - oy, cz = hz - oz, tc = cx * dx + cy * dy + cz * dz; if (tc > 0 && tc < best + 0.3) { const px = cx - dx * tc, py = cy - dy * tc, pz = cz - dz * tc, d2 = px * px + py * py + pz * pz; if (d2 < 0.0256) { const th = tc - Math.sqrt(0.0256 - d2); if (th < best + 0.25) { best = Math.min(best, th); be = s; head = true; } } } }
if (!be) return null; res.e = be; res.t = best; res.head = head; return res;
};
// ammunition pouches left by the fallen
Expand Down
1 change: 1 addition & 0 deletions e63334287a3deaa3/ironveil/js/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
const hp = Math.round(P.hp); if (last.hp !== hp) { last.hp = hp; el['h-hp'].classList.toggle('on', hp < 100); el['h-hp'].classList.toggle('low', hp < 40); el['h-hpb'].style.width = hp + '%'; set('hl', el['h-hpl'], MO.T('Health')); }
// crosshair opens with spread, hides when aiming
const g = 5 + (W.spread || 0.03) * 520; el.cross.style.opacity = P.aimK > 0.5 || P.sprintK > 0.6 || W.reloading || !P.alive ? 0 : 0.85;
const ad = P.aimK > 0.6 && !W.reloading && P.alive ? 1 : 0; if (last.ad !== ad) { last.ad = ad; document.getElementById('ads').style.opacity = ad; }
const gk = g | 0; if (last.g !== gk) { last.g = gk; el.ct[0].style.top = (-g - 9) + 'px'; el.ct[1].style.top = g + 'px'; el.ct[2].style.left = (-g - 9) + 'px'; el.ct[3].style.left = g + 'px'; }
// being seen: a meter that fills while a soldier is working out what you are, red once the fight is on
let aw = 0; for (const s of MO.enemies.list) if (s.alive && s.state !== 'combat' && s.aware > aw) aw = s.aware;
Expand Down
4 changes: 2 additions & 2 deletions e63334287a3deaa3/ironveil/js/maps/hamlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@


L.targets = [{ id: 'A', label: 'A', kind: 'flak', x: -18, z: 17, ry: 1.0 }, { id: 'B', label: 'B', kind: 'flak', x: 30, z: 15, ry: -1.3 }, { id: 'C', label: 'C', kind: 'flak', x: -16, z: -42.5, ry: 2.4 }];
L.spawn = { x: laneX(66) + 0.4, z: 66, yaw: 0 };
L.spawn = { x: -27, z: 67, yaw: -0.22 }; // the glider field, behind the hedgerow: a quiet start
/* soldiers on the map at the start: kind, post, and a patrol route if they walk one */
L.posts = [
{ k: 'r', x: 0.5, z: 38, path: [[0.5, 38], [-1, 6], [0.8, 38]] }, { k: 'r', x: -1.5, z: 36, path: [[-1.5, 36], [1, 4], [-1.4, 36]], lag: 1.6 },
{ k: 'r', x: 0.5, z: 30, path: [[0.5, 30], [-1, 6], [0.8, 30]] }, { k: 'r', x: -1.5, z: 28, path: [[-1.5, 28], [1, 4], [-1.4, 28]], lag: 1.6 },
{ k: 'r', x: -9, z: 20.5, face: 1.5 }, { k: 'r', x: -15.5, z: 20, face: 2.2 }, { k: 's', x: -21, z: 14, face: 0.8 },
{ k: 's', x: 4.8, z: -5.2, face: 0.2 }, { k: 'r', x: -4.6, z: -10.8, face: 0.1 },
{ k: 'r', x: 27.5, z: 18, face: -1.2 }, { k: 'r', x: 33, z: 12.5, face: -2.4 }, { k: 'r', x: 16, z: 28, path: [[16, 28], [42, 30], [44, 4], [14, 4]] },
Expand Down
2 changes: 1 addition & 1 deletion e63334287a3deaa3/ironveil/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
P.eye = MO.lerp(1.66, 1.02, P.crouchK) - land * 0.09 - dead * 1.1;
cam.position.set(P.pos.x + Math.cos(P.yaw) * bx, P.pos.y + Math.max(0.22, P.eye + by), P.pos.z - Math.sin(P.yaw) * bx);
cam.rotation.set(P.pitch + kp, P.yaw + ky, roll + dead * 0.9 + Math.sin(bob) * 0.004 * amp, 'YXZ');
const fov = S.fov + 5 * P.sprintK - (S.fov - 52) * P.aimK * 0.62; if (Math.abs(cam.fov - fov) > 0.01) { cam.fov = fov; cam.updateProjectionMatrix(); }
const fov = S.fov + 5 * P.sprintK - (S.fov - 50) * P.aimK * 0.72; if (Math.abs(cam.fov - fov) > 0.01) { cam.fov = fov; cam.updateProjectionMatrix(); }
const u = MO.R.mFinal.uniforms; u.uHurt.value = MO.damp(u.uHurt.value, hurtK, 10, dt); u.uLow.value = MO.damp(u.uLow.value, P.alive ? MO.sat((45 - P.hp) / 45) : 1, 6, dt); u.uAim.value = P.aimK;
P.bob = bob; P.bobAmp = amp; P.landK = land;
};
Expand Down
2 changes: 1 addition & 1 deletion e63334287a3deaa3/ironveil/js/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
vec3 t = aces(c); float tl = dot(t, vec3(0.2126, 0.7152, 0.0722)); t = mix(vec3(tl), t, 0.9 - 0.25 * smoothstep(0.6, 1.0, tl));
t += vec3(-0.012, 0.004, 0.022) * (1.0 - smoothstep(0.0, 0.35, tl)); // cool shadows
t *= mix(vec3(1.0), vec3(1.05, 1.0, 0.93), smoothstep(0.45, 1.0, tl)); // warm highlights
float vig = smoothstep(0.95, 0.25, sqrt(r2) * (1.25 + 0.25 * uAim)); t *= mix(0.42, 1.0, vig);
float vig = smoothstep(0.95, 0.25, sqrt(r2) * (1.25 - 0.15 * uAim)); t *= mix(0.42, 1.0, vig);
float tg = dot(t, vec3(0.299, 0.587, 0.114)); t = mix(t, vec3(tg) * vec3(1.0, 0.9, 0.88), uLow * 0.6);
t = mix(t, vec3(0.5, 0.02, 0.0) * (0.4 + tg), uHurt * smoothstep(0.1, 0.5, r2 * 1.6));
t = pow(max(t, 0.0), vec3(1.0 / 2.2));
Expand Down
6 changes: 3 additions & 3 deletions e63334287a3deaa3/ironveil/js/weapon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Midnight Ops: the Thompson. 30 rounds, about 700 a minute, 26 damage a round (head x2.2), hits are instant.
/* Midnight Ops: the Thompson. 30 rounds, about 700 a minute, 26 damage a round, a headshot always kills, hits are instant.
The gun's motion is a handful of damped springs kicked by impulses (recoil, look sway, landing), plus a walk bob
tied to the player's stride. The reload is hand-written keyframes for the left hand and the magazine; its sounds
fire at set times in the same timeline. */
Expand Down Expand Up @@ -58,7 +58,7 @@
// the gun's camera has a narrower field of view than the world's: bring the muzzle point to where it appears
const ex = eh ? ox + v1.x * eh.t : ox + v1.x * d, ey = eh ? oy + v1.y * eh.t : oy + v1.y * d, ez = eh ? oz + v1.z * eh.t : oz + v1.z * d;
MO.fx.tracer(v2.x, v2.y, v2.z, ex, ey, ez, true);
if (eh) { P.hits++; const dmg = DMG * (eh.head ? 2.2 : 1) * (eh.t > 60 ? 0.75 : 1); MO.fx.impact(ex, ey, ez, -v1.x, 0.2, -v1.z, 'flesh'); A && A.play('hit_flesh', { x: ex, y: ey, z: ez, vol: 0.8 });
if (eh) { P.hits++; const dmg = eh.head ? 999 : DMG * (eh.t > 60 ? 0.75 : 1); // a headshot always kills MO.fx.impact(ex, ey, ez, -v1.x, 0.2, -v1.z, 'flesh'); A && A.play('hit_flesh', { x: ex, y: ey, z: ez, vol: 0.8 });
const killed = eh.e.hit(dmg, eh.head, v1.x, v1.z); MO.emit('hit', eh.head, killed); }
else if (wh) { tag = hit.box ? hit.box.tag : MO.ground.at(hit.x, hit.z).kind; if (tag === 'stone' && !hit.box) tag = 'stone';
MO.fx.impact(hit.x, hit.y, hit.z, hit.nx, hit.ny, hit.nz, tag);
Expand Down Expand Up @@ -110,7 +110,7 @@
const aim = P.aimK, run = P.sprintK * (1 - aim), bobA = P.bobAmp * (1 - 0.85 * aim), bx = Math.cos(P.bob) * 0.006 * bobA * (1 + run), by = Math.abs(Math.sin(P.bob)) * -0.008 * bobA * (1 + run * 1.5), t = MO.time;
const br = Math.sin(t * 1.3) * 0.0016 * (1 - 0.6 * aim), br2 = Math.sin(t * 0.9 + 1) * 0.0012;
// aim: bring the rear sight onto the eye line
const ax = -M.sight.x, ay = -M.sight.y, az = -0.09 - M.sight.z;
const ax = -M.sight.x, ay = -M.sight.y, az = -0.24 - M.sight.z; // eye well behind the rear sight, so the sights stay small and the view open
root.position.set(MO.lerp(HIP.p[0], ax, aim) + bx + sx * 0.0035 - run * 0.05 + rx,
MO.lerp(HIP.p[1], ay, aim) + by + br + dy * 0.02 - drop - run * 0.035 - P.crouchK * 0.008 * (1 - aim) + sy * -0.003,
MO.lerp(HIP.p[2], az, aim) + kz * 0.016 * (1 - 0.45 * aim) + run * 0.06);
Expand Down
Loading