From e6ca121b867e1b3ab87e96d02cd4f3eb00edb06c Mon Sep 17 00:00:00 2001 From: Wizzard <rich@bandaholics.cash> Date: Mon, 10 Mar 2025 13:29:01 -0400 Subject: [PATCH] Better C4 visualizers --- webradar/script.js | 61 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/webradar/script.js b/webradar/script.js index 3e7bdd8..7166409 100644 --- a/webradar/script.js +++ b/webradar/script.js @@ -159,6 +159,31 @@ function mapCoordinates(coordinates) { return { x: offset_x, y: offset_y } } +function drawPlayerBomb(pos, playerType) { + if (!map) return; + + if (zoomSet) { + pos = boundingCoordinates(mapCoordinates(pos), boundingRect); + textSize = boundingScale(10, boundingRect); + } else { + pos = mapCoordinates(pos); + textSize = 10; + } + + const textY = pos.y + (drawNames ? (drawGuns ? 50 : 35) : (drawGuns ? 35 : 20)); + + ctx.fillStyle = bombColor; + + ctx.font = `${textSize}px Arial`; + ctx.textAlign = "center"; + ctx.textBaseline = "top"; + + ctx.lineWidth = 2; + ctx.strokeStyle = "black"; + ctx.strokeText("[C4]", pos.x, textY); + ctx.fillText("[C4]", pos.x, textY); +} + function drawPlayerName(pos, playerName, playerType, hasAwp, hasBomb) { if (!map) return; @@ -325,6 +350,13 @@ function render() { ); } + if (data.Player.hasBomb && !data.Player.isDormant) { + drawPlayerBomb( + data.Player.pos, + data.Player.playerType + ); + } + if (drawNames && data.Player.playerName) { drawPlayerName(data.Player.pos, data.Player.playerName, data.Player.playerType); } @@ -442,22 +474,35 @@ function drawBomb(pos, planted) { if (zoomSet) { pos = boundingCoordinates(mapCoordinates(pos), boundingRect) - size = boundingScale(5, boundingRect); + size = boundingScale(8, boundingRect); } else { pos = mapCoordinates(pos) - size = 5 + size = 8 } ctx.beginPath(); ctx.arc(pos.x, pos.y, size, 0, 2 * Math.PI); ctx.fillStyle = bombColor; ctx.fill(); + + ctx.lineWidth = 2; + ctx.strokeStyle = "black"; + ctx.stroke(); + + ctx.font = size * 1.2 + "px Arial"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillStyle = "white"; + ctx.fillText("C4", pos.x, pos.y); + ctx.closePath(); if (planted && ((new Date().getTime() / 1000) % 1) > 0.5) { ctx.strokeStyle = enemyColor - ctx.lineWidth = 1; - ctx.stroke() + ctx.lineWidth = 3; + ctx.beginPath(); + ctx.arc(pos.x, pos.y, size + 4, 0, 2 * Math.PI); + ctx.stroke(); } } @@ -514,14 +559,6 @@ function drawEntity(pos, fillStyle, dormant, hasBomb, yaw, hasAwp, playerType, i ctx.fill(); } - if (hasBomb) { - ctx.beginPath(); - ctx.arc(pos.x, pos.y, circleRadius / 2, 0, 2 * Math.PI); - ctx.fillStyle = bombColor; - ctx.fill(); - } - - ctx.closePath(); // Calculate arrowhead points