Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d438b52
wip(hands): boxing stance base: less blade, shorter wider base, forwa…
user1303836 Nov 17, 2026
304c312
fix(hands): keep the picture when the resolution scaler reaches its b…
user1303836 Nov 17, 2026
ed9dd56
test(hands): pin the kept shadow map as a comparison texture
user1303836 Nov 17, 2026
b28f12c
wip(hands): stance, range guard, idle life and step-drag footwork
user1303836 Nov 17, 2026
2854ddd
wip(hands): punch mechanics, guards, evasions and hit reactions
user1303836 Nov 17, 2026
7e11700
wip(hands): x-ray bone breaks, bodies that wear the fight, spurting w…
user1303836 Nov 17, 2026
c4b7252
Merge branch 'fix/hands-low-tier-blank' into feature/hands-boxer-polish
user1303836 Nov 17, 2026
5bcb1bb
Merge branch 'feature/hands-polish-stance' into feature/hands-boxer-p…
user1303836 Nov 17, 2026
98e0efd
Merge branch 'feature/hands-polish-punch' into feature/hands-boxer-po…
user1303836 Nov 17, 2026
08bb037
Merge branch 'feature/hands-polish-gore' into feature/hands-boxer-polish
user1303836 Nov 17, 2026
f7bc178
wip(hands): ring lighting, skin shading, tailored trunks, contact sha…
user1303836 Nov 17, 2026
dc91636
wip(hands): officials stand upright, walk in strides, count, wave off…
user1303836 Nov 17, 2026
df76316
Merge branch 'feature/hands-polish-look' into feature/hands-boxer-polish
user1303836 Nov 17, 2026
6ccf9bc
Merge branch 'feature/hands-polish-officials' into feature/hands-boxe…
user1303836 Nov 17, 2026
2a5adaa
wip(hands): styles stand differently, fighters at ease stand tall, a …
user1303836 Nov 17, 2026
a2684bb
wip(hands): punch form retuned on the merged stance
user1303836 Nov 17, 2026
3d73b52
wip(hands): officials round two in progress
user1303836 Nov 17, 2026
60dd82d
Merge branch 'feature/hands-polish-punch' into feature/hands-boxer-po…
user1303836 Nov 17, 2026
0162eda
Merge branch 'feature/hands-polish-officials' into feature/hands-boxe…
user1303836 Nov 17, 2026
a5f51d2
feat(hands): rebuild the bundle and document the stance harness params
user1303836 Nov 17, 2026
728e7f2
Merge remote-tracking branch 'origin/main' into feature/hands-boxer-p…
user1303836 Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ git diff --exit-code -- src/intelstream/hands/static

`npm run build` typechecks, writes exactly `index.html`, `assets/hands.js`, and `assets/hands.css` into `src/intelstream/hands/static`, and runs the scanner. Those generated files are committed so production Python installations do not require Node. Change TypeScript/CSS in `web/hands`, rebuild, inspect the output, commit source and generated files together, and require the final `git diff --exit-code` after a clean rebuild. Never hand-edit the generated bundle.

The fixed three-file deployment contract embeds the mesh-only Boxer rig and its five source textures (re-encoded as JPEG by the generator) in `hands.js`; the resulting production script is about 2.89 MB (about 1.45 MB gzip). This startup-cost tradeoff keeps the Activity self-contained and avoids runtime asset requests. `scripts/hands_pose_strip.js` renders a pose frozen at a list of times into one frame strip for motion review. `npm run dev` also serves `?model-lab=1&pose=<name>&cam=<angle>&trauma=<light|heavy|cut>` as a pose lab for reviewing the runtime animation and injury shading without a match (poses include punches, guards, slips, knockdown, seated, celebrate and wave_off), and `?fixture=1` with `&finisher=head|hand`, `&phase=rest`, `&pin=1|corner`, `&blood=reduced|off` or `&platform=mobile` for presentation review. Both take the engine's injuries: `&injuries=<ids>` carried from the start, `&inflict=<ids>` happening one after another, `&bloodvol=<0..1000>`, and `&fatality=<id>` (the fixture runs FINISH HIM, the kill, its replay and the result card). The lab also takes `&dead=<bled_out|brain|gutted>`, `&dazed=1` and `&vomit=1`; the fixture takes `&death=<bled_out|brain|gutted>` and `&injuries1=<ids>` for the other fighter.
The fixed three-file deployment contract embeds the mesh-only Boxer rig and its five source textures (re-encoded as JPEG by the generator) in `hands.js`; the resulting production script is about 2.94 MB (about 1.46 MB gzip). This startup-cost tradeoff keeps the Activity self-contained and avoids runtime asset requests. `scripts/hands_pose_strip.js` renders a pose frozen at a list of times into one frame strip for motion review. `npm run dev` also serves `?model-lab=1&pose=<name>&cam=<angle>&trauma=<light|heavy|cut>` as a pose lab for reviewing the runtime animation and injury shading without a match (poses include punches, guards, slips, knockdown, seated, celebrate and wave_off), and `?fixture=1` with `&finisher=head|hand`, `&phase=rest`, `&pin=1|corner`, `&blood=reduced|off` or `&platform=mobile` for presentation review. Both take the engine's injuries: `&injuries=<ids>` carried from the start, `&inflict=<ids>` happening one after another, `&bloodvol=<0..1000>`, and `&fatality=<id>` (the fixture runs FINISH HIM, the kill, its replay and the result card). The lab also takes `&dead=<bled_out|brain|gutted>`, `&dazed=1` and `&vomit=1`; the fixture takes `&death=<bled_out|brain|gutted>` and `&injuries1=<ids>` for the other fighter. For judging how the boxers stand and move, both take `&gap=<engine units between the two>`; the fixture takes `&calm=1` (both standing in their stances, nothing scripted) or `&calm=walk` (circling), `&guard=high|low`, `&styles=<one>,<two>`, `&wear=1` (bodies marked by the fight from the start) and `&referee=count|break`; the lab takes `&speed=<m/s>` for the walks, `&xray=<bone>` to play a bone break's cut-in and `&wear=<blows>`.

For a standalone presentation fixture, run `npm --prefix web/hands run dev` and open the printed URL with `?fixture=1`. For the real two-process localhost flow, terminal one runs the Python bot/Hands server with valid Discord credentials:

Expand Down
928 changes: 538 additions & 390 deletions src/intelstream/hands/static/assets/hands.js

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions web/hands/src/audio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { INJURY_SOUNDS } from "./assets/injury-sounds";
import { fatalityOf, injuryKind, type FatalityId, type GoreCue, type InjuryKind } from "./injuries";
import type { ArcadeInjury } from "./render/renderer";
import { XRAY_SNAP_SECONDS } from "./render/xray";

/** Finishers without a voice of their own borrow the nearest one. */
const BORROWED_VOICE: Partial<Readonly<Record<ArcadeInjury, ArcadeInjury>>> = { head_burst: "decapitation", eye_left: "jaw_dislocation", eye_right: "jaw_dislocation", ribs_left: "shoulder_left", ribs_right: "shoulder_right" };
Expand Down Expand Up @@ -461,8 +462,11 @@ export class AudioFeedback {
switch (cue.kind) {
case "injury": {
const sound = INJURY_SOUND[injuryKind(cue.injury)];
if (explicit) this.wound(sound, 0);
else this.impact(0.3, false, 0.9);
if (explicit) {
this.wound(sound, 0);
// Every injury that cracks is a bone, shown breaking in its X-ray a moment after the punch.
if (sound === "crack") this.xray();
} else this.impact(0.3, false, 0.9);
this.ooh(1);
this.crowdSwell(0.8);
if (sound !== "crack") this.crowdVoice({ ...GROAN, delay: 0.45 });
Expand Down Expand Up @@ -501,6 +505,13 @@ export class AudioFeedback {
else this.chop(delay);
}

/** The X-ray of a breaking bone: a hum that rises to the snap, the bone going in close-up, and the wet give of the marrow. */
private xray(): void {
this.tone({ from: 90, to: 440, duration: XRAY_SNAP_SECONDS, type: "sine", gain: 0.1, delay: 0 });
this.crack(XRAY_SNAP_SECONDS);
this.noise({ duration: 0.16, frequency: 520, sweepTo: 170, gain: 0.2, type: "lowpass", q: 4, delay: XRAY_SNAP_SECONDS + 0.03, offset: 0.3 });
}

/** A bone breaking: a dry snap, the dull knock of what it was holding up, and the splintering after it. */
private crack(delay: number): void {
this.noise({ duration: 0.03, frequency: 3400, sweepTo: 1800, gain: 0.34, type: "bandpass", q: 2.2, delay });
Expand Down
81 changes: 73 additions & 8 deletions web/hands/src/dev-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REST_CORNER_OFFSET } from "./manifest";
import { REST_CORNER_OFFSET, punchTiming } from "./manifest";
import * as THREE from "three";
import { FATALITY_IDS, INJURY_IDS, fatalityFor, parseDeathCause, type InjuryId } from "./injuries";
import { SharedActionIntent } from "./input/action-buffer";
Expand Down Expand Up @@ -32,6 +32,14 @@ const base = (id: string): Draft => ({

const PUNCHES = ["jab", "straight", "hook", "uppercut"] as const;

/** Where a `calm` fighter stands at `seconds`: the one on the `side` (-1 or 1) of the centre the pair turns round. */
function calmPlace(seconds: number, gap: number, walking: boolean, side: number): { x: number; y: number } {
const turn = walking ? seconds * 0.3 : 0;
const half = (gap + (walking ? Math.sin(seconds * 0.9) * 35 : 0)) / 2;
const drift = walking ? Math.sin(seconds * 0.47) * 70 : 0;
return { x: drift + side * Math.cos(turn) * half, y: side * Math.sin(turn) * half };
}

export function runDevelopmentFixture(root: HTMLElement): () => void {
root.innerHTML = `<section class="activity"><canvas class="fight"></canvas><header class="topbar"><strong>HANDS · DEV FIXTURE</strong><span>Production never enters this harness</span></header></section>`;
const bloodParam = new URLSearchParams(window.location.search).get("blood");
Expand All @@ -56,6 +64,8 @@ export function runDevelopmentFixture(root: HTMLElement): () => void {
let tick = 0;
let eventId = 0;
const refereeBlowsShown = new Set<number>();
const refereeAt = { x: 0, y: 140 };
let brokenCycle = -1;
let finalSent = false;
let bellRung = false;
let thrownWindow = -1;
Expand Down Expand Up @@ -98,23 +108,33 @@ export function runDevelopmentFixture(root: HTMLElement): () => void {
}
// `mouthpiece=1` puts the gum shields back before every exchange so each big head shot knocks one out.
if (new URLSearchParams(window.location.search).get("mouthpiece") === "1" && cycle < 0.1) renderer.labEffects.clearMouthpieces();
if (cycle < 0.55 && one.taunt_ticks === 0 && two.taunt_ticks === 0 && !closing) {
if (cycle < 0.75 && one.taunt_ticks === 0 && two.taunt_ticks === 0 && !closing) {
const punch = PUNCHES[Math.floor(t / 3.2) % PUNCHES.length]!;
attacker.action = punch;
attacker.action_hand = Math.floor(t / 3.2) % 3 === 0 ? "right" : "left";
attacker.action_target = Math.floor(t / 3.2) % 4 === 1 ? "body" : "head";
attacker.action_power = Math.floor(t / 3.2) % 5 === 2 ? "power" : "normal";
// `wear=1` names each punch as the engine does, so it leaves its mark where its glove lands and its blood on both men.
if (new URLSearchParams(window.location.search).get("wear") === "1") attacker.action_key = `${punch}:${attacker.action_hand}:${attacker.action_target}:${attacker.action_power}`;
defender.defense = Math.floor(t / 6.4) % 2 === 0 ? "guard_high" : "none";
const punchWindow = Math.floor(t / 3.2);
// The punch is a real action instance, so the fighters throw it and it lands on its contact tick.
const sparId = `spar-${punchWindow}`;
const sparStart = Math.round(punchWindow * 3.2 * 30);
const sparTiming = punchTiming(punch, attacker.action_target, attacker.action_power);
Object.assign(attacker, {
action_id: sparId, action_key: `${punch}:${attacker.action_hand}:${attacker.action_target}:${attacker.action_power}`, action_start_tick: sparStart,
action_startup_ticks: sparTiming.startup, action_active_ticks: sparTiming.active, action_recovery_ticks: sparTiming.recovery,
});
if (thrownWindow !== punchWindow) {
thrownWindow = punchWindow;
eventId += 1;
events.push({ event_id: eventId, tick, kind: "punch_start", actor_id: attacker.player_id, target_id: null, amount: 0, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 0, direction: 0, action_id: null });
events.push({ event_id: eventId, tick, kind: "punch_start", actor_id: attacker.player_id, target_id: null, amount: 0, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 0, direction: 0, action_id: sparId });
}
if (cycle >= 0.2 && landedWindow !== punchWindow) {
if (tick >= sparStart + sparTiming.startup && landedWindow !== punchWindow) {
landedWindow = punchWindow;
eventId += 1;
events.push({ event_id: eventId, tick, kind: "hit", actor_id: attacker.player_id, target_id: defender.player_id, amount: 210, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 100, direction: attacker.facing, action_id: null });
events.push({ event_id: eventId, tick: sparStart + sparTiming.startup, kind: "hit", actor_id: attacker.player_id, target_id: defender.player_id, amount: 210, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 100, direction: attacker.facing, action_id: sparId });
defender.stunned_ticks = 12;
}
}
Expand All @@ -129,6 +149,9 @@ export function runDevelopmentFixture(root: HTMLElement): () => void {
const flash = finisher === "flash";
const pinned = search.get("pin") === "1";
const knockdownCycle = finisher === null ? t % 14 : (t < 2.5 ? 0 : 12);
// `referee=count` puts the red fighter down six seconds into each cycle, in the engine's knockdown phase, so the
// referee counts over him from his place beside him until the cycle ends.
const downAt = search.get("referee") === "count" ? 6 : 11;
// A body shot that puts him on a knee a third of a second after it lands.
const bodyCollapse = finisher === "body" && t >= 2.5 && t < 2.85;
// The sparring stops for the body shot; a punch on a fighter who is down would be an arcade finisher.
Expand Down Expand Up @@ -156,14 +179,15 @@ export function runDevelopmentFixture(root: HTMLElement): () => void {
eventId += 1;
events.push({ event_id: eventId, tick, kind: "knockdown", actor_id: one.player_id, target_id: two.player_id, amount: 1, detail: "body", blood: 0, direction: 0, action_id: "fixture-body" });
}
} else if (knockdownCycle > 11 && knockdownCycle < 13.4) {
} else if (knockdownCycle > downAt && knockdownCycle < (downAt < 11 ? 14 : 13.4)) {
two.is_downed = !flash;
two.action = null;
two.x = 140;
two.y = 40;
one.x = -60;
one.y = -30;
const trigger = finisher === null ? knockdownCycle > 11 && knockdownCycle < 11.15 : t >= 2.5 && t < 2.65;
two.get_up_count = Math.floor(knockdownCycle - downAt);
const trigger = finisher === null ? knockdownCycle > downAt && knockdownCycle < downAt + 0.15 : t >= 2.5 && t < 2.65;
if (trigger) {
eventId += 1;
// `finisher=head` severs the head, `burst` bursts it with a big counter, `eye` forces an eye out
Expand Down Expand Up @@ -209,6 +233,27 @@ export function runDevelopmentFixture(root: HTMLElement): () => void {
one.x = 292;
one.y = 284;
}
// `calm=1` stands both fighters in their stances at `gap` (150 without one) with nothing scripted, to judge how
// they stand; `calm=walk` has them circle each other while the pair drifts and the gap opens and closes, and
// `guard=high|low` has them hold that guard.
const calm = search.get("calm");
if (calm !== null) {
events.length = 0;
const spacing = Number.isFinite(fixedGap) && fixedGap > 0 ? fixedGap : 150;
const guard = search.get("guard");
for (const [fighter, side] of [[one, -1], [two, 1]] as const) {
const now = calmPlace(t, spacing, calm === "walk", side);
const next = calmPlace(t + 1 / 30, spacing, calm === "walk", side);
const other = calmPlace(t, spacing, calm === "walk", -side);
const apart = Math.hypot(other.x - now.x, other.y - now.y) || 1;
Object.assign(fighter, {
x: Math.round(now.x), y: Math.round(now.y), velocity_x: next.x - now.x, velocity_y: next.y - now.y,
facing: -side, facing_x: Math.round(((other.x - now.x) / apart) * 1000), facing_y: Math.round(((other.y - now.y) / apart) * 1000),
action: null, taunt_ticks: 0, stunned_ticks: 0, clinch_ticks: 0, is_downed: false,
defense: guard === "high" ? "guard_high" : guard === "low" ? "guard_low" : "none",
});
}
}
if (forcedRest) {
const corner = search.get("corner");
for (const [fighter, sign] of [[one, -1], [two, 1]] as const) {
Expand Down Expand Up @@ -348,9 +393,29 @@ export function runDevelopmentFixture(root: HTMLElement): () => void {
if (t >= blows[1]!.at) official = { ...official, alive: false };
refereeDownFor = t >= blows[1]!.at ? Math.max(0, blows[1]!.at + 5 - t) : 0;
}
// `referee=break` stands the referee where the engine does, 62 units off the middle of the two on his own side of
// them, following them at its pace, and has him break each clinch a moment after it is tied.
if (search.get("referee") === "break") {
const midX = (one.x + two.x) / 2;
const midY = (one.y + two.y) / 2;
const across = Math.hypot(one.y - two.y, two.x - one.x) || 1;
const side = (refereeAt.x - midX) * (one.y - two.y) + (refereeAt.y - midY) * (two.x - one.x) >= 0 ? 62 : -62;
const dx = midX + ((one.y - two.y) / across) * side - refereeAt.x;
const dy = midY + ((two.x - one.x) / across) * side - refereeAt.y;
const step = Math.min(1, 18 / Math.max(1, Math.hypot(dx, dy)));
refereeAt.x += dx * step;
refereeAt.y += dy * step;
const look = Math.hypot(midX - refereeAt.x, midY - refereeAt.y) || 1;
official = { ...official, x: Math.round(refereeAt.x), y: Math.round(refereeAt.y), facing_x: Math.round(((midX - refereeAt.x) / look) * 1000), facing_y: Math.round(((midY - refereeAt.y) / look) * 1000) };
if (tauntCycle > 4.3 && tauntCycle < 5.1 && brokenCycle !== Math.floor(t / 12)) {
brokenCycle = Math.floor(t / 12);
eventId += 1;
events.push({ event_id: eventId, tick, kind: "referee_break", actor_id: null, target_id: null, amount: 0, detail: "", blood: 0, direction: 0, action_id: null });
}
}
const flashOver = flash && t >= 2.5;
const snapshot: EngineSnapshot = {
tick, phase: decided || flashOver || dead ? "complete" : finishing ? "finish" : introducing ? "countdown" : forcedRest ? "rest" : refereeDownFor > 0 ? "referee_down" : "fight", round_number: search.get("intro") === "1" ? 1 : 3, phase_ticks_remaining: decided || dead ? 0 : finishing ? Math.round((killAt - t) * 30) : introducing ? Math.max(0, 90 - tick) : forcedRest ? Math.max(0, 450 - tick) : Math.max(0, 5400 - tick),
tick, phase: decided || flashOver || dead ? "complete" : finishing ? "finish" : introducing ? "countdown" : forcedRest ? "rest" : refereeDownFor > 0 ? "referee_down" : downAt < 11 && two.is_downed ? "knockdown" : "fight", round_number: search.get("intro") === "1" ? 1 : 3, phase_ticks_remaining: decided || dead ? 0 : finishing ? Math.round((killAt - t) * 30) : introducing ? Math.max(0, 90 - tick) : forcedRest ? Math.max(0, 450 - tick) : Math.max(0, 5400 - tick),
fighters: [{ ...one }, { ...two }],
referee: official,
events,
Expand Down
11 changes: 11 additions & 0 deletions web/hands/src/gore-feedback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AnnouncerVoice } from "./announcer";
import { AudioFeedback } from "./audio";
import { HapticFeedback } from "./haptics";
import { FATALITY_IDS, INJURY_IDS, type DeathCause, type GoreCue } from "./injuries";
import { XRAY_SNAP_SECONDS } from "./render/xray";
import type { Settings } from "./settings";

const full: Settings = { volume: 1, haptics: true, reducedMotion: false, blood: "full", camera: "broadcast", commentary: true, announcer: true };
Expand Down Expand Up @@ -167,6 +168,16 @@ describe("gore heard", () => {
expect(longest(rip)).toBeGreaterThanOrEqual(0.5);
});

it("snaps a bone twice, as the punch lands and again as its X-ray shows it go, and only when that is drawn", async () => {
const snaps = async (injury: (typeof INJURY_IDS)[number], settings: Settings = full): Promise<number[]> =>
wet((await heard({ kind: "injury", injury }, settings)).noises).filter((noise) => noise.filters[0]!.frequency.set[0]!.value === 3400).map((noise) => noise.start).sort((a, b) => a - b);
const broken = await snaps("ribs_left_broken");
expect(broken).toHaveLength(2);
expect(broken[1]! - broken[0]!).toBeCloseTo(XRAY_SNAP_SECONDS, 5);
expect(await snaps("ear_left_torn")).toHaveLength(0);
expect(await snaps("ribs_left_broken", { ...full, blood: "reduced" })).toHaveLength(0);
});

it("pumps a severed limb's blood out in beats after the chop", async () => {
const { noises, context } = await heard({ kind: "injury", injury: "forearm_right_severed" });
const late = wet(noises).filter((noise) => noise.start - context.currentTime >= 0.25 && noise.filters[0]!.type === "bandpass" && noise.stop - noise.start > 0.15).map((noise) => noise.start - context.currentTime);
Expand Down
5 changes: 5 additions & 0 deletions web/hands/src/haptics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fatalityOf, type GoreCue } from "./injuries";
import { XRAY_SNAP_SECONDS, breakFor } from "./render/xray";
import { coarsePointer } from "./input/touch";
import type { Settings } from "./settings";
import type { CombatEvent } from "./types";
Expand All @@ -19,6 +20,8 @@ const patterns: Readonly<Record<string, Pattern>> = {
const gorePatterns: Readonly<Record<GoreCue["kind"], Pattern>> = {
injury: [150, 0.55, 0.6], vomit: [90, 0.15, 0.45], finish_him: [180, 0.65, 0.3], fatality: [180, 0.65, 0.65], death: [170, 0.5, 0.12],
};
/** The second jolt of a broken bone, as its X-ray shows it snap. */
const BONE_SNAP: Pattern = [120, 0.65, 0.5];

export class HapticFeedback {
constructor(private readonly settings: () => Settings) {}
Expand All @@ -38,6 +41,8 @@ export class HapticFeedback {
gore(cue: GoreCue): void {
if (!this.settings().haptics || (cue.kind === "death" && fatalityOf(cue.cause) !== null)) return;
this.rumble(gorePatterns[cue.kind]);
const current = this.settings();
if (cue.kind === "injury" && breakFor(cue.injury) !== null && current.blood === "full" && !current.reducedMotion) setTimeout(() => this.rumble(BONE_SNAP), XRAY_SNAP_SECONDS * 1000);
}

private rumble(pattern: Pattern): void {
Expand Down
Loading
Loading