From 6c05a7d0c24204ac6b16bd5f416ca654442fd68b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 18:16:47 +0000 Subject: [PATCH 01/12] Midnight Ops shooting: learnable recoil pattern, per-gun head shots, honest first shot, touch-only aim assist - SMG, pistol and rifle kick in the same pattern every magazine (under 15 % random on top); moving and jumping make it worse - the first aimed shot is dead on only once the gun has settled; the pistol now blooms too - pistol head shots take two; the SMG fires its real 600 rounds a minute - aim assist only on touch screens; reloads can be broken off and keep the magazine once it is in - hit, head and kill markers drawn differently; low and empty ammo events - debrief: a skill rating out of 1000 (accuracy, head shots, time, deaths, times spotted), best kept per mission - player health comes back later and slower Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rM7Bycwoc6n2GG95HK7 --- e63334287a3deaa3/ironveil/es.js | 7 ++ e63334287a3deaa3/ironveil/index.html | 8 +- e63334287a3deaa3/ironveil/js/camera.js | 4 +- e63334287a3deaa3/ironveil/js/core.js | 47 ++++++----- e63334287a3deaa3/ironveil/js/hud.js | 22 +++-- e63334287a3deaa3/ironveil/js/menus.js | 6 +- e63334287a3deaa3/ironveil/js/mission.js | 28 ++++++- e63334287a3deaa3/ironveil/js/weapons.js | 106 +++++++++++++++++------- 8 files changed, 166 insertions(+), 62 deletions(-) diff --git a/e63334287a3deaa3/ironveil/es.js b/e63334287a3deaa3/ironveil/es.js index 9a19bd3b..dad69f5c 100644 --- a/e63334287a3deaa3/ironveil/es.js +++ b/e63334287a3deaa3/ironveil/es.js @@ -19,6 +19,13 @@ 'Sketch map of the area': 'Croquis de la zona', 'Game view': 'Vista del juego', 'PAUSED': 'PAUSA', 'Resume': 'Seguir', 'Restart from checkpoint': 'Volver al punto de control', 'Restart mission': 'Reiniciar la misión', 'Quit to map table': 'Salir a la mesa de mapas', 'Game': 'Juego', 'Video': 'Video', 'Audio': 'Audio', 'Look sensitivity': 'Sensibilidad de la vista', 'Aim sensitivity': 'Sensibilidad al apuntar', 'While aiming or scoped': 'Al apuntar o con la mira', + // ---- shooting (aim assist only on touch screens, debrief rating, hit and ammo cues) + 'Enemies slow to notice and miss more. Strong aim assist on touch screens.': 'Los enemigos tardan en verte y fallan más. Mucha ayuda de puntería en pantallas táctiles.', + 'A fair fight. Light aim assist on touch screens.': 'Una pelea pareja. Poca ayuda de puntería en pantallas táctiles.', + 'Sharp eyes, hard hits. Faint aim assist on touch screens.': 'Ven bien y pegan fuerte. Una pizca de ayuda de puntería en pantallas táctiles.', + 'Touch screens only (never with a mouse). 0 turns it off.': 'Solo en pantallas táctiles (nunca con ratón). 0 la apaga.', + 'Skill rating': 'Nota de habilidad', 'Skill rating of {n} or better': 'Nota de habilidad de {n} o más', 'Head shots': 'Tiros a la cabeza', 'Deaths': 'Muertes', + 'new best': 'nuevo récord', 'best {n}': 'récord {n}', 'par {t}': 'referencia {t}', 'Invert look up and down': 'Invertir la vista arriba y abajo', 'Aim assist strength': 'Fuerza de la ayuda de puntería', "Multiplies the difficulty's assist. 0 turns it off.": 'Multiplica la ayuda de la dificultad. 0 la apaga.', 'Auto-fire on target': 'Disparo automático sobre el blanco', 'Touch screens: fires when the reticle is on an enemy': 'Pantallas táctiles: dispara cuando la mira está sobre un enemigo', 'Subtitle size': 'Tamaño de subtítulos', 'Small': 'Chico', 'Medium': 'Mediano', 'Large': 'Grande', 'Blood effects': 'Efectos de sangre', 'Off: hits show dust puffs instead': 'Apagado: los impactos muestran polvo', diff --git a/e63334287a3deaa3/ironveil/index.html b/e63334287a3deaa3/ironveil/index.html index 28e83cf4..ff6213a5 100644 --- a/e63334287a3deaa3/ironveil/index.html +++ b/e63334287a3deaa3/ironveil/index.html @@ -348,9 +348,9 @@

The Farmhouse

Difficulty
- - - + + +
@@ -400,7 +400,7 @@

Settings

- + diff --git a/e63334287a3deaa3/ironveil/js/camera.js b/e63334287a3deaa3/ironveil/js/camera.js index a0327c84..263ee57a 100644 --- a/e63334287a3deaa3/ironveil/js/camera.js +++ b/e63334287a3deaa3/ironveil/js/camera.js @@ -69,7 +69,9 @@ // ---------------------------------------------------------------- aim assist const diff = () => (IV.mission && IV.mission.diff) || 0; - function assistScale() { return IV.settings.assist * (IV.touch ? T.assist.touchMul : 1); } + // aim assist is for thumbs: with a mouse there is none on any difficulty, whatever the Settings value says + function assistScale() { return IV.touch ? (+IV.settings.assist || 0) * T.assist.touchMul : 0; } + C.assistScale = assistScale; // the best enemy to snap toward: visible, alive, within the cone, closest to the centre of the view C.findTarget = function (cone, maxRange) { const AI = IV.ai; if (!AI) return null; diff --git a/e63334287a3deaa3/ironveil/js/core.js b/e63334287a3deaa3/ironveil/js/core.js index ebb9b94c..bc80c292 100644 --- a/e63334287a3deaa3/ironveil/js/core.js +++ b/e63334287a3deaa3/ironveil/js/core.js @@ -66,16 +66,19 @@ pitchMin: -1.25, pitchMax: 1.2, // rad sens: 0.0023 // rad per mouse pixel at sensitivity 1 }, - assist: { // aim assist (difficulty Recruit, Regular, Veteran) - snap: [0.85, 0.45, 0], // fraction of the angle to the target removed when aim is pressed + assist: { // aim assist (difficulty Recruit, Regular, Veteran). TOUCH SCREENS ONLY: with a mouse + // there is none on any difficulty (camera.js assistScale), whatever the setting says + snap: [0.85, 0.45, 0], // fraction of the angle to the target removed when aim is pressed (over the shoulder only) cone: [0.26, 0.17, 0], // rad, half-angle of the cone searched on aim - friction: [0.55, 0.35, 0], // look slowdown over a target while hip-firing (0..1) + friction: [0.4, 0.28, 0.15], // look slowdown over a target (0..1); light, so a thumb still has to track frictionCone: 0.06, // rad - touchMul: 1.35, // stronger on touch screens + touchMul: 1, // multiplier on touch screens (Settings 'Aim assist' 0..1 on top) scopeMaxRange: 60, // m: no assist at all on the scoped rifle past this snapTime: 0.12 // s, how long the snap takes (eased, not instant) }, - health: { max: 100, regenDelay: 4.5, regenRate: 22 }, // hp, s, hp/s + // the player. 100 hp against an enemy rifle hit of about 28-34 on Regular is 3 or 4 hits; nothing comes back until + // 6.5 s after the last hit, then 12 hp/s (empty to full in about 8 s more), so breaking contact matters + health: { max: 100, regenDelay: 6.5, regenRate: 12 }, // hp, s, hp/s ballistics: { v0: 800, // m/s rifle muzzle velocity drag: 0.00069, // 1/m, quadratic drag factor (k in dv/dt = -k|v|v): ~650 m/s left at 300 m @@ -85,22 +88,28 @@ smgV0: 280, pistolV0: 250 }, weapons: { - rifle: { dmg: 140, rpm: 0, mag: 5, reserve: 30, reload: 2.6, bolt: 1.05, spread: 0.0004, hipSpread: 0.03, recoil: 0.065, noise: 260, zoom: 4 }, - smg: { dmg: 30, fall: [20, 45, 0.6], rpm: 600, mag: 30, reserve: 120, reload: 2.2, spread: 0.008, hipSpread: 0.03, bloom: 0.0025, bloomMax: 0.04, recoil: 0.012, noise: 180 }, - pistol: { dmg: 45, fall: [15, 35, 0.5], rpm: 300, mag: 8, reserve: 32, reload: 1.6, spread: 0.006, hipSpread: 0.018, recoil: 0.03, noise: 42 }, + // dmg = hp per chest hit (a guard has 100, an MG gunner 120); head/limb = multipliers (default headMul/limbMul); + // fall = [m where falloff starts, m where it ends, share kept]; spread/hipSpread = cone half-angle (rad) aimed/from + // the hip; bloom per shot up to bloomMax, eased back at bloomBack per s once the trigger is let go + rifle: { dmg: 140, head: 2.6, limb: 0.65, rpm: 0, mag: 5, reserve: 30, reload: 2.6, bolt: 1.05, spread: 0.0004, hipSpread: 0.035, recoil: 0.065, noise: 260, zoom: 4 }, + smg: { dmg: 30, head: 2.6, limb: 0.6, fall: [20, 45, 0.6], rpm: 600, mag: 30, reserve: 120, reload: 2.2, spread: 0.006, hipSpread: 0.032, bloom: 0.0028, bloomMax: 0.04, bloomBack: 0.12, recoil: 0.012, noise: 180 }, + pistol: { dmg: 42, head: 2.0, limb: 0.6, fall: [15, 35, 0.5], rpm: 300, mag: 8, reserve: 32, reload: 1.6, spread: 0.005, hipSpread: 0.02, bloom: 0.004, bloomMax: 0.018, bloomBack: 0.09, recoil: 0.03, noise: 42 }, + firstShot: 0.22, // s: a shot aimed standing still, this long after the last one, goes exactly where the sights point // Recoil (rad). Each shot's kick splits in two: `keep` of it stays in the aim (you pull it back down yourself), - // the rest is a transient offset on the view that snaps in at `snap` 1/s (90/s: 95 % in about 35 ms), holds for `hold` s after the last - // shot, then eases away at `decay` 1/s. The offset is part of the aim: bullets go where the view points. - // pitch/yaw = per-shot kick from the hip; ads, crouch, prone multiply it; jitter = +- fraction per shot. - // A full-power bolt-action round: one heavy kick that is mostly gone after half a second. A pistol-calibre - // open-bolt SMG: small kicks on a schedule (sched: [until shot n, multiplier], ...), a slow sideways wander - // (wander amplitude, rate per shot) whose phase is re-rolled after a `pause` s break. A service pistol: a sharp - // snap that settles fast. + // the rest is a transient offset on the view that snaps in at `snap` 1/s (90/s: 95 % in about 33 ms), holds for + // `hold` s after the last shot, then eases away at `decay` 1/s (8/s: 95 % gone in about 0.37 s). The offset is + // part of the aim: bullets go where the view points. + // pitch = per-shot climb from the hip; yaw = per-shot sideways step; pat = the sideways PATTERN, [shot n, share of + // yaw] keyframes (linear between them), the same every magazine, so pulling down and across it is a skill that + // carries over; jitter = +- random share on top (pitch and yaw). sched = [until shot n, pitch multiplier], ...; + // a string of shots starts again from shot 1 once the gun has rested `pause` s. ads, crouch, prone multiply the + // kick; move adds this share at a full jog, air this share while off the ground (a jump). recoil: { - rifle: { pitch: 0.062, yaw: 0.010, keep: 0.30, snap: 90, hold: 0.1, decay: 8, ads: 0.62, crouch: 0.85, prone: 0.55, jitter: 0.12, clampP: 0.3, clampY: 0.12 }, - smg: { pitch: 0.0072, yaw: 0.0014, keep: 0.36, snap: 60, hold: 0.09, decay: 6.5, ads: 0.6, crouch: 0.85, prone: 0.55, jitter: 0.15, clampP: 0.22, clampY: 0.1, - sched: [[2, 1.25], [10, 1], [30, 0.45]], wander: 0.0036, wanderRate: 0.55, pause: 0.25 }, - pistol: { pitch: 0.026, yaw: 0.006, keep: 0.24, snap: 90, hold: 0.06, decay: 10, ads: 0.7, crouch: 0.9, prone: 0.7, jitter: 0.15, clampP: 0.2, clampY: 0.1 } + rifle: { pitch: 0.062, yaw: 0.008, pat: [[1, 0.6]], keep: 0.30, snap: 90, hold: 0.1, decay: 8, ads: 0.62, crouch: 0.85, prone: 0.55, move: 0.35, air: 1.2, jitter: 0.12, clampP: 0.3, clampY: 0.12, pause: 0.25 }, + smg: { pitch: 0.0072, yaw: 0.0024, keep: 0.34, snap: 90, hold: 0.1, decay: 8, ads: 0.6, crouch: 0.85, prone: 0.55, move: 0.35, air: 1.2, jitter: 0.12, clampP: 0.22, clampY: 0.1, + sched: [[3, 1.3], [10, 1], [30, 0.5]], + pat: [[1, 0.15], [4, 0.35], [7, 1], [11, 0.9], [13, -0.6], [18, -1.1], [21, -0.4], [24, 0.7], [30, 1]], pause: 0.25 }, + pistol: { pitch: 0.026, yaw: 0.005, pat: [[1, 0.5], [8, 0.9]], keep: 0.24, snap: 90, hold: 0.06, decay: 9, ads: 0.7, crouch: 0.9, prone: 0.7, move: 0.35, air: 1.2, jitter: 0.12, clampP: 0.2, clampY: 0.1, pause: 0.25 } }, headMul: 2.6, limbMul: 0.65, grenade: { fuse: 4.0, radius: 7, dmg: 220, throwV: 16, count: 2 }, diff --git a/e63334287a3deaa3/ironveil/js/hud.js b/e63334287a3deaa3/ironveil/js/hud.js index 296c1f7e..2cec4a34 100644 --- a/e63334287a3deaa3/ironveil/js/hud.js +++ b/e63334287a3deaa3/ironveil/js/hud.js @@ -6,11 +6,11 @@ 'use strict'; const $ = IV.$, W = IV.world, T = IV.TUNING; const H = IV.hud = {}; - let cv, g, dpr = 1, hitT = 0, hitKill = false, hitHead = false, dmgT = 0, sup = 0, barks = [], fleckT = 0, flecks = []; + let cv, g, dpr = 1, hitT = 0, hitLife = 0.22, hitKill = false, hitHead = false, dmgT = 0, sup = 0, barks = [], fleckT = 0, flecks = []; const P = IV.player; H.init = function () { cv = $('hudc'); g = cv.getContext('2d'); - IV.on('hitmarker', h => { hitT = 0.28; hitKill = h.kill; hitHead = h.head; }); + IV.on('hitmarker', h => { hitKill = !!h.kill; hitHead = !!h.head; hitT = hitLife = hitKill ? 0.42 : hitHead ? 0.32 : 0.22; }); IV.on('hurt', h => { dmgT = 1; fleckT = 1.2; makeFlecks(h.dmg); H.dmgDir = { a: P.hurtDir, x: h.from ? h.from.x : null, z: h.from ? h.from.z : null, t: 1.6 }; addArc(h); }); IV.on('shot', k => { H.kickK = Math.min(1.6, (H.kickK || 0) + (k === 'rifle' ? 1.2 : k === 'pistol' ? 0.8 : 0.45)); }); IV.on('suppressed', k => { sup = Math.min(1, sup + k * 0.6); }); @@ -135,7 +135,7 @@ if (C.mode === 'scope' && WP.scoped) drawScope(w, h, u); else if (WP.binoc && C.mode === 'scope') drawBinoc(w, h, u); else if (P.alive && !P.cine && !(C.mode === 'first' && (WP.aiming || WP.scoped))) drawReticle(cx, cy, u, dt); // always there from the hip (sprinting, jumping, reloading too); gone only down the sights - if (C.mode !== 'scope') drawHit(cx, cy, u); + drawHit(cx, cy, u); // through the scope too: a rifle kill is confirmed where you are looking drawGrenadeWarn(cx, cy, u); drawAwareness(cx, cy, u); drawCompass(w, u); @@ -192,13 +192,19 @@ } g.shadowBlur = 0; } - // hit marker: four ticks round the centre, white on a hit, warm on a kill, red on a head kill; shown in ADS too + // hit markers, three kinds that read at a glance: a HIT is four short thin white ticks; a HEAD hit is thicker amber + // ticks; a KILL is long heavy red ticks that spread out (a head kill adds a red ring). Shown down the sights too. function drawHit(cx, cy, u) { if (hitT <= 0) return; - const k = 6 * u + (0.28 - hitT) * 20 * u, c = hitKill ? (hitHead ? '#ff5a3c' : '#f2e2c0') : '#fff'; - g.strokeStyle = c; g.lineWidth = (hitKill ? 3 : 2) * u; g.shadowColor = 'rgba(0,0,0,.8)'; g.shadowBlur = 3 * u; - g.beginPath(); for (const [a, b] of [[-1, -1], [1, -1], [-1, 1], [1, 1]]) { g.moveTo(cx + a * k, cy + b * k); g.lineTo(cx + a * (k + 8 * u), cy + b * (k + 8 * u)); } g.stroke(); - g.shadowBlur = 0; + const age = hitLife - hitT, fade = Math.min(1, hitT / 0.12); + const kind = hitKill ? 'kill' : hitHead ? 'head' : 'hit'; + const c = kind === 'kill' ? '255,74,46' : kind === 'head' ? '255,194,58' : '255,255,255'; + const k = (kind === 'kill' ? 7 : 6) * u + age * (kind === 'kill' ? 30 : 16) * u, len = (kind === 'kill' ? 13 : kind === 'head' ? 10 : 7) * u; + g.strokeStyle = `rgba(${c},${fade.toFixed(3)})`; g.lineWidth = (kind === 'kill' ? 3.6 : kind === 'head' ? 3 : 2) * u; g.lineCap = 'round'; + g.shadowColor = 'rgba(0,0,0,.85)'; g.shadowBlur = 3 * u; + g.beginPath(); for (const [a, b] of [[-1, -1], [1, -1], [-1, 1], [1, 1]]) { g.moveTo(cx + a * k, cy + b * k); g.lineTo(cx + a * (k + len), cy + b * (k + len)); } g.stroke(); + if (kind === 'kill' && hitHead) { g.lineWidth = 2.2 * u; g.beginPath(); g.arc(cx, cy, k + len + 5 * u, 0, 6.29); g.stroke(); } + g.shadowBlur = 0; g.lineCap = 'butt'; } // awareness: one arc per soldier who has noticed something, placed round the reticle in his direction function drawAwareness(cx, cy, u) { diff --git a/e63334287a3deaa3/ironveil/js/menus.js b/e63334287a3deaa3/ironveil/js/menus.js index eb347f7d..3bd1e861 100644 --- a/e63334287a3deaa3/ironveil/js/menus.js +++ b/e63334287a3deaa3/ironveil/js/menus.js @@ -88,7 +88,11 @@ $('rMedalTx').textContent = IV.t(s.medal === 'gold' ? 'Gold' : s.medal === 'silver' ? 'Silver' : 'Bronze'); $('rDiff').textContent = IV.t(IV.mission.DIFF[s.diff].name); $('rCrit').innerHTML = s.crit.map(c => `
  • ${c.text}
  • `).join(''); - const rows = [['Time', IV.fmtTime(s.time)], ['Accuracy', s.shots ? s.acc + '%' : '—'], ['Times spotted', s.spotted], ['Enemies down', s.kills], ['Takedowns', s.takedowns], ['Optional objectives', s.optional + ' / ' + s.optionalTotal]]; + const P = s.scoreParts || {}, pt = v => v != null ? ` +${v}` : ''; + const rows = [['Skill rating', `${s.score} / 1000` + (s.newBest && s.prevBest ? ` ${IV.t('new best')}` : s.prevBest ? ` ${IV.t('best {n}', { n: s.prevBest })}` : '')], + ['Accuracy', (s.shots ? s.acc + '%' : '—') + pt(P.acc)], ['Head shots', (s.hits ? s.headPct + '% (' + s.headHits + ')' : '—') + pt(P.head)], + ['Time', IV.fmtTime(s.time) + ` ${IV.t('par {t}', { t: IV.fmtTime(s.par) })}` + pt(P.time)], ['Deaths', s.deaths + pt(P.deaths)], ['Times spotted', s.spotted + pt(P.spotted)], + ['Enemies down', s.kills], ['Takedowns', s.takedowns], ['Optional objectives', s.optional + ' / ' + s.optionalTotal]]; $('rStats').innerHTML = rows.map(r => `${IV.t(r[0])}${r[1]}`).join(''); const next = IV.missions.list.find(d => d.num === def.num + 1 && IV.playable(d.id)); $('rNext').hidden = false; diff --git a/e63334287a3deaa3/ironveil/js/mission.js b/e63334287a3deaa3/ironveil/js/mission.js index 9451b892..33626df6 100644 --- a/e63334287a3deaa3/ironveil/js/mission.js +++ b/e63334287a3deaa3/ironveil/js/mission.js @@ -116,27 +116,53 @@ }; M.restoreCheckpoint = function () { const cp = IV.save.cp; + const deaths = IV.weapons.stats.deaths || 0; // a retry keeps counting this run's deaths if (cp && cp.mission === M.def.id && cp.idx > 0) M.begin(cp.idx, cp.data); else M.begin(0, null); + IV.weapons.stats.deaths = Math.max(deaths, IV.weapons.stats.deaths || 0); }; M.fail = function (reason) { if (M.failed || M.finished) return; M.failed = true; M.on = false; IV.emit('missionFailed', reason); }; + // The skill rating (0-1000) on the debrief: what a better player does better, each part capped so no single one + // carries a run. Accuracy 250 (60 % of rounds on target is full marks), head shots 200 (40 % of hits), time 200 + // (half the par time is full, par is 100, one and a half par is 0), deaths 200 (minus 100 each), times spotted 150 + // (minus 50 each). A run without a shot fired keeps full accuracy and head-shot marks: a clean ghost is skill too. + M.RATE_GOLD = 700; + M.PAR = { bootcamp: 360, nightdrop: 900 }; + M.rate = function (s, def) { + const par = def.par || M.PAR[def.id] || 600, cl = IV.clamp; + const p = { + acc: s.shots ? Math.round(250 * cl(s.hits / s.shots / 0.6, 0, 1)) : 250, + head: s.hits ? Math.round(200 * cl(s.headHits / s.hits / 0.4, 0, 1)) : 200, + time: Math.round(200 * cl((1.5 * par - s.time) / par, 0, 1)), + deaths: Math.max(0, 200 - 100 * s.deaths), + spotted: Math.max(0, 150 - 50 * (s.spotted || 0)) + }; + s.scoreParts = p; s.score = p.acc + p.head + p.time + p.deaths + p.spotted; s.par = par; + return s.score; + }; M.complete = function () { if (M.finished || M.failed) return; M.finished = true; M.on = false; const st = IV.weapons.stats, def = M.def; const s = { time: M.time, shots: st.shots, hits: st.hits, acc: st.shots ? Math.round(st.hits / st.shots * 100) : 0, kills: st.kills, heads: st.heads, takedowns: st.takedowns, spotted: IV.ai.spottedCount, optional: M.objs.filter(o => o.optional && o.state === 'done').length, optionalTotal: def.optionalTotal || M.objs.filter(o => o.optional).length, diff: M.diff }; + s.headHits = st.headHits || 0; s.deaths = st.deaths || 0; s.headPct = s.hits ? Math.round(s.headHits / s.hits * 100) : 0; + M.rate(s, def); const crit = (def.medals || []).map(c => ({ text: IV.t(c.text, c.vars), ok: !!c.ok(s, M) })); + crit.push({ text: IV.t('Skill rating of {n} or better', { n: M.RATE_GOLD }), ok: s.score >= M.RATE_GOLD }); const n = crit.filter(c => c.ok).length; - s.medal = n >= 3 ? 'gold' : n >= 2 ? 'silver' : 'bronze'; s.crit = crit; + s.medal = n >= crit.length ? 'gold' : n >= crit.length - 1 ? 'silver' : 'bronze'; s.crit = crit; const rec = IV.save.missions[def.id] = IV.save.missions[def.id] || {}; const rank = { bronze: 1, silver: 2, gold: 3 }; rec.done = true; rec.last = s.medal; if (!rec.medal || rank[s.medal] > rank[rec.medal]) rec.medal = s.medal; if (!rec.best || s.time < rec.best) rec.best = Math.round(s.time); + // the best skill rating and the run that set it (fields added to the save; older saves simply lack them) + s.prevBest = rec.bestScore || 0; rec.lastScore = s.score; + if (!rec.bestScore || s.score > rec.bestScore) { rec.bestScore = s.score; rec.bestRun = { score: s.score, acc: s.acc, headPct: s.headPct, time: Math.round(s.time), deaths: s.deaths, spotted: s.spotted, diff: s.diff }; s.newBest = true; } if (def.id === 'bootcamp') IV.save.tut = true; if (IV.save.cp && IV.save.cp.mission === def.id) IV.save.cp = null; IV.persist(); diff --git a/e63334287a3deaa3/ironveil/js/weapons.js b/e63334287a3deaa3/ironveil/js/weapons.js index ac5c4688..3d34493d 100644 --- a/e63334287a3deaa3/ironveil/js/weapons.js +++ b/e63334287a3deaa3/ironveil/js/weapons.js @@ -9,10 +9,17 @@ const WP = IV.weapons = { cur: 'rifle', aiming: false, scoped: false, binoc: false, busyThrow: null, firingRecently: false, hideSlungWhenAiming: true, inv: null, reloadT: 0, boltT: 0, cool: 0, bloom: 0, burst: 0, lastFire: -9, bullets: [], throws: [], wind: { x: 1.6, z: 0.4 }, - stats: { shots: 0, hits: 0, kills: 0, heads: 0, takedowns: 0 }, models: {}, tagged: new Set(), takedownTarget: null + stats: { shots: 0, hits: 0, kills: 0, heads: 0, takedowns: 0, headHits: 0, deaths: 0 }, models: {}, tagged: new Set(), takedownTarget: null }; const NAMES = { rifle: 'Scoped rifle', smg: 'Submachine gun', pistol: 'Pistol' }; WP.name = k => IV.t(NAMES[k] || k); + // deaths count toward the debrief rating: kept in the run's stats and in the saved checkpoint, so the retry that + // follows (mission.js restoreCheckpoint) and a Continue after closing the page both still know + IV.on('playerDied', () => { + WP.stats.deaths = (WP.stats.deaths || 0) + 1; + const cp = IV.save.cp, M = IV.mission; + if (cp && M.def && cp.mission === M.def.id && cp.data && cp.data.stats) { cp.data.stats.deaths = WP.stats.deaths; IV.persist(); } + }); // ---------------------------------------------------------------- ballistics // Step a round with quadratic drag relative to the air (so wind drifts it) and gravity. @@ -57,7 +64,7 @@ WP.has = loadout.has || { rifle: true, smg: true, pistol: true }; WP.cur = loadout.start || 'smg'; WP.aiming = WP.scoped = WP.binoc = false; WP.busyThrow = null; WP.reloadT = WP.boltT = WP.cool = WP.bloom = 0; WP.bullets.length = 0; WP.throws.length = 0; - WP.stats = { shots: 0, hits: 0, kills: 0, heads: 0, takedowns: 0 }; WP.tagged = new Set(); + WP.stats = { shots: 0, hits: 0, kills: 0, heads: 0, takedowns: 0, headHits: 0, deaths: 0 }; WP.tagged = new Set(); WP.lowCued = {}; // models on the hero const A = P.actor; for (const k in WP.models) A.detach(WP.models[k]); @@ -77,6 +84,7 @@ } WP.equip = function (k) { if (!WP.has[k] || k === WP.cur || WP.busyThrow) return; + if (WP.reloadT > 0) WP.cancelReload(); WP.cur = k; WP.reloadT = 0; WP.boltT = 0; WP.cool = 0.35; WP.bloom = 0; WP.spread = null; equipModels(); P.actor.setUpper(null); IV.audio && IV.audio.play('equip'); @@ -148,16 +156,18 @@ } if (hitEnt) { const hx = x0 + ux * best, hy = y0 + uy * best, hz = z0 + uz * best; - const mul = b.flat ? (hitZone === 'head' ? 1.4 : 1) : hitZone === 'head' ? WT.headMul : hitZone === 'limb' ? WT.limbMul : 1; + const ws = b.wk && WT[b.wk] || WT; // the player's rounds carry their gun's zone multipliers + const mul = b.flat ? (hitZone === 'head' ? 1.4 : 1) : hitZone === 'head' ? (ws.head || WT.headMul) : hitZone === 'limb' ? (ws.limb || WT.limbMul) : 1; const wasAlive = hitEnt.alive; const fo = b.fall ? IV.clamp(1 - (b.travelled - b.fall[0]) / (b.fall[1] - b.fall[0]), 0, 1) * (1 - b.fall[2]) + b.fall[2] : 1; hitEnt.hit(hitZone, b.dmg * mul * fo, { x: ux, y: uy, z: uz }, b.owner ? b.owner.pos : null, b); IV.fx.blood(hx, hy, hz, ux, uy, uz, hitZone === 'head' || b.dmg > 100); if (b.owner === WP.playerEnt) { - WP.stats.hits++; + WP.stats.hits++; if (hitZone === 'head') WP.stats.headHits++; const killed = wasAlive && !hitEnt.alive; if (killed) { WP.stats.kills++; if (hitZone === 'head') WP.stats.heads++; } - IV.emit('hitmarker', { kill: killed, head: hitZone === 'head' }); + // three markers the HUD draws differently (hit, head, kill); sounds can key off the same event + IV.emit('hitmarker', { kill: killed, head: hitZone === 'head', zone: hitZone, kind: b.wk }); IV.audio && IV.audio.play(killed ? 'killThud' : 'hitThud'); } b.alive = false; return; @@ -193,11 +203,12 @@ function fire() { const k = WP.cur, w = WT[k], inv = WP.inv[k], c = W.camera, d = IV.camera.lookDir; if (inv.mag <= 0) { - IV.audio && IV.audio.play('dry'); WP.cool = 0.3; + IV.audio && IV.audio.play('dry'); WP.cool = 0.3; IV.emit('ammo', { kind: k, state: 'empty', res: inv.res }); if (inv.res > 0) startReload(); else { const alt = ['pistol', 'smg', 'rifle'].find(x => x !== k && WP.has[x] && WP.inv[x] && WP.inv[x].mag + WP.inv[x].res > 0); if (alt) WP.equip(alt); } // out of rounds: draw the next gun that has any return; } + const restedFor = IV.time - WP.lastFire; inv.mag--; WP.stats.shots++; WP.lastFire = IV.time; WP.firingRecently = true; let ox, oy, oz, dx, dy, dz; const model = WP.models[k], muzzle = model.userData.muzzle; @@ -225,14 +236,17 @@ } // spread: tight aimed, loose from the hip, bloom for the SMG, worse while moving let sp = WP.currentSpread(); - if ((WP.aiming || WP.scoped) && P.speed < 0.3 && (k !== 'smg' || WP.burst === 0)) sp = 0; // first aimed shot, standing still: dead on + // the first aimed shot standing still, with the gun settled (WT.firstShot s since the last round), goes dead on: + // tapping and short bursts with a beat between them keep that; holding the trigger or spamming does not + const settled = restedFor > WT.firstShot; + if ((WP.aiming || WP.scoped) && P.speed < 0.3 && P.grounded !== false && settled) sp = 0; const a = Math.random() * 6.283, r = Math.sqrt(Math.random()) * sp; const ux = new THREE.Vector3(dx, dy, dz), ortho1 = new THREE.Vector3().crossVectors(ux, Math.abs(dy) < 0.9 ? new THREE.Vector3(0, 1, 0) : new THREE.Vector3(1, 0, 0)).normalize(), ortho2 = new THREE.Vector3().crossVectors(ux, ortho1); ux.addScaledVector(ortho1, Math.cos(a) * r).addScaledVector(ortho2, Math.sin(a) * r).normalize(); const v0 = k === 'rifle' ? BL.v0 : k === 'smg' ? BL.smgV0 : BL.pistolV0; // the round flies along the sight line; its tracer is drawn leaving the visible muzzle and merging onto that line // over the first few metres (vis: muzzle minus origin, faded out by fx.js) - WP.spawnBullet({ x: ox, y: oy, z: oz, vx: ux.x * v0, vy: ux.y * v0, vz: ux.z * v0, drag: k === 'rifle' ? BL.drag : 0.0012, dmg: w.dmg, fall: w.fall, owner: WP.playerEnt, team: 'us', tracer: k === 'smg' && (WP.stats.shots % 3 === 0), life: k === 'rifle' ? 2.5 : 1.2, vis: WP.scoped ? null : { x: mz.x - ox, y: mz.y - oy, z: mz.z - oz } }); // tracer rounds every third in the SMG magazine + WP.spawnBullet({ x: ox, y: oy, z: oz, vx: ux.x * v0, vy: ux.y * v0, vz: ux.z * v0, drag: k === 'rifle' ? BL.drag : 0.0012, dmg: w.dmg, fall: w.fall, wk: k, owner: WP.playerEnt, team: 'us', tracer: k === 'smg' && (WP.stats.shots % 3 === 0), life: k === 'rifle' ? 2.5 : 1.2, vis: WP.scoped ? null : { x: mz.x - ox, y: mz.y - oy, z: mz.z - oz } }); // tracer rounds every third in the SMG magazine // effects IV.fx.muzzle(mz.x, mz.y, mz.z, ux.x, ux.y, ux.z, k === 'rifle', !!(IV.fp && IV.fp.on() && !WP.scoped)); const fpArms = IV.fp && IV.fp.realActive && IV.fp.realActive(); // first person on the arms rig: its clip events throw the cases @@ -245,30 +259,44 @@ // wander, pistol a sharp snap; a kept part stays in the aim, the rest springs back after the trigger is let go const motion = IV.settings.motion ? 0.6 : 1; recoil(k); - if (k === 'smg') WP.bloom = Math.min(w.bloomMax, WP.bloom + w.bloom); + if (w.bloom) WP.bloom = Math.min(w.bloomMax, WP.bloom + w.bloom); IV.camera.shake((k === 'rifle' ? 0.12 : 0.05) * motion); IV.fp && IV.fp.recoil(k === 'rifle' ? 1 : k === 'smg' ? 0.35 : 0.6); // the bolt: as long as the arms' fire and bolt clips take in first person, else the tuning value if (k === 'rifle') { const fl = IV.fp && IV.fp.clipLen ? IV.fp.clipLen(WP.aiming || WP.scoped ? 'fireAds' : 'fire', 'rifle') + IV.fp.clipLen('boltCycle', 'rifle') : 0; WP.boltT = fl > 0.3 && IV.fp.on() ? fl : WT.rifle.bolt; if (!fpArms) setTimeout(() => IV.audio && IV.audio.play('bolt'), 330); } - WP.cool = w.rpm ? 60 / w.rpm : 0.18; + WP.cool = (WP.cool > -T.step ? Math.min(0, WP.cool) : 0) + (w.rpm ? 60 / w.rpm : 0.18); // carry the part of a step already spent, so 600 rpm is 600 at 60 steps a second + lowCue(k); IV.setUpper(P.actor, k === 'rifle' ? 'boltCycle' : 'fire'); IV.emit('shot', k); } // one shot's kick. WP.recN counts rounds in the current string: it and the SMG's wander phase start again only once // the gun has rested for spec.pause (quick taps continue the same path; a real pause starts from a fresh side) - WP.recPhase = 0; WP.lastShotAt = -9; WP.recN = 0; + WP.lastShotAt = -9; WP.recN = 0; + // the sideways pattern: linear between the [shot, share] keyframes, held past the last one + function patAt(pat, n) { + if (!pat || !pat.length) return 0; + if (n <= pat[0][0]) return pat[0][1]; + for (let i = 1; i < pat.length; i++) if (n <= pat[i][0]) { const a = pat[i - 1], b = pat[i]; return a[1] + (b[1] - a[1]) * (n - a[0]) / (b[0] - a[0]); } + return pat[pat.length - 1][1]; + } + WP.patAt = patAt; + WP.recoilMul = function (k) { // what stance, the sights, moving and jumping do to a kick + const R = WT.recoil[k]; if (!R) return 1; + let m = (WP.aiming || WP.scoped ? R.ads : 1) * (P.stance === 'prone' ? R.prone : P.stance === 'crouch' ? R.crouch : 1); + m *= 1 + (R.move || 0) * IV.clamp((P.speed - 0.3) / (T.move.run - 0.3), 0, 1.3) + (P.grounded === false && !P.vault ? R.air || 0 : 0); + return m; + }; function recoil(k) { const R = WT.recoil[k]; if (!R) return; const rest = IV.time - WP.lastShotAt; WP.lastShotAt = IV.time; - if (rest > (R.pause || 0.25) || WP.recKind !== k) { WP.recN = 0; WP.recPhase = Math.random() * 6.283; WP.recKind = k; } + if (rest > (R.pause || 0.25) || WP.recKind !== k) { WP.recN = 0; WP.recKind = k; } const n = ++WP.recN; WP.burst++; - let m = (WP.aiming || WP.scoped ? R.ads : 1) * (P.stance === 'prone' ? R.prone : P.stance === 'crouch' ? R.crouch : 1); - if (R.sched) { for (const s of R.sched) if (n <= s[0]) { m *= s[1]; break; } if (n > R.sched[R.sched.length - 1][0]) m *= R.sched[R.sched.length - 1][1]; } - const j = 1 + (Math.random() * 2 - 1) * R.jitter; - let yaw; - if (R.wander && n > 3) yaw = Math.sin(n * R.wanderRate + WP.recPhase) * R.wander + (Math.random() - 0.5) * R.yaw; - else yaw = (Math.random() - 0.5) * 2 * R.yaw; - IV.camera.kick(R.pitch * m * j, yaw * m, R); + let m = WP.recoilMul(k); + if (R.sched) { let s = R.sched[R.sched.length - 1][1]; for (const e of R.sched) if (n <= e[0]) { s = e[1]; break; } m *= s; } + // the same climb and the same sideways walk every magazine, with a little random on top (R.jitter) + const jp = 1 + (Math.random() * 2 - 1) * R.jitter, jy = (Math.random() * 2 - 1) * R.jitter; + const yaw = R.yaw * (patAt(R.pat, n) * (1 + jy) + jy * 0.5); + IV.camera.kick(R.pitch * m * jp, -yaw * m, R); // a positive pattern share walks the view right (yaw is + to the left) } WP.recoilShot = recoil; // the spread cone (rad). spreadTarget is where the cone wants to be right now (aimed or hip, stance, how fast you @@ -280,17 +308,32 @@ let sp = ads ? w.spread : w.hipSpread; sp *= 1 + (ads ? 0.9 : 0.7) * IV.clamp((P.speed - 0.3) / (T.move.run - 0.3), 0, 1) + (P.sprinting ? 0.3 : 0); // a jog about 70 % more, a sprint 100 % if (P.stance === 'crouch') sp *= 0.8; else if (P.stance === 'prone') sp *= 0.6; - if (k === 'smg') sp += WP.bloom * (ads ? 0.7 : 1); + if (w.bloom) sp += WP.bloom * (ads ? 0.7 : 1); if (P.grounded === false && !P.vault) sp += 0.022; // airborne (a jump): wide open return sp; }; WP.spread = null; WP.currentSpread = function () { return WP.spread == null ? WP.spreadTarget() : WP.spread; }; function stepSpread(dt) { const t = WP.spreadTarget(); WP.spread = WP.spread == null ? t : WP.spread + (t - WP.spread) * (1 - Math.exp(-18 * dt)); } + // a cue the moment the magazine runs low (a quarter or less) and when it runs dry; the HUD shows it, audio can hook it + function lowCue(k) { + const inv = WP.inv[k], cap = WT[k].mag; WP.lowCued = WP.lowCued || {}; + if (inv.mag === 0) IV.emit('ammo', { kind: k, state: 'out', res: inv.res }); + else if (cap > 1 && inv.mag <= Math.max(1, Math.floor(cap * 0.27)) && !WP.lowCued[k]) { WP.lowCued[k] = true; IV.emit('ammo', { kind: k, state: 'low', res: inv.res }); } + if (inv.mag > Math.floor(cap * 0.27)) WP.lowCued[k] = false; + } + // a reload can be broken off (sprint, switch weapons, or pull the trigger with rounds still in the gun); whatever + // stage it finished stays done: once the new magazine is in (magIn: the arms' clip event in first person, 60 % of + // the reload time otherwise) its rounds are in the gun + WP.cancelReload = function () { + if (WP.reloadT <= 0) return; + WP.reloadT = 0; WP.fpReload = null; WP.reloadStage = null; P.actor.setUpper(null); IV.fp && IV.fp.cancelAction && IV.fp.cancelAction(); + IV.emit('reloadCancel', WP.cur); + }; function startReload() { const k = WP.cur, inv = WP.inv[k]; if (WP.reloadT > 0 || inv.res <= 0 || inv.mag >= WT[k].mag) return; - WP.reloadT = WT[k].reload; WP.scoped = false; + WP.reloadT = WT[k].reload; WP.scoped = false; WP.reloadStage = { total: WT[k].reload, magged: false }; // first person on the arms rig: rounds go in at the clip's 'magIn' and the reload ends at its 'done' (js/fp.js); // the timer is only a safety net a little past the clip's end const rl = IV.fp && IV.fp.onReload ? IV.fp.onReload(inv.mag === 0) : 0; @@ -300,8 +343,8 @@ if (!WP.fpReload) IV.audio && IV.audio.play('reload', { kind: k }); } function finishReload() { - if (!(WP.fpReload && WP.fpReload.magged)) { const k = WP.cur, inv = WP.inv[k], need = WT[k].mag - inv.mag, take = Math.min(need, inv.res); inv.mag += take; inv.res -= take; } - WP.fpReload = null; P.actor.setUpper(WP.aiming ? 'aimIdle' : null); + if (!(WP.fpReload && WP.fpReload.magged) && !(WP.reloadStage && WP.reloadStage.magged)) { const k = WP.cur, inv = WP.inv[k], need = WT[k].mag - inv.mag, take = Math.min(need, inv.res); inv.mag += take; inv.res -= take; } + WP.fpReload = null; WP.reloadStage = null; WP.lowCued[WP.cur] = false; P.actor.setUpper(WP.aiming ? 'aimIdle' : null); } WP.magIn = function () { if (WP.reloadT > 0 && WP.fpReload && !WP.fpReload.magged) { const k = WP.cur, inv = WP.inv[k], take = Math.min(WT[k].mag - inv.mag, inv.res); inv.mag += take; inv.res -= take; WP.fpReload.magged = true; } }; WP.reloadDone = function () { if (WP.reloadT > 0 && WP.fpReload) { WP.reloadT = 0; finishReload(); } }; @@ -449,11 +492,16 @@ WP.step = function (dt) { const I = IV.input; IV.camera.stepRecoil && IV.camera.stepRecoil(dt); - WP.cool = Math.max(0, WP.cool - dt); WP.throwCool = Math.max(0, (WP.throwCool || 0) - dt); + WP.cool = Math.max(-T.step, WP.cool - dt); WP.throwCool = Math.max(0, (WP.throwCool || 0) - dt); if (WP.boltT > 0) { WP.boltT -= dt; if (WP.boltT <= 0) P.actor.setUpper(WP.aiming ? 'aimIdle' : null); } - if (WP.reloadT > 0 && P.sprinting) { WP.reloadT = 0; WP.fpReload = null; P.actor.setUpper(null); IV.fp && IV.fp.cancelAction && IV.fp.cancelAction(); } // sprinting cancels a reload (no rounds added) - if (WP.reloadT > 0) { WP.reloadT -= dt; if (WP.reloadT <= 0) finishReload(); } - WP.bloom = Math.max(0, WP.bloom - dt * (I.held('fire') ? 0.01 : 0.12)); + if (WP.reloadT > 0 && P.sprinting) WP.cancelReload(); // sprinting breaks off a reload (a magazine already in stays in) + if (WP.reloadT > 0) { + WP.reloadT -= dt; + // no arms clip to say when the magazine goes in: it goes in at 60 % of the reload time + const rs = WP.reloadStage; if (rs && !WP.fpReload && !rs.magged && WP.reloadT <= rs.total * 0.4) { const k = WP.cur, inv = WP.inv[k], take = Math.min(WT[k].mag - inv.mag, inv.res); inv.mag += take; inv.res -= take; rs.magged = true; } + if (WP.reloadT <= 0) finishReload(); + } + WP.bloom = Math.max(0, WP.bloom - dt * (I.held('fire') ? 0.01 : (WT[WP.cur].bloomBack || 0.12))); if (!I.held('fire')) WP.burst = 0; WP.firingRecently = IV.time - WP.lastFire < 0.6; stepSpread(dt); @@ -498,10 +546,12 @@ else if (!wantAim && IV.upperOf(P.actor) === 'aimIdle') P.actor.setUpper(null); // reload if (I.pressed('reload')) startReload(); + // pulling the trigger with rounds still in the gun breaks off a reload and fires + if (I.pressed('fire') && WP.reloadT > 0 && WP.inv[WP.cur].mag > 0 && !P.sprinting) { WP.cancelReload(); WP.cool = Math.max(WP.cool, 0.12); } // fire const auto = WT[WP.cur].rpm >= 400; const trig = auto ? I.held('fire') : I.pressed('fire'); - if (trig && WP.cool <= 0 && WP.reloadT <= 0 && WP.boltT <= 0 && !P.sprinting && !(P.sprintOutT > 0)) fire(); + if (trig && WP.cool <= 1e-6 && WP.reloadT <= 0 && WP.boltT <= 0 && !P.sprinting && !(P.sprintOutT > 0)) fire(); else if (trig && P.sprinting) P.sprinting = false; }; From 85ba4113bdd1d89db75c3bcd2db35c5650452531 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 18:20:56 +0000 Subject: [PATCH 02/12] Midnight Ops shooting: a wider sideways walk in the SMG's recoil pattern Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rM7Bycwoc6n2GG95HK7 --- e63334287a3deaa3/ironveil/js/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e63334287a3deaa3/ironveil/js/core.js b/e63334287a3deaa3/ironveil/js/core.js index bc80c292..86fea6ab 100644 --- a/e63334287a3deaa3/ironveil/js/core.js +++ b/e63334287a3deaa3/ironveil/js/core.js @@ -106,7 +106,7 @@ // kick; move adds this share at a full jog, air this share while off the ground (a jump). recoil: { rifle: { pitch: 0.062, yaw: 0.008, pat: [[1, 0.6]], keep: 0.30, snap: 90, hold: 0.1, decay: 8, ads: 0.62, crouch: 0.85, prone: 0.55, move: 0.35, air: 1.2, jitter: 0.12, clampP: 0.3, clampY: 0.12, pause: 0.25 }, - smg: { pitch: 0.0072, yaw: 0.0024, keep: 0.34, snap: 90, hold: 0.1, decay: 8, ads: 0.6, crouch: 0.85, prone: 0.55, move: 0.35, air: 1.2, jitter: 0.12, clampP: 0.22, clampY: 0.1, + smg: { pitch: 0.0072, yaw: 0.0032, keep: 0.34, snap: 90, hold: 0.1, decay: 8, ads: 0.6, crouch: 0.85, prone: 0.55, move: 0.35, air: 1.2, jitter: 0.12, clampP: 0.22, clampY: 0.1, sched: [[3, 1.3], [10, 1], [30, 0.5]], pat: [[1, 0.15], [4, 0.35], [7, 1], [11, 0.9], [13, -0.6], [18, -1.1], [21, -0.4], [24, 0.7], [30, 1]], pause: 0.25 }, pistol: { pitch: 0.026, yaw: 0.005, pat: [[1, 0.5], [8, 0.9]], keep: 0.24, snap: 90, hold: 0.06, decay: 9, ads: 0.7, crouch: 0.9, prone: 0.7, move: 0.35, air: 1.2, jitter: 0.12, clampP: 0.2, clampY: 0.1, pause: 0.25 } From b87d1a3790db8c2ac0a31424a82bfb9da0dfbf2a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 18:40:27 +0000 Subject: [PATCH 03/12] Midnight Ops enemies: harder, fairer fights Guards answer fire where they stand on first contact instead of turning their backs to run for cover, hand turns to fire on quickly, and fire longer bursts. Accuracy now follows seconds of unbroken sight, range, how you move across their sights, the light on you, smoke and their own state. Rifle hits do 34 on Regular. Squads flank and throw a shouted grenade at a spot you hold, two men push your last known spot while the rest cover it, the wounded limp or crawl. New calls tell you what they are about to do (Spanish added). The squadmate covers rather than carries the fight. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rMA1ShmNuiCqMrmnvkS --- e63334287a3deaa3/ironveil/es.js | 12 +- e63334287a3deaa3/ironveil/js/ai.js | 291 ++++++++++++++++++++------- e63334287a3deaa3/ironveil/js/ally.js | 14 +- e63334287a3deaa3/ironveil/js/core.js | 30 ++- 4 files changed, 264 insertions(+), 83 deletions(-) diff --git a/e63334287a3deaa3/ironveil/es.js b/e63334287a3deaa3/ironveil/es.js index 9a19bd3b..7302f4df 100644 --- a/e63334287a3deaa3/ironveil/es.js +++ b/e63334287a3deaa3/ironveil/es.js @@ -139,6 +139,16 @@ 'Hold to cook and aim (the arc shows where it lands), let go to throw. Tap throws at once': 'Mantén para quitar el seguro y apuntar (el arco muestra dónde cae), suelta para tirar. Un toque la tira enseguida', 'Hold to aim (the arc shows where it lands), let go to throw. Guards go to look': 'Mantén para apuntar (el arco muestra dónde cae), suelta para tirar. Los guardias van a mirar', 'Jump': 'Saltar', - 'Jump / vault / stand up': 'Saltar / pasar por encima / pararse' + 'Jump / vault / stand up': 'Saltar / pasar por encima / pararse', + // ---- enemy calls (js/ai.js): what they are about to do + 'Loading!': '¡Cargando!', 'Changing magazine!': '¡Cambio de cargador!', + 'I am working round him!': '¡Lo rodeo por el costado!', 'Moving to flank!': '¡Voy por el flanco!', + 'Pull back! Pull back!': '¡Atrás! ¡Atrás!', 'Too many of them, back!': '¡Son demasiados, atrás!', + 'Grenade out!': '¡Granada va!', 'Throwing one in!': '¡Le tiro una!', 'Smoke him out!': '¡Hay que sacarlo de ahí!', + 'Keep his head down!': '¡Que no asome la cabeza!', 'Covering fire!': '¡Fuego de cobertura!', 'Pin him there!': '¡Déjenlo clavado ahí!', + 'I am hit!': '¡Me dieron!', 'Ah! Hit!': '¡Ah! ¡Herido!', 'My leg!': '¡Mi pierna!', 'I am hit in the leg!': '¡Me dieron en la pierna!', + 'Where did he go?': '¿Adónde se fue?', 'Lost him!': '¡Lo perdí!', 'I cannot see him!': '¡No lo veo!', + 'Move up on him! Slowly!': '¡Avancen hacia él! ¡Despacio!', 'You two, check where he was!': '¡Ustedes dos, revisen donde estaba!', + 'Man down!': '¡Hombre caído!', 'He is down!': '¡Cayó!', 'Hold still...': 'Quieto...', 'Got you now...': 'Ya te tengo...' }); })(); diff --git a/e63334287a3deaa3/ironveil/js/ai.js b/e63334287a3deaa3/ironveil/js/ai.js index 7ca3818c..a479266e 100644 --- a/e63334287a3deaa3/ironveil/js/ai.js +++ b/e63334287a3deaa3/ironveil/js/ai.js @@ -17,11 +17,17 @@ lost: ['Nothing. Just the wind.', 'Probably a fox.', 'Back to it.'], spotted: ['There! Enemy!', 'Alarm! Over there!', 'Contact!'], body: ['Man down! Over here!', 'He is dead! Search the area!'], - grenade: ['Grenade!'], reload: ['Reloading!'], flank: ['Go round the side!'], fallback: ['Falling back!'], - ready: ['I have him!', 'Steady... now!', 'In my sights!', 'Take him!'], rack: ['Gun up!', 'Feeding a belt!'] + grenade: ['Grenade!'], reload: ['Reloading!', 'Loading!', 'Changing magazine!'], flank: ['Go round the side!', 'I am working round him!', 'Moving to flank!'], + fallback: ['Falling back!', 'Pull back! Pull back!', 'Too many of them, back!'], + ready: ['I have him!', 'Steady... now!', 'In my sights!', 'Take him!'], rack: ['Gun up!', 'Feeding a belt!'], + throwing: ['Grenade out!', 'Throwing one in!', 'Smoke him out!'], suppress: ['Keep his head down!', 'Covering fire!', 'Pin him there!'], + hit: ['I am hit!', 'Ah! Hit!'], hitLeg: ['My leg!', 'I am hit in the leg!'], lostHim: ['Where did he go?', 'Lost him!', 'I cannot see him!'], + push: ['Move up on him! Slowly!', 'You two, check where he was!'], manDown: ['Man down!', 'He is down!'], + sniper: ['Hold still...', 'Got you now...'] }; - AI.bark = function (e, kind) { - if (IV.time < (e.barkT || 0) || !BARK[kind]) return; + // force: the warnings that matter to you (a grenade coming, a flank) skip his talk cooldown + AI.bark = function (e, kind, force) { + if ((!force && IV.time < (e.barkT || 0)) || !BARK[kind]) return; const d = Math.hypot(e.pos.x - P.pos.x, e.pos.z - P.pos.z); if (d > 45) return; e.barkT = IV.time + 6; IV.hud && IV.hud.bark(e, IV.t(BARK[kind][Math.floor(Math.random() * BARK[kind].length)])); @@ -69,7 +75,9 @@ Enemy.prototype.setState = function (s) { if (this.state === s || !this.alive) return; const was = this.state; this.state = s; this.stateT = 0; this.path = null; - if (s === 'combat') { this.alerted = true; if (was !== 'combat') { AI.spotted(this); } } + // into combat: for the first moments he answers where he stands (kneels, takes his turn if one is free) rather than + // turning his back to run for cover + if (s === 'combat') { this.alerted = true; if (was !== 'combat') { this.openUntil = IV.time + A.openHold; AI.spotted(this); } } if (s === 'searching' || s === 'investigating') this.alerted = true; IV.emit('aiState', { e: this, s, was }); }; @@ -77,25 +85,42 @@ Enemy.prototype.hit = function (zone, dmg, dir, from, b) { if (!this.alive) return; this.hp -= dmg; - if (this.hp <= 0) return this.die(dir, b && b.explosive); - // flinch (upper body) for light hits, a full stagger for heavy ones; either way his aim is thrown off for a moment + if (this.hp <= 0) return this.die(dir, b && b.explosive, zone); + // flinch (upper body) for light hits, a full stagger for heavy ones; either way his aim is thrown off for a moment. + // The flinch follows the hit: the body twists away from the side the round came in on and is knocked back a step if (dmg >= 60 && IVChars.clips && IVChars.clips.indexOf('stagger') >= 0) this.actor.play('stagger', { once: true, fade: 0.08 }); else this.actor.setUpper('hit'); + if (dir) { + const side = dir.x * Math.cos(this.bodyYaw) - dir.z * Math.sin(this.bodyYaw); // + the round travels to his left + this.bodyYaw += IV.clamp(side, -1, 1) * (zone === 'limb' ? 0.22 : 0.38); + this.knock = { x: dir.x * (dmg >= 60 ? 1.6 : 0.9), z: dir.z * (dmg >= 60 ? 1.6 : 0.9), t: 0.22 }; + } + // a limb hit low on the body: he limps from now on; badly hurt men crawl to cover + if (zone === 'limb' && b && b.y != null && b.y - this.pos.y < 0.95) this.limp = true; + else if (zone === 'limb' && Math.random() < 0.4) this.limp = true; + AI.bark(this, this.limp && zone === 'limb' ? 'hitLeg' : 'hit', Math.random() < 0.5); this.suppr = Math.min(1, this.suppr + 0.6); this.stagger = dmg >= 60 ? 0.7 : 0.45; this.shotT = Math.max(this.shotT, 0.5); + releaseToken(this); // hit mid-burst: his turn is over if (from) { this.lkp = { x: from.x, z: from.z, t: IV.time }; this.target = this.target || WPent(); } this.aw = 1; this.setState('combat'); AI.noise(this.pos.x, this.pos.z, 25, 'shout', this); }; const WPent = () => IV.weapons.playerEnt; - Enemy.prototype.die = function (dir, blast) { + Enemy.prototype.die = function (dir, blast, zone) { + const wasCombat = this.state === 'combat'; this.alive = false; this.state = 'dead'; this.hp = 0; this.aw = 0; + releaseToken(this); const front = dir ? (dir.x * -Math.sin(this.bodyYaw) + dir.z * -Math.cos(this.bodyYaw)) < 0 : Math.random() < 0.5; // shot from the front falls backwards this.actor.setUpper(null); const running = this.speed > 3 && IVChars.clips && IVChars.clips.indexOf('deathRun') >= 0; this.actor.play(running ? 'deathRun' : front ? 'deathBack' : 'deathFront', { fade: 0.08, once: true }); - // the body carries its momentum: running men tumble forward, a shot pushes a little - if (dir && !blast) { this.fallV = { x: dir.x * 1.2 + this.vel.x * 0.5, z: dir.z * 1.2 + this.vel.z * 0.5 }; } + // the body carries its momentum: running men tumble forward, a shot pushes a little, a head shot drops him where he + // stands, a blast throws him + if (dir && !blast) { const k = zone === 'head' ? 0.25 : 1.2; this.fallV = { x: dir.x * k + this.vel.x * 0.5, z: dir.z * k + this.vel.z * 0.5 }; } if (blast && dir) this.fallV = { x: dir.x * 3, z: dir.z * 3 }; + // his friends flinch and one calls it + if (wasCombat) AI.lost++; + if (wasCombat) { let called = false; for (const q of AI.list) { if (q === this || !q.alive || Math.hypot(q.pos.x - this.pos.x, q.pos.z - this.pos.z) > 20) continue; q.suppr = Math.min(1, q.suppr + 0.3); if (!called && q.state === 'combat') { called = true; AI.bark(q, 'manDown'); } } } this.deadT = 0; this.bodyAt = null; if (this.glint) this.glint.material.opacity = 0; AI.bodies.push(this); @@ -136,6 +161,21 @@ return k; } AI.canSee = inView; + // smoke from explosions hangs a few seconds: through the thick of it nobody sees (0), past its edge they see badly + // (0.5); clear air 1. AI.smokes is also open to missions (a smoke pot: AI.addSmoke(x, z, r, seconds)) + AI.smokes = []; + AI.addSmoke = function (x, z, r, sec) { AI.smokes.push({ x, z, r, until: IV.time + sec }); if (AI.smokes.length > 8) AI.smokes.shift(); }; + function smokeK(ax, az, bx, bz) { + let k = 1; + for (let i = AI.smokes.length - 1; i >= 0; i--) { + const s = AI.smokes[i]; if (s.until < IV.time) { AI.smokes.splice(i, 1); continue; } + const dx = bx - ax, dz = bz - az, l2 = dx * dx + dz * dz || 1, t = IV.clamp(((s.x - ax) * dx + (s.z - az) * dz) / l2, 0, 1); + const d = Math.hypot(ax + dx * t - s.x, az + dz * t - s.z); + if (d < s.r) return 0; if (d < s.r * 1.6) k = 0.5; + } + return k; + } + AI.smokeK = smokeK; function perceive(e, dt) { const d = Math.hypot(P.pos.x - e.pos.x, P.pos.z - e.pos.z); e.seeing = false; @@ -144,6 +184,7 @@ if (d < r) { const chestY = P.pos.y + (P.stance === 'prone' ? 0.3 : P.stance === 'crouch' ? 0.95 : 1.35), headY = P.eyeY(); let k = inView(e, P.pos.x, headY, P.pos.z, d); if (!k) k = inView(e, P.pos.x, chestY, P.pos.z, d); + 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; const close = 1 - d / r; @@ -159,7 +200,9 @@ if (da < 45 && inView(e, al.pos.x, al.pos.y + 1.2, al.pos.z, da)) { e.seeAlly = true; } else e.seeAlly = false; } else e.seeAlly = false; if (e.seeing) e.seeT += dt; else e.seeT = Math.max(0, e.seeT - dt * 2); - e.expo = IV.clamp((e.expo || 0) + (e.seeing ? A.expoUp[diff()] : -A.expoDown) * dt, 0, 1); + // exposure: seconds of continuous sight of you (drains expoDrain times faster out of sight); accuracy follows it + e.expoT = e.seeing ? (e.expoT || 0) + dt : Math.max(0, (e.expoT || 0) - dt * A.expoDrain); + e.expo = 1 - Math.exp(-e.expoT / A.expoTau[diff()]); if (!e.seeing && e.state !== 'combat') e.aw = Math.max(0, e.aw - A.decay * dt * (e.state === 'unaware' ? 1.6 : 1)); // bodies if (e.state !== 'combat') for (const b of AI.bodies) { @@ -281,8 +324,12 @@ const ux = (tx - c.x) / dT, uz = (tz - c.z) / dT, facing = -(c.nx * ux + c.nz * uz); if (facing < 0.35) continue; const dS = Math.hypot(c.x - e.pos.x, c.z - e.pos.z); - let s = facing * 4 - dS * 0.35 - Math.abs(dT - (e.kind === 'officer' ? 20 : 16)) * 0.12 + (c.low ? 0.5 : 0); + // distance from you: inside his weapon's band (SMG close, rifle further), the middle of it best + const band = A.prefRange[wclass(e)], mid = (band[0] + band[1]) / 2; + let s = facing * 4 - dS * 0.35 - Math.abs(dT - mid) * 0.12 + (c.low ? 0.5 : 0); + if (dT < band[0]) s -= (band[0] - dT) * 0.5; else if (dT > band[1]) s -= (dT - band[1]) * 0.35; if (back) s += (dT - Math.hypot(e.pos.x - tx, e.pos.z - tz)) * 0.6; + else s -= Math.max(0, dT - Math.hypot(e.pos.x - tx, e.pos.z - tz) - 4) * 0.3; // no long runs away from you to reach it if (flank) { const a0 = IV.yawTo(e.pos.x - tx, e.pos.z - tz), a1 = IV.yawTo(c.x - tx, c.z - tz); s += Math.min(1.4, Math.abs(IV.wrapA(a1 - a0))) * 6; } // other soldiers' cover: spread out, both on the ground and by bearing round the target (two men on the same // line from you are one target; men on different bearings make you turn your head) @@ -308,14 +355,15 @@ const now = IV.time; // safety nets: the holder died or left combat, or was granted a burst he could not start (ran for cover, ducked // back) within 1.5 s of his telegraph ending - the turn passes on, and he telegraphs again next time - for (const [k, t] of AI.tokens) if (!k.alive || k.state !== 'combat' || now - t.at > 9 || (!k.teleShot && now - t.at > A.tele[diff()] + 1.5)) releaseToken(k); + for (const [k, t] of AI.tokens) if (!k.alive || k.state !== 'combat' || now - t.at > 9 || (!k.teleShot && now - t.at > teleFor(k) + 1.5)) releaseToken(k); if (AI.tokens.has(e)) return true; if (AI.tokens.size >= A.tokens[diff()] || now - AI.lastGrant < A.tokenGap[diff()]) return false; AI.tokens.set(e, { at: now }); AI.lastGrant = now; e.burstLeft = burstSize(e); - telegraph(e, A.tele[diff()], 'ready'); + telegraph(e, teleFor(e), e.kind === 'sniper' ? 'sniper' : 'ready'); return true; } + const teleFor = e => e.kind === 'sniper' ? A.sniperTele[diff()] : A.tele[diff()]; // the warning before a burst: he brings the gun up, calls out, a glint shows at night; the first round may not // leave before `delay` has passed (ai.js keeps that; tests read AI.teleLog) function telegraph(e, delay, kind) { @@ -333,34 +381,61 @@ // warning at once instead of a whole firing interval later); otherwise the weapon's own interval function teleWait(e, gap) { return IV.time < (e.teleUntil || 0) ? e.teleUntil - IV.time + 0.03 : gap; } function noteShot(e) { if (e.teleShot) return; e.teleShot = true; for (let i = AI.teleLog.length - 1; i >= 0; i--) { const l = AI.teleLog[i]; if (l.id === e.id) { if (l.first == null) l.first = IV.time; break; } } } + // the chance that one round at you hits. Exposure (seconds he has watched you without a break) tightens it; range, how + // you stand and move across his sights, the light on you, smoke, and his own state (suppressed, hit, moving) loosen it + function hitChance(e, d) { + const D = diff(); + let p = A.acc[D] * (A.expoFloor + (1 - A.expoFloor) * (e.expo || 0)); + let rk = IV.clamp(A.rangeRef / Math.max(5, d), 0.22, 1.3); + if ((e.wkind === 'enemySmg' || e.wkind === 'pistol') && d > 25) rk *= 0.6; + p *= rk; + // you: stance, then movement across his line (straight at him barely helps), sprinting worst of all + p *= P.stance === 'prone' ? 0.5 : P.stance === 'crouch' ? 0.78 : 1; + const vx = P.vel ? P.vel.x : 0, vz = P.vel ? P.vel.z : 0, ux = (P.pos.x - e.pos.x) / Math.max(0.1, d), uz = (P.pos.z - e.pos.z) / Math.max(0.1, d); + const along = vx * ux + vz * uz, across = Math.abs(vx * uz - vz * ux), sp = across + Math.abs(along) * 0.3; + p /= 1 + 0.16 * sp; + if (P.sprinting) p *= 0.7; + if (P.crops) p *= 0.7; + // the light on you (moonlight, shadow, a lamp); your own muzzle flash lights you up + const lt = AI.playerLight(), Dk = A.dark; + let lk = lt >= 0.55 ? Dk.lit : lt >= 0.3 ? Dk.moon : Dk.shadow; + if (IV.weapons.firingRecently) lk = Math.max(lk, Dk.flash); + p *= lk * smokeK(e.pos.x, e.pos.z, P.pos.x, P.pos.z); + // him: suppressed, just hit, on the move + p *= 1 - e.suppr * 0.6; + if (e.stagger > 0) p *= 0.4; + if (e.speed > 0.6) p *= 0.45; + if (e.kind === 'sniper') p = Math.min(0.85, p * 2.4); + if (e.kind === 'gunner') p *= 0.55; + if (IV.mission.enemyAccMul) p *= IV.mission.enemyAccMul; + return Math.min(0.9, p); + } + AI.hitChance = hitChance; function shoot(e, tgt, dt) { const d = Math.hypot(tgt.pos.x - e.pos.x, tgt.pos.z - e.pos.z); const isP = !!tgt.isPlayer; if (isP && e.kind !== 'gunner') { - if (!haveToken(e)) { if (e.lkp && Math.random() < 0.35) suppressFire(e, e.lkp); return; } + // no turn free: he asks again shortly (the turn goes to whoever asks first once one frees up); now and then he + // fires a covering round at your last known spot instead + if (!haveToken(e)) { if (e.lkp && IV.time > (e.supT || 0) && Math.random() < 0.35) { e.supT = IV.time + 1.5; suppressFire(e, e.lkp); } return 'wait'; } if (IV.time < e.teleUntil) return; // still coming up into the aim: no round before the telegraph is over } if (isP && e.kind === 'gunner' && IV.time < (e.teleUntil || 0)) return; if (isP) noteShot(e); IV.emit('enemyFire', { e, atPlayer: isP }); - // the accuracy ramp: exposure grows with continuous sight of you and drains fast once you break it; suppression - // and your movement loosen it - const ramp = isP ? (A.expoFloor + (1 - A.expoFloor) * e.expo) * (e.kind === 'sniper' ? 0.85 : 1) : 1; - let p = A.acc[diff()] * ramp * IV.clamp(15 / Math.max(5, d), 0.25, 1.3) * (1 - e.suppr * 0.6); - if (isP) p /= 1 + 0.06 * Math.max(0, P.speed - 1); - if (isP) { p *= P.stance === 'prone' ? 0.5 : P.stance === 'crouch' ? 0.75 : 1; if (P.sprinting) p *= 0.6; if (P.crops) p *= 0.7; } - if (e.kind === 'sniper') p = Math.min(0.9, p * 2.4); - if (e.kind === 'gunner') p *= 0.55; - if (IV.mission.enemyAccMul) p *= IV.mission.enemyAccMul; - // the first shots of an engagement miss close by on purpose: a warning, and a direction - e.engShots = e.seeT < 0.2 ? 0 : (e.engShots || 0) + 1; - const hit = (!isP || e.engShots > 2 || e.kind === 'sniper') && Math.random() < p; + const p = isP ? hitChance(e, d) : A.acc[diff()] * IV.clamp(A.rangeRef / Math.max(5, d), 0.22, 1.3) * (1 - e.suppr * 0.6) * (tgt.stance === 'crouch' ? 0.75 : 1); + // the first rounds of each new sight of you miss close by on purpose: a warning, and a direction (new: he had lost + // you long enough for his exposure to drain, not every time he bobs up from cover) + e.engShots = (e.expoT || 0) < 0.25 ? 0 : (e.engShots || 0) + 1; + const hit = (!isP || e.engShots > A.warnShots[diff()] || e.kind === 'sniper') && Math.random() < p; + if (isP) { AI.lastP = p; if (AI.shotLog) AI.shotLog.push({ id: e.id, t: IV.time, p, d, expoT: e.expoT, hit }); } const muz = e.weapon.userData.muzzle.getWorldPosition(new THREE.Vector3()); const tp = targetPoint(tgt); - if (hit) { tp.y += (Math.random() - 0.5) * 0.4; } + // a hit lands on the body; only close in (under 20 m) can it stray up to the head, and never on a warning round + if (hit) { tp.y += d < 20 ? (Math.random() - 0.45) * 0.45 : (Math.random() - 0.6) * 0.35; } else { const a = Math.random() * 6.28, r = 0.7 + Math.random() * 2; tp.x += Math.cos(a) * r; tp.y += Math.sin(a) * r * 0.5 + 0.3; tp.z += Math.sin(a) * r; } const dx = tp.x - muz.x, dy = tp.y - muz.y, dz = tp.z - muz.z, l = Math.hypot(dx, dy, dz), v = 720; - const dmg = e.kind === 'sniper' ? A.sniperDmg[diff()] : A.dmg[diff()] * (isP ? 1 : 0.6); + const dmg = e.kind === 'sniper' ? A.sniperDmg[diff()] : A.dmg[diff()] * (e.wkind === 'enemySmg' || e.wkind === 'pistol' ? A.smgDmg : 1) * (isP ? 1 : 0.6); IV.weapons.spawnBullet({ x: muz.x, y: muz.y, z: muz.z, vx: dx / l * v, vy: dy / l * v + (l / v) * 4.9, vz: dz / l * v, drag: 0, dmg, flat: true, owner: e, team: 'them', tracer: !W.day && (e.kind === 'gunner' || Math.random() < 0.45), enemy: true, life: 1.4 }); IV.fx.muzzle(muz.x, muz.y, muz.z, dx / l, dy / l, dz / l, e.kind !== 'officer'); if (IV.weapons.gunShot) IV.weapons.gunShot(e.weapon, e.wkind); e.lastShotT = IV.time; @@ -381,6 +456,7 @@ return; } if (this.scripted) { this.scripted(dt, this); return; } + if (this.knock && this.knock.t > 0) { this.knock.t -= dt; o.x = this.pos.x + this.knock.x * dt; o.z = this.pos.z + this.knock.z * dt; W.collide(o, 0.3, this.pos.y + 0.45, this.pos.y + 1.7); this.pos.x = o.x; this.pos.z = o.z; this.pos.y = W.groundAt(o.x, o.z, this.pos.y); } this.perT -= dt; if (this.perT <= 0) { perceive(this, 0.1); this.perT += 0.1; } this.suppr = Math.max(0, this.suppr - dt * 0.35); @@ -468,8 +544,8 @@ if (g && !e.fixed) { if (!e.fleeT) AI.bark(e, 'grenade'); e.fleeT = 1; const ax = e.pos.x - g.x, az = e.pos.z - g.z, al = Math.hypot(ax, az) || 1; moveTo(e, e.pos.x + ax / al * 9, e.pos.z + az / al * 9, A.runSpeed * 1.1, dt); e.stance = 'stand'; return; } e.fleeT = 0; const tgt = e.target = pickTarget(e); - if (e.o.noShoot) { e.speed = IV.damp(e.speed, 0, 8, dt); faceTo(e, P.pos.x, P.pos.z, 6, dt); e.actor.setUpper('aimIdle'); return; } const tp = e.seeing || (tgt !== WPent() && e.seeAlly) ? tgt.pos : e.lkp ? e.lkp : tgt.pos; + if (e.o.noShoot) { e.speed = IV.damp(e.speed, 0, 8, dt); faceTo(e, tp.x, tp.z, 6, dt); e.actor.setUpper('aimIdle'); return; } if (e.seeing) e.lkp = { x: P.pos.x, z: P.pos.z, t: IV.time }; const canShoot = (e.seeing || e.seeAlly) && IV.time - (e.firstSee || 0) > A.reaction[diff()]; if (!e.seeing && !e.seeAlly) e.firstSee = IV.time; else if (!e.firstSee) e.firstSee = IV.time; @@ -495,60 +571,84 @@ if (!e.seeing && IV.time - (e.lkp ? e.lkp.t : 0) > 30) { e.aw = 0.8; e.setState('searching'); } return; } - // fall back when hurt and alone - const alone = !AI.list.some(q => q !== e && q.alive && q.state === 'combat' && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < 22); - if (e.hp < 50 && alone && !e.fellBack) { e.fellBack = true; const c = chooseCover(e, tp, false, true); if (c) { if (e.cover) e.cover.used = null; e.cover = c; c.used = e; AI.bark(e, 'fallback'); } } - // flank role: one of a pair swings wide + const D = diff(), now = IV.time; + const lostFor = e.seeing || e.seeAlly ? 0 : now - (e.lkp ? e.lkp.t : now); + if (lostFor > 4 && !e.lostCalled) { e.lostCalled = true; AI.bark(e, 'lostHim'); } else if (lostFor === 0) e.lostCalled = false; + // a grenade on its way: he has shouted; after the wind-up it is thrown at the spot you have been holding + if (e.throwAt) { + e.speed = IV.damp(e.speed, 0, 10, dt); faceTo(e, e.throwAt.x, e.throwAt.z, 8, dt); e.stance = 'stand'; + if (now >= e.throwAt.t) { IV.weapons.enemyGrenade(e, e.throwAt.x, e.throwAt.z); e.actor.setUpper('throw'); e.throwAt = null; e.shotT = Math.max(e.shotT, 1); e.peek = false; e.peekT = 1.2; } + return; + } + // hurt: limping men move slower; a badly hurt one crawls to cover + const slow = (e.limp ? 0.55 : 1) * (e.stagger > 0 ? 0.4 : 1); + if (e.hp < 30) e.crawl = true; + // fall back, once: when hurt, or when the squad has lost men and he is nearly alone + let friends = 0; for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < 25) friends++; + if (!e.fellBack && (e.hp < 50 || (AI.lost >= 2 && friends <= 1))) { + e.fellBack = true; const c = chooseCover(e, tp, false, true); + if (c) { if (e.cover) e.cover.used = null; e.cover = c; c.used = e; e.coverT = 0; releaseToken(e); AI.bark(e, 'fallback', true); } + } + // firing position: cover between him and you, in his weapon's range band, on a different bearing from his friends; + // a flanker swings wide if (!e.cover || e.coverT > 14 || (e.cover && exposed(e.cover, tp))) { if (e.cover) e.cover.used = null; const flank = e.role === 'flank'; - e.cover = chooseCover(e, tp, flank, false); e.coverT = 0; - if (e.cover) { e.cover.used = e; if (flank) AI.bark(e, 'flank'); } + e.cover = chooseCover(e, tp, flank, e.fellBack); e.coverT = 0; + if (e.cover) { e.cover.used = e; if (flank) AI.bark(e, 'flank', true); } } e.coverT += dt; e.shotT -= dt; if (e.cover && Math.hypot(e.cover.x - e.pos.x, e.cover.z - e.pos.z) > 0.6) { - // run to cover; snap-shoot only if very close - moveTo(e, e.cover.x, e.cover.z, A.runSpeed * (e.stagger > 0 ? 0.4 : 1), dt); - e.stance = 'stand'; e.peek = false; e.actor.setUpper(canShoot && dT < 15 ? 'aimIdle' : null); - if (canShoot && dT < 12 && e.shotT <= 0 && e.mag > 0) { shoot(e, tgt, dt); e.shotT = teleWait(e, 1.1 + Math.random()); } + // caught in the open within his range: his turn (call, weapon up, then the burst) is taken where he stands, down + // on one knee; without a turn he runs on to cover. A crawling man only crawls + const opening = now < (e.openUntil || 0) && (e.seeing || e.seeAlly) && dT < snapRange(e) && !e.crawl && !e.fellBack; + if (opening && !AI.tokens.has(e) && AI.tokens.size >= A.tokens[D] && canShoot) e.openUntil = 0; // no turn free: off to cover + if (!e.crawl && canShoot && dT < snapRange(e) && e.shotT <= 0 && e.mag > 0) { e.shotT = shoot(e, tgt, dt) === 'wait' ? 0.25 : teleWait(e, burstGap(e)); } + if (opening && !AI.tokens.has(e)) { e.speed = IV.damp(e.speed, 0, 12, dt); faceTo(e, tp.x, tp.z, 7, dt); e.stance = 'crouch'; e.actor.setUpper('aimIdle'); return; } + if (!e.crawl && AI.tokens.has(e) && canShoot) { + e.speed = IV.damp(e.speed, 0, 12, dt); faceTo(e, tp.x, tp.z, 7, dt); e.stance = 'crouch'; e.actor.setUpper('aimIdle'); + if (e.mag <= 0) { e.mag = 10; e.shotT = 2.4; AI.bark(e, 'reload'); releaseToken(e); } + return; + } + moveTo(e, e.cover.x, e.cover.z, e.crawl ? 0.7 : A.runSpeed * slow, dt); + // on the move he keeps his head turned to where you are (as far as a neck turns), so he can still see you + e.headYaw = IV.clamp(IV.wrapA(IV.yawTo(tp.x - e.pos.x, tp.z - e.pos.z) - e.bodyYaw), -1.2, 1.2); + e.stance = e.crawl ? 'prone' : 'stand'; e.peek = false; e.actor.setUpper(!e.crawl && canShoot && dT < 15 ? 'aimIdle' : null); return; } + e.headYaw = IV.damp(e.headYaw, 0, 6, dt); + if (e.role === 'flank') e.role = 'normal'; // round on your flank: from here he fights like the rest e.speed = IV.damp(e.speed, 0, 10, dt); faceTo(e, tp.x, tp.z, 7, dt); // peek cycle: hidden, then exposed and firing e.peekT = (e.peekT || 0) - dt; - if (e.peek && AI.tokens.has(e) && e.peekT < 0.3) e.peekT = 0.3; // his turn (telegraph, then the burst): he stays up until it is over + const suppressing = now < (e.supUntil || 0) && !AI.tokens.has(e) && AI.know; + if (e.peek && (AI.tokens.has(e) || suppressing) && e.peekT < 0.3) e.peekT = 0.3; // his turn (telegraph, then the burst) or covering fire: he stays up until it is over if (e.peekT <= 0) { e.peek = !e.peek; e.peekT = e.peek ? 1.6 + Math.random() * 1.2 : (1.1 + Math.random() * 1.6) * (1 + e.suppr * 1.8); } const low = e.cover ? e.cover.low : false; - e.stance = e.peek ? 'stand' : (low ? 'crouch' : 'stand'); - if (!e.cover) { e.stance = 'crouch'; e.peek = true; } + e.stance = e.crawl ? 'prone' : e.peek ? 'stand' : (low ? 'crouch' : 'stand'); + if (!e.cover) { e.stance = e.crawl ? 'prone' : 'crouch'; e.peek = true; } // the rifle comes up to the shoulder only for his own burst (the telegraph) or suppressing fire; peeking while // he waits for his turn he looks over the gun, so who is about to fire at you reads from across the field - e.actor.setUpper(e.peek && (AI.tokens.has(e) || IV.time < (e.supUpT || 0) || !tgt.isPlayer) ? 'aimIdle' : null); - // tall cover (hedge, wall end): side-step out of it to peek - if (e.cover && !low) { const off = e.peek ? 0.9 : 0; const side = { x: -e.cover.nz, z: e.cover.nx }; e.peekOff = IV.damp(e.peekOff || 0, off, 6, dt); } + e.actor.setUpper(e.peek && (AI.tokens.has(e) || now < (e.supUpT || 0) || !tgt.isPlayer) ? 'aimIdle' : null); if (e.peek && e.mag > 0 && e.shotT <= 0) { - if (canShoot) { - shoot(e, tgt, dt); - if (IV.time < (e.teleUntil || 0)) e.shotT = teleWait(e, 0); // his turn was just granted: the first round leaves as the telegraph ends - else { e.shotT = (e.wkind === 'enemySmg' ? 0.12 : AI.tokens.has(e) ? 0.7 + Math.random() * 0.35 : 0.9 + Math.random() * 0.8) * (1 + e.suppr); e.burst = (e.burst || 0) + 1; if (e.wkind === 'enemySmg' && e.burst % 5 === 0) e.shotT = 1.2; } - } - else if (e.lkp && IV.time - e.lkp.t < 5 && Math.random() < 0.3) { suppressFire(e, e.lkp); e.shotT = 1.5; } - } - if (e.mag <= 0) { e.mag = 10; e.shotT = 2.4; e.peek = false; e.peekT = 2.4; AI.bark(e, 'reload'); } - // grenade at a target that has been hiding behind cover for a while - AI.grenadeCool -= dt; - if (!e.seeing && e.lkp && AI.grenadeCool <= 0 && IV.time - e.lkp.t > 2 && IV.time - e.lkp.t < 10 && dT > 9 && dT < 30 && Math.random() < 0.004 * (1 + diff())) { - AI.grenadeCool = A.grenadeCooldown * (diff() === 0 ? 1.5 : 1); AI.bark(e, 'grenade'); - IV.weapons.enemyGrenade(e, e.lkp.x + (Math.random() - 0.5) * 3, e.lkp.z + (Math.random() - 0.5) * 3); - e.actor.setUpper('throw'); - } - // lost you for a long time: push to your last known position, then search - if (!e.seeing && !e.seeAlly && IV.time - (e.lkp ? e.lkp.t : 0) > 12) { - if (e.lkp && Math.hypot(e.lkp.x - e.pos.x, e.lkp.z - e.pos.z) > 4 && !e.noRoam) { if (e.cover) e.cover.used = null; e.cover = null; moveTo(e, e.lkp.x, e.lkp.z, A.searchSpeed, dt); e.stance = 'stand'; e.actor.setUpper('aimIdle'); } - if (IV.time - (e.lkp ? e.lkp.t : 0) > 26) { e.aw = 0.85; e.interest = e.lkp; e.setState('searching'); } + if (canShoot) { e.shotT = shoot(e, tgt, dt) === 'wait' ? 0.25 : teleWait(e, burstGap(e)); } + else if (suppressing) { suppressFire(e, AI.know); e.shotT = e.wkind === 'enemySmg' ? 0.3 : 0.9 + Math.random() * 0.4; if (e.mag > 0) e.mag--; } + else if (e.lkp && now - e.lkp.t < 5 && Math.random() < 0.3) { suppressFire(e, e.lkp); e.shotT = 1.5; } } + if (e.mag <= 0) { e.mag = 10; e.shotT = 2.4; e.peek = false; e.peekT = 2.4; AI.bark(e, 'reload'); releaseToken(e); } + // lost you: after a while the two nearest move up on your last known position, the others watch it from cover; + // later still the whole group goes to a proper search + if (lostFor > A.pushLost[D] && e.lkp) { + let rank = 0; const dl = Math.hypot(e.lkp.x - e.pos.x, e.lkp.z - e.pos.z); + for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && !q.fixed && !q.noRoam && Math.hypot(e.lkp.x - q.pos.x, e.lkp.z - q.pos.z) < dl) rank++; + if (rank < 2 && dl > 4 && !e.noRoam && !e.crawl) { + if (e.cover) e.cover.used = null; e.cover = null; if (!e.pushing) { e.pushing = true; AI.bark(e, 'push'); } + moveTo(e, e.lkp.x, e.lkp.z, A.searchSpeed * slow, dt); e.stance = 'stand'; e.actor.setUpper('aimIdle'); + } + if (lostFor > A.searchLost[D]) { e.pushing = false; e.aw = 0.85; e.interest = e.lkp; e.setState('searching'); } + } else e.pushing = false; }, alarm(e, dt) { const al = AI.alarm; @@ -561,6 +661,13 @@ dead() {} }; BEH.scripted = () => {}; + const wclass = e => e.wkind === 'enemySmg' ? 'smg' : e.wkind === 'pistol' ? 'pistol' : 'rifle'; + function snapRange(e) { return A.snapRange[wclass(e)]; } + // the wait after a round: an SMG burst is quick (a pause every five), a rifleman works his bolt; suppression slows both + function burstGap(e) { + if (e.wkind === 'enemySmg') return AI.tokens.has(e) ? 0.12 : 0.9 + Math.random() * 0.6; // the burst runs out the token's rounds + return (AI.tokens.has(e) ? 0.6 + Math.random() * 0.3 : 0.9 + Math.random() * 0.8) * (1 + e.suppr); + } function exposed(c, tp) { const dx = tp.x - c.x, dz = tp.z - c.z, d = Math.hypot(dx, dz); return -(c.nx * dx / d + c.nz * dz / d) < 0.2; @@ -586,7 +693,9 @@ if (AI.alarmRung) return; AI.alarmRung = true; IV.audio && IV.audio.alarm(true); - for (const q of AI.list) if (q.alive && q.state !== 'combat') { q.alerted = true; q.aw = Math.max(q.aw, 0.9); q.lkp = q.lkp || { x: P.pos.x + (Math.random() - 0.5) * 30, z: P.pos.z + (Math.random() - 0.5) * 30, t: IV.time }; q.setState('searching'); } + // the bell sends everyone to search round what the squad knows (or round the man who rang it), never round you + const at = AI.know || (by && by.lkp) || (by && by.pos) || P.pos; + for (const q of AI.list) if (q.alive && q.state !== 'combat') { q.alerted = true; q.aw = Math.max(q.aw, 0.9); q.lkp = q.lkp || { x: at.x + (Math.random() - 0.5) * 30, z: at.z + (Math.random() - 0.5) * 30, t: IV.time }; q.setState('searching'); } IV.emit('alarm', by); }; AI.spotted = function (e) { @@ -596,8 +705,10 @@ // the nearest friend becomes the flanker let best = null, bd = 25; for (const q of AI.list) if (q !== e && q.alive && !q.fixed && q.role !== 'flank') { const d = Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z); if (d < bd && q.state === 'combat') { bd = d; best = q; } } if (best && !AI.list.some(q => q.alive && q.role === 'flank')) best.role = 'flank'; - AI.alertNear(e, 18, P.pos); - for (const q of AI.list) if (q !== e && q.alive && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < 18 && q.state !== 'combat') { q.aw = 1; q.lkp = { x: P.pos.x, z: P.pos.z, t: IV.time }; q.setState('combat'); } + // he shouts where you are (his own last known position of you: what he saw or heard) + const at = e.lkp || { x: e.pos.x, z: e.pos.z }; + AI.alertNear(e, 18, at); + for (const q of AI.list) if (q !== e && q.alive && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < 18 && q.state !== 'combat') { q.aw = 1; q.lkp = { x: at.x, z: at.z, t: IV.time }; q.setState('combat'); } }; // ---------------------------------------------------------------- animation @@ -628,7 +739,8 @@ if (this.alive) { // aim at the target / look about let ap = 0, ay = this.headYaw; - if (this.state === 'combat' && this.target) { const t = this.target.pos, d = Math.hypot(t.x - this.pos.x, t.z - this.pos.z); ap = Math.atan2(t.y + this.target.chestH() - this.eye(), d); ay = IV.clamp(IV.wrapA(IV.yawTo(t.x - this.pos.x, t.z - this.pos.z) - this.bodyYaw), -1, 1); } + // his gun follows you only while he can see you; otherwise it points at where he last knew you were + if (this.state === 'combat' && this.target) { const sees = this.seeing || this.seeAlly, t = sees || !this.lkp ? this.target.pos : { x: this.lkp.x, y: this.pos.y, z: this.lkp.z }, d = Math.hypot(t.x - this.pos.x, t.z - this.pos.z); ap = Math.atan2(t.y + this.target.chestH() - this.eye(), d); ay = IV.clamp(IV.wrapA(IV.yawTo(t.x - this.pos.x, t.z - this.pos.z) - this.bodyYaw), -1, 1); } this.actor.setAim(ap, ay); this._ap = ap; this._ay = ay; } // cull animation work for far soldiers (update every few frames) @@ -667,11 +779,50 @@ // ---------------------------------------------------------------- the manager AI.reset = function () { for (const e of AI.list) { e.actor.dispose(); if (e.glint && e.glint.parent) e.glint.parent.remove(e.glint); if (e.tglint && e.tglint.parent) e.tglint.parent.remove(e.tglint); } - AI.tokens.clear(); AI.lastGrant = -99; AI.teleLog = []; + AI.tokens.clear(); AI.lastGrant = -99; AI.teleLog = []; AI.know = null; AI.coT = 0; AI.flankAt = 0; AI.grenadeAt = 0; AI.lost = 0; AI.smokes = []; AI.list = []; AI.bodies = []; AI.masks = []; AI.maskUntil = 0; AI.loud = false; AI.alarm = null; AI.alarmRung = false; AI.grenadeCool = 0; AI.lastSpotted = -99; AI.spottedCount = 0; AI.ignorePlayer = false; }; + IV.on && IV.on('explosion', g => { if (g && g.x != null) AI.addSmoke(g.x, g.z, 3.2, 5); }); AI.spawn = function (o) { const e = new Enemy(o); AI.list.push(e); return e; }; + // ---------------------------------------------------------------- the squad: what they know, and who does what + // AI.know is the freshest last-known position any of them has (from sight or sound, never read from you directly) and + // since when you have been on that spot (within 3.5 m). Hold one spot too long and one man is sent round your flank + // while another keeps your head down; hold it longer and one shouts and lobs a grenade there. + AI.know = null; AI.coT = 0; AI.flankAt = 0; AI.grenadeAt = 0; AI.lost = 0; + function coordinate(dt) { + AI.coT -= dt; if (AI.coT > 0) return; AI.coT = 0.25; + const D = diff(), now = IV.time; let newest = null, n = 0; + for (const e of AI.list) if (e.alive && e.state === 'combat' && !e.scripted) { n++; if (e.lkp && (!newest || e.lkp.t > newest.t)) newest = e.lkp; } + if (!n || !newest) { AI.know = null; return; } + const K = AI.know; + if (!K || Math.hypot(newest.x - K.x, newest.z - K.z) > 3.5) AI.know = { x: newest.x, z: newest.z, t: newest.t, since: newest.t }; + else K.t = Math.max(K.t, newest.t); + const k = AI.know, held = now - k.since, fresh = now - k.t < 10; + if (!fresh) return; + const free = AI.list.filter(e => e.alive && e.state === 'combat' && !e.fixed && !e.noRoam && !e.scripted && !AI.tokens.has(e) && !e.throwAt && !e.crawl); + // a flanker, and covering fire while he moves + if (held > A.campFlank[D] && now > AI.flankAt && free.length >= 2 && !AI.list.some(q => q.alive && q.state === 'combat' && q.role === 'flank')) { + let f = null, fd = 1e9; for (const e of free) { const d = Math.hypot(e.pos.x - k.x, e.pos.z - k.z); if (e.hp >= 50 && d > 8 && d < 40 && d < fd) { fd = d; f = e; } } + if (f) { + f.role = 'flank'; if (f.cover) f.cover.used = null; f.cover = null; AI.flankAt = now + 15; + const c = free.find(e => e !== f && W.clear(e.pos.x, e.eye(), e.pos.z, k.x, W.height(k.x, k.z) + 1, k.z, F.SIGHT)) || free.find(e => e !== f); + if (c) { c.supUntil = now + 4.5; AI.bark(c, 'suppress', true); } + IV.emit('aiOrder', { kind: 'flank', e: f }); + } + } + // a grenade at the spot you have held: the thrower shouts first, then throws after grenadeWarn s + if (held > A.campGrenade[D] && now > AI.grenadeAt && now - k.t < 8) { + let g = null, gd = 1e9; for (const e of free) { const d = Math.hypot(e.pos.x - k.x, e.pos.z - k.z); if (d > 9 && d < 30 && d < gd) { gd = d; g = e; } } + if (g) { + AI.grenadeAt = now + A.grenadeCooldown[D]; + g.throwAt = { t: now + A.grenadeWarn, x: k.x + (Math.random() - 0.5) * 2.5, z: k.z + (Math.random() - 0.5) * 2.5 }; + AI.bark(g, 'throwing', true); IV.emit('aiOrder', { kind: 'grenade', e: g }); + } + } + } + AI.coordinate = coordinate; AI.step = function (dt) { + coordinate(dt); let loud = false; for (const e of AI.list) { e.step(dt); if (e.alive && e.state === 'combat') loud = true; } if (loud !== AI.loud) { AI.loud = loud; IV.emit('loud', loud); } diff --git a/e63334287a3deaa3/ironveil/js/ally.js b/e63334287a3deaa3/ironveil/js/ally.js index 3fd9621a..12de09a8 100644 --- a/e63334287a3deaa3/ironveil/js/ally.js +++ b/e63334287a3deaa3/ironveil/js/ally.js @@ -9,6 +9,7 @@ const P = IV.player; const diff = () => (IV.mission && IV.mission.diff) || 0; AL.NAME = 'Cpl. Dunning'; + AL.accMul = 0.55; // share of T.ally.acc he hits with (useful, never the one who wins the fight) AL.spawn = function (x, z, yaw) { AL.remove(); @@ -67,8 +68,10 @@ if (!e.target) e.bodyYaw = IV.turnToward(e.bodyYaw, IV.yawTo(dx, dz), T.move.turnRate * 0.8, dt); return false; } + // who he fights: first the soldier whose turn it is to fire at you (weapon up, about to shoot), so his fire spoils that + // man's aim; otherwise the nearest one he can see function visibleEnemy(e) { - let best = null, bd = 70; + let best = null, bd = 70, tok = null; const free = AL.mode === 'fire' || IV.ai.loud; if (!free) return null; for (const q of IV.ai.list) { @@ -76,13 +79,15 @@ if (AL.mode !== 'fire' && q.state !== 'combat') continue; const d = Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z); if (d > bd) continue; if (!W.clear(e.pos.x, e.pos.y + 1.45, e.pos.z, q.pos.x, q.pos.y + q.chestH(), q.pos.z, F.BULLET)) continue; + if (IV.ai.tokens && IV.ai.tokens.has(q) && !tok) tok = q; bd = d; best = q; } - return best; + return tok || best; } function shoot(e, q) { const d = Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z); - const p = T.ally.acc * IV.clamp(14 / Math.max(5, d), 0.25, 1.2) * (q.stance === 'crouch' ? 0.7 : 1); + // he keeps heads down more than he kills: about half the hit rate of the tuning value, more against a man in the open + const p = T.ally.acc * AL.accMul * IV.clamp(14 / Math.max(5, d), 0.25, 1.2) * (q.stance === 'crouch' ? 0.7 : 1) * (q.cover ? 0.8 : 1); const muz = e.weapon.userData.muzzle.getWorldPosition(new THREE.Vector3()); const tp = { x: q.pos.x, y: q.pos.y + q.chestH() + (Math.random() - 0.5) * 0.3, z: q.pos.z }; if (Math.random() > p) { const a = Math.random() * 6.28, r = 0.6 + Math.random() * 1.6; tp.x += Math.cos(a) * r; tp.y += 0.3 + Math.sin(a) * 0.5; tp.z += Math.sin(a) * r; } @@ -129,7 +134,8 @@ if (q) { e.bodyYaw = IV.dampA(e.bodyYaw, IV.yawTo(q.pos.x - e.pos.x, q.pos.z - e.pos.z), 8, dt); e.actor.setUpper('aimIdle'); - if (e.shotT <= 0) { shoot(e, q); e.burst = (e.burst || 0) + 1; e.shotT = e.burst % 4 === 0 ? 0.9 + Math.random() * 0.6 : 0.11; } + // short bursts of three with a pause to re-aim: steady covering fire rather than a wall of lead + if (e.shotT <= 0) { shoot(e, q); e.burst = (e.burst || 0) + 1; e.shotT = e.burst % 3 === 0 ? 1.4 + Math.random() * 0.8 : 0.11; } } else { e.actor.setUpper(sc && sc.aim ? 'aimIdle' : null); if (arrived && sc && sc.yaw != null) e.bodyYaw = IV.dampA(e.bodyYaw, sc.yaw, 6, dt); diff --git a/e63334287a3deaa3/ironveil/js/core.js b/e63334287a3deaa3/ironveil/js/core.js index ebb9b94c..ca1afe49 100644 --- a/e63334287a3deaa3/ironveil/js/core.js +++ b/e63334287a3deaa3/ironveil/js/core.js @@ -125,20 +125,34 @@ 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 - reaction: [0.9, 0.6, 0.35], // s before the first shot once spotted - accRamp: 1.1, // s of exposure to reach full accuracy - acc: [0.22, 0.38, 0.55], // hit chance per shot at full ramp, 15 m, standing (difficulty) - dmg: [9, 14, 22], // hp per enemy rifle/smg hit + 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 + // to full after about 3 * expoTau s (9, 8, 7 s); out of sight it drains expoDrain times as fast as it builds. + acc: [0.5, 0.76, 0.85], // hit chance per shot at full exposure, 20 m, you standing still and lit (difficulty) + expoTau: [3, 2.7, 2.3], expoDrain: 3, expoFloor: 0.3, + rangeRef: 20, // m: the range factor is rangeRef / d (capped 1.3 close, 0.22 far: 0.4 at 50 m); SMG men lose more past 25 m + warnShots: [2, 1, 1], // the first rounds of each new sight of you miss close by on purpose (a crack, a direction) + dark: { moon: 0.85, shadow: 0.62, lit: 1, flash: 0.92 }, // accuracy by the light on you (your own muzzle flash lights you) + dmg: [26, 34, 36], // hp per enemy rifle hit before the difficulty's damage-taken multiplier (x0.6, x1, x1.45): 16, 34, 52 + smgDmg: 0.75, // an SMG round does this share of a rifle round sniperDmg: [45, 60, 85], + sniperTele: [2.4, 2, 1.6], // s: the sniper's glint and call before his shot (the long, obvious tell) + prefRange: { smg: [8, 18], rifle: [16, 30], pistol: [10, 22] }, // m: firing spots chosen in this band from you + openHold: 3, // s: on first contact he answers from where he stands (if a turn to fire is free) before moving + snapRange: { smg: 22, rifle: 34, pistol: 16 }, // m: caught in the open he stops and fires (his turn) instead of running first + campFlank: [16, 11, 8], // s you stay on one spot they know (within 3.5 m) before one of them is sent round your flank + campGrenade: [13, 8, 6], // s on one known spot before a grenade (one man shouts first, then throws) + grenadeWarn: 0.9, // s from his shout to the throw + pushLost: [14, 10, 8], // s out of sight before two of them move up on your last known position (the rest cover it) + searchLost: [30, 22, 18], // s out of sight before the whole group goes to a proper search searchTime: 38, // s runSpeed: 3.9, walkSpeed: 1.45, searchSpeed: 2.2, turnRate: 6.3, // m/s; rad/s body turn (360 deg/s) - grenadeCooldown: 24, // s, shared by all enemies + grenadeCooldown: [30, 22, 16], // s between enemy grenades, shared by all enemies (difficulty) tokens: [2, 3, 4], // how many soldiers may shoot at you at once (difficulty) tokenGap: [1.6, 1.25, 0.9], // s, at least this long between two soldiers being allowed to open fire on you tele: [0.7, 0.5, 0.35], // s, the 'ready' telegraph (weapon raised, a call, a glint at night) before each burst at you - burst: { rifle: 2, smg: 5, pistol: 3, sniper: 1 }, // rounds per token: the token goes back when the burst ends - expoUp: [0.18, 0.25, 0.35], expoDown: 0.45, // accuracy exposure gained per second of continuous sight, lost per second out of it - expoFloor: 0.3, // share of full accuracy at zero exposure (full at exposure 1) + burst: { rifle: 3, smg: 6, pistol: 3, sniper: 1 }, // rounds per token: the token goes back when the burst ends rackTime: 0.6, // s, an MG gunner racks his gun before each new burst at you alarmDelay: 2.2, // s ringing before the alarm counts truckDelay: 28 // s after the alarm (or 60 when the telephone wire is cut) From fcd41153f8aa3af6c48c0e9e02c8f063bd56284e Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 18:56:12 +0000 Subject: [PATCH 04/12] Midnight Ops enemies: tune Regular accuracy, cap any one shot at 80 percent, cheaper fall-back check Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rMA1ShmNuiCqMrmnvkS --- e63334287a3deaa3/ironveil/js/ai.js | 6 +++--- e63334287a3deaa3/ironveil/js/core.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/e63334287a3deaa3/ironveil/js/ai.js b/e63334287a3deaa3/ironveil/js/ai.js index a479266e..e810b906 100644 --- a/e63334287a3deaa3/ironveil/js/ai.js +++ b/e63334287a3deaa3/ironveil/js/ai.js @@ -408,7 +408,7 @@ if (e.kind === 'sniper') p = Math.min(0.85, p * 2.4); if (e.kind === 'gunner') p *= 0.55; if (IV.mission.enemyAccMul) p *= IV.mission.enemyAccMul; - return Math.min(0.9, p); + return Math.min(e.kind === 'sniper' ? 0.85 : 0.8, p); // nobody is a sure shot } AI.hitChance = hitChance; function shoot(e, tgt, dt) { @@ -584,8 +584,7 @@ const slow = (e.limp ? 0.55 : 1) * (e.stagger > 0 ? 0.4 : 1); if (e.hp < 30) e.crawl = true; // fall back, once: when hurt, or when the squad has lost men and he is nearly alone - let friends = 0; for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < 25) friends++; - if (!e.fellBack && (e.hp < 50 || (AI.lost >= 2 && friends <= 1))) { + if (!e.fellBack && (e.hp < 50 || (AI.lost >= 2 && friendsNear(e, 25) <= 1))) { e.fellBack = true; const c = chooseCover(e, tp, false, true); if (c) { if (e.cover) e.cover.used = null; e.cover = c; c.used = e; e.coverT = 0; releaseToken(e); AI.bark(e, 'fallback', true); } } @@ -661,6 +660,7 @@ dead() {} }; BEH.scripted = () => {}; + function friendsNear(e, r) { let n = 0; for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && Math.abs(q.pos.x - e.pos.x) < r && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < r) n++; return n; } const wclass = e => e.wkind === 'enemySmg' ? 'smg' : e.wkind === 'pistol' ? 'pistol' : 'rifle'; function snapRange(e) { return A.snapRange[wclass(e)]; } // the wait after a round: an SMG burst is quick (a pause every five), a rifleman works his bolt; suppression slows both diff --git a/e63334287a3deaa3/ironveil/js/core.js b/e63334287a3deaa3/ironveil/js/core.js index ca1afe49..c8419fbf 100644 --- a/e63334287a3deaa3/ironveil/js/core.js +++ b/e63334287a3deaa3/ironveil/js/core.js @@ -129,8 +129,8 @@ // 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 // to full after about 3 * expoTau s (9, 8, 7 s); out of sight it drains expoDrain times as fast as it builds. - acc: [0.5, 0.76, 0.85], // hit chance per shot at full exposure, 20 m, you standing still and lit (difficulty) - expoTau: [3, 2.7, 2.3], expoDrain: 3, expoFloor: 0.3, + acc: [0.48, 0.75, 0.82], // hit chance per shot at full exposure, 20 m, you standing still and lit (difficulty) + expoTau: [3, 2.7, 2.3], expoDrain: 3, expoFloor: 0.25, rangeRef: 20, // m: the range factor is rangeRef / d (capped 1.3 close, 0.22 far: 0.4 at 50 m); SMG men lose more past 25 m warnShots: [2, 1, 1], // the first rounds of each new sight of you miss close by on purpose (a crack, a direction) dark: { moon: 0.85, shadow: 0.62, lit: 1, flash: 0.92 }, // accuracy by the light on you (your own muzzle flash lights you) From 86a8da96a0159eb0d3ddbc05b0d5fb83938fe754 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 19:00:19 +0000 Subject: [PATCH 05/12] Midnight Ops shooting: recoil comments describe the fixed pattern Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rM7Bycwoc6n2GG95HK7 --- e63334287a3deaa3/ironveil/js/weapons.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e63334287a3deaa3/ironveil/js/weapons.js b/e63334287a3deaa3/ironveil/js/weapons.js index 3d34493d..4cdfbcdd 100644 --- a/e63334287a3deaa3/ironveil/js/weapons.js +++ b/e63334287a3deaa3/ironveil/js/weapons.js @@ -255,8 +255,8 @@ else if (k !== 'rifle') { const rt = new THREE.Vector3(-1, 0, 0).applyQuaternion(model.getWorldQuaternion(new THREE.Quaternion())); IV.fx.casing(mz.x - ux.x * 0.5, mz.y, mz.z - ux.z * 0.5, rt.x * 2.2 + Math.random(), 2 + Math.random(), rt.z * 2.2 + Math.random()); } IV.audio && IV.audio.play(k, { x: mz.x, z: mz.z, own: true }); IV.ai && IV.ai.noise(P.pos.x, P.pos.z, w.noise, 'shot', P); - // recoil (TUNING.weapons.recoil): rifle one heavy kick, SMG a per-shot climb schedule with a slow sideways - // wander, pistol a sharp snap; a kept part stays in the aim, the rest springs back after the trigger is let go + // recoil (TUNING.weapons.recoil): rifle one heavy kick, SMG a per-shot climb schedule with a fixed sideways + // pattern, pistol a sharp snap; a kept part stays in the aim, the rest springs back after the trigger is let go const motion = IV.settings.motion ? 0.6 : 1; recoil(k); if (w.bloom) WP.bloom = Math.min(w.bloomMax, WP.bloom + w.bloom); @@ -269,8 +269,8 @@ IV.setUpper(P.actor, k === 'rifle' ? 'boltCycle' : 'fire'); IV.emit('shot', k); } - // one shot's kick. WP.recN counts rounds in the current string: it and the SMG's wander phase start again only once - // the gun has rested for spec.pause (quick taps continue the same path; a real pause starts from a fresh side) + // one shot's kick. WP.recN counts rounds in the current string: it starts again from shot 1 only once the gun has + // rested for spec.pause (quick taps carry on along the same path; a real pause starts the pattern again) WP.lastShotAt = -9; WP.recN = 0; // the sideways pattern: linear between the [shot, share] keyframes, held past the last one function patAt(pat, n) { From 5e9a0dcd45925fd9223550d35a5f33544ae99ab3 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 20:34:02 +0000 Subject: [PATCH 06/12] Midnight Ops enemies: Recruit grenades land wider and come later, nobody throws onto a friend Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rMA1ShmNuiCqMrmnvkS --- e63334287a3deaa3/ironveil/js/ai.js | 7 +++++-- e63334287a3deaa3/ironveil/js/core.js | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/e63334287a3deaa3/ironveil/js/ai.js b/e63334287a3deaa3/ironveil/js/ai.js index e810b906..d01dca3d 100644 --- a/e63334287a3deaa3/ironveil/js/ai.js +++ b/e63334287a3deaa3/ironveil/js/ai.js @@ -812,10 +812,13 @@ } // a grenade at the spot you have held: the thrower shouts first, then throws after grenadeWarn s if (held > A.campGrenade[D] && now > AI.grenadeAt && now - k.t < 8) { - let g = null, gd = 1e9; for (const e of free) { const d = Math.hypot(e.pos.x - k.x, e.pos.z - k.z); if (d > 9 && d < 30 && d < gd) { gd = d; g = e; } } + // never onto a friend: no throw when one of them is within 6 m of the spot + const friendNear = AI.list.some(q => q.alive && Math.hypot(q.pos.x - k.x, q.pos.z - k.z) < 6); + let g = null, gd = 1e9; if (!friendNear) for (const e of free) { const d = Math.hypot(e.pos.x - k.x, e.pos.z - k.z); if (d > 9 && d < 30 && d < gd) { gd = d; g = e; } } if (g) { AI.grenadeAt = now + A.grenadeCooldown[D]; - g.throwAt = { t: now + A.grenadeWarn, x: k.x + (Math.random() - 0.5) * 2.5, z: k.z + (Math.random() - 0.5) * 2.5 }; + const sc = A.grenadeScatter[D], a = Math.random() * 6.283, r = sc * Math.sqrt(Math.random()); + g.throwAt = { t: now + A.grenadeWarn, x: k.x + Math.cos(a) * r, z: k.z + Math.sin(a) * r }; AI.bark(g, 'throwing', true); IV.emit('aiOrder', { kind: 'grenade', e: g }); } } diff --git a/e63334287a3deaa3/ironveil/js/core.js b/e63334287a3deaa3/ironveil/js/core.js index c8419fbf..0f18d445 100644 --- a/e63334287a3deaa3/ironveil/js/core.js +++ b/e63334287a3deaa3/ironveil/js/core.js @@ -142,7 +142,8 @@ openHold: 3, // s: on first contact he answers from where he stands (if a turn to fire is free) before moving snapRange: { smg: 22, rifle: 34, pistol: 16 }, // m: caught in the open he stops and fires (his turn) instead of running first campFlank: [16, 11, 8], // s you stay on one spot they know (within 3.5 m) before one of them is sent round your flank - campGrenade: [13, 8, 6], // s on one known spot before a grenade (one man shouts first, then throws) + campGrenade: [16, 8, 6], // s on one known spot before a grenade (one man shouts first, then throws) + grenadeScatter: [4.5, 2.5, 1.8], // m: how far from that spot his grenade may land grenadeWarn: 0.9, // s from his shout to the throw pushLost: [14, 10, 8], // s out of sight before two of them move up on your last known position (the rest cover it) searchLost: [30, 22, 18], // s out of sight before the whole group goes to a proper search From 407f3558e120f766bbfeb438e0104313e29c40bc Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 22:10:38 +0000 Subject: [PATCH 07/12] Midnight Ops enemies: Recruit forgiving again (lighter hits, slower aim), header comment brought up to date Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rMA1ShmNuiCqMrmnvkS --- e63334287a3deaa3/ironveil/js/ai.js | 8 +++++--- e63334287a3deaa3/ironveil/js/core.js | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/e63334287a3deaa3/ironveil/js/ai.js b/e63334287a3deaa3/ironveil/js/ai.js index d01dca3d..d6b267ed 100644 --- a/e63334287a3deaa3/ironveil/js/ai.js +++ b/e63334287a3deaa3/ironveil/js/ai.js @@ -2,8 +2,11 @@ speed and surface, shots, rocks, impacts; masked by aircraft and engines), and moves through six states: unaware -> suspicious -> investigating -> searching -> combat -> returning. Searches go in pairs, bodies raise the alarm, officers run for the bell, and in combat they take cover, peek, suppress, flank in pairs, lob the odd grenade - and fall back when alone and hurt. Accuracy ramps up over about a second of seeing you, so being spotted is not - instant death. Kinds: rifleman, officer, sniper (scope glint), gunner (MG). */ + and fall back when hurt or nearly alone. Only a few fire at you at once (attack tokens), each after a tell (gun up, + a call, a glint at night). Accuracy grows with seconds of unbroken sight of you and falls with range, your movement + across their sights, darkness, smoke and their own suppression, so cover and moving between bursts beat standing in + the open. Hold one spot and they flank you, keep your head down, and shout before a grenade. Kinds: rifleman, + officer, sniper (scope glint, long tell), gunner (MG). */ (function () { 'use strict'; const T = IV.TUNING, A = T.ai, W = IV.world, F = IV.CF; @@ -734,7 +737,6 @@ Enemy.prototype.frame = function (alpha, dt) { const r = this.actor.root; r.position.lerpVectors(this.prev, this.pos, alpha); - if (this.peekOff && this.cover && !this.cover.low) { r.position.x += -this.cover.nz * this.peekOff * 0; } r.rotation.y = this.bodyPrev + IV.wrapA(this.bodyYaw - this.bodyPrev) * alpha + Math.PI; if (this.alive) { // aim at the target / look about diff --git a/e63334287a3deaa3/ironveil/js/core.js b/e63334287a3deaa3/ironveil/js/core.js index 0f18d445..d32023da 100644 --- a/e63334287a3deaa3/ironveil/js/core.js +++ b/e63334287a3deaa3/ironveil/js/core.js @@ -128,13 +128,13 @@ 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 - // to full after about 3 * expoTau s (9, 8, 7 s); out of sight it drains expoDrain times as fast as it builds. - acc: [0.48, 0.75, 0.82], // hit chance per shot at full exposure, 20 m, you standing still and lit (difficulty) - expoTau: [3, 2.7, 2.3], expoDrain: 3, expoFloor: 0.25, + // to full after about 3 * expoTau s (11, 8, 7 s); out of sight it drains expoDrain times as fast as it builds. + acc: [0.36, 0.75, 0.82], // hit chance per shot at full exposure, 20 m, you standing still and lit (difficulty) + expoTau: [3.6, 2.7, 2.3], expoDrain: 3, expoFloor: 0.25, rangeRef: 20, // m: the range factor is rangeRef / d (capped 1.3 close, 0.22 far: 0.4 at 50 m); SMG men lose more past 25 m warnShots: [2, 1, 1], // the first rounds of each new sight of you miss close by on purpose (a crack, a direction) dark: { moon: 0.85, shadow: 0.62, lit: 1, flash: 0.92 }, // accuracy by the light on you (your own muzzle flash lights you) - dmg: [26, 34, 36], // hp per enemy rifle hit before the difficulty's damage-taken multiplier (x0.6, x1, x1.45): 16, 34, 52 + dmg: [18, 34, 36], // hp per enemy rifle hit before the difficulty's damage-taken multiplier (x0.6, x1, x1.45): 11, 34, 52 smgDmg: 0.75, // an SMG round does this share of a rifle round sniperDmg: [45, 60, 85], sniperTele: [2.4, 2, 1.6], // s: the sniper's glint and call before his shot (the long, obvious tell) From 4c41f4387ab9117e02361dfef78ffa1519acd071 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 23:10:40 +0000 Subject: [PATCH 08/12] Midnight Ops enemies: cheaper per-step work (flat distances, fewer searches and allocations) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cw2rMA1ShmNuiCqMrmnvkS --- e63334287a3deaa3/ironveil/js/ai.js | 87 +++++++++++++++--------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/e63334287a3deaa3/ironveil/js/ai.js b/e63334287a3deaa3/ironveil/js/ai.js index d6b267ed..d98dcd8a 100644 --- a/e63334287a3deaa3/ironveil/js/ai.js +++ b/e63334287a3deaa3/ironveil/js/ai.js @@ -14,6 +14,7 @@ const AI = IV.ai = { list: [], bodies: [], maskUntil: 0, masks: [], loud: false, alarm: null, alarmRung: false, grenadeCool: 0, lastSpotted: -99, spottedCount: 0, perceiveP: null }; const P = IV.player; const diff = () => (IV.mission && IV.mission.diff) || 0; + const hyp = (x, z) => Math.sqrt(x * x + z * z); // flat distance (Math.hypot is slow in the hot loops) const BARK = { suspicious: ['Hm? Who is there?', 'Did you hear that?', 'Something moved.'], investigate: ['I will take a look.', 'Stay here. I am checking it.'], @@ -31,7 +32,7 @@ // force: the warnings that matter to you (a grenade coming, a flank) skip his talk cooldown AI.bark = function (e, kind, force) { if ((!force && IV.time < (e.barkT || 0)) || !BARK[kind]) return; - const d = Math.hypot(e.pos.x - P.pos.x, e.pos.z - P.pos.z); if (d > 45) return; + const d = hyp(e.pos.x - P.pos.x, e.pos.z - P.pos.z); if (d > 45) return; e.barkT = IV.time + 6; IV.hud && IV.hud.bark(e, IV.t(BARK[kind][Math.floor(Math.random() * BARK[kind].length)])); }; @@ -45,7 +46,7 @@ this.actor.attach(this.weapon, 'handR'); if (this.wkind === 'mg' && IV.weapons.prepMG) IV.weapons.prepMG(this.weapon); this.actor.groundAt = (x, z) => W.groundAt(x, z, this.pos.y + 0.4); - this.actor.onFoot = (side, k) => { if (Math.hypot(this.pos.x - W.camera.position.x, this.pos.z - W.camera.position.z) < 32) IV.footFx(this.pos, this.speed > 3 ? 'run' : this.stance === 'crouch' ? 'crouch' : 'walk', k, false, 0.5); }; + this.actor.onFoot = (side, k) => { if (hyp(this.pos.x - W.camera.position.x, this.pos.z - W.camera.position.z) < 32) IV.footFx(this.pos, this.speed > 3 ? 'run' : this.stance === 'crouch' ? 'crouch' : 'walk', k, false, 0.5); }; // never start inside a hedge or a wall (scripted spawns use rough positions) if (o.y == null && IV.nav.grid && !IV.nav.walkable(o.x, o.z)) { const p = IV.nav.nearest(o.x, o.z, 6); if (p) { o.x = p.x; o.z = p.z; } } this.pos = new THREE.Vector3(o.x, W.height(o.x, o.z), o.z); this.prev = this.pos.clone(); this.vel = new THREE.Vector3(); @@ -123,7 +124,7 @@ if (blast && dir) this.fallV = { x: dir.x * 3, z: dir.z * 3 }; // his friends flinch and one calls it if (wasCombat) AI.lost++; - if (wasCombat) { let called = false; for (const q of AI.list) { if (q === this || !q.alive || Math.hypot(q.pos.x - this.pos.x, q.pos.z - this.pos.z) > 20) continue; q.suppr = Math.min(1, q.suppr + 0.3); if (!called && q.state === 'combat') { called = true; AI.bark(q, 'manDown'); } } } + if (wasCombat) { let called = false; for (const q of AI.list) { if (q === this || !q.alive || hyp(q.pos.x - this.pos.x, q.pos.z - this.pos.z) > 20) continue; q.suppr = Math.min(1, q.suppr + 0.3); if (!called && q.state === 'combat') { called = true; AI.bark(q, 'manDown'); } } } this.deadT = 0; this.bodyAt = null; if (this.glint) this.glint.material.opacity = 0; AI.bodies.push(this); @@ -173,14 +174,14 @@ for (let i = AI.smokes.length - 1; i >= 0; i--) { const s = AI.smokes[i]; if (s.until < IV.time) { AI.smokes.splice(i, 1); continue; } const dx = bx - ax, dz = bz - az, l2 = dx * dx + dz * dz || 1, t = IV.clamp(((s.x - ax) * dx + (s.z - az) * dz) / l2, 0, 1); - const d = Math.hypot(ax + dx * t - s.x, az + dz * t - s.z); + const d = hyp(ax + dx * t - s.x, az + dz * t - s.z); if (d < s.r) return 0; if (d < s.r * 1.6) k = 0.5; } return k; } AI.smokeK = smokeK; function perceive(e, dt) { - const d = Math.hypot(P.pos.x - e.pos.x, P.pos.z - e.pos.z); + const d = hyp(P.pos.x - e.pos.x, P.pos.z - e.pos.z); e.seeing = false; if (P.alive && !AI.ignorePlayer) { const light = AI.playerLight(), r = AI.visRange(e, light); @@ -199,7 +200,7 @@ } // the squadmate is only noticed once the shooting has started if (!e.seeing && e.state === 'combat' && IV.ally && IV.ally.ent && IV.ally.ent.alive) { - const al = IV.ally.ent, da = Math.hypot(al.pos.x - e.pos.x, al.pos.z - e.pos.z); + const al = IV.ally.ent, da = hyp(al.pos.x - e.pos.x, al.pos.z - e.pos.z); if (da < 45 && inView(e, al.pos.x, al.pos.y + 1.2, al.pos.z, da)) { e.seeAlly = true; } else e.seeAlly = false; } else e.seeAlly = false; if (e.seeing) e.seeT += dt; else e.seeT = Math.max(0, e.seeT - dt * 2); @@ -210,7 +211,7 @@ // bodies if (e.state !== 'combat') for (const b of AI.bodies) { if (b.found || b === e) continue; - const db = Math.hypot(b.pos.x - e.pos.x, b.pos.z - e.pos.z); + const db = hyp(b.pos.x - e.pos.x, b.pos.z - e.pos.z); const lit = W.lightAt(b.pos.x, b.pos.y + 0.3, b.pos.z); const rb = 34 * Math.min(1.1, lit) * (W.surfAt(b.pos.x, b.pos.z) === IV.S.crops ? 0.25 : 1) + 2; if (db < rb && inView(e, b.pos.x, b.pos.y + 0.3, b.pos.z, db)) { @@ -227,7 +228,7 @@ AI.alertNear = function (e, r, at) { for (const o of AI.list) { if (o === e || !o.alive || o.state === 'combat') continue; - if (Math.hypot(o.pos.x - e.pos.x, o.pos.z - e.pos.z) < r) { o.alerted = true; o.aw = Math.max(o.aw, 0.7); o.lkp = { x: at.x, z: at.z, t: IV.time }; o.interest = { x: at.x, z: at.z }; o.setState('searching'); } + if (hyp(o.pos.x - e.pos.x, o.pos.z - e.pos.z) < r) { o.alerted = true; o.aw = Math.max(o.aw, 0.7); o.lkp = { x: at.x, z: at.z, t: IV.time }; o.interest = { x: at.x, z: at.z }; o.setState('searching'); } } }; @@ -239,9 +240,9 @@ for (const e of AI.list) { if (!e.alive || e.busy) continue; let r = radius * m; - for (const mk of AI.masks) if (mk.on && Math.hypot(e.pos.x - mk.x, e.pos.z - mk.z) < mk.r) r *= mk.mul; + for (const mk of AI.masks) if (mk.on && hyp(e.pos.x - mk.x, e.pos.z - mk.z) < mk.r) r *= mk.mul; if (e.alerted) r *= 1.2; - const d = Math.hypot(e.pos.x - x, e.pos.z - z); + const d = hyp(e.pos.x - x, e.pos.z - z); // a stone just out of earshot still makes a calm guard turn and listen (suspicious, no walk) if (type === 'rock' && d > r && d < r * T.noise.rockFaint && (e.state === 'unaware' || e.state === 'returning')) { e.aw = Math.max(e.aw, A.suspicious + 0.05); e.interest = { x, z }; e.setState('suspicious'); AI.bark(e, 'suspicious'); IV.emit('heard', { e, type: 'rockFaint' }); continue; @@ -284,12 +285,12 @@ const o = { x: 0, z: 0 }; function moveTo(e, tx, tz, speed, dt) { // (re)path when the goal moved or we have none - if (!e.path || !e.goal || Math.hypot(e.goal.x - tx, e.goal.z - tz) > 1.5 || e.repath <= 0) { + if (!e.path || !e.goal || hyp(e.goal.x - tx, e.goal.z - tz) > 1.5 || e.repath <= 0) { e.goal = { x: tx, z: tz }; e.path = IV.nav.path(e.pos.x, e.pos.z, tx, tz) || [{ x: tx, z: tz }]; e.pathI = 0; e.repath = 2.5; } e.repath -= dt; const p = e.path[e.pathI]; if (!p) { e.speed = IV.damp(e.speed, 0, 8, dt); return true; } - const dx = p.x - e.pos.x, dz = p.z - e.pos.z, d = Math.hypot(dx, dz); + const dx = p.x - e.pos.x, dz = p.z - e.pos.z, d = hyp(dx, dz); if (d < 0.45) { e.pathI++; if (e.pathI >= e.path.length) { e.speed = 0; return true; } return false; } e.speed = IV.damp(e.speed, speed, 6, dt); // no gliding and no instant 180s: turn first (in place) when the way on is well behind, at a capped rate @@ -299,7 +300,7 @@ const st = Math.min(d, e.speed * dt); o.x = e.pos.x + dx / d * st; o.z = e.pos.z + dz / d * st; // keep apart from other soldiers - for (const q of AI.list) { if (q === e || !q.alive) continue; const sx = o.x - q.pos.x, sz = o.z - q.pos.z, sd = Math.hypot(sx, sz); if (sd < 0.75 && sd > 0.001) { o.x += sx / sd * (0.75 - sd) * 0.5; o.z += sz / sd * (0.75 - sd) * 0.5; } } + for (const q of AI.list) { if (q === e || !q.alive) continue; const sx = o.x - q.pos.x, sz = o.z - q.pos.z, sd = hyp(sx, sz); if (sd < 0.75 && sd > 0.001) { o.x += sx / sd * (0.75 - sd) * 0.5; o.z += sz / sd * (0.75 - sd) * 0.5; } } W.collide(o, 0.3, e.pos.y + 0.45, e.pos.y + 1.7); e.vel.set((o.x - e.pos.x) / dt, 0, (o.z - e.pos.z) / dt); e.pos.x = o.x; e.pos.z = o.z; e.pos.y = W.groundAt(e.pos.x, e.pos.z, e.pos.y); @@ -322,24 +323,24 @@ const tx = tgt.x, tz = tgt.z; for (const c of pts) { if (c.used && c.used !== e) continue; - const dT = Math.hypot(c.x - tx, c.z - tz); if (dT < 6 || dT > 55) continue; + const dT = hyp(c.x - tx, c.z - tz); if (dT < 6 || dT > 55) continue; // the cover's face must point away from the target (the wall is between us) const ux = (tx - c.x) / dT, uz = (tz - c.z) / dT, facing = -(c.nx * ux + c.nz * uz); if (facing < 0.35) continue; - const dS = Math.hypot(c.x - e.pos.x, c.z - e.pos.z); + const dS = hyp(c.x - e.pos.x, c.z - e.pos.z); // distance from you: inside his weapon's band (SMG close, rifle further), the middle of it best const band = A.prefRange[wclass(e)], mid = (band[0] + band[1]) / 2; let s = facing * 4 - dS * 0.35 - Math.abs(dT - mid) * 0.12 + (c.low ? 0.5 : 0); if (dT < band[0]) s -= (band[0] - dT) * 0.5; else if (dT > band[1]) s -= (dT - band[1]) * 0.35; - if (back) s += (dT - Math.hypot(e.pos.x - tx, e.pos.z - tz)) * 0.6; - else s -= Math.max(0, dT - Math.hypot(e.pos.x - tx, e.pos.z - tz) - 4) * 0.3; // no long runs away from you to reach it + if (back) s += (dT - hyp(e.pos.x - tx, e.pos.z - tz)) * 0.6; + else s -= Math.max(0, dT - hyp(e.pos.x - tx, e.pos.z - tz) - 4) * 0.3; // no long runs away from you to reach it if (flank) { const a0 = IV.yawTo(e.pos.x - tx, e.pos.z - tz), a1 = IV.yawTo(c.x - tx, c.z - tz); s += Math.min(1.4, Math.abs(IV.wrapA(a1 - a0))) * 6; } // other soldiers' cover: spread out, both on the ground and by bearing round the target (two men on the same // line from you are one target; men on different bearings make you turn your head) const bc = IV.yawTo(c.x - tx, c.z - tz); for (const q of AI.list) { if (q === e || !q.alive || !q.cover) continue; - if (Math.hypot(q.cover.x - c.x, q.cover.z - c.z) < 3) s -= 3; + if (hyp(q.cover.x - c.x, q.cover.z - c.z) < 3) s -= 3; if (q.state === 'combat') { const db = Math.abs(IV.wrapA(IV.yawTo(q.cover.x - tx, q.cover.z - tz) - bc)); if (db < 0.52) s -= 2.5 * (1 - db / 0.52); } } if (s > bs) { bs = s; best = c; } @@ -415,7 +416,7 @@ } AI.hitChance = hitChance; function shoot(e, tgt, dt) { - const d = Math.hypot(tgt.pos.x - e.pos.x, tgt.pos.z - e.pos.z); + const d = hyp(tgt.pos.x - e.pos.x, tgt.pos.z - e.pos.z); const isP = !!tgt.isPlayer; if (isP && e.kind !== 'gunner') { // no turn free: he asks again shortly (the turn goes to whoever asks first once one frees up); now and then he @@ -489,7 +490,7 @@ } } else { const ps = e.post; - if (Math.hypot(e.pos.x - ps.x, e.pos.z - ps.z) > 0.8 && !e.fixed) { moveTo(e, ps.x, ps.z, A.walkSpeed, dt); return; } + if (hyp(e.pos.x - ps.x, e.pos.z - ps.z) > 0.8 && !e.fixed) { moveTo(e, ps.x, ps.z, A.walkSpeed, dt); return; } e.speed = IV.damp(e.speed, 0, 8, dt); // scan slowly between the post's look directions const sc = ps.scan || [0], k = Math.floor(IV.time / 6 + e.id) % sc.length; @@ -507,7 +508,7 @@ const at = e.interest || e.lkp; if (!at) { e.setState('returning'); return; } e.actor.setUpper('aimIdle'); if (e.fixed) { faceTo(e, at.x, at.z, 4, dt); if (e.stateT > 8) e.setState('returning'); return; } - const arrived = Math.hypot(at.x - e.pos.x, at.z - e.pos.z) < 1.6 || moveTo(e, at.x, at.z, A.searchSpeed * 0.8, dt); + const arrived = hyp(at.x - e.pos.x, at.z - e.pos.z) < 1.6 || moveTo(e, at.x, at.z, A.searchSpeed * 0.8, dt); if (arrived) { e.speed = IV.damp(e.speed, 0, 8, dt); e.lookT = (e.lookT || 0) + dt; e.headYaw = Math.sin(e.lookT * 1.3) * 0.45; @@ -523,7 +524,7 @@ const pts = [], R = IV.R; for (let i = 0; i < 6; i++) { const a = i / 6 * 6.283 + R() * 0.5, r = 4 + R() * 10, p = IV.nav.nearest(at.x + Math.cos(a) * r, at.z + Math.sin(a) * r, 4); if (p) pts.push(p); } if (!e.partner || !e.partner.alive || e.partner.state === 'dead') { - let bp = null, bd = 25; for (const q of AI.list) if (q !== e && q.alive && !q.fixed && q.state !== 'combat' && !q.partner) { const d = Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z); if (d < bd) { bd = d; bp = q; } } + let bp = null, bd = 25; for (const q of AI.list) if (q !== e && q.alive && !q.fixed && q.state !== 'combat' && !q.partner) { const d = hyp(q.pos.x - e.pos.x, q.pos.z - e.pos.z); if (d < bd) { bd = d; bp = q; } } if (bp) { e.partner = bp; bp.partner = e; bp.alerted = true; bp.lkp = at; if (bp.state !== 'searching') bp.setState('searching'); } } const half = e.partner && e.partner.id < e.id ? 1 : 0; @@ -543,8 +544,8 @@ }, combat(e, dt) { // a live grenade close by: get away from it first - const g = IV.weapons.throws.find(g => g.kind === 'grenade' && !g.enemy && g.fuse < 3.5 && Math.hypot(g.x - e.pos.x, g.z - e.pos.z) < 6.5); - if (g && !e.fixed) { if (!e.fleeT) AI.bark(e, 'grenade'); e.fleeT = 1; const ax = e.pos.x - g.x, az = e.pos.z - g.z, al = Math.hypot(ax, az) || 1; moveTo(e, e.pos.x + ax / al * 9, e.pos.z + az / al * 9, A.runSpeed * 1.1, dt); e.stance = 'stand'; return; } + const g = IV.weapons.throws.length ? IV.weapons.throws.find(g => g.kind === 'grenade' && !g.enemy && g.fuse < 3.5 && hyp(g.x - e.pos.x, g.z - e.pos.z) < 6.5) : null; + if (g && !e.fixed) { if (!e.fleeT) AI.bark(e, 'grenade'); e.fleeT = 1; const ax = e.pos.x - g.x, az = e.pos.z - g.z, al = hyp(ax, az) || 1; moveTo(e, e.pos.x + ax / al * 9, e.pos.z + az / al * 9, A.runSpeed * 1.1, dt); e.stance = 'stand'; return; } e.fleeT = 0; const tgt = e.target = pickTarget(e); const tp = e.seeing || (tgt !== WPent() && e.seeAlly) ? tgt.pos : e.lkp ? e.lkp : tgt.pos; @@ -552,7 +553,7 @@ if (e.seeing) e.lkp = { x: P.pos.x, z: P.pos.z, t: IV.time }; const canShoot = (e.seeing || e.seeAlly) && IV.time - (e.firstSee || 0) > A.reaction[diff()]; if (!e.seeing && !e.seeAlly) e.firstSee = IV.time; else if (!e.firstSee) e.firstSee = IV.time; - const dT = Math.hypot(tp.x - e.pos.x, tp.z - e.pos.z); + const dT = hyp(tp.x - e.pos.x, tp.z - e.pos.z); // officer: run for the alarm bell if (e.kind === 'officer' && AI.alarm && !AI.alarmRung && !AI.alarm.off) { BEH.alarm(e, dt); return; } // fixed posts (sniper, gunner) fight from where they are @@ -601,7 +602,7 @@ } e.coverT += dt; e.shotT -= dt; - if (e.cover && Math.hypot(e.cover.x - e.pos.x, e.cover.z - e.pos.z) > 0.6) { + if (e.cover && hyp(e.cover.x - e.pos.x, e.cover.z - e.pos.z) > 0.6) { // caught in the open within his range: his turn (call, weapon up, then the burst) is taken where he stands, down // on one knee; without a turn he runs on to cover. A crawling man only crawls const opening = now < (e.openUntil || 0) && (e.seeing || e.seeAlly) && dT < snapRange(e) && !e.crawl && !e.fellBack; @@ -615,7 +616,7 @@ } moveTo(e, e.cover.x, e.cover.z, e.crawl ? 0.7 : A.runSpeed * slow, dt); // on the move he keeps his head turned to where you are (as far as a neck turns), so he can still see you - e.headYaw = IV.clamp(IV.wrapA(IV.yawTo(tp.x - e.pos.x, tp.z - e.pos.z) - e.bodyYaw), -1.2, 1.2); + if (e.perT > 0.1 - dt * 1.5) e.headYaw = IV.clamp(IV.wrapA(IV.yawTo(tp.x - e.pos.x, tp.z - e.pos.z) - e.bodyYaw), -1.2, 1.2); // once per perception tick e.stance = e.crawl ? 'prone' : 'stand'; e.peek = false; e.actor.setUpper(!e.crawl && canShoot && dT < 15 ? 'aimIdle' : null); return; } @@ -643,8 +644,8 @@ // lost you: after a while the two nearest move up on your last known position, the others watch it from cover; // later still the whole group goes to a proper search if (lostFor > A.pushLost[D] && e.lkp) { - let rank = 0; const dl = Math.hypot(e.lkp.x - e.pos.x, e.lkp.z - e.pos.z); - for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && !q.fixed && !q.noRoam && Math.hypot(e.lkp.x - q.pos.x, e.lkp.z - q.pos.z) < dl) rank++; + let rank = 0; const dl = hyp(e.lkp.x - e.pos.x, e.lkp.z - e.pos.z); + for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && !q.fixed && !q.noRoam && hyp(e.lkp.x - q.pos.x, e.lkp.z - q.pos.z) < dl) rank++; if (rank < 2 && dl > 4 && !e.noRoam && !e.crawl) { if (e.cover) e.cover.used = null; e.cover = null; if (!e.pushing) { e.pushing = true; AI.bark(e, 'push'); } moveTo(e, e.lkp.x, e.lkp.z, A.searchSpeed * slow, dt); e.stance = 'stand'; e.actor.setUpper('aimIdle'); @@ -655,7 +656,7 @@ alarm(e, dt) { const al = AI.alarm; e.actor.setUpper(null); e.stance = 'stand'; - if (Math.hypot(al.x - e.pos.x, al.z - e.pos.z) > 1.2) { moveTo(e, al.x, al.z, A.runSpeed * 1.05, dt); e.ringT = 0; return; } + if (hyp(al.x - e.pos.x, al.z - e.pos.z) > 1.2) { moveTo(e, al.x, al.z, A.runSpeed * 1.05, dt); e.ringT = 0; return; } e.speed = 0; faceTo(e, al.bx || al.x, al.bz || al.z, 6, dt); e.ringT += dt; e.actor.play('salute', { fade: 0.15 }); e.ringUntil = IV.time + 0.25; if (e.ringT > A.alarmDelay && !AI.alarmRung) { AI.ringAlarm(e); } @@ -663,7 +664,7 @@ dead() {} }; BEH.scripted = () => {}; - function friendsNear(e, r) { let n = 0; for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && Math.abs(q.pos.x - e.pos.x) < r && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < r) n++; return n; } + function friendsNear(e, r) { let n = 0; for (const q of AI.list) if (q !== e && q.alive && q.state === 'combat' && Math.abs(q.pos.x - e.pos.x) < r && hyp(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < r) n++; return n; } const wclass = e => e.wkind === 'enemySmg' ? 'smg' : e.wkind === 'pistol' ? 'pistol' : 'rifle'; function snapRange(e) { return A.snapRange[wclass(e)]; } // the wait after a round: an SMG burst is quick (a pause every five), a rifleman works his bolt; suppression slows both @@ -672,7 +673,7 @@ return (AI.tokens.has(e) ? 0.6 + Math.random() * 0.3 : 0.9 + Math.random() * 0.8) * (1 + e.suppr); } function exposed(c, tp) { - const dx = tp.x - c.x, dz = tp.z - c.z, d = Math.hypot(dx, dz); + const dx = tp.x - c.x, dz = tp.z - c.z, d = hyp(dx, dz); return -(c.nx * dx / d + c.nz * dz / d) < 0.2; } // suppressing fire at a remembered spot: rounds land 1.8-4 m round it, so it pins you without being an unannounced @@ -706,12 +707,12 @@ if (IV.time - AI.lastSpotted > 8) { AI.spottedCount++; IV.emit('spotted', e); } AI.lastSpotted = IV.time; // the nearest friend becomes the flanker - let best = null, bd = 25; for (const q of AI.list) if (q !== e && q.alive && !q.fixed && q.role !== 'flank') { const d = Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z); if (d < bd && q.state === 'combat') { bd = d; best = q; } } + let best = null, bd = 25; for (const q of AI.list) if (q !== e && q.alive && !q.fixed && q.role !== 'flank') { const d = hyp(q.pos.x - e.pos.x, q.pos.z - e.pos.z); if (d < bd && q.state === 'combat') { bd = d; best = q; } } if (best && !AI.list.some(q => q.alive && q.role === 'flank')) best.role = 'flank'; // he shouts where you are (his own last known position of you: what he saw or heard) const at = e.lkp || { x: e.pos.x, z: e.pos.z }; AI.alertNear(e, 18, at); - for (const q of AI.list) if (q !== e && q.alive && Math.hypot(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < 18 && q.state !== 'combat') { q.aw = 1; q.lkp = { x: at.x, z: at.z, t: IV.time }; q.setState('combat'); } + for (const q of AI.list) if (q !== e && q.alive && hyp(q.pos.x - e.pos.x, q.pos.z - e.pos.z) < 18 && q.state !== 'combat') { q.aw = 1; q.lkp = { x: at.x, z: at.z, t: IV.time }; q.setState('combat'); } }; // ---------------------------------------------------------------- animation @@ -742,11 +743,11 @@ // aim at the target / look about let ap = 0, ay = this.headYaw; // his gun follows you only while he can see you; otherwise it points at where he last knew you were - if (this.state === 'combat' && this.target) { const sees = this.seeing || this.seeAlly, t = sees || !this.lkp ? this.target.pos : { x: this.lkp.x, y: this.pos.y, z: this.lkp.z }, d = Math.hypot(t.x - this.pos.x, t.z - this.pos.z); ap = Math.atan2(t.y + this.target.chestH() - this.eye(), d); ay = IV.clamp(IV.wrapA(IV.yawTo(t.x - this.pos.x, t.z - this.pos.z) - this.bodyYaw), -1, 1); } + if (this.state === 'combat' && this.target) { const sees = this.seeing || this.seeAlly, t = sees || !this.lkp ? this.target.pos : { x: this.lkp.x, y: this.pos.y, z: this.lkp.z }, d = hyp(t.x - this.pos.x, t.z - this.pos.z); ap = Math.atan2(t.y + this.target.chestH() - this.eye(), d); ay = IV.clamp(IV.wrapA(IV.yawTo(t.x - this.pos.x, t.z - this.pos.z) - this.bodyYaw), -1, 1); } this.actor.setAim(ap, ay); this._ap = ap; this._ay = ay; } // cull animation work for far soldiers (update every few frames) - const d = Math.hypot(this.pos.x - W.camera.position.x, this.pos.z - W.camera.position.z); + const d = hyp(this.pos.x - W.camera.position.x, this.pos.z - W.camera.position.z); this.animAcc = (this.animAcc || 0) + dt; const seen = onScreen(this.pos) && d < (W.quality === 0 ? 140 : 260); const every = !seen && d > 6 ? 0.25 : d > 90 ? 0.15 : d > 50 ? 0.066 : 0; @@ -797,14 +798,16 @@ for (const e of AI.list) if (e.alive && e.state === 'combat' && !e.scripted) { n++; if (e.lkp && (!newest || e.lkp.t > newest.t)) newest = e.lkp; } if (!n || !newest) { AI.know = null; return; } const K = AI.know; - if (!K || Math.hypot(newest.x - K.x, newest.z - K.z) > 3.5) AI.know = { x: newest.x, z: newest.z, t: newest.t, since: newest.t }; + if (!K || hyp(newest.x - K.x, newest.z - K.z) > 3.5) AI.know = { x: newest.x, z: newest.z, t: newest.t, since: newest.t }; else K.t = Math.max(K.t, newest.t); const k = AI.know, held = now - k.since, fresh = now - k.t < 10; if (!fresh) return; + const wantFlank = held > A.campFlank[D] && now > AI.flankAt, wantGren = held > A.campGrenade[D] && now > AI.grenadeAt && now - k.t < 8; + if (!wantFlank && !wantGren) return; const free = AI.list.filter(e => e.alive && e.state === 'combat' && !e.fixed && !e.noRoam && !e.scripted && !AI.tokens.has(e) && !e.throwAt && !e.crawl); // a flanker, and covering fire while he moves - if (held > A.campFlank[D] && now > AI.flankAt && free.length >= 2 && !AI.list.some(q => q.alive && q.state === 'combat' && q.role === 'flank')) { - let f = null, fd = 1e9; for (const e of free) { const d = Math.hypot(e.pos.x - k.x, e.pos.z - k.z); if (e.hp >= 50 && d > 8 && d < 40 && d < fd) { fd = d; f = e; } } + if (wantFlank && free.length >= 2 && !AI.list.some(q => q.alive && q.state === 'combat' && q.role === 'flank')) { + let f = null, fd = 1e9; for (const e of free) { const d = hyp(e.pos.x - k.x, e.pos.z - k.z); if (e.hp >= 50 && d > 8 && d < 40 && d < fd) { fd = d; f = e; } } if (f) { f.role = 'flank'; if (f.cover) f.cover.used = null; f.cover = null; AI.flankAt = now + 15; const c = free.find(e => e !== f && W.clear(e.pos.x, e.eye(), e.pos.z, k.x, W.height(k.x, k.z) + 1, k.z, F.SIGHT)) || free.find(e => e !== f); @@ -813,10 +816,10 @@ } } // a grenade at the spot you have held: the thrower shouts first, then throws after grenadeWarn s - if (held > A.campGrenade[D] && now > AI.grenadeAt && now - k.t < 8) { + if (wantGren) { // never onto a friend: no throw when one of them is within 6 m of the spot - const friendNear = AI.list.some(q => q.alive && Math.hypot(q.pos.x - k.x, q.pos.z - k.z) < 6); - let g = null, gd = 1e9; if (!friendNear) for (const e of free) { const d = Math.hypot(e.pos.x - k.x, e.pos.z - k.z); if (d > 9 && d < 30 && d < gd) { gd = d; g = e; } } + const friendNear = AI.list.some(q => q.alive && hyp(q.pos.x - k.x, q.pos.z - k.z) < 6); + let g = null, gd = 1e9; if (!friendNear) for (const e of free) { const d = hyp(e.pos.x - k.x, e.pos.z - k.z); if (d > 9 && d < 30 && d < gd) { gd = d; g = e; } } if (g) { AI.grenadeAt = now + A.grenadeCooldown[D]; const sc = A.grenadeScatter[D], a = Math.random() * 6.283, r = sc * Math.sqrt(Math.random()); From 2d7b3b93f31b6be0d752a15ce2654acaca237e1f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 23:14:15 +0000 Subject: [PATCH 09/12] Midnight Ops: a round never starts at a gun model left behind by an animation Seen by the enemies helper's Night Drop bot after planting the charge: the player's gun model stayed 2.7 m away and every round started there. If the muzzle is more than 1.8 m from the player's eye the round now starts at the eye. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01DfCR7RPoK1UNAvb7iRuPWn --- e63334287a3deaa3/ironveil/js/weapons.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e63334287a3deaa3/ironveil/js/weapons.js b/e63334287a3deaa3/ironveil/js/weapons.js index 4cdfbcdd..ef8ac179 100644 --- a/e63334287a3deaa3/ironveil/js/weapons.js +++ b/e63334287a3deaa3/ironveil/js/weapons.js @@ -214,6 +214,9 @@ const model = WP.models[k], muzzle = model.userData.muzzle; muzzle.getWorldPosition(mz); if (IV.fp && IV.fp.on() && !WP.scoped) IV.fp.muzzle(mz); // first person: the flash and tracer start at the visible muzzle + // a gun left behind by an animation (seen after planting the charge: the model stayed 2.7 m away and every round + // started there, into the sandbags) must never be where a round starts: fall back to the player's eye + { const ey = P.pos.y + (P.eyeH || 1.6), gx = mz.x - P.pos.x, gy = mz.y - ey, gz = mz.z - P.pos.z; if (gx * gx + gy * gy + gz * gz > 1.8 * 1.8) mz.set(P.pos.x, ey, P.pos.z); } if (WP.scoped) { // from the scope: start one sight-height below the eye, angled up by the zero angle const up = new THREE.Vector3(0, 1, 0).applyQuaternion(c.quaternion); From 0f1be4ffe3203f9f69f97acdbcd87e9bad7c0bd9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 00:57:22 +0000 Subject: [PATCH 10/12] README: Midnight Ops shooting rules, enemy behaviour and difficulty as they are now Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01DfCR7RPoK1UNAvb7iRuPWn --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 935afa0b..e1ff3bf4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Personal site hosted with GitHub Pages at **https://ascoding11.github.io**, the - `e63334287a3deaa3/chromaflage/`: Chromaflage (Back Room), paint-yourself hide and seek for up to 8 players (Three.js, Firebase Realtime Database rooms under `rooms/cf-…`, same project and rules as Rumble Karts; Quick match uses `rooms/cf-pub-1` to `cf-pub-4`; invite links go through the home page as `#cf-`). Hiders paint their own bodies in a paint studio (brush, an eyedropper that reads the true colour of whatever surface you click, fill, undo, glossiness) and pose to hide (crouch under tables, lie under beds, flatten, or stick to a wall with G or the Stick button and slide up, down and along it at any height, upright or sideways, until they jump to let go); seekers tag them with a blaster that fires a shot every 0.18 s (`FIRE_GAP`) for as long as the mouse button or the touch Tag button is held, with no reload pause: a miss costs one of 10 ink (`INK_MAX`), a hit costs nothing, and ink trickles back all the time at one shot every 2.5 s (`INK_REGEN`), so a seeker can keep firing at a hider who jumps about but blind spraying soon runs the tank dry and then gets a shot every 2.5 s. Fire rate and ink live only on the seeker's computer, which also decides hits (a ray against the hiders as it draws them) and sends a tag claim (`tg`) for the host to check, so changing them needs no change to the room data. Modes: Classic and Infection. Like Showdown, everything travels through each player's own node at `rooms/cf-/players/`, because the shared rules expect `n, c, x, z, h, ts` there and refuse other paths (such as `events`) for new prefixes: position and pose (`y, po, fl, p`, and `wl`: 0, or 1 to 4 for the way the wall a hider is stuck to faces, with `y` its height), body (`s` shape, `sz` size, `rf` glossiness), paint (`pv` version and `pd`, the 256 × 256 body texture as a WebP data URL, or JPEG where the browser can't make WebP; about 1 KB for a plain colour and 10–20 KB for a detailed pattern, re-sent at most every 1.2 s and only when it changed, so late joiners read it straight from the node), the last shot (`sh`), squeak (`ta`) and tag claim (`tg`). The host (newest host number `he`, else whoever has been in the room longest) publishes the round as JSON in its own `rs` and checks tag claims loosely; if it leaves, the next player carries on from the last round it saw. Anything read from another player's node is untrusted (any player can make itself host with a high `he`): `sanitizeRS` rebuilds a received round state field by field (known phases, numbers clamped, player ids checked and lists capped, settings through `cleanSet`), `remoteTarget` keeps positions inside the map and angles finite, and scores are shown as numbers, so keep new round-state fields going through `sanitizeRS` and escape anything put in `innerHTML`. A tab in the background gets no animation frames, so a 1 s timer keeps its node's `ts` fresh and, for the host, keeps the round ticking. Bodies are modelled about 1.7 units tall and drawn at `BODY` (0.64) times their size setting, so Normal is about 1.08 m. The Doll is a soft, rounded figure (a big round head on a short neck, a plump body, thick arms and legs with rounded ends, two small eyes), each part turned on a lathe (`latheGeo`, `dollParts`) with the texture spread evenly up the profile and normals taken from the profile so there are no shading seams; the Block is a slim slab. Each body shape has a 256 × 256 texture atlas where every texel knows its 3D spot on the body, so brushes paint by distance in 3D (`atlasOf`, `Paint`). Keep each part's region of the atlas (the `rect` passed to `latheGeo`) when reshaping a body, or saved and synced paint jobs land on the wrong parts; the Doll was reshaped inside the same regions, so paint saved before that lands on roughly the same places. Maps are axis-aligned boxes plus round props, built by `buildManor` (Hollyhock Manor: 48 × 38 m, a party night in a country house, with an 8 m grand hall whose staircase climbs to a gallery, ten rooms under 4.2 m ceilings), `buildMuseum` (Marlowe Museum: 58 × 50 m, a 7 m lobby, a top-lit grand gallery with free-standing walls, six galleries, a gift shop, a café and the storeroom) `buildRyokan` (Kirinoya Inn: 50 × 40 m, a Japanese inn round a glass-roofed garden courtyard, with four tatami guest rooms, a banquet hall, a tea room, a futon store, the hot-spring bath, the kitchen and a games lounge), and six everyday places: `buildSchool` (Birchwood High: 44 × 32 m, a locker-lined corridor, two classrooms, a science lab, a library, an art room, the staff room, toilets and the PE store), `buildOffice` (Larkspur & Co: 48 × 34 m, a reception, an open-plan floor of desk pods, a meeting room, the manager's office, a kitchenette, a server room, a store, a lounge and toilets), `buildMarket` (Greenleaf Market: 50 × 36 m, a 4.2 m supermarket floor of aisles, produce tables, chillers, freezer islands, a bakery, a deli and six checkouts, a café, the bakery kitchen, a stockroom with pallet racking and a forklift, the staff room, an office, toilets and a cold room), `buildHotel` (Hotel Bellamy: 48 × 36 m, a marble lobby with columns, a piano and a reception desk, a bar with a pool table, a restaurant, and off a carpeted corridor five guest rooms, each with a bathroom whose bath you can climb into, plus housekeeping and the laundry), `buildLeisure` (Riverside Leisure Centre: 50 × 38 m, a 7 m sports hall with bleachers, hoops and a climbing wall, a gym, a dance studio, the reception and café, two changing rooms with lockers and showers, first aid, the equipment store, an office and the plant room) and `buildFlats` (Maple Court: 46 × 31 m, four flats off a landing, each with a living room and kitchen, a bedroom, a children's room with bunk beds, a study, a hall and a bathroom, plus the residents' laundry and the bike and bin store; the north flats are the south ones mirrored by `flat()`). The everyday maps share painters, `everydayMats` and the `everyday` furniture (desks, office and school chairs, lockers, gondola shelving, counters, divans and bunk beds, bathroom pieces, gym kit, bleachers, trolleys, pallets). Walls, floors and ceilings come from `kit`: `wallX`/`wallZ` build a wall as two half-thick slabs, one per room, each reaching 1 cm past the centre line so the two overlap and leave no seam to slip into, each from a side spec (`w` wallpaper, `lo` and `lh` lower panelling, `h` height, `base`, `rail`, `crown`, `casing`), with door openings and their casings; `win`, `pic`, `flat` and `sconce` hang windows (an evening view), framed pictures, signs and wall lights, and `ag` places furniture with its back to a wall. Wall slabs are marked `wall`, and trims, pictures and curtains are not solid, so a hider can still stick to the wall behind them. The `Builder` helpers are `box`, `at` for turned furniture, `prop` for round things from the shared `geo()` cache (baked with the boxes into one mesh per material, so a map is about one draw call per material), `ceil` for ceilings drawn from below only so the menu's view from above looks into the rooms, `spot` for places bots hide under tables, beds and the inn's futon cupboard, and `lamp` for point lights, of which only six spread-out ones are used, three on the Fast setting; the furniture helpers are in `furn` (tables, round tables with cloths, chairs, benches, sofas, beds, a grand piano, a fireplace, plants and palms, lamps and chandeliers, washing lines, curtains you can walk into, vending machines, plinths and mannequins, which make good decoys). The bots only walk the floor: the manor's gallery and the inn's raised entrance step are for players. Each map gives `spawns`, a `seek` start and an `attract` spot for the menu's doll. Boxes marked `soft` (cloth and leaves) block the view and the seeker bot's line of sight but not the blaster's pellets. The boxes are also the colliders, the bots' navigation grid, line of sight and the surfaces the eyedropper and bots sample; they are filed in a 2 m grid (`buildGrid`, `solidsIn`, `rayMap`) so rays and collisions stay quick. Every pattern is drawn on a canvas by the `P` painters (damask and striped wallpapers, wood panelling, marble, tatami, shoji and fusuma, rugs, portraits, landscapes and modern paintings, and so on), from a fixed seed so all players get the same map. Every room must keep a ceiling. To add a map, write a `build…` function and add it to `MAPS`, then check it the way the existing ones were checked: every spawn, the seeker start and every bot `spot` free and reachable from the seeker start, a ceiling and a floor everywhere, no ray escaping the shell, and no solid furniture cut into a wall. Bodies collide as their pose's footprint circles against the boxes (`moveEnt`): each move is cut into steps shorter than the body's radius and anything it runs into pushes it back out the face it came in through (`pushOut`), so nothing can be crossed in one frame; a box whose top is within a step of the feet (`stepOf`: 0.45 m standing, half the body's height crouching or lying) is climbed only when there is room to stand on it, otherwise it is solid (a chair seat over its legs, a bed frame under its quilt); a box whose bottom is within 1 cm of the top of the head doesn't block, so a body that just fits under a table fits; low furniture is solid down to the floor unless the gap under it is at least as tall as the smallest lying body (`minGap`, the Petite Block, about 0.15 m: `Builder.finish` adds an invisible collider under anything lower); a body that finds itself inside something (after growing, say) moves to the nearest free spot that isn't across a wall (`freeSpot`, `wallBetween`), and a move never ends on the far side of a wall. The practice seeker bot "sees" by rendering a small view of you with and without you and comparing the colours (`perceive`, delta E), so better paint really does keep you hidden; it sweeps its gaze up and down so it can spot hiders high on walls, and furniture blocks its view. Practice hider bots sometimes hang on walls or tuck under furniture. Online rooms follow a daily map rotation: `dayMaps` shuffles all the maps with the day number as the seed (days start at midnight US Eastern standard time, `DAY_SHIFT`) and keeps the first three, and the map is `dayMaps(now)[floor(now / 15 min) % 3]` (`rotMap`), worked out from the shared server clock (`Net.now`). The host publishes it as `rs.map` in the lobby and when it starts a round, so a round in progress finishes on its map and the next round or the lobby moves on; the lobby shows the map now and "Next map in m:ss" with the next map's name (`rotText`), and the menu names today's three. The host of a private room can still pick a single map instead of "Daily rotation" (the `map` round setting, -1 for the rotation); Practice has a picker of every map; Quick match and invite links are unchanged. Nothing is stored online between rounds; your name, body, last paint job and settings are saved in the browser under `chroma-…`. Parties can launch it (its row in `GAMES` in `party.js`). On touch screens the page adds `touch` to `body`, and the `body.touch` rules at the end of the stylesheet place the HUD, the lobby card and the paint studio for phones held upright or sideways (keep them clear of the stick and buttons when adding HUD pieces). The lobby card and the paint studio scroll an inner box (`.lb-body`, `.st-body`) instead of the card itself, because Chrome can leave a blank patch in the 3D view under a scrolling box with a solid background. Effects (`splat`, `pellet`, `confetti`, `puff`, all under `fxRoot`) are drawn only on each player's own computer and are hidden from the practice bot's eyes (`perceive` hides `fxRoot`), so they can be restyled without changing what can be hidden against: a pellet is a short streak with a pale tail and a small flash at the blaster, the mark it leaves is one of five splat shapes made once by `splatGeo` (a wobbly blob with lobes and stray drops, in the same pink and about the same size as a plain round mark) that pops open and throws off a few drops, and a find adds a gold ring and a sparkle to the confetti. The Fast setting gets fewer drops and less confetti (`fxHigh`). On the HUD the crosshair kicks on each shot, the FOUND banner, the "Found …" text and the Still hidden number pop when they change (`hudPop`), the clock turns pink and beats in the last ten seconds of hide or seek time, and the results card rises into place; all of these are skipped when the device asks for reduced motion. Lighting, shadows, map colours and patterns, the paint palette and how paint is sampled were deliberately left alone, because in this game any change to how a surface is lit changes how well a paint job matches it. **Turkey Week** (`../events.js`, November 15 to 26, 2026): seekers wear a pilgrim hat as part of their gear; hiders never do, because a hat would give them away: one shared hat geometry and material from `events.js` (`tkHat`), one extra draw call each. The game reads the one Turkey Week switch on the Back Room page (see `events.js` below) once, when it loads (off means no hats are made); it has no button of its own. **Seeker kit** (hidden: captains only for now; `KIT_PUBLIC = false` and `kitOn()` in `index.html`, and `?seekerkit=1` turns it on for testing, on localhost or in an automated browser only): seven hats (a detective deerstalker, a safari hat, a painter's beret, a museum guard cap, a hard hat, an exterminator cap and goggles), four tools that take the blaster's place in the hand (a magnifying glass, a paint scraper, a spray bottle and a feather duster), plus, from 19 Nov, twelve more hats (8 to 19: team cap, football helmet, sweatband, referee cap, pirate hat with an eye patch, fedora, top hat, robot antenna, champion headband, hockey helmet, bowler hat, mascot ears) and eight more tools (5 to 12: foam finger, pirate hook, walking cane, whistle, tennis racket, hockey stick, spyglass, robot claw), each still one merged mesh, a paint splash when the wearer catches someone (a ring of see-through droplets that flies outward and is gone within 0.6 s, and a small SPLAT! above the caught hider's head) and a caught animation for the hider they catch (it hops and pops along its own up direction, spinning only when it was upright), all drawn by `kit.js`, which the page fetches only when this player may open the Seeker kit (a button under the body choices on the menu opens a screen with a model of you as a seeker) or someone in the room wears a kit; for everyone else it never loads and every hook (`if(CK)`) does nothing. Seekers only: hats and tools are added inside the seeker gear (`Avatar.gear` and `Avatar.gun`), which the page shows only while a body is a seeker, and the two effects start only once the host has marked a hider found, are drawn under `fxRoot` for at most 1.2 s and leave no marks, so nothing changes how a hider looks or how easy a hider is to see while hiding. Shooting is still the camera's ray, so a tool changes neither reach nor tagging (the pellet still starts at the hand), hats stay low and above the visor, and your own hat and tool are hidden while the camera is pulled in close to them. A kit is four item numbers, the `no` of Chromaflage's items in `cosmetics.js` ([hat, tool, splash, caught], 0 for none; `kit.js` keeps its lists in the same order, so never reorder them), saved as `chroma-kit` and sent in the player's own node as `kt` (`'3.1.1.0'`, only when something is worn; older pages ignore it, and `kit.js` checks every number and draws the plain gear for one it does not know). Each hat and tool is one mesh (its pieces merged with vertex colours, one geometry per item, one shared material); a dressed seeker's blaster becomes one merged mesh too and a hat replaces the Turkey Week hat, so a dressed seeker is never more draw calls than a plain one. It has Spanish: its words are in `chromaflage/es.js` (lang.js; map names and the signs inside the maps stay in English), with a Language switch in Settings and the pause menu. - `e63334287a3deaa3/backrooms-1v1/`: Backrooms 1v1–4v4 (Back Room; the folder keeps its original `backrooms-1v1` name), a third-person build-fight shooter in Level 0 of the Backrooms (Three.js). Practice is you against the Entity, a bot that runs only in your browser. Online rooms hold up to 8 players split into Red and Blue (1v1 to 4v4, uneven teams like 4v3 are allowed and never filled with bots) in the Firebase Realtime Database under `rooms/br-…` (same project and rules as Rumble Karts; invite links go through the home page as `#br-`). Quick match waits in `rooms/br-queue/players` and pairs two people into a `br-q…` room for a 1v1. Each player writes only their own node `players/`: `n`, `c`, `x`, `z`, `h` and `ts` always (the shared rules expect that shape), plus height, pitch, health, shield, weapon, a dead flag, the match `m` and round `rd` the position belongs to, the team picked in the lobby `t`, kills this match `k`, join time `j`, `mv`, the newest map version the page can build (3), and `ev`, set to 1 by a page that can edit builds; about 20 times a second during a round (15 in rooms of 5 or more) while something changed, and twice a second otherwise or while nothing has. The host is the live player who has been in the room longest (the next in line takes over when they leave; a newcomer only starts judging who the host is once the room's players and round have loaded, so a slow phone joining mid-match can't take over and reset it) and is the only one who changes `round`: `{id, ends, seed, ns, ph, pt, to, rn, sr, sb, ro, dd, rw, mw, fm, rz, mv, ed}`, where `id` is the match, `ph` the phase (`lobby`, `cd` countdown, `fight`, `over`, `end`), `pt` when the phase ends, `to` the rounds to win (3, 5 or 10, host's choice), `rn` the round, `sr`/`sb` the team scores, `ro` the roster (`uid:r;uid:b`), `dd` who is out this round, `rw`/`mw` the round and match winners, `fm` a forfeit, `rz` the host's "Randomize teams" draw (each player then moves themself), `mv` the map version for this match (see below) and `ed` whether builds can be edited in it (see Editing builds). The host writes with transactions guarded on `id`, `ph` and `rn`, and keeps `ends` at the time of writing because the rules cap how far ahead it can be. Shots, builds and deaths go through `events/` (deleted after 5 s): the shooter's rays pass through teammates and the shot lists only the enemies it hit; the victim applies damage only from someone on the other team of the same match, and reports its own death naming the last shooter, which gives the kill credit. A round ends when one team has nobody left: dead, or silent for 10 s (a closed tab removes its node at once). A team with nobody left in the room (disconnected, or silent for 20 s) forfeits the match. A host whose own tab has just frozen waits a moment for the queued updates before judging anyone. Players who join mid-match wait in the lobby or watch until the next one, and dead players watch a living teammate (click, or tap Next on a touch screen, for the next one). **Find tags:** once a round's fight has run for 1 minute 30 seconds (`FIND_AT`), every 15 seconds (`FIND_EVERY`) a name tag shows over every living player for 2 seconds (`FIND_SHOW`), through walls, with how far away they are, so players who can't find each other can; it pops in white, holds in the team colour and blinks out (a plain fade with reduced motion), with a soft ping. A tag for someone off the screen is pinned to the nearest edge with an arrow showing which way to turn. Nothing is sent for this: the clock (`findClock`) is the round's own, online the server-clock time since the fight began (the round node's `pt`, which is when the countdown ended and is left alone for the whole fight phase), so every browser flashes at the same moments, and in practice the seconds fought this round (the tag is the Entity's). Between flashes nothing changes: teammates' tags show all the time, as before, and an enemy's only while in sight. From ten seconds before the first flash a small chip (`#find`, under the score; on a phone, under the health bars sideways and in the top right corner upright) counts down to the next one, and the first flash of a match adds one line to the feed. The tags are the same HTML labels as the ordinary name tags (a fixed size on screen, so readable far away and not huge up close), so they add no draw calls. An older copy of the page in the room just never shows them. **Maps:** every round is a new, randomly generated Level 0, in practice and online, on a grid of 4 m cells with walls on the cell edges and posts on the corners (`layoutV3`, map version 3). Every map is built the same way, so they all feel like the same place: a 3 × 3 room round each spawn, then rooms of 2 × 2 to 2 × 4 cells dropped at random until about two fifths of the floor is rooms, and everything else one-cell-wide (4 m) corridor. Every wall is full height: no low partitions, stray wall slabs, open halls or pillar fields (the most a room gets is one column in the middle, about one room in three). The rooms and corridor cells are joined into a tree and then given a few loops (a second or third way into some rooms, the odd extra link between corridors, most dead ends opened onto something), with three rules: never two openings side by side in one room wall, never four corridor cells open as a square (corridors stay one cell wide), and never a short piece of wall left standing on its own. Where a room opens onto something else the opening is a doorway, with a 0.8 m jamb of wall (`JAMB`) each side wherever the wall carries on past it. Any straight line of more than six cells (`V3_RUN`, 24 m) gets a wall across it near the middle, and the corridor jogs round it. The lighting is the same everywhere: about one ceiling panel in twelve is dead (the floor under it a little darker), up to three flicker on their own, and most maps have one or two banks (a room or a stretch of corridor) that flicker together and dim the walls, floor and ceiling around them; there are no tinted wallpapers, damp carpets or special rooms. Then each spawn is cleared to an open, lit 3 × 3 area, anything that can't be reached on foot is opened up, and the layout is checked for fairness (`fairV2`: both teams' spawns about as far from the middle on foot, the two halves within about a third of each other's cover, no huge detour between the teams); one that fails is redrawn (about one in four), and if sixteen in a row fail (in practice never), the closest is made point-symmetric, which is fair by construction but can leave a few open patches along the middle. Checked on 600 generated maps of every size and roster: no low partitions or free-standing wall pieces, no 3 × 3 block of cells without a wall inside it outside the spawn areas, no straight run longer than six cells, every cell reachable, the same seed always gives the same map; the longest sightline on a map is 23–53 m (v2: 42–69 m). A v3 map has more walls, so its collision boxes are joined up along each wall line (`solidsV3`: walls and jambs that touch end to end become one box, and posts in the middle of a straight run are left out), which leaves fewer boxes than a v2 map (about 210 against 310) and less work per frame for movement and shots. Size depends on the number of players and a little chance: 11–13 cells across for a 1v1 (and practice), 12–14 for 3–4 players, 14–15 for 5–6, 15–16 for 7–8. Red spawns along the west edge and Blue along the east. Online, the layout of round `rn` comes from the match's `seed` and `rn` (`roundSeed`), and its size from that and the roster size, so every player builds the same rooms without anything new being sent; a short blackout covers the change between rounds. **Older copies of the page** (still open in someone's tab after an update) only know earlier layouts, which are kept unchanged in the page and checked to build exactly the same walls, pillars and lights for the same seed: the original maze (`layoutV1`: one per match from `seed`, 12, 14 or 16 cells by room size (`ns`), Red's and Blue's spawn areas cleared), and the previous random layout (`layoutV2`, map version 2: the floor split into areas furnished in different ways (twisty corridors, small rooms, open halls with stray wall slabs, pillar fields, office cubicles behind 1.25 m grey partitions you can see and jump over, solid blocks of wall), joined by doorways or with no wall at all, each lit its own way, sometimes with a different wallpaper or a special room). Each player's node says which maps their page can build (`mv`), and the host writes into a new match the newest version every player in the room has: `mv: 3`, `mv: 2`, or no `mv`, in which case everyone, new pages included, plays the original maze for that match, so a mixed room always agrees on the walls (an older page that joins in the middle of a newer match only watches, and may see the wrong walls until the next match). A host on a v2 page writes `mv: 2` at most, and one on a v1 page never writes `mv`, so the same applies. The collision rules below hold for every layout: automated walks and jumps into walls, doorway jambs, partitions, big pillars and wall blocks, spawns for every roster shape and shots at every kind of solid, run on hundreds of generated layouts, found nothing passing through or stuck inside a wall; and scripted runs and jumps at built walls, floors and ramps from every side, at 60, 30 and 20 frames a second and thrown at up to 20 m/s, with random building and with the Entity's own code, found nothing inside or through a build. Builds can't be placed inside a solid block of wall. **Editing builds:** aim at a wall, floor or ramp your team built (in practice, one you built; never the other team's or the Entity's) from within 6 m (`EDIT_RANGE`) and press Edit (G, or the Edit touch button): the piece turns into a grid of tiles, 3 × 3 on a wall and 2 × 2 on a floor or a ramp (a ramp's are its low and high halves, left and right). **Edit on release** (a setting, on by default, in the menu under Look sensitivity and on the pause screen, saved as `br1v1-editOnRelease`; a `br1v1-editRelease` saved by the first version is still read; the Edit key itself is rebindable in Change keys like any other): hold Edit and the tile under the crosshair is picked at once, every tile the crosshair then sweeps across is picked too (no need to hold Shoot / place, though it does the same), and letting go of Edit confirms (`editHold`, `editKeyUp`, `paintTile`). The first tile of a sweep decides whether it opens or closes tiles. A quick tap of Edit (under 0.25 s, `EDIT_TAP`) that did no more than pick that first tile leaves the grid open with that tile still picked (so two taps make a one-tile window), the setting-off way: Shoot / place opens or closes the tile under the crosshair (hold and sweep for several) and Edit again confirms. A longer hold that changes nothing cancels. Either way Reload resets the piece to whole (the touch button reads Reset) and Aim cancels; on a touch screen the buttons read Tile, Done, Reset and Cancel while editing, and a finger put down on the grid picks the tiles it touches instead of turning the view (`editFingerDown`, `screenRay`), so you hold Edit with one thumb, drag the other over the tiles and let go. While you edit, the line of help names the shape so far (Door, Window, Arch, Half wall, Narrow ramp…, `edName`) and what to press next; until your first confirmed edit it spells the whole thing out (`br1v1-editHelp`). The tile under the crosshair is worked out on the grid's own plane, and a point up to a third of a tile off the edge counts as the edge tile (`edTileAt`, `EDIT_EDGE`), so the bottom row of a wall you stand against is easy to pick; when the line of sight finds none of your builds, eight lines just around it are tried (`EDIT_FAN`), so an edge or a seam up close still opens. Your own body is hidden while the grid is up, so it doesn't cover the tiles. That gives a window, a door, a half wall, an arch, a floor with a corner cut, a half-width ramp and so on. At least one tile has to stay. Nothing changes until you confirm, and then the new shape is there at once (it used to land 0.4 s later, `EDIT_T`, now gone); you can't shoot while the grid is up, and a Shoot / place still held from picking tiles doesn't fire until it's let go (`editLatch`). The build message is the same as before. A piece's shape is `ed`, one bit per tile cut out (tile (u,v) is bit `v*n+u`; 0 is the whole piece). The tiles left are joined into as few rectangles as it takes (`edRects`), and each rectangle is one ordinary solid box, or for a ramp one ordinary ramp sheet with a smaller footprint (`pieceShape`), so there is no second collision system: movement, `pushOut` / `rampOut` and shots run the same code as for a whole piece, you walk through a door and shoot through a window because no box is there, and what is left blocks from every side (tiles that come back on a body move it out, as a new build does). The picture is one mesh made of the same rectangles (`pieceGeo`), so an edited piece is still one draw call; the grid you see while editing is three, in place of the piece, and only on your screen. Checked with the game's own movement and shots against the tiles themselves: every one of the 511 wall shapes both ways round (shots straight and slanted through every tile from both sides, walks at it along its length, thrown and jumping bodies), all 15 floor shapes and all 15 ramp shapes in all four directions, at 60, 30 and 20 frames a second, and whole pieces compared number for number with the page before editing. Online an edit travels as the build message for that spot again with `ed` added, the host answers anyone who comes into a round late (`bq`) with every piece standing, its health, shape and team (`bs`), and only the team that built a piece may reshape it (a message from anyone else is ignored). A page from before editing ignores a build for a spot that is taken, so it would keep the whole piece; to keep a mixed room agreeing on the shapes, every page says in its player node whether it can edit (`ev`), and the host turns editing on for a match (`ed: 1` in the round node, written like `mv`) only if every page in the room can: otherwise the Edit key says a player needs to refresh. The Entity does not edit; when a build stops it, it shoots the part it walked into (`bump`), whatever the shape, and it sees and shoots through openings only. Keys and mouse buttons can be changed in the Controls panel (`keybinds.js`, saved as `keybinds:backrooms-1v1`; the Change keys button under Controls in the menu, and Controls on the pause screen): move, jump, shoot / place, aim (Shift and right click), the three guns, reload, the three build pieces (two keys each), Edit (G), the arrow keys that look around when the mouse can't be locked, and pause (P; Esc is fixed). Clicking to watch the next teammate stays on the left mouse button, and the mouse wheel still switches guns. On touch screens it has a move stick, drag-to-look, Fire/Place, Jump, Aim, Reload, Edit and pause buttons, with the weapon and build slots as buttons along the top; while you watch, those give way to a Next button, and the lobby, pause and results screens are plain buttons that fit a phone either way up. Each browser is trusted for its own health and hits, so it isn't cheat-proof. A test hook (`window.__br`) exists only when `navigator.webdriver` is set (its `findShift` moves the find-tag clock forward so a test need not wait a minute and a half). **How it's drawn** (the picture only: nothing here is sent to other players or changes collision, damage or movement): the scene is lit by a soft overall light plus a warm light from one side and a weak cool one from the other, so walls facing different ways, and the two sides of a character, come out in different shades. The carpet is darker than the walls, and its texture repeats once per cell with a pool of light baked into the middle, so the floor is brightest under each ceiling panel and darkest along the walls. Walls, posts, pillars and doorway jambs have a dark skirting board, which is part of the same geometry (`joinGeos`, `skirtW`), so each kind is still one instanced mesh and the collision boxes are unchanged; working ceiling panels have a soft glow round them (one more instanced mesh). A character's suit is a few meshes, each made of several boxes joined together (`parts`), and each of the three guns is one shared mesh coloured per corner (`GUN_GEO`; `GUN_TIP` is how far each muzzle is from the hands), so the detail costs no extra draw calls; every character has a round shadow on the ground under it, which shrinks during a jump and lies along a ramp. The detail stays inside the outline the plain characters had, so nobody is drawn bigger than before: the suit's body, legs and head are the same boxes, each gun is squeezed along its barrel to the length of the plain one it replaced (`gunFit`: rifle 0.78 m, shotgun 0.86 m, sniper 1.18 m), and the shadow is 1 m across, about the width of the figure (a wider one made characters read as larger). Keep to that if you add more detail. A shot shows a muzzle flash at the end of the shooter's barrel and kicks the gun back; tracers are thin glowing beams sized to stay about two pixels wide near and far, and are drawn from the end of the barrel, though the shot itself still starts at `muzzleOf` as before; where a shot lands there is a flash and three sparks. The tracers, flashes and sparks come from small pools made once (`pool`; the sparks are one instanced mesh), so shooting creates no new objects. With the browser's reduced-motion setting on, the muzzle flash, gun kick and sparks are left out. **Turkey Week** (`../events.js`, November 15 to 26, 2026): every suit wears a pilgrim hat: one shared hat geometry and material from `events.js` (`tkHat`), one extra draw call each. The game reads the one Turkey Week switch on the Back Room page (see `events.js` below) once, when it loads (off means no hats are made); it has no button of its own. **Locker** (hidden: captains only for now): `locker.js` holds 36 outfits (18 sports kits, 4 robots, 4 pirates with eye patches, 6 costume-party suits, astronaut, wizard, firefighter and knight), 19 gun skins (7 of them animated: Gold, Chrome, Neon Pulse, Frostbite, Lava, Galaxy, Rainbow Flow and Circuit Board shine, pulse, flow or twinkle on one shared clock), 6 build skins, 8 elimination effects and 8 round-win celebrations, all drawn in code; the same items, by number, are Backrooms' block in `../cosmetics.js` (`backrooms-1v1`, prefix `br`). `BR_PUBLIC = false` near the top of the page is the one switch that opens it to everyone; until then `lockerOn()` asks `../captains.js` (`BackRoomCaptains.may(false, 'locker', 'br1v1-locker')`, so `?locker=1` works on localhost or in an automated browser), and a Locker button and screen appear in the menu only for those players. `locker.js` is fetched only for them, or when someone in the room wears something; for everyone else it is never loaded, `LK` stays null and the page draws, sends and saves exactly what it did before. While the shop is off everything is free to wear and what is worn is saved as `br1v1-kit`. Online it travels in the player's own node as one optional field, `lk` (a letter per slot and the item's number, e.g. `o12g3c2`: o outfit, g gun skin, b build skin, e elimination, c celebration), checked strictly; an unknown number draws the default for that slot, and a page from before the Locker ignores the field and draws the plain suit. Looks only and fair in ranked play: every outfit is built on the plain suit's own boxes (legs, body, head, sleeves, gloves) with a pack the size of the air tank on its back, so none is drawn smaller; the main colour is the team colour online (an outfit's own colours only in practice). The test hook's `__lk.fair()` draws each outfit flat from four sides against the plain suit in both team colours: outline 100–120% (hats add height), brightness never lower, colour distance from the walls and carpet never more than 0.02 lower, no more of it close to the wall or carpet colours, at least 40% of it in team colours (the rest is bold white, black, gold, silver and bright accents, never wall yellow, carpet brown or the other team's colour). Locker items use their own shared material (`lockerMat`), which adds a little of each item's own colour as light, because the dim yellow room light turns bright colours muddy; the plain suit and plain guns keep the game's own materials. Gun skins recolour the same three guns (`GUN_SRC`, cut into stripes or patches, through the same `gunFit`, so length and shape are unchanged; the sniper's lens stays). Build skins only change the picture on a piece (opaque, the same frame and brace; each measured at least as far from the walls, carpet and team colours as plywood), and a piece takes its builder's skin (a late joiner's `bs` copy of the round draws plywood). Elimination effects play where the player falls (centred on the body), for everyone, when the player who got them wears one, and are over in 1.5 s (the falling body takes 2.2 s). Celebrations play only while the round is over and the wearer's team won it, and stop as soon as they move or shoot; they move only the picture. An outfit is fewer draw calls than the plain suit (6–7 against 12) with geometry cached per outfit and team colour; skins and effects add none except two instanced meshes while an effect plays. During Turkey Week an outfit with its own hat hides the pilgrim hat. **Spanish** (lang.js): its words are in `backrooms-1v1/es.js`, text it puts together (banners, lobby, help line, results) goes through `TX()`, HUD parts that change during play are `data-noi18n`, and only team and room keys go over the network, never words. - `e63334287a3deaa3/drop-zone/`: Driftfall (Back Room; the folder is `drop-zone`), a third-person battle royale for up to 30 players on Gullrock Isle (Three.js; Firebase Realtime Database rooms under `rooms/dz-…`, same project and rules as Rumble Karts; invite links go through the home page as `#dz-`; Quick match uses the public rooms `dz-pub-1` to `dz-pub-4`, the fullest one still boarding first; online matches are people only, at least 2). Everyone rides the Drifter (a big blue cargo plane, see The Drifter below) across the island, jumps when they like on a line that changes every match, jumps when they like (Space, or Jump on a phone; anyone still aboard drops automatically as it leaves the island), falls, opens a steerable glider (Space again, or automatically about 44 m up) and lands anywhere, on roofs and hillsides too. Then it's loot, build and fight until one is left. **Island:** 240 × 240 m, with real terrain since map version 5 (hills, a ridge, cliffs, a reservoir and a shore: see Land) (it was 320 m until map version 2: the seven places were moved closer together as whole blocks on the 4 m grid, the buildings themselves are unchanged), about 40 s' run across and 57 s corner to corner at 6 m/s, built by `buildWorld()` from a few tools; each place is built inside `grp(dx, dz, dy, …)` with its shift from the old layout and the height of its pad in `OFS`, so the place code still reads in the old coordinates: `house()` (walls with doors and windows, a floor per 4 m level and a flat roof, both sitting between the walls rather than under them, zigzag ramp stairs from `zigzag()` that need a free cell at each end, a parapet, and a trim band round the outside between levels; how each is drawn is in Buildings below), `wallRun`, `slab`, `staticRamp`, props (`crate`, `bale`, `car`, `fence`, `pine`, `oak`, `rock`, `bush`). Seven places: Haybale Farm (barn with a loft and roof stairs, farmhouse, silo), Signal Point (a 20 m lattice tower with zigzag ramps), Pinecone Plaza (a two-level mall round an atrium, shops along the north side, car park), Spillway Dam (a 12 m dam wall with stair towers at both ends, a pump house), Moonbeam Motel (two wings of rooms, a balcony reached by a ramp, an empty pool), Starfall Crater (a ring of boulders round a fallen star, two sheds) and Timber Camp (log cabins and a sawmill shed), plus sheds along the tracks. Every floor and roof is at a multiple of 4 m on the same 4 m grid as builds (each place's pad is too). All static geometry is merged into 16 chunk meshes with vertex colours (one material; on the plain look no textures except the builds', the ground's and the buildings' own (see Buildings), which are mipmapped and anisotropic, and no shadow maps), the ground is one mesh over the height grid, chests, floor loot, each build kind, tracers and particles are one instanced mesh each, so a view with 30 players in the match measured 16–55 draw calls; each player is one mesh (the merged body, plus the glider when it's out), and everyone's legs are one instanced mesh and the held items one instanced mesh per kind (`legIM`, `gunIM`, filled by `syncLimbs()` just before each render from the models' leg and item `Object3D`s, which only carry the pose), so 30 players close together cost about 36 draw calls instead of about 120 (legs and items are hidden past 70 m). Solid boxes sit in a spatial hash of 8 m cells (`hash`, `rhash` for ramps), which movement, `groundAt` and the ray walk (`raycast`, cell by cell) use instead of the whole list. **Look:** characters are built from `ROUND_BOX` (a box with rounded edges and smooth shading, added with `bagRBox`), still one merged body per player with instanced legs; hitboxes were unchanged by that (they shrank with the characters later, see Character size). The Graphics setting (`driftfall:gfx`, Pretty or Fast) and `fxWatch()` pick one of three levels, applied by `lookSync()` from `drawScene()`: 0 is the plain look above (always on touch screens and on Fast); 1 adds a surface grain to the one shared material (`MAT.onBeforeCompile` lays a drawn noise texture over every face from three sides using each mesh's own coordinates, compiled in only while `MAT.defines.FINE` is set), real shadows from the sun (one 2048 px map covering 92 m around the camera, moved in whole-texel steps by `followSun()`; everything using `MAT` and the builds cast and receive, flagged by `shadowFlags()`), a sky dome with a soft sun (hidden inside the storm, where the flat purple sky takes over) and a sea that catches the light; 2 adds a light colour grade (`grade`: the finished frame is copied to a texture and redrawn with a little more colour and contrast and darker corners; there is no bloom, because in daylight most pale surfaces are already at full brightness). Because it is a shooter the frame rate comes first: it starts at level 1, steps up to 2 only after about 6 s of frames under 12.5 ms, and steps down after 2 s over 18 ms once `autores.js` has lowered the resolution to 0.8 or less; a level it had to leave is not tried again that visit (`fxMax`). Level 1 roughly doubles the draw calls near buildings (the shadow pass draws the chunks around you again). Nothing about the look is sent to other players. **Flicker fixes (map version 2):** no two faces share a plane any more (floors and roofs used to share the walls' outer faces, partitions reached into the floor above, posts shared faces with slabs and railings, and the trim band was a solid slab over each upper floor that also hid the mall's atrium and the stair holes); the camera's near plane follows the view (0.08 m pulled in against a wall, 0.15 m on foot, 0.5 m in the air, 1 m on the Drifter) and the far plane is 800 m, so distant faces a few centimetres apart don't fight; the farm's stripes were 4 m wide to match the ground's 2 m vertex grid (they are 1 m furrows now that the ground is a picture, see Ground). Keep new boxes off each other's faces (stop a box 1–2 cm short, or let it pass through the other) rather than flush with them. **Movement, building and shooting** started as a copy of Backrooms 1v1–4v4 (the same jump, step and `moveEntity`/`pushOut`; the speed, the collision box and the ramp rules have since changed, see Collision, Character size and Pace), the same wall/floor/ramp binds (Q/Z, F/X, C/E) and pieces on the 4 m grid (up to 8 levels above the land under them; see Land for how they meet a slope), the same over-the-shoulder aim from the camera with rays from the muzzle, headshots and damage numbers. Builds cost 10 scrap (you start with 30); the Crowbar (V or 5, or an empty slot) gathers scrap from trees (14 a hit), rocks and walls (6–10), and loot has scrap bundles. **Destruction:** builds and most of the map break. Each weapon has its own structure damage `sd` per bullet (Pistol 24, Heavy Pistol 55, SMG 12, Drum SMG 15, Pump Shotgun 13 and Auto Shotgun 9 a pellet with their close-range falloff, AR 22, Heavy AR 40, Bolt Sniper 150, Scout Sniper 80; the Crowbar 50), scaled by rarity and distance like player damage. Builds have 150 (walls) or 140 health and darken in three stages. On the map, `buildWorld()` makes breakable *pieces* with `brk(health, scrap, fn)` (everything `fn` adds is one piece): each 4 m cell of a house wall per level (with its trim band and, on top, its parapet; 240), each 4 × 4 m cell of a floor or roof (200), partitions (150 a cell), trees (170), rocks (80 + 60 per metre of size), cars (260), the farm truck, crates, bales, fence sections, railings (in up to 4 m lengths), the motel's balcony, posts and sign, the sawmill's posts and roof and the log pile. The ground, the dam's wall, ribs and stair towers, the tower's posts and floors, the silo, the star, stairs and ground-level decorations never break, so the map stays playable. A piece is a range of vertices in the chunk meshes plus its boxes; breaking it squashes the vertices to a point (one small buffer update a frame, `mpFlush`, no extra draw calls) and takes its boxes out of the hash, so players, shots, builds and bots go through; the pieces left standing round a broken wall, floor or railing keep a ragged edge (see Buildings). Damage darkens a piece in three stages the same way. Boxes of pieces in a line (a wall's cells, a floor's row) are merged into one solid per unbroken stretch (`runs()`), so movement and rays check about as many boxes as before. `mpLink()` records which pieces touch and which touch the ground or something unbreakable; when a piece breaks, anything that has lost every path to the ground breaks too (a roof whose walls are gone), and chests and loot on it drop (`mpBreak`). The breaker gets twice the piece's crowbar scrap. Pieces are numbered in build order (1,185 of them), the same in every browser; a new match restores them (`resetMap`). **Loot** is decided by the match seed, so nobody has to send it: about 82% of the 40 chest spots have a chest each match (`spawnLoot`), and each floor spot has a 72% chance of an item (`FLOOR_R` odds); a chest gives a weapon (`CHEST_R` odds, better than the floor's) with its ammo, often a heal and sometimes scrap (`chestLoot`). Weapons (`WEAP`): ten, two in each of five families (`fam`: pistols, SMGs, shotguns, rifles, snipers), each with its own model, colour, sound, damage, fire rate, spread, range and falloff, magazine and reload, and ammo type (light, rifle, shells, heavy); see Weapons below; rarity (Common to Legendary, grey/green/blue/purple/gold) adds 7% damage a step and trims the reload. Heals (`HEALS`): Bandage +25 health (2.5 s), Medkit to full (6 s), Shield Fizz +25 shield (2 s), Shield Jug +50 shield (4.5 s); shield caps at 100 and you walk slowly while using one. Four slots (1–4, the mouse wheel, or tapping the slots); ammo, scrap, heals and weapons are picked up by walking over them when there's room, and G (or the touch Open/Take/Swap button) opens chests and swaps the item in your hand for one on the floor (with nothing in reach it edits the build you are aiming at, see Building and editing). Knocked-out players drop everything. **Storm** (`STORM`, `makeStorm`): the circle (180 m radius, `R0`) covers the island at first, then closes in six phases toward seeded centres, each pulled toward the middle if it would fall at sea (first close 70 s after the Drifter sets off; the last closes to nothing about 4¾ minutes in), and damage outside (health only) grows from 1 to 15 a second. The Drifter's line starts and ends 230 m either side of a point within 37 m of the middle, so it's always over the sea at both ends. The minimap (tap it, or M, for the big map with place names) shows the circle, the next one (dashed), the Drifter's line with a little plane on it, and you. **Rooms and matches:** each player writes only their own node `rooms/dz-/players/`: `n, c, x, z, h, ts` always (as the shared rules expect), plus `y`, `p` (pitch), `hp`, `sh`, `st` (state: `l` lobby, `b` on the Drifter, `f` falling, `g` gliding, `a` on the ground, `d` knocked out, `o` watching), `w` (what's in hand), `m` (the match), `j` (join time), `k` (knockouts), `pl` (placing), `dm` (damage), `oc` (chests they opened this match, dot-separated) and `pk` (loot they took, comma-separated, so a late joiner or a new host sees the right island), and `ev/e0`…`ev/e23`, a ring of their recent events (each with a number `i` that only goes up, the match `m` and a time `t`): `s` shots (muzzle, tracer ends, the new health of builds hit `pd` `[key, hp]` and of map pieces hit `md` `[id, hp]`, hits on players `hs`), `b` builds and edits of them (see Building and editing), `o` chest opened, `u` item taken, `dr` item dropped, `x` knocked out (by whom, placing, the dropped items). Writes are `update()`s of only the fields that changed: about 12 a second while you're moving in a match (10 with 10+ others in the room, 8 with 20+), a heartbeat every second or two otherwise. Every node also carries `mv`, the map version (2 since the island shrank, 3 for the slower pace, 4 for the November 2026 fixes: solid ramps, and later the smaller characters, the pace and the new weapons, 5 for real terrain, 6 for edited builds; a node without it is version 1). The host is the live player on the same map version who has been in the room longest; its node also carries `ms`, the match state (`{id, ph: 'lobby'|'play'|'end', ce: countdown end, sd: seed, t0: when the Drifter sets off, ro: roster, nh: people at the start, wn: winner, we: when the results end, mv: map version}`), and during a match `br: {m: match, b: …}`, the broken map pieces as a base64 bitset with trailing zeros dropped (about 200 characters with everything broken). Players apply the shooter's reported health for builds and pieces, the lowest anyone reports, but never more than one shot of that weapon could take; a late joiner, anyone who missed an event, and the next host take the rest from `br`. The host's node also lists the builds standing (`bd`, see Building and editing), so a late joiner gets them too; there's no list of broken builds, because a broken one is just not in it. **Map versions:** the host only counts people on its own version for the lobby, the countdown and the roster, and only those elect a host; a page that sees someone on a newer version says "This match uses a newer map, reload to join." with a Reload button and sits matches out; the host's lobby says how many people have an older copy. Pages from before map versions existed don't know any of this: they're simply left out of the new pages' matches. Next time the island changes, raise `MAPV`. A match starts when the host presses Start (with 2 or more people) or 60 s after a second person joins the lobby; a lone player can't start one; the Drifter line, the storm and the loot all come from `sd`, and the clock from `t0` (server time), so everyone agrees without sending them. **Bots** are in Practice only (11 of them; online matches are people only, so no bot slots, no bot list in the host's node and no bot hand-over). They're marked BOT in tags, the feed and the results, and this browser runs them: they jump, glide to a chest, loot, fight, heal, run from the storm and now and then wall up when shot; they walk straight at things where the way is clear, round cliffs, boulders and buildings by `landPath` (see Land) and in and out of buildings by the nearest ground-floor door (`setGoal`), stepping to one side when something holds them up, shoot through breakable cover (builds, walls, trees) at someone within 35 m, break through a breakable thing they're stuck against (up to ten tries) or a line of builds they can't get round (see Building and editing), and leave loot they get stuck on alone for 25 s; they don't use stairs, so upstairs loot is for people. They're tuned to be beatable: a reaction of 1–1.6 s, loose aim (0.085–0.135 rad error, more until they've watched you a while), a little over half their weapon's fire rate and rare building; a rifle bot 20 m from someone standing still does about a quarter of the damage it used to. **Hits:** the shooter's browser decides what its shots hit (`resolveShot`) and lists hits in the shot event; the victim's browser applies them only after a sanity check (`acceptHit`: a real weapon, no more than one shot of it can do, from within 16 m of where the shooter really is, within the weapon's range, and not faster than it fires), and reports its own knockout, which credits the shooter; hits on bots go to the host. If the host leaves, the next in line carries on the same match from the last `ms` it saw, with the broken pieces it already has. Someone who joins mid-match waits in the lobby panel or watches (Watch the match), and drops in at the next one; a room holds 30 (`MAX_ROOM`). Other players and bots are drawn with `netsmooth.js`. Results: placing, knockouts, damage and time, with the room's final order when the match ends. Leaderboards hooks (online matches only, which always start with at least two people): `add('matches', 1)`, `add('wins', 1)`, `max('kills', n)` (most knockouts in a match) and `min('place', n)` (best placing; `place` is in stats.js's `LOWER`). Saved in the browser under `driftfall:` keys: `name`, `col` (your colour), `sens`, `room`; keys in `keybinds:drop-zone`. Touch: a move stick, drag-to-look, Fire (Place, Use or Hit as it fits), Jump, Aim, Reload, an Open/Take/Swap button that appears when something's in reach, an Edit button that appears when the crosshair is on a build of yours, and the Crowbar, four slots and the scrap chip as buttons along the top (tap the chip to build: the three pieces appear next to it; tap it again, or a slot, to stop); the map is top right. Practice (offline) is the same match against 11 bots with no database at all, on its own clock that stops while paused. A slow frame is played in steps of at most 1/20 s (up to a quarter of a second), since the Drifter and the storm run on the clock. **Keeping it smooth (November 2026 audit):** every shader is compiled while the page loads (`warmShaders`, with the hidden meshes shown for a moment; the storm wall's used to compile, and freeze a frame, the first time it closed in), and the minimap's island picture is drawn during the menu rather than on a match's first frame (it takes about 30 ms). Sounds have a budget (`voice`: 14 nodes per 1/20 s, then only loud ones, and your own hit, hurt and pick-up sounds always), so a big fight or a building coming down doesn't build hundreds of audio nodes in one frame. The HUD only writes a value to the page when it changes (`hudSet`), name tags reuse their vectors and only move when they move a pixel, banners restart their slide-in without forcing a layout, and the storm (`stormAt`), hitboxes, the camera and movement no longer make new objects every frame. The lobby list is only drawn while the lobby is showing (every update from anyone used to redraw it, four times a second, mid-match), player names go through the name filter once (`cleanName` keeps them), and an update with no new events doesn't sort the event ring, so taking in another player's update costs about a fifth of what it did with 30 in a room. Writes are unchanged (`update()`s of the changed fields, about 50 bytes each, 10–12 a second while moving), so it plays with pages from before the audit. Each browser is trusted for its own health and hits, so it isn't cheat-proof. A test hook (`window.__dz`) exists only when `navigator.webdriver` is set. **Turkey Week** (`../events.js`, November 15 to 26, 2026): every player's cap is a pilgrim hat, built into the same body geometry (`bodyGeo`), so no extra draw calls; the game reads the one Turkey Week switch on the Back Room page (see `events.js` below) once, when it loads, and has no button of its own. **Collision (November 2026 fix):** ramps used to be a walking surface only, so a body could walk into one from the side or from under its high end and jump up through it from below, which is how people came up through stairs, ramp builds and the floors the stairs lead to. A ramp is now also a solid slab 0.36 m thick under its surface (`rampIn`, `rampBlocked`, `rampUnder` next to `moveEntity`): its side and its underside stop a body, its underside is a ceiling for a jump, and like a box it carries a body whose footprint overlaps it at all. So the map's zigzag stairs have to be walked round to the foot of each flight (the free cell at each end is for that), and two ramps built in one cell facing opposite ways no longer make a staircase. A body on the ground follows a ramp up as it moves rather than afterwards. Something built on a body (`pushOut`) moves it out the side its middle is already on, by no more than 1.2 m, never across the piece and never into a ramp; while a body is inside something it can only move back out, and can't rise. A piece built by this browser (you, a Practice bot) isn't placed if someone here would be left inside it (a floor through the head of someone on a ramp used to pop them up through it); a ramp built on someone stands them on it. Pieces arriving from other players are always placed. Loot heights come from `groundAt`, which now counts a ramp's edge, one more reason old and new pages mustn't share a match (see map versions). **Character size (November 2026):** characters were a fifth too big for the world, so everything about them is 0.8 of what it was (`BS`): the model is 1.72 m tall with its cap instead of 2.15 m and about 0.8 m across the shoulders instead of 1.0 m (the group is scaled, so the legs, the held item and the glider shrink with it); the collision box is 0.6 m wide and 1.6 m tall (`R` 0.3, `H` 1.6; was 0.72 and 1.95); the hit areas are a head box 0.45 m wide from 1.2 to 1.67 m up and a body box 0.67 m wide up to 1.2 m (were 0.56 m, 1.5 to 2.08 m, and 0.84 m up to 1.5 m), so everyone is a smaller target by about a third in area; the eye and bot-aim heights (`EYE` 1.3, `AIM_Y` 0.9), the muzzle (`MUZ_Y` 1.1) and the name tag (2 m up) follow. The camera sits 4 m behind instead of 3.5 m and 0.7 m to the side instead of 0.78 m, so a character takes about a third of the screen's height instead of nearly half. Jump height (1.7 m), step height (0.6 m), doors, walls and builds are unchanged, so doors and windows are roomier and a jump clears relatively more than it did. **Pace:** everything that sets how fast a match feels is in one block near the top (`SPEED`, `AIR`, `BUS_V`, then `WEAP`'s `dmg` and `STORM`'s times). In November 2026 it was all slowed by a sixth to a fifth (running 6.6 to 5.4 m/s, weapon damage about a sixth lower, the storm's times 1.2 times longer so the last circle closes 5:41 in rather than 4:44); running then felt sluggish, so the movement speeds came most of the way back while damage and the storm's times stayed: running 5.4 to 6.0 m/s (bots still 0.92 of it; aiming 0.7 and healing 0.45 of it as before), steering while falling 13.5 to 15 m/s and falling 25 to 28 m/s, gliding 9.2 to 10.3 m/s forward and 5.5 to 6.1 m/s down, the Drifter 20 to 22.5 m/s (it crosses the island in about 20 s instead of 23 s). **Weapons (November 2026: ten instead of five):** each family has a quick, light one and a slow, hard-hitting one, so two finds of the same family play differently. Damage a shot (headshot), seconds between shots, magazine, reload: Pistol 20 (35), 0.2, 12, 1.3 s and Heavy Pistol `hc` 42 (74), 0.55, 6, 1.7 s (silver, a fat cylinder, wood grip); SMG 12 (18), 0.075, 28, 2 s and Drum SMG `ds` 15 (23), 0.11, 40, 2.6 s (yellow, a drum under it; slower but tighter, longer range, a bigger magazine); Pump Shotgun 9 pellets of 8, 0.9, 5, 2.1 s and Auto Shotgun `as` 7 pellets of 6, 0.4, 8, 2.6 s (dark red; wider spread, 32 m instead of 40 m); AR 18 (27), 0.12, 30, 1.9 s and Heavy AR `hr` 34 (54), 0.28, 18, 2.2 s (dark teal; the most accurate when aimed, 180 m); Bolt Sniper 82 (164), 1.3, 4, 2.5 s and Scout Sniper `ss` 44 (88), 0.5, 8, 2.8 s (pale slate, a small green scope, less zoom). The old five keep their ids (`pi`, `sm`, `sg`, `ar`, `sr`) and numbers; the Shotgun and Sniper are now called Pump Shotgun and Bolt Sniper. **Names (November 2026, clearer guns):** every name is " " with the type one of Pistol, SMG, Shotgun, AR or Sniper, so it always says what kind of gun it is (the Rifle and Heavy Rifle became AR and Heavy AR; ids, saved data and network messages are unchanged); `name` is shown everywhere (hotbar, pickup prompt, pickup line, kill feed, ammo panel) and `short`, the type alone, only in a hotbar slot too narrow for the whole name (`fitSlotName`, so on a phone a slot reads PISTOL, SMG, SHOTGUN, AR or SNIPER and the ammo panel above the slots gives the whole name of the gun in hand). The two of a family share a colour, light and dark (pistols cream and silver, SMGs orange and yellow, shotguns red and dark red, ARs teal and dark teal, snipers slate and pale slate). Chests and floor loot roll all ten (`W_ODDS`: 12, 10, 11, 9, 11, 9, 15, 11, 7, 5 in the order above), so the loot a seed gives is different from before; the new ids travel in `w` (what's in hand), in shot events and in dropped and taken items, and a page from before them would reject them, which is why the map version went to 4: old pages are kept out of new matches and told to reload. To add a weapon: a row in `WEAP` (with `fam` and `col`), its id in `WIDS` and `W_ODDS`, a model in `GUN_GEO` (with the end of its barrel, which goes into `GUN_TIP`), a rarity-band position in `RTAG`, a sound in `sfxShot`, and optionally `TR_W`, `FLASH`, `KICK`, `PUNCH`, `RECOIL` and `RELOAD_ST`; then raise `MAPV`. Bots pick and use weapons by family. `ICONS` holds a small picture of every weapon, the crowbar, the two heal models and the three build pieces, drawn once at load from the same geometry the game uses (`makeIcons`). **Aiming (November 2026):** holding Aim is different for every weapon, set by four fields in its `WEAP` row: `fov` (the zoom; the normal view is 72), `ad` and `as` (how far behind and to the side the camera sits; the normal view is 4 m and 0.7 m) and `pose` (where the gun is held while aiming, seen over the shoulder: since the models were remade it is only a small lift from the normal hold, because the arms stay in the pose the body is drawn in while a weapon is held). Pistol fov 58, Heavy Pistol 50, SMG 62, Drum SMG 56, Pump Shotgun 60, Auto Shotgun 66: these six stay over the shoulder at 3 to 3.4 m; the two ARs go to the eye (`ad` 0, your own character hidden), AR fov 46 and Heavy AR 34. **Reticles (November 2026, clearer guns):** one style per family, the same from the hip and aimed (aiming only pulls it in, because the spread is smaller and the view zoomed), drawn by `RET` into `#cross` (an inline SVG, one CSS pixel per unit, put on a whole pixel in the middle of the view, 2 px white lines over a 1 px dark edge on each side so they stay sharp and read on bright sky and in dark rooms): Pistol a dot in a thin ring; SMG a small ring with four short ticks outside it; Shotgun a wide ring broken into four arcs; AR the classic four lines and a dot (the dot turns red when aimed, like a red-dot sight); Sniper from the hip a ring with cross hairs through it; the crowbar, heals and building a dot. Rings and gaps are the real spread of the shot in pixels at the current zoom (`RET.size`: `hip` or `ads`, more while moving, from `curSpread`, the same numbers the shot uses), plus a short kick of a few pixels after each of your own shots (`retKick`, `RET_KICK`) that eases back in about a tenth of a second. The snipers aim through a real scope (`#scope`: a round lens in a black surround with a rim and a darker edge to the glass, `SCOPE` sets its size and colours; Bolt Sniper fov 16, Scout Sniper fov 30 with a wider, green-rimmed lens), both with the same plain reticle (`SNIPER_RET`): thin cross hairs 1.5 px wide at any size with an open middle and a red centre point, two small marks on each arm and thick posts from the edge, with a faint pale edge so they show in a dark room. (Before, every weapon had its own sight picture in `SIGHT` and `#sight`; both are gone.) Look sensitivity already scales with the zoom. Nothing about aiming is sent to other players, so they don't see your gun raised. **Weapon models and feel (November 2026 remake):** all ten were rebuilt to the standard of Shell Crackers' guns; only looks, motion and sound changed, so damage, fire rates, magazines, spread, ranges and everything sent to other players are as they were and the map version is still 4. Each is still one merged mesh with its colours in the corners (one draw call for everyone holding that weapon and one for all of them on the ground, as before), now 300 to 770 triangles instead of 110 to 240 (Pistol 304, Heavy Pistol 508, SMG 504, Drum SMG 536, Pump Shotgun 612, Auto Shotgun 552, AR 556, Heavy AR 536, Bolt Sniper 772, Scout Sniper 676). In the clearer-guns pass (November 2026) each was pushed towards its stereotype so the family shows at a glance: the Pistol lost its under-barrel lamp (a plain slide on a frame); the Pump Shotgun's barrel is thicker; the Auto Shotgun lost its carry handle (it read as a rifle) and got shorter and chunkier: a fat barrel with a big square brake, a low rail, a fat box magazine and a solid stock; the AR has the classic black carry handle with the rear sight on it, a tall front sight post, a round ringed handguard and a black stock; the Heavy AR has a top rail with a small boxy red-dot sight, a long square handguard with a front grip, a big curved magazine and a shorter, thicker barrel with a brake (no bipod or wood any more, which made it look like a sniper); the Bolt Sniper's bipod legs now hang down and forward instead of lying folded. The Heavy Pistol stays a revolver (its reload works the cylinder) and the SMG, Drum SMG and Scout Sniper keep their shapes. `GUN_GEO` builds them from a few kinds of part: `bx` a box (optionally tilted), `ob` a bar with its long edges cut off and shaded smooth (so a body reads as rounded plastic), `cyl`, `pin` and `peg` a cylinder along the barrel, across it or upright, and `ex` a side outline pushed out sideways with bevelled edges (the stocks); `grip` and `guard` add the grip and the trigger guard every weapon shares. In a weapon's own coordinates -z is forward and the right hand (a 0.146 cube) is centred on (0, 0, 0.12): the grip goes down through the hand, the body sits on top of it, and a stock runs back over the forearm and stops at the chest (z 0.4), so with any outfit the weapon is in the hand and nothing passes through the arm or the body (before, the hand was inside the body of the gun and the stock ran through the forearm). `HOLD` is where a weapon is held: a little outside and above the middle of the hand and turned 4° outward, so its top shows over your shoulder from behind; it also tips up and down with the aim (yours, bots' and other players', from the pitch already sent). From directly behind your own character you still only see the back half of it past your shoulder (the colour, the scope, the drum, the carry handle of the AR), because the arms hold every weapon in the pose the body is drawn in; the whole outline shows on other players, on the ground, in the hotbar and when you aim over the shoulder. `GUN_TIP[id]` is the end of the barrel: the flash, the tracer and the spent case are drawn from the weapon as it is held (`gunTip`, `gunPoint`), while the shot itself still starts at `muzzleOf` and what is sent is unchanged; looking down the rifles' sights the flash and the tracer start just under the sight, and a scope shows no flash. `animModel` adds the motion, all of it turning about the hand: `KICK[id]` (how far a shot shoves the weapon back, how far the muzzle jumps and how fast it settles; the crowbar has its own swing, `SWING`, see Body and animation), the pump of the Pump Shotgun and the bolt of the Bolt Sniper worked between shots (0.2 to 1.1 s after the shot, two sounds and the case hopping out, `gunAct`; other players' too, from their shot events), a reload motion for each kind (`RELOAD_ST`: magazine out, magazine in, rack; the Pump Shotgun a shell at a time; the Heavy Pistol's cylinder; the Bolt Sniper's bolt) with a sound at each stage, and a swing up from below when an item is taken out (`userData.sw`). Reloads show for you and for bots only, since a reload is not sent. `FLASH[id]` is the size of the muzzle flash and the length of its tongue (shotguns wide and short, rifles and snipers long, SMGs a flicker; the big ones add a dimmer glow), `TR_TL` how long each family's tracer is, `shell` the spent case (a bit from the shared pool, only within 30 m; shotgun shells are red, the Heavy Pistol keeps its cases), and `PUNCH[id]` widens your view by up to 1.7° for a moment with each of your own shots (zoom only, so the aim point does not move; `updateCamera` eases it back). With reduced motion there is no kick, action, swing, case or view punch. Sounds are still made on the spot: `sfxShot` has ten shots that differ in pitch, length and tail (`burst` can now start late and sweep its filter), and `sfxPump`, `sfxBolt`, `sfxReload` (out, in, rack, shell, open, shut), `sfxSwitch` and `sfxDry` (the click of an empty weapon with nothing left to load) are new. Floor loot is the same model, turning about its own middle (`GUN_MID`) and nearly level so the outline reads, over a glow in the rarity colour with a clearer ring; past 75 m a weapon is only its glow. The rarity band on a held weapon is a cut-edged sleeve to match the bodies (`RTAG`, drawn by `rarIM` as before). **Hotbar (November 2026):** every slot shows a picture of what is in it, taken from `ICONS` (so it is the item's real model: the ten weapons, the crowbar, a first-aid box for Bandage and Medkit, a bottle for the two shields, and the three build pieces), with the rounds loaded or the count in the top right corner, the name underneath (a weapon's whole name, or just its type where the slot is too narrow) and the rarity as a bar along the bottom (`slotIcon`, `slotLabel`). Scrap has its own chip in the hotbar (`#matsBox`: a stack of planks and the count in big figures, which jumps when it changes and turns red below the cost of a piece) instead of a small line in the health panel, and each build piece shows its cost (10) next to the same little plank, greyed and red when you can't afford it. The three build pieces are only in the hotbar while you are building (`#slots.building`): the new Build key (B, `build` in the key settings, `toggleBuild`) or a tap on the scrap chip goes in with the piece you last used and comes back out, and Q/Z, F/X and C/E still go straight to a piece as before; a slot key, the crowbar or Aim leaves build mode and the pieces go away again. **Land (November 2026, map version 5):** the island is no longer flat. `designLand()` fills a grid of heights (`TH`, one every 2 m, reaching 16 m past the 240 m square for the sea bed) and `terrainH(x, z)` reads it with the very triangles the ground is drawn with, so what you see is what you stand on. Everything asks that one function: the drawn ground (`landGeo`), walking, falling, gliding and landing (`walkH`, `groundAt`, `moveEntity`), shots, sight lines and the camera (`rayTerrain` inside `raycast`), where loot, chests, props, trees and bots stand, builds, the storm's centres, the bots' paths and both maps. The grid is made from whole-number hashes, + − × ÷ and square roots only and rounded to 1/32 m, so every browser has the same land to the last bit and loot lies at the same height for everyone. Sea level is 0. Shape (`designH`): rolling noise for the low ground; smooth mounds measured from points pushed about by noise, the highest winning where they meet (Signal Point's hill at 16 m, a ridge from it east to the top of the dam at 20 m, the plateau that holds the reservoir, the farm's tableland at 8 m, a knoll on the west shore, a hillock south of the plaza, the timber shelf at 8 m); creased, ridged noise on the high ground; the crater is a real bowl whose rim is lower at four gaps; a wandering coast with round corners and beaches, and cliffs where the high north and east meet the sea. Each place stands on a level pad (`PADS`, `LVL`: farm 8 m, Signal Point 16, plaza 4, dam yard 8, motel 4, crater floor 4, timber camp 8; the five sheds on the multiple of 4 m nearest the land under them, `SHED_Y`) that blends back into the land over 6 to 12 m, and `grp()` raises everything the place adds by its level (`OFY`), so buildings, doors, stairs and ramps are exactly as they were. Single props (`onLand`: trees, rocks, bales, crates, fence sections, the crater's boulders) stand on the land under them, sunk a little. What moved: the farm's field is smaller and lies on the slope below the yard; the dam's paved yard is shorter (the valley closes in at both ends of the wall); the reservoir is real water 9 m above the yard and narrower than its old painted rectangle; one shed moved 12 m south; trees stand in clumps; two crater boulders that sat across a shed's doors are gone; a chest against a wall keeps its loot inside the room. **Slopes:** the steepest ground a body can walk up is 45° (`SLOPE_MAX`: 1 m up per metre along). Steeper land is a cliff: it stops a body like a wall, and a body that lands on one slides down it at 7.5 m/s (`SLIDE_V`) and can't jump until it is off (`e.slide`). Gentler ground is followed up as you move and stuck to on the way down, so nobody hops downhill. Where the sea is deeper than 1 m a body stays 1 m under the surface (`WADE`), and wading waist-deep is slower (0.72 of running). The camera is pushed in by the land as by a wall and is never under it. **Surface** (`landMaterial`; it replaces the 2048 px picture of the whole island, which was a blur up close): the shader decides what each pixel of ground is from its height, its slope and a small control map drawn once at load (`paintControl`: 1024 px, 512 on Fast and on phones; red is dirt, green is paving, blue is how much darker): grass with broad paler and darker patches, sand below about 1.4 m that is wet at the waterline with a line of foam, bare rock on faces steeper than about 40°, dirt for the tracks, yards, clearings and the ploughed field, paving with its joints drawn on the 4 m grid. Fine detail comes from one tiling texture made in code (`landDetail`: 512 px, 256 on Fast; blades, grain and pebbles, rock strata and concrete in its four channels), read once every 5 m and, for broad variation, at a 47 m scale, so it is sharp at your feet and the tiling never shows from the air; where two materials meet the grain decides which wins, so a track's edge is a crisp ragged line of pebbles and tufts rather than a fade. Every corner of the ground carries a baked shade: darker in hollows and where a hill or cliff stands between it and the sun. Pretty reads the 47 m scale from the texture, adds a finer layer of detail, strata mapped from both sides on cliffs and wind in the grass (six reads a pixel, as many as the old Pretty ground, one of them filtered at a slant); Fast reads two textures a pixel (the old ground read one) and takes its broad variation from a value stored at each corner of the ground. Water (`waterGeo`): the sea and the reservoir are sheets whose colour and clearness are set at each corner from the depth under them (clear turquoise shallows, solid blue further out). Scatter (`scatterLand`): grass tufts where the ground is grass (4,400 on Pretty, 1,600 on Fast, 1,200 on phones; they shrink away between 40 and 65 m) and small stones (420, or 150), two instanced meshes, neither solid. **Cost,** at the same five views before and after: draw calls are up by one to four (Pretty 18–32 before, 20–35 after; Fast 8–22 before, 9–24 after: the ground is still one mesh, the sea and the reservoir replace the sea and its shallow ring, tufts and stones add two); triangles went from 55–84 thousand to 84–114 thousand on Pretty and from 51–80 thousand to 64–94 thousand on Fast (the ground's own 37 thousand are unchanged; the rest is tufts, stones and a few more trees); the ground's textures went from about 21 MB of graphics memory to 7 MB on a computer and from 5.3 MB to 1.8 MB on Fast and phones. Frame times could only be measured in software drawing, where they were too noisy to rank (between the same and half as long again in both looks), so try it on a real school laptop before trusting it. Nothing new runs every frame except height lookups (one grid read and a few multiplies each) and the wind's clock; a 150 m ray over the land costs about 8 millionths of a second (6 before). **Builds on slopes:** the grid stays level, at multiples of 4 m, so builds still line up with buildings and each other. A wall must show at least 1.5 m above the highest land along it, and where its foot is above the land a skirt of darker planks fills the gap down to the ground (`skirtOf`, `skirtIM`: part of the same solid, one more draw call while any exist); a floor may not be more than 0.3 m under the land at the highest point of its cell; a ramp's top must stand 0.5 m clear of the land, its foot may run into the hillside and you walk onto it where it comes out; nothing may be more than 8 levels above the land under it (`landOk`). `playerBuildSpec()` and the bots take the lowest level that passes (`landFit`), so a piece is never placed underground; on a place's pad the levels are what they always were. The rule that a piece isn't built where it would trap someone is unchanged and counts the skirt. Every browser has the same land, so everyone agrees which pieces are allowed and nothing new is sent. **Bots on the land:** `buildNav()` cuts the island into 4 m cells and closes the ones that are cliff, inside a building, or filled by a boulder, the dam's wall or the foot of a stair; when the straight line to a goal crosses a closed cell (`landClear`), `landPath()` finds a way round (A*, run only when a bot picks a goal) and hands back a few corners to walk through. Deep water costs three times as much as land and high ground a little less than low; of two places to wander to, a bot usually takes the higher. Held up by a trunk or a corner, a bot steps to one side, then the other, before giving up. In stepped bots-only matches (tests only: `__dz.step`, `STUCK_LOG`) no bot gave up on a goal. **Maps:** `buildMapBg` draws the minimap and the big map from the land itself: sea by depth, sand, grass that pales with height, rock on steep faces, tracks and paving from the control map, lit from the north-west so slopes read, and a darker line every 4 m of height. To change the land: edit `designH` or `PADS` (keep every pad a multiple of 4 m), check that no cliff cuts a place off, then raise `MAPV`. **Buildings (November 2026, still map version 5):** every building, the props round them and the light they stand in were remade, without changing what is solid. `house()` makes exactly the boxes it always did, in the same order, so the 1,185 breakable pieces keep their numbers, sizes and neighbours, and stairs, doors, loot spots and the bots' paths are where they were (checked with a fingerprint of every box, piece, ramp, loot spot and nav cell before and after; a page from before the change and a new one play in the same room and break the same pieces). What changed is what is drawn. Each building has a style (`KS`: barn, farmhouse, hut, mall, pump, motel, office, mine, cabin, shed; pass `st` to `house()`): an outer and an inner wall surface, trim, a plinth, corners (boards, log ends, steel angles or concrete pilasters), window and door frames with sills, the door (a sliding barn pair, a leaf folded back against the wall, a steel leaf with a hazard band, or none), shutters, flower boxes, a canopy or porch roof over doors, the roof edge (eaves on rafter ends, a stepped cornice, or a fascia with a neon tube), a capped parapet, the roof, floors, a floor laid on the ground indoors, ceilings and skirting. `kitWall()` adds all of that to a wall cell inside the cell's own `brk()`, so it breaks with the cell and nothing is left hanging; a building can add its own extras per wall cell (`x`), roof cell (`rx`) and floor cell (`fx`): the barn's hatch, hoist, beams and vents, the mall's name, skylights, coolers and strip lights, the hut's cooler and dish, the pump house's risers, the office's and motel's signs, the cabins' chimney breasts. The drawing tools: `kb()` (a detail box: drawn only, never solid, only the faces asked for), `wk()` (the same in a wall's own terms: along it, up, out from its face), `deco()` (any other shape, turned any way), `sign()` (raised block letters from a small dot font, `FONT`, drawn cell by cell so each letter breaks with its piece of wall), `lampPost()` and `bays()`; `FK` makes `sbox()` draw its box with a different surface on each face, and `NOVIS` makes it count toward its piece's size without being drawn (the kit draws it instead). Detail drawn while `DECO` is set, and everything from `kb()`, doesn't count toward a piece's size, because that size decides which pieces touch and hold each other up. To add detail: draw it with these inside the piece's `brk()` and never call `solid()`; keep anything that isn't solid thin, low (under about 0.4 m), flat against a wall or above head height, so nobody can hide inside something shots pass through. Anything that changes a solid box, a doorway, a stair or the number or order of pieces needs `MAPV` raised. **Surfaces** (`KIT_TEX`, `TX`): one array texture with eighteen layers, each a 2 m tile drawn in code at load (upright boards, clapboard, brick, stucco, corrugated sheet, cast concrete, shingles, logs, floor tiles, roofing felt, glass, riveted panels, straw, stone blocks, hazard stripes, and since the audit natural rock with cracks and lichen for `rock()`, bark for trunks and leaf clumps for canopies and bushes, `TX.RK`, `TX.BK`, `TX.LV`), laid on in metres from each face's own position, so a plank or a brick is the same size on every wall (128 pixels a metre; 64 on phones). A layer is a pale pattern tinted by the wall's paint (its vertex colour), except where its alpha is 0, where it keeps its own colour (mortar, nail heads, stripes). The island's chunks carry one more attribute, `dzA`: the layer, the height above the foot of the thing (the shader darkens and dirties the bottom metre or so of every wall, post and trunk) and how far indoors a face is (indoor faces are dimmer, more so on Fast, which has no shadows to do it). Each building has its own slight colour cast (`TINT`). It needs WebGL 2; without it the island keeps plain paint. One texture read a pixel on both looks, and no new passes. **Stairs, railings, props:** the map's stairs are drawn as sixteen steps over a soffit (what is walked on is still the smooth ramp); railings are panels with a cap rail and a post; cars and the farm's tractor are rounded toy vehicles with wheels, lights and bumpers inside the same solid boxes; crates are banded planks and bales are straw; the motel has loungers, a tiled pool with lane lines and a ladder and its name in raised letters with neon round it; the plaza's planters have a timber seat round the rim and its cars stand in painted bays under lamp posts (drawn only: a pole is 12 cm thick); the silo is ribbed and hooped with a ladder; the tower has white bands, cross braces above the first floor and a mast with drums, panels and a beacon; the dam is cast concrete with sluice gates, its name and lamps along the walkway; the sawmill stands on stone pads under a tin roof on rafters, with plank stacks and stumps; shards stand out of the fallen star. **Broken edges:** a wall, floor, roof or railing piece that breaks no longer leaves a clean hole: the pieces still standing round it keep a few jagged stubs of it where it joined them, and a wall that stood on the ground leaves rubble along its foot (`shardsFor`, one instanced mesh, `shardIM`, up to 1,200 stubs, a draw call only while something is broken). Stubs are drawn only; a stub goes when the piece it hangs on goes (`shardsOff`); which stubs exist depends only on what is broken, so everyone sees the same and a late joiner gets them from the broken list. **Light:** the sun is where it was (a roof, the two sunlit sides and the two shaded sides of a building are different tones); the fill light's ground colour is pale stone instead of grass green and a little stronger (0.58, ambient 0.11), so walls in shade keep their own colour instead of going olive. Shadows (Pretty) are unchanged and sit under the new eaves, canopies, sills and the balcony; the darker foot round every building on the ground was already there. **Cost,** at five views, before and after: draw calls are unchanged (16–25 on Pretty, 16–24 on Fast, not counting the shadow pass, which draws the chunks near you again); triangles went from 96–111 thousand to 121–150 thousand on Pretty and from 79–94 thousand to 99–125 thousand on Fast (Fast, as set when the page loads, and phones leave out the kit's smallest pieces, `KLITE`); the chunks' vertices went from 109 thousand to 224 thousand (about 4 MB to 11 MB of graphics memory with the new attribute); the surfaces add one texture of 5.2 MB (1.3 MB on phones). Frame times could not be measured here (software drawing), so try it on a real school laptop and a phone. Not done: a simpler version of far buildings (the island is 240 m across and already 16 meshes), filmic tone mapping and sRGB output (they would change every colour in the game, guns and characters included), ambient occlusion and bloom passes, glass in windows (windows stay open holes because shots pass through them), pitched roofs (roofs are walked on), benches and big roof clutter such as tanks (they would need new solid boxes, which needs a new map version). **Building and editing (November 2026, map version 6):** building was a copy of Backrooms 1v1–4v4's from the start (the same placing from your own cell and the way you face, the same 0.09 s build clock, so holding Place while you move or turn puts up about ten pieces a second, the same ghost and sounds), and it now has Backrooms' editing too, on Driftfall's own pieces, so there is still one build system. Also carried over: a new piece pops in from 0.82 of its size in about a ninth of a second (`piecesTick`; not with reduced motion); the ghost shows what you will get, a wall's skirt included (it used to show only the 4 m box, which floats above a slope); every piece knows who built it (`owner`: a player's id, a Practice bot's, `me` in Practice). Kept from Driftfall: 10 scrap a piece (an edit is free), the land rules and skirts, the rule that a piece isn't built where it would trap someone, the 4 m grid, health and the three shades, build mode and the hotbar. **Editing:** aim at a wall, floor or ramp you built from within 6 m (`EDIT_RANGE`) and press Edit (H, `edit` in the key settings, because G is Open / Take here and T is the chat; G does it too when nothing is in reach to open or take; on a touch screen an Edit button appears while the crosshair is on a build of yours): the piece turns into a grid of tiles, 3 × 3 on a wall and 2 × 2 on a floor or a ramp (a ramp's are its low and high halves, left and right). It works as in Backrooms (one copy of the code, see there): **Edit on release** is a setting, on by default, in the menu next to the faces switch and on the pause screen (`driftfall:editOnRelease`): hold Edit (or G when it is doing the editing), the tiles the crosshair sweeps across are picked, and letting go confirms; a quick tap leaves the grid open, and then (or with the setting off) Fire opens or closes the tile under the crosshair and Edit again confirms. Reload resets the piece to whole and Aim cancels; the touch buttons read Tile, Done, Reset and Cancel meanwhile, and a finger put down on the grid picks the tiles it touches, so on a phone you hold Edit, drag the other thumb over the tiles and let go. The line of help names the shape and spells everything out until your first confirmed edit (`driftfall:editHelp`); targeting is as generous as Backrooms' (`edTileAt`, `EDIT_FAN`), and your own body is hidden while the grid is up. At least one tile has to stay. Nothing changes until you confirm, and then the new shape is there at once (it used to land 0.4 s later); you can't shoot while the grid is up, and a Fire still held from picking tiles doesn't fire until it's let go. Driftfall has no teams, so your side is you: the only builds you can edit are the ones you placed, never another player's or a bot's. Picking a slot, the crowbar or a build piece, opening the big map, being knocked out or going more than 10 m away closes the grid and changes nothing. **Shapes:** a piece's shape is `ed`, one bit per tile cut out (tile (u,v) is bit `v*n+u`; 0 is the whole piece), with Backrooms' own `ED_N`, `edRects` and `pieceShape`: the tiles left are joined into as few rectangles as it takes, and each rectangle is one ordinary box in the spatial hash, or for a ramp one ordinary ramp sheet with a smaller footprint, so there is no second collision system: you walk through a door and shoot through a window because no box is there. For that, every ramp (the map's stairs too) is now a sheet with a footprint `ax0`…`az1` and a range `t0`…`t1` up its slope (`addRamp` gives the map's the whole cell), and `rampH`, `rampUnder`, `rayRamp` and the ceiling test in `moveEntity` read those instead of assuming the cell; a whole piece is the one box or sheet it always was. A wall's skirt is not part of the grid: under an edited wall it is a box of its own, the full width, from the land up to the wall's foot, so a door cut where the land is lower has a sill (walked over if it is under 0.6 m, jumped onto if it is more). The trap rule covers edits: tiles are not put back onto someone in this browser who can't simply be nudged clear (`wouldTrap`; you are told someone is in the way), and a door put back with you standing in it moves you out. **Drawing:** whole pieces stay in the three instanced meshes; an edited piece's rectangles are unit boxes in one more instanced mesh shared by every edited piece of every kind (`partIM`, `partsOf`; each box's window of the plank texture is a per-instance attribute, `uvw`, so the planks run on across a cut), which makes thirty edited pieces one draw call, not thirty (measured: 36 calls with thirty whole pieces in view, 34 with the same thirty edited, the three kinds' own meshes then being empty); the grid you see while editing is three more, in place of the piece, and only on your screen. **Online:** an edit travels as the build event for that spot again with `ed` and `n` added (`n` counts the piece's edits, so an older shape never replaces a newer one), and is taken only from the player who built the piece. The host's node also carries `bd: {m, s}`, the builds standing, nine characters a piece (kind and direction, x, z, level, `ed`, `n`, and the builder as a place in the roster; `buildList`), written again at most every two seconds: a late joiner gets every piece in its shape from it, and a page that missed a build or an edit catches up (`applyBuilds`). A page never removes a piece because of the list (a build the host itself missed stays missing for the host), and doesn't put back one it saw break in the last 8 s. A page from before this would keep the whole piece where a door was cut, and the two would disagree about what is solid, so the map version went to 6: older pages are kept out of new matches and told to reload, the usual way. **Bots** don't edit. They see and shoot through openings only (their sight line and their shots are the game's rays), walk through a door that is in their way, and break the part of a build that holds them, looking at head and shin height as well as chest height (`botBreak`), since an edited piece can hold a body by its top or its bottom alone. A bot that slides to and fro along a line of builds for two seconds without getting nearer its goal now breaks through it (stepping aside never came to a stop, so it never counted as stuck; that was so before editing too). **Checked** with the game's own movement and shots against the tiles themselves: on flat ground every one of the 511 wall shapes both ways round (275,940 shots straight and slanted through every tile from both sides, 14,308 walks, 840,000 moves of thrown and jumping bodies at 60, 30 and 20 frames a second), all 15 floor shapes and all 15 ramp shapes in all four directions; on slopes 14 walls with skirts of 0.5 to 3.7 m in 20 shapes each (shots at every tile and at the skirt, 1.7 million moves, doors walked through where the land allows and stopped by the sill where it doesn't), and 8 floors and 8 ramps in every shape; whole pieces compared number for number with the page before (37 pieces on flat and sloping ground, 444,000 moves and 11,100 rays, all identical). Weak or not done: the first wall on rising ground can still show as little as 1.5 m above it (the land rule from map version 5 was left alone); you still start with 30 scrap, three pieces, so a build fight needs the crowbar first; on a phone the build pieces are still behind the scrap chip; a body that another player's build lands on can still be left inside it (as before: only this browser's own builds and edits are refused). **Spanish (November 2026):** the whole game has Spanish through `../lang.js` (switch in the menu's settings and the pause menu), with Driftfall's words in `drop-zone/es.js`; the menus, lobby, results, Creative tools, Face and Locker are translated by lang.js, while the HUD, banner and kill feed are `data-noi18n` and put their words through `T()` (an exact lookup in es.js's list, cheap enough for every frame), and player names, room codes and place names are never translated, nothing translated is sent, and a weapon's rarity is written out per weapon in es.js because Spanish adjectives agree with the noun (`'Rare Pump Shotgun'`), with an extra shorter word (`'Shotgun (tight)'`) for the narrowest phone slots. -- `e63334287a3deaa3/ironveil/`: Midnight Ops (**preview, admin page only**; Back Room folder; the folder keeps the working title `ironveil`, and the display name lives in ONE constant, `IV.GAME_NAME` in `js/core.js`, which fills the page title, the logo, the content note and the "turn your phone" card, so the name can change without touching anything else), a single-player first-person Second World War campaign (an over-the-shoulder view stays in Settings as "View") (three.js r187 from the site's own build, `/lib/three/r187/three.min.js` plus `three-addons.min.js` for GLTFLoader and SkeletonUtils, see `lib/three/README.md`; plus `../autores.js`, `../keybinds.js`, `/e63334287a3deaa3/lang.js` with its own `es.js`, `stats.js`; Web Audio; no Firebase, nothing online). v1 has **Boot Camp** (a five-minute training course) and **Mission 1, Night Drop**; missions 2 to 8 are listed on the map table as "Coming soon" with their one-line briefings (`IV.menus.COMING` in `js/menus.js`). **Content note and blood:** the first time the game opens (until accepted) a screen before the title says it contains war violence and blood, with an "I understand, continue" button and a Back link (`localStorage` `ironveil:terms` = `1`). Settings has a **Blood effects** switch (on once accepted): off turns every blood effect (hit puffs, spray, the small fading decals, which are capped at `TUNING.blood.decals`, the screen-edge flecks) into dust. No dismemberment, gore close-ups or executions, no hate symbols: the enemy wears field grey with a plain invented white chevron on the helmet. **Files:** `index.html` (page, styles, HUD and menu markup), `js/core.js` (namespace, the one `TUNING` object with every feel number and its units, maths, seeded noise, settings and save), `world.js` (renderer, quality presets Low/Medium/High, sky, moon and fog, the heightfield, colliders in an 8 m spatial hash, ray casts, how lit a point is for stealth), `kit.js` (merged static geometry with world-space UVs, hedgerows, walls, fences, trees, buildings with real door and window openings, props, instanced grass and crops), `env/` (the environment kit, `window.IVEnv`, made separately: ground, grass, trees, hedges, walls, props, atmosphere, decals and the post stack, all generated in code; loaded with plain script tags before the game's own files; `?noenv` shows the old code-made stand-ins), `art.js` (the art factory: every hedge, wall, fence, tree, building, prop, pole, crop field, grass, the stream, the atmosphere and the bullet-impact hook go through `IV.art.*`; when `window.IVEnv` (the environment art module in `ironveil/env/`) is loaded it draws them and `kit.js` only makes the colliders, so layout, collision, nav and cover never change with the look), `nav.js` (0.5 m walk grid, A*, string pulling, cover points), `player.js`, `camera.js` (over-the-shoulder camera with collision, shoulder swap, the scope, aim assist), `weapons.js` (every bullet is a projectile with drag, gravity and wind; the scope's drop marks are computed from the same simulation), `ai.js`, `ally.js`, `fx.js`, `audio.js` (all synthesised), `hud.js`, `menus.js`, `touch.js`, `main.js` (fixed 60 Hz step with interpolation, app state, test hooks), `missions/bootcamp.js`, `missions/nightdrop.js`, and `js/chars-standin.js` (see Characters). **Saving:** `localStorage` `ironveil:save` = `{v: 1, diff, missions: {id: {done, medal, best, last}}, settings: {...}, cp: {mission, diff, idx, data}, tut}`; `cp` is the last checkpoint (its `data` holds the mission's flags, which soldiers are dead, objectives, ammunition, the clock and stats), so Continue on the title resumes there; finishing a mission clears it. Key bindings are `keybinds:ironveil`, the language is the Back Room's `lang:v1`. Bump `v` and migrate in `load()` if the shape changes. **Missions are data plus a few functions**, registered with `IV.missions.register({id, num, title, line, briefing: [...], preview: [{text, opt}], world: {size, day, height(x,z), surface(x,z), groundColor(x,z,y,n,c), waterLevel?, fog, fogColor}, build(M), setup(M, cpIndex, data), step?(M, dt), frame?(M, dt), sketch(g, w, h, sk), medals: [{text, ok(stats, M)}] x3})`. `build` makes the static world once (kept while you replay); `setup` places the player, squadmate and soldiers for a checkpoint and starts the script. The script uses `M.obj(id, text, {optional, marker})`, `M.done(id)`, `M.when(cond, fn)`, `M.after(sec, fn)`, `M.interact({x, z, r, text, hold, done})`, `M.say(text)` / `M.hq(text)` (radio subtitles, text only), `M.checkpoint(n)`, `M.fail(reason)` and `M.complete()`; three medal criteria give gold (all), silver (two) or bronze. To add a mission: copy `missions/nightdrop.js`, give it the next `num` and a new `id`, add its `