From 35f8edcbd2b024b5220fd6272800cb9fe19fb811 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 24 Sep 2024 12:59:28 +0200 Subject: tc: prevent too far problems with new target selection --- test-client/main.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test-client/main.ts') diff --git a/test-client/main.ts b/test-client/main.ts index 103212e4..605bca5e 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -374,10 +374,15 @@ export function get_interact_target(): V2 | undefined { const t = tiles.get([bx + ox, by + oy] + "") if (!t) continue if (data.tile_interact[t.kind]) { - const dx = rx - (bx + ox + 0.5) - const dy = ry - (by + oy + 0.5) + const cx = (bx + ox + 0.5) + const cy = (by + oy + 0.5) + const dx = rx - cx + const dy = ry - cy + const pdx = me.position.x - cx + const pdy = me.position.y - cy const d = Math.sqrt(dx * dx + dy * dy) - if (d < 1.5 && d < best_d) { + const pd = Math.sqrt(pdx * pdx + pdy * pdy) + if (pd < 2 && d < best_d) { best_d = d best = { x: bx + ox, y: by + oy } } -- cgit v1.2.3-70-g09d2