From e2e6da47efc68ff37c680ae991d0756fd464fbeb Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 15:38:39 +0100 Subject: ESP: vertical health bar right of the box, HP number beside it --- src/esp.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/esp.cpp') diff --git a/src/esp.cpp b/src/esp.cpp index d12c718..3914342 100644 --- a/src/esp.cpp +++ b/src/esp.cpp @@ -284,23 +284,30 @@ void esp_draw() { else if (t.neutral) surf_color(220, 220, 220, 255); else surf_color(255, 60, 60, 255); float w = t.h * 0.45f; // ponytail: constant aspect, no OBB width - surf_rect(0, (int)(t.sx - w / 2), (int)(t.sy - t.h), (int)(t.sx + w / 2), (int)t.sy); + int left = (int)(t.sx - w / 2); + int right = (int)(t.sx + w / 2); + int top = (int)(t.sy - t.h); + int bot = (int)t.sy; + surf_rect(0, left, top, right, bot); if (t.show_health) { float frac = t.health / (t.maxhealth > 1.0f ? t.maxhealth : 100.0f); if (frac > 1) frac = 1; + if (frac < 0) frac = 0; + // vertical bar just right of the box, HP number beside it + int bx0 = right + 2, bx1 = right + 5; surf_color(0, 0, 0, 200); - surf_rect(1, (int)(t.sx - w / 2), (int)t.sy + 1, (int)(t.sx + w / 2), (int)t.sy + 4); + surf_rect(1, bx0, top, bx1, bot); + int fill_top = bot - (int)((float)(bot - top) * frac); + if (fill_top < top) fill_top = top; if (frac > 0.5f) surf_color(40, 255, 40, 255); else if (frac > 0.25f) surf_color(255, 255, 0, 255); else surf_color(255, 40, 40, 255); - surf_rect(1, (int)(t.sx - w / 2), (int)t.sy + 2, - (int)(t.sx - w / 2 + w * frac), (int)t.sy + 3); + if (fill_top < bot) + surf_rect(1, bx0, fill_top, bx1, bot); + char hptext[16]; + snprintf(hptext, sizeof(hptext), "%d", (int)t.health); + draw_text_col(bx1 + 3, top, hptext, 255, 255, 255); } - char label[64]; - if (t.show_health) - snprintf(label, sizeof(label), "%s %d", t.name, (int)t.health); - else - snprintf(label, sizeof(label), "%s", t.name); - draw_text_col((int)(t.sx - w / 2), (int)(t.sy - t.h) - 14, label, 255, 255, 255); + draw_text_col(left, top - 14, t.name, 255, 255, 255); } } -- cgit v1.2.3