From 36191a88e0734f2d9ca423d1ef4b91501301ae7c Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 28 Dec 2021 19:45:42 +0100 Subject: [PATCH] Improve the crosshair color health algorithm Instead of only having 3 states (red/orange/white), this changes the crosshair color smoothly depending on health remaining. The colors used at <= 25 and 50 HP remain identical to what they were before. --- source/src/renderhud.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index e9bdbd55ae..a5a94fac0e 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -229,8 +229,11 @@ void drawcrosshair(playerent *p, int n, color *c, float size) if(n==CROSSHAIR_TEAMMATE) glColor3ub(255, 0, 0); else if(!m_osok) { - if(p->health<=25) glColor3ub(255,0,0); - else if(p->health<=50) glColor3ub(255,128,0); + // color crosshair depending on health + if(p->health<=25) glColor3ub(255, 0, 0); + else if(p->health<=75) glColor3ub(255, (p->health-25)/50.0f * 255, 0); + else if(p->health<=99) glColor3ub(255, 255, (p->health-75)/25.0f * 255); + else glColor3ub(255, 255, 255); } } float s = size>0 ? size : (float)crosshairsize;