From d7c241c7df7e07fc68ecfab82bf7c4ed17e720ea Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Tue, 1 Mar 2011 00:55:43 +0200 Subject: [PATCH] Crosshair coloring by health, moar Xonotic code --- data/defaultVoretournament.cfg | 1 + data/qcsrc/client/View.qc | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/data/defaultVoretournament.cfg b/data/defaultVoretournament.cfg index c40476e3..e1ff01e5 100644 --- a/data/defaultVoretournament.cfg +++ b/data/defaultVoretournament.cfg @@ -109,6 +109,7 @@ _cl_playermodel models/player/vixen.zym _cl_playerskin 0 crosshair 1 seta crosshair_pickup 1 "crosshair grows then shrinks back when picking up an item" +seta crosshair_color_by_health 0 "if enabled, crosshair color will depend on current health" seta crosshair_pickup_speed 4 "speed of the crosshair pickup effect" seta crosshair_ring_alpha 0.5 "alpha of the crosshair ammo ring" seta crosshair_ring_size 3 "size of the crosshair ammo ring" diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 9a1b97ab..4d445a35 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -998,6 +998,50 @@ void CSQC_UpdateView(float w, float h) wcross_color_y = cvar("crosshair_swallowindicator_color_green"); wcross_color_z = cvar("crosshair_swallowindicator_color_blue"); } + else if(cvar("crosshair_color_by_health")) + { + local float x = getstati(STAT_HEALTH); + + //x = red + //y = green + //z = blue + + wcross_color_z = 0; + + if(x > 200) + { + wcross_color_x = 0; + wcross_color_y = 1; + } + else if(x > 150) + { + wcross_color_x = 0.4 - (x-150)*0.02 * 0.4; + wcross_color_y = 0.9 + (x-150)*0.02 * 0.1; + } + else if(x > 100) + { + wcross_color_x = 1 - (x-100)*0.02 * 0.6; + wcross_color_y = 1 - (x-100)*0.02 * 0.1; + wcross_color_z = 1 - (x-100)*0.02; + } + else if(x > 50) + { + wcross_color_x = 1; + wcross_color_y = 1; + wcross_color_z = 0.2 + (x-50)*0.02 * 0.8; + } + else if(x > 20) + { + wcross_color_x = 1; + wcross_color_y = (x-20)*90/27/100; + wcross_color_z = (x-20)*90/27/100 * 0.2; + } + else + { + wcross_color_x = 1; + wcross_color_y = 0; + } + } else { wcross_color_x = cvar("crosshair_color_red"); -- 2.39.2