Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/usage.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ setdesc "crosshairsize" "size of crosshair (in terms of screen size)" "value"
setdesc "crosshairhitspeed" "duration for hit crosshair to show following a hit on an opponent (milliseconds)" "value"
setdesc "crosshairblend" "determines crosshair opacity (0 = transparent 1 = opaque)" "value"
setdesc "crosshairaccamt" "determines blend by accuracy level intensity (when blend by accuracy is enabled)" "value"
setdesc "crosshairflash" "determines whether the crosshair flashes when at critical health (less than the heal amount)" "value"
setdesc "crosshairhealth" "determines whether to color the crosshair depending on the current health" "value"
setdesc "crosshairthrob" "determines scale of crosshair throb (size change) effect (like while gaining health)" "value"
setdesc "crosshairtex" "determines path to crosshair image file" "file"
setdesc "showfps" "display the frames per second counter on the hud;^n0 = no display^n1 = display average fps^n2 = display average fps and best and worst difference^n3 = display average fps and fps range^n4 = display average fps and average/worst frametimes" "value"
Expand Down
35 changes: 31 additions & 4 deletions src/game/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,11 +1174,38 @@ namespace hud
else if(crosshairweapons&2) c = vec::fromcolor(W(game::focus->weapselect, colour));
else if(crosshairtone) skewcolour(c.r, c.g, c.b, crosshairtone);
int heal = game::focus->gethealth(game::gamemode, game::mutators);
if(crosshairflash && game::focus->state == CS_ALIVE && game::focus->health < heal)
if(crosshairflash && game::focus->state == CS_ALIVE)
{
int millis = lastmillis%1000;
float amt = (millis <= 500 ? millis/500.f : 1.f-((millis-500)/500.f))*clamp(float(heal-game::focus->health)/float(heal), 0.f, 1.f);
flashcolour(c.r, c.g, c.b, 1.f, 0.f, 0.f, amt);
const float ratio = clamp(float(game::focus->health)/float(heal), 0.0f, 2.0f);

if(ratio < 0.2f)
{
// Red (critical health level)
c.r = 1.0f;
c.g = 0.0f;
c.b = 0.0f;
}
else if(ratio < 0.6f)
{
// Red-yellow
c.r = 1.0f;
c.g = (ratio-0.2f)/0.4f;
c.b = 0.0f;
}
else if(ratio < 1.0f)
{
// Yellow-white
c.r = 1.0f;
c.g = 1.0f;
c.b = (ratio-0.6f)/0.4f;
}
else
{
// Green (overheal)
c.r = 2.0f - ratio;
c.g = 1.0f;
c.b = 2.0f - ratio;
}
}
if(crosshairthrob > 0 && regentime && game::focus->lastregen && lastmillis-game::focus->lastregen <= regentime)
{
Expand Down