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.

1 change: 1 addition & 0 deletions e63334287a3deaa3/ironveil/es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions e63334287a3deaa3/ironveil/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ <h2>Settings</h2>
<label for="sBlood">Blood effects<small>Off: hits show dust puffs instead</small></label><input id="sBlood" type="checkbox">
<label for="sView">View<small>First person, or the camera over your shoulder</small></label><select id="sView"><option value="first">First person</option><option value="third">Over the shoulder</option></select>
<label for="sCrouch">Crouch<small>Toggle: press to crouch, again to stand. Hold: crouched while the key is down</small></label><select id="sCrouch"><option value="0">Toggle</option><option value="1">Hold</option></select>
<label for="sSprint">Sprint<small>Hold: sprint while the key is down. Toggle: press once, it stops when you stop or aim</small></label><select id="sSprint"><option value="0">Hold</option><option value="1">Toggle</option></select>
<label for="sBob">Camera bob<small>A small step bob and a dip when you land</small></label><input id="sBob" type="checkbox">
<label for="sMotion">Reduced motion<small>Less camera shake and sway, no lightning flashes</small></label><input id="sMotion" type="checkbox">
</div>
Expand Down
17 changes: 13 additions & 4 deletions e63334287a3deaa3/ironveil/js/ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
function inView(e, x, y, z, d) {
const face = e.bodyYaw + e.headYaw, a = Math.abs(IV.wrapA(IV.yawTo(x - e.pos.x, z - e.pos.z) - face));
let k = a < A.fovH ? 1 : a < A.fovPeriph ? 0.35 : 0;
if (d < 0.9 && k === 0) k = 0.3; // bumping into him (a takedown from behind at 1.7 m still works)
if (d < 0.55 && k === 0) k = 0.3; // bumping right into him (the takedown reaches 2.2 m, so it never needs this close)
if (k === 0) return 0;
const ey = e.eye();
if (!W.clear(e.pos.x, ey, e.pos.z, x, y, z, F.SIGHT)) return 0;
Expand Down Expand Up @@ -191,8 +191,10 @@
if (k && smokeK(e.pos.x, e.pos.z, P.pos.x, P.pos.z) === 0) k = 0; // thick smoke between: nothing to see
if (k) {
e.seeing = true;
// the close-range boost is for what he looks straight at; at the edge of his eye (k < 1) a figure close by
// is a movement he half-notices, so it builds suspicion (he turns to look) rather than spotting you outright
const close = 1 - d / r;
const gain = A.gain[diff()] * (0.6 + 3.2 * close * close) * k * (e.alerted ? 1.35 : 1) * (IV.mission.awareMul || 1);
const gain = A.gain[diff()] * (0.6 + 3.2 * close * close * (k >= 1 ? 1 : 0.25)) * k * (e.alerted ? 1.35 : 1) * (IV.mission.awareMul || 1);
e.aw = Math.min(1.2, e.aw + gain * dt);
e.lkp = { x: P.pos.x, z: P.pos.z, t: IV.time };
}
Expand Down Expand Up @@ -251,7 +253,12 @@
const k = 1 - d / r;
if (type === 'step') {
if (src === P && AI.ignorePlayer) continue;
e.aw = Math.min(1.1, e.aw + A.hearGain * (0.4 + k) * (A.gain[diff()] / 0.85));
// A footstep is a sound, not a sighting: it builds with how close and loud it was (k squared, so steps at the
// edge of earshot barely register) and can make him suspicious or send him to look, but never past
// stepCap: only his eyes put him into a fight. Before, each step added 0.45 x (0.4 + k) with no cap, so two
// jogging steps behind a guard took him straight to 'spotted' and every knife approach failed.
const cap = A.stepCap;
if (e.state !== 'combat' && e.aw < cap) e.aw = Math.min(cap, e.aw + A.hearGain * k * k * 1.6 * (A.gain[diff()] / 0.85));
e.interest = { x: x + (Math.random() - 0.5) * d * 0.3, z: z + (Math.random() - 0.5) * d * 0.3 };
if (e.state === 'combat') e.lkp = { x, z, t: IV.time };
IV.emit('heard', { e, type });
Expand Down Expand Up @@ -502,7 +509,9 @@
},
suspicious(e, dt) {
e.speed = IV.damp(e.speed, 0, 8, dt);
const at = e.interest || e.lkp; if (at) faceTo(e, at.x, at.z, 4, dt);
// he stops and listens for a moment, then turns toward it at a wary pace (about 1.5 s for a half turn), which
// leaves a window to finish a takedown from behind
const at = e.interest || e.lkp; if (at && e.stateT > A.listenTime) faceTo(e, at.x, at.z, 2.4, dt);
e.headYaw = Math.sin(e.stateT * 1.3) * 0.25;
if (e.stateT > 4 && e.aw < A.suspicious) { AI.bark(e, 'lost'); e.setState(e.home ? 'returning' : 'unaware'); }
},
Expand Down
2 changes: 1 addition & 1 deletion e63334287a3deaa3/ironveil/js/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
right.set(Math.cos(yaw), 0, -Math.sin(yaw));
// FOV
const sprintK = P.sprinting ? 1 : 0;
C._spr = IV.damp(C._spr || 0, sprintK, 6, dt);
C._spr = IV.damp(C._spr || 0, sprintK, sprintK ? 6 : 12, dt); // eases in, lets go fast so a sprint-to-aim zoom does not drift
let fov = S.fov + C._spr * CT.sprintFov;
C.fovBase = fov;
const fp1 = IV.fp && IV.fp.on();
Expand Down
10 changes: 6 additions & 4 deletions e63334287a3deaa3/ironveil/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
eye: { stand: 1.62, crouch: 1.08, prone: 0.42 }, // m eye height above the feet by stance
cadence: { walk: 1.7, run: 2.6, sprint: 3.1, crouch: 1.45, crouchRun: 2.0, prone: 0.8 }, // footfalls per second by gait:
// the guards hear one per footfall, so noise follows gait and stance, not raw speed
sprintOut: 0.22, // s after a sprint before the weapon can fire or aim
sprintOut: 0.16, // s after a sprint before the weapon can fire (a shot asked for sooner is kept and goes then)
waterMul: 0.55 // speed in the stream
},
cam: {
Expand Down Expand Up @@ -114,7 +114,7 @@
headMul: 2.6, limbMul: 0.65,
grenade: { fuse: 4.0, radius: 7, dmg: 220, throwV: 16, count: 2 },
rock: { throwV: 15, noise: 15, count: 99 },
takedownRange: 2.0, takedownAngle: 1.9 // m, rad (|angle between enemy facing and you| must be > this behind them)
takedownRange: 2.2, takedownAngle: 1.35 // m; rad: you must be outside his clear view (where his head points, fovH 1.15 + margin), never in front of his body
},
noise: { // m, how far a sound carries in quiet night air
sprint: 16, run: 9.5, walk: 5, crouchRun: 4.5, crouch: 2.4, prone: 1.2, vault: 6, land: 7,
Expand All @@ -133,7 +133,9 @@
gain: [0.55, 0.85, 1.25], // awareness gained per second at point blank (difficulty)
decay: 0.12, // awareness lost per second when nothing is seen
suspicious: 0.3, investigate: 0.62, spotted: 1.0,
hearGain: 0.45, // awareness from one footstep heard at the edge
hearGain: 0.45, // awareness from one footstep heard right beside him (x k^2 x 1.6, k = 1 - d / earshot)
stepCap: 0.85, // footsteps alone never take awareness past this (below 'spotted': only sight starts a fight)
listenTime: 0.5, // s a suspicious guard stands listening before he turns toward the sound
reaction: [0.55, 0.47, 0.4], // s of continuous sight before he may act on seeing you (open fire, call it in)
// accuracy: hit chance per shot = acc * exposure ramp * range * your stance/movement * light * his own state.
// Exposure is seconds of continuous sight of you: the ramp is 1 - exp(-t / expoTau), from expoFloor at first sight
Expand Down Expand Up @@ -250,7 +252,7 @@
// cp: { mission, diff, idx, data } (the last checkpoint, so Continue resumes there), tut: boot camp finished once }
const KEY = 'ironveil:save';
const DEF_SETTINGS = { sens: 1, aimSens: 0.75, invert: false, assist: IV.touch ? 1 : 0, auto: IV.touch, sub: 1, motion: IV.reducedMotion, blood: true, bob: true,
quality: IV.touch ? 0 : 1, view: 'first', crouchHold: false, fov: 74, bright: 1, vol: 0.8, sfx: 1, mus: 0.55, mute: false };
quality: IV.touch ? 0 : 1, view: 'first', crouchHold: false, sprintToggle: false, fov: 74, bright: 1, vol: 0.8, sfx: 1, mus: 0.55, mute: false };
function load() {
let s = null;
try { s = JSON.parse(localStorage.getItem(KEY) || 'null'); } catch (e) { s = null; }
Expand Down
18 changes: 15 additions & 3 deletions e63334287a3deaa3/ironveil/js/fp.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

// ---------------------------------------------------------------- camera
const right = new THREE.Vector3(), tmp = new THREE.Vector3(), up = new THREE.Vector3(0, 1, 0), hv = new THREE.Vector3();
const TD_EYE = 0.55; // m, closest the eye comes to a takedown victim's head
FP.frame = function (cam, dt, dir, yaw, pitch) {
const S = IV.settings, W8 = IV.weapons, pr = P.render;
// eye height by stance, eased (a slight overshoot coming up)
Expand Down Expand Up @@ -100,7 +101,16 @@
if (cl > 1e-3) { const h = W.raycast(pr.x + f.x * 0.08, ey, pr.z + f.z * 0.08, cx / cl, 0, cz / cl, cl + 0.15, F.SOLID | F.SIGHT, true); if (h) { const k = Math.max(0, h.t - 0.15) / cl; cx *= k; cz *= k; } }
cx *= FP.crK * (1 - bk); cz *= FP.crK * (1 - bk);
}
const exo = f.x * 0.08 * (1 - bk) + (FP.hx || 0) * bk + cx, ezo = f.z * 0.08 * (1 - bk) + (FP.hz || 0) * bk + cz, eyo = (ey - pr.y) * (1 - bk) + (FP.hy != null ? FP.hy : ey - pr.y) * bk;
let exo = f.x * 0.08 * (1 - bk) + (FP.hx || 0) * bk + cx, ezo = f.z * 0.08 * (1 - bk) + (FP.hz || 0) * bk + cz; const eyo = (ey - pr.y) * (1 - bk) + (FP.hy != null ? FP.hy : ey - pr.y) * bk;
// knife takedown: the hero's clip lunges the head forward into the guard, and the eye rides that head bone, so the
// eye ended up inside his helmet. Keep the eye at least TD_EYE m (level) from the guard's head the whole move, so the
// knife hand and the guard stay in view in front of you.
const vic = W8.takedownVictim;
if (vic && P.cineClip && vic.actor) {
const vb = vic.actor.bone && vic.actor.bone('Head'); if (vb) vb.getWorldPosition(tmp); else tmp.set(vic.pos.x, vic.pos.y + 1.6, vic.pos.z);
const dx = pr.x + exo - tmp.x, dz = pr.z + ezo - tmp.z, d = Math.hypot(dx, dz);
if (d < TD_EYE) { const k = d > 1e-3 ? (TD_EYE - d) / d : 0; if (k) { exo += dx * k; ezo += dz * k; } else { exo -= fb.x * TD_EYE; ezo -= fb.z * TD_EYE; } }
}
cam.position.set(pr.x + right.x * (FP.lean * 0.3 + bx) + exo, pr.y + eyo + by + (C.bobY || 0) - Math.abs(FP.lean) * 0.04, pr.z + right.z * (FP.lean * 0.3 + bx) + ezo);
// never into the ground: the drawn ground's flat triangles sit above the true height in dips (up to ~0.3 m), so
// prone, with the eye about 0.3 m up, the near plane could cut into it and show the underside. Keep the eye 15 cm
Expand Down Expand Up @@ -297,7 +307,7 @@
else if (e === 'eject') caseFrom(v);
else if (e === 'shot' && v.kind !== 'rifleScoped') caseFrom(v);
else if (e === 'charge' || e === 'slide') A && A.play('click', { f: 2900, vol: 0.45 });
else if (e === 'pin') A && A.play('pin');
else if (e === 'pin') { if (!(WP.busyThrow && WP.busyThrow.kind === 'rock')) A && A.play('pin'); } // a rock has no pin
}
// a socket of the arms (viewmodel camera frame) as the world point in front of which it is drawn
// The arms pass has its own 55 degree camera, the world camera 60-95 (more while sprinting). A point in the arms'
Expand Down Expand Up @@ -356,7 +366,9 @@
const aiming = !!(W8.aiming || W8.scoped), a = IV.clamp(C.adsE || 0, 0, 1);
FP.vmAim = a;
// the sprint carry lets go quickly when aiming is asked for straight out of a sprint
FP.vmSpr = IV.damp(FP.vmSpr || 0, P.sprinting ? 1 : 0, P.sprinting ? 7 : aiming ? 20 : 10, dt);
// (and stays off while the hands are busy: a reload or a throw carried on at a sprint keeps the gun up to work it)
const carry = P.sprinting && !(W8.reloadT > 0) && !W8.busyThrow;
FP.vmSpr = IV.damp(FP.vmSpr || 0, carry ? 1 : 0, carry ? 8 : aiming ? 22 : 12, dt);
if (W8.binoc && FP.lastEvent && FP.lastEvent.e === 'atEye') FP.atEye = true;
if (W8.binoc && !FP.atEye && v.current === 'binoculars' && FP.binocT == null) FP.binocT = IV.time;
if (W8.binoc && FP.binocT != null && IV.time - FP.binocT > rig.len('binoculars') + 0.05) FP.atEye = true; // no 'atEye' event: the end of the clip
Expand Down
44 changes: 27 additions & 17 deletions e63334287a3deaa3/ironveil/js/hands.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
// ------------------------------------------------------------------ dimensions (gloved adult hand)
const FINGERS = {
// MCP joint (x, y, z) segment lengths radius knuckle..tip depth/width
index: { m: [-0.0315, 0.0860, 0.0], L: [0.044, 0.026, 0.022], r: [0.0096, 0.0076], d: 0.92 },
middle: { m: [-0.0105, 0.0900, 0.0], L: [0.049, 0.030, 0.023], r: [0.0096, 0.0076], d: 0.92 },
ring: { m: [0.0105, 0.0865, -0.0005], L: [0.045, 0.028, 0.022], r: [0.0094, 0.0074], d: 0.92 },
little: { m: [0.0315, 0.0770, -0.0020], L: [0.035, 0.021, 0.020], r: [0.0084, 0.0066], d: 0.93 }
index: { m: [-0.0315, 0.0860, 0.0], L: [0.045, 0.027, 0.022], r: [0.0096, 0.0071], d: 0.90 },
middle: { m: [-0.0105, 0.0900, 0.0], L: [0.050, 0.031, 0.023], r: [0.0097, 0.0072], d: 0.90 },
ring: { m: [0.0105, 0.0865, -0.0005], L: [0.046, 0.029, 0.022], r: [0.0093, 0.0069], d: 0.90 },
little: { m: [0.0315, 0.0770, -0.0020], L: [0.036, 0.022, 0.020], r: [0.0082, 0.0061], d: 0.92 }
};
const ORDER = ['index', 'middle', 'ring', 'little'];
const THUMB = { base: [-0.0225, 0.0175, -0.0075], L: [0.044, 0.031, 0.027], r: [0.0108, 0.0086] };
const BULGE = [0.0014, 0.0012, 0.0010]; // extra dorsal depth at the MCP, PIP and DIP knuckles
const BULGE = [0.0024, 0.0017, 0.0012]; // extra dorsal depth at the MCP, PIP and DIP knuckles (gloved knuckles read as bumps) // extra dorsal depth at the MCP, PIP and DIP knuckles

// ------------------------------------------------------------------ small vector helpers (load time only)
const V = (x, y, z) => new T.Vector3(x, y, z);
Expand Down Expand Up @@ -91,7 +91,7 @@
// vertex tints (linear multipliers of the glove map's 47, 48, 50): the knuckle panel and the low ribs on the back a
// little lighter than the charcoal leather (sRGB about 70-75), so the back of the hand reads without the ribs looking
// like metal rods
const TINT = { panel: [1.4, 1.36, 1.28], rib: [1.6, 1.55, 1.45] };
const TINT = { panel: [0.95, 0.94, 0.93], rib: [1.6, 1.55, 1.45] };
const tintOf = t => Array.isArray(t) ? t : [t || 1, t || 1, t || 1];
function Builder(R) { this.R = R; this.pos = [[], []]; this.nrm = [[], []]; this.uv = [[], []]; this.idx = [[], []]; this.col = [[], []]; }
Builder.prototype.tube = function (rings, o) {
Expand Down Expand Up @@ -400,14 +400,9 @@
info.thumbDirs = (tpose.dirs || []).map(d => { const v = V(d[0], d[1], d[2]).normalize(); return [+v.x.toFixed(4), +v.y.toFixed(4), +v.z.toFixed(4)]; });
B.tube(thumbRings(th), { capStart: true, u0: 0.25 });
B.tube(webRings(th, chains.index, cup), { radial: 8, capStart: true });
// the back of the glove: three raised seams from the cuff toward the gaps between the knuckles, and a stitched
// knuckle panel (a flat pad over the knuckle line)
const seamZ = y => 0.0118 + (y > 0.06 ? -0.0004 : 0.0003);
for (const sx of [-0.021, -0.007, 0.007, 0.021]) {
const pts = [];
for (let i = 0; i <= 5; i++) { const y = 0.012 + i * 0.011; const x = sx * (0.75 + 0.25 * i / 5); pts.push(V(x - 0.0008, y, seamZ(y) - cup * 0.0015 * (x / 0.03) * (x / 0.03))); }
B.tube(cordRings(pts, 0.0015, V(0, 0, 1)), { radial: 6, capStart: true, tint: TINT.rib });
}
// the back of the glove: a flat stitched knuckle panel (a thin pad over the knuckle line, a little darker). The
// raised cords that used to run up the back read as claw marks at arm's length and are gone; the stitching is in
// the normal map.
{
const pr = [];
const knk = ORDER.map(n => chains[n].joints[0]);
Expand All @@ -418,14 +413,29 @@
pr.push(V(x, 0.078 - 0.006 * Math.abs(k - 0.4), zi + 0.0118));
}
const rings = cordRings(pr, 0, V(0, 0, 1));
rings.forEach((r, i) => { const k = Math.sin((i / 6) * Math.PI); r.hw = 0.0085 + 0.0015 * k; r.hd = 0.0017; r.hp = 0.0017; r.e = 3; });
rings.forEach((r, i) => { const k = Math.sin((i / 6) * Math.PI); r.hw = 0.0075 + 0.0012 * k; r.hd = 0.0009; r.hp = 0.0009; r.e = 3.2; });
B.tube(rings, { radial: 8, capStart: true, tint: TINT.panel });
}
// glove cuff, and the sleeve with its turned-back end
const fa = pose.forearm || [0, -1, 0];
B.tube(armRings(fa, pose.sleeve || 0.12, 'glove'), { radial: R + 4, capStart: true, capEnd: true });
let sEnd = null;
if (!pose.noSleeve) { const sr = armRings(fa, pose.sleeve || 0.12, 'sleeve'); B.tube(sr, { radial: R + 4, mat: 1, capEnd: false, capStart: true, vScale: 12 }); sEnd = sr[sr.length - 1]; }
// wear: leather rubs pale and dry over the knuckles, along the finger backs and at the tips, and stays dark and
// oiled in the palm's creases (vertex colour multiplies the leather map; glove only)
{
const spots = [];
for (const n of ORDER) { const j = chains[n].joints, fr = chains[n].frames; for (let q = 0; q < 3; q++) spots.push([j[q].clone().addScaledVector(fr[q].Z, 0.009), q ? 0.006 : 0.008, q ? 0.32 : 0.42]); spots.push([j[3], 0.007, 0.3]); }
spots.push([th.joints[1].clone(), 0.008, 0.25], [th.joints[3].clone(), 0.007, 0.3]);
const P = B.pos[0], C = B.col[0], pv = new T.Vector3();
for (let i = 0, vi = 0; i < P.length; i += 3, vi++) {
pv.set(P[i], P[i + 1], P[i + 2]);
let w = 0; for (const [c, r, a] of spots) { const d2 = pv.distanceToSquared(c); if (d2 < r * r * 9) w += a * Math.exp(-d2 / (r * r)); }
const palm = pv.z < -0.006 && pv.y > 0.0 && pv.y < 0.085 ? 0.88 : 1;
const k = Math.min(1.45, 1 + w) * palm, t = C[vi];
C[vi] = [t[0] * k, t[1] * k * 0.985, t[2] * k * 0.96];
}
}
const g = B.geometry(pose.side === 'l');
if (sEnd) { // the sleeve's open end (tests check it never shows on screen): its centre and frame, and its vertices
info.sleeveEndVerts = [g.attributes.position.count - (R + 6), R + 5]; // the last ring (the start cap's centre vertex comes after it)
Expand Down Expand Up @@ -500,11 +510,11 @@
const gloveC = canvasTex(W, W, d => {
for (let i = 0; i < W * W; i++) {
const m = mott[i], g = grain[i], k = 0.8 + m * 0.32 + (g - 0.5) * 0.06;
d[i * 4] = 47 * k; d[i * 4 + 1] = 48 * k; d[i * 4 + 2] = 50 * k; d[i * 4 + 3] = 255;
d[i * 4] = 64 * k; d[i * 4 + 1] = 49 * k; d[i * 4 + 2] = 38 * k; d[i * 4 + 3] = 255; // worn brown leather (service gloves), not grey rubber
}
});
gloveC.encoding = T.sRGBEncoding;
const gloveR = canvasTex(W, W, d => { for (let i = 0; i < W * W; i++) { const v = (0.78 + (mott[i] - 0.55) * 0.15 + (grain[i] - 0.5) * 0.08) * 255; d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = v; d[i * 4 + 3] = 255; } });
const gloveR = canvasTex(W, W, d => { for (let i = 0; i < W * W; i++) { const v = (0.7 + (mott[i] - 0.55) * 0.22 + (grain[i] - 0.5) * 0.12) * 255; d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = v; d[i * 4 + 3] = 255; } });
const glove = new T.MeshStandardMaterial({ name: 'vmGlove', color: 0xffffff, vertexColors: true, map: gloveC, normalMap: gloveN, roughnessMap: gloveR, roughness: 0.82, metalness: 0, envMapIntensity: 0.5 });
glove.normalScale.set(0.9, 0.9);
// wool serge: field drab, darker than grass; a fine diagonal weave and fibre noise only (no ribs)
Expand Down
Loading
Loading