local function pointToDist3D(x1, y1, z1, x2, y2, z2) return R_PointToDist2(0, z1 / FU, R_PointToDist2(x1 / FU, y1 / FU, x2 / FU, y2 / FU), z2 / FU) end local function getNearestTargetDistance(p) local bestDist = INT32_MAX local x1, y1, z1 = p.mo.x, p.mo.y, p.mo.z for t in players.iterate do local tmo = t.mo if tmo and tmo.health > 0 and not (t.pflags & PF_TAGIT) then local dist = pointToDist3D(x1, y1, z1, tmo.x, tmo.y, tmo.z) bestDist = min(bestDist, dist) end end if bestDist < INT32_MAX then return bestDist else return nil end end hud.add(function(v, p) if not (G_TagGametype() and p.mo and (p.pflags & PF_TAGIT)) then return end local dist = getNearestTargetDistance(p) local s = "NO TARGET" local color = V_GRAYMAP if dist ~= nil then dist = dist / 64 s = dist .. "m" local blinkSpeed = max(dist / 10, TICRATE / 8) color = (leveltime / blinkSpeed % 2) and V_REDMAP or 0 end local w = v.stringWidth(s, V_ALLOWLOWERCASE) v.drawString(160 - w / 2, 168, s, V_ALLOWLOWERCASE | V_SNAPTOBOTTOM | color) end, "game")