diff --git a/static/script.js b/static/script.js index 77d940bc..9dfaab4f 100644 --- a/static/script.js +++ b/static/script.js @@ -3858,8 +3858,10 @@ function updateRadarWindow(msg) { const hasTiles = dungeonTileCanvases && Object.keys(dungeonTileCanvases).length > 0; // Normalize rotation value to radians (same as UB's DungeonCell.cs) + // Raw value is quaternion W component: 1→180°, ~0.707→-90°, ~-0.707→90°, 0→0° function cellRotation(rot) { - if (rot === 1) return Math.PI; + if (Math.abs(rot - 1) < 0.01) return Math.PI; + if (Math.abs(rot + 1) < 0.01) return Math.PI; if (rot < -0.70 && rot > -0.8) return Math.PI / 2; if (rot > 0.70 && rot < 0.8) return -Math.PI / 2; return 0; @@ -3877,8 +3879,9 @@ function updateRadarWindow(msg) { ctx.globalAlpha = isCurrentFloor ? 0.85 : 0.12; (level.cells || []).forEach(cell => { - // UB mirrors X, Y flipped for north-up (AC Y+ = north, canvas Y+ = down) - const dx = -(cell.x - playerX) * scale; + // Direct relative position (UB mirrors both cell and player, cancels out) + // Y negated for north-up (AC Y+ = north, canvas Y+ = down) + const dx = (cell.x - playerX) * scale; const dy = -(cell.y - playerY) * scale; const tileCanvas = hasTiles ? dungeonTileCanvases[String(cell.env_id)] : null; @@ -3976,7 +3979,7 @@ function updateRadarWindow(msg) { // Use raw physics coords in dungeons (X mirrored), EW/NS on surface let dX, dY; if (isDungeon && obj.raw_x !== undefined) { - dX = -(obj.raw_x - playerX); // X mirrored + dX = (obj.raw_x - playerX); dY = -(obj.raw_y - playerY); // Y flipped for north-up } else { dX = obj.ew - playerEW; @@ -4039,7 +4042,7 @@ function updateRadarWindow(msg) { const withDist = objects.map(obj => { let distMeters, dX, dY; if (isDungeon && obj.raw_x !== undefined) { - dX = -(obj.raw_x - playerX); + dX = (obj.raw_x - playerX); dY = -(obj.raw_y - playerY); distMeters = Math.sqrt(dX * dX + dY * dY); // raw coords are ~meters } else {