commit 82a3c831707bf7ed5d6be236df73fda825b42e42
parent 187ba79d6fcda9e1a5382d06178d1609049ecaae
Author: anon <anon@example.com>
Date: Fri, 30 Oct 2026 11:05:05 +0000
Follow moving native targets between picker probes
Diffstat:
4 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/DEVELOPERS.md b/DEVELOPERS.md
@@ -515,7 +515,8 @@ The driver provides:
`click` performs that conversion itself. This handles CSS scaling of the canvas.
- `pick(type, id)` probes near the entity's projected position and returns native
coordinates only after the real game picker reports that identity. It moves
- the browser pointer; it does not select or activate the entity. Position the
+ the browser pointer and follows the latest projection between probes; it does
+ not select or activate the entity. Position the
character/camera normally first, then click the returned point. Occlusion and
offscreen targets should fail visibly rather than bypass picking.
- `save(directory)` writes `trace.json` and `screen.png`. Keep it inside a
diff --git a/TODO.md b/TODO.md
@@ -2965,6 +2965,13 @@ with payloads and known client/server provenance.
## Thorough gameplay regression testing
+- [x] Follow moving native projections during gameplay picking. The next
+ ordinary Leet entered the viewport during a failed pick, while all probes
+ stayed near its first offscreen position. A focused public-driver regression
+ reproduces the stale position and passes with projection refresh between
+ probes. All seven public-driver tests and the existing WASM browser harness
+ pass. The ordinary two-client run then selects a walking Leet and defeats it
+ from full health, reaching 1,100 XP without grants or edited stats, funds or enemies.
- [x] Include original mission booths and entrances in native frame snapshots.
Their shared n3Dynel layout and typed directory identity are recovered from
the client. A WASM fixture distinguishes equal numeric IDs, and an ordinary
diff --git a/client/tests/game_test.mjs b/client/tests/game_test.mjs
@@ -115,3 +115,19 @@ test('client errors still fail waits after ordinary traffic fills the trace', as
assert.equal(game.events.some(event => event.kind === 'error'), false);
assert.equal(game.errors[0].message, 'native client aborted');
});
+
+test('picking follows a moving native projection between probes', async () => {
+ const game = new GameTest();
+ const moves = [];
+ game.page = {mouse: {move: async (x, y) => { moves.push([x, y]); }}};
+ game.point = async (x, y) => ({x, y});
+ let frame = 0;
+ game.snapshot = async () => ({frame: ++frame,
+ actors: [{type: 50000, id: 7, screenPosition: [frame === 1 ? 100 : 200, 100, 0.5]}],
+ hover: moves.at(-1)?.[0] === 199 ? [50000, 7] : [0, 0]});
+
+ const point = await game.pick(50000, 7);
+
+ assert.deepEqual(point, [199, 100]);
+ assert.deepEqual(moves, [[100, 100], [199, 100]]);
+});
diff --git a/tools/client/game_test.mjs b/tools/client/game_test.mjs
@@ -233,17 +233,18 @@ export class GameTest {
async pick(type, id) {
this.record({kind: 'action', action: 'pick', type, id});
- const state = await this.snapshot();
- const actor = state.actors.find(actor => actor.type === type && actor.id === id);
- assert(actor?.screenPosition, `Entity ${type}:${id} is not projected`);
- const [x, y, depth] = actor.screenPosition;
- assert(depth >= 0 && depth <= 1, `Entity ${type}:${id} is outside the camera depth range`);
+ let state = await this.snapshot();
// Distant models can be only a few pixels wide around their projected origin.
for (const dy of [0, -8, -20, -40, 8, 20]) for (const dx of [0, -1, 1, -8, 8, -20, 20]) {
+ // Follow native movement while probing, including an entity entering the view.
+ const actor = state.actors.find(actor => actor.type === type && actor.id === id);
+ assert(actor?.screenPosition, `Entity ${type}:${id} is not projected`);
+ const [x, y, depth] = actor.screenPosition;
+ assert(depth >= 0 && depth <= 1, `Entity ${type}:${id} is outside the camera depth range`);
const point = await this.point(x + dx, y + dy);
await this.page.mouse.move(point.x, point.y);
- const sample = await this.snapshot();
- if (sample.hover[0] === type && sample.hover[1] === id) return [x + dx, y + dy];
+ state = await this.snapshot();
+ if (state.hover[0] === type && state.hover[1] === id) return [x + dx, y + dy];
}
throw new Error(`Native picker did not hit ${type}:${id} near its screen position`);
}