Port blood effect from Xonotic code. When your health is under a certain amount,...
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 25 Feb 2011 20:50:52 +0000 (22:50 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 25 Feb 2011 20:50:52 +0000 (22:50 +0200)
data/defaultVoretournament.cfg
data/qcsrc/client/Defs.qc
data/qcsrc/client/View.qc

index 0c88250b4a84c91e154d3593100358628afaff03..f1202cc420f78be21dc9ca8d7ec1cc5e12c2f616 100644 (file)
@@ -1059,6 +1059,19 @@ con_chatwidth 0.6
 con_notifysize 10\r
 con_notifyalign 0\r
 \r
+seta hud_damage 0.55 "an improved version of gl_polyblend for damage, draw an image instead when hurt"\r
+seta hud_damage_gentle_alpha_multiplier 0.10 "how much to multiply alpha of flash when using the cl_gentle version, it's much more opaque than the non-gentle version"\r
+seta hud_damage_gentle_color "1 0.7 1" "color of flash for cl_gentle version"\r
+seta hud_damage_color "1 0 0" "color of flash"\r
+seta hud_damage_factor 0.025 "(damage * factor) = how much to add to the alpha value"\r
+seta hud_damage_fade_rate 0.75 "how much to subtract from the alpha value each second"\r
+seta hud_damage_maxalpha 1.5 "how much to limit the alpha value to"\r
+seta hud_damage_pain_threshold 0.1 "how much alpha to ignore (must be bigger than the hud_damage_factor so that e.g. rot is ignored)"\r
+seta hud_damage_pain_threshold_lower 1.25 "how much we lower pain_threshold with when nearing 0 health (if pain_threshold gets negative then we always draw a flash at alpha = fabs(pain_threshold)"\r
+seta hud_damage_pain_threshold_lower_health 50 "at which health we start lowering pain_threshold"\r
+seta hud_damage_pain_threshold_pulsating_min 0.6 "minimum value when calculating the pulse: max(pulsating_min, fabs(sin(PI * time / period))"\r
+seta hud_damage_pain_threshold_pulsating_period 0.8 "one pulse every X seconds"\r
+\r
 seta hud_contents 1 "an improved version of gl_polyblend for liquids such as water/lava/slime, draw a filler when inside the liquid"\r
 seta hud_contents_factor 1 "factor at which to multiply the current faded value."\r
 seta hud_contents_fadeintime 0.02 "factor of time it takes for the alpha level to reach normal value when entering the liquid"\r
index 92cd3b00e7c2fb38835277ef9dd349f320702574..1f2edf68bbee691a43b3c1779309a657fc2de0d4 100644 (file)
@@ -156,7 +156,7 @@ float               sb_showaccuracy;
 // float               coop;\r
 // float               deathmatch;\r
 \r
-// float               dmg_take;\r
+float          dmg_take;\r
 // float               dmg_save;\r
 // vector              dmg_origin;\r
 \r
index 37090311ca38342258b94c9451e20733d5f00eb9..07321ed6228c6922a20e1309ce94d50228a84b69 100644 (file)
@@ -253,7 +253,9 @@ float camera_mode;
 float chase_active_old;\r
 float artwork_fade;\r
 float pickup_crosshair_time, pickup_crosshair_size;\r
+float myhealth, myhealth_prev, myhealth_flash;\r
 float contentavgalpha, liquidalpha_prev;\r
+vector myhealth_gentlergb;\r
 vector liquidcolor_prev;\r
 string artwork_image;\r
 string intermission_song;\r
@@ -501,6 +503,67 @@ void CSQC_UpdateView(float w, float h)
                        drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL);\r
        }\r
 \r
+       if(cvar("hud_damage"))\r
+       {\r
+               float myhealth_flash_temp;\r
+               myhealth = getstati(STAT_HEALTH);\r
+\r
+               // fade out\r
+               myhealth_flash = max(0, myhealth_flash - cvar("hud_damage_fade_rate") * frametime);\r
+               // add new damage\r
+               myhealth_flash = bound(0, myhealth_flash + dmg_take * cvar("hud_damage_factor"), cvar("hud_damage_maxalpha"));\r
+\r
+               float pain_threshold, pain_threshold_lower, pain_threshold_lower_health;\r
+               pain_threshold = cvar("hud_damage_pain_threshold");\r
+               pain_threshold_lower = cvar("hud_damage_pain_threshold_lower");\r
+               pain_threshold_lower_health = cvar("hud_damage_pain_threshold_lower_health");\r
+\r
+               if(pain_threshold_lower && myhealth < pain_threshold_lower_health)\r
+               {\r
+                       pain_threshold = pain_threshold - max(cvar("hud_damage_pain_threshold_pulsating_min"), fabs(sin(M_PI * time / cvar("hud_damage_pain_threshold_pulsating_period")))) * pain_threshold_lower * (1 - max(0, myhealth)/pain_threshold_lower_health);\r
+               }\r
+\r
+               myhealth_flash_temp = bound(0, myhealth_flash - pain_threshold, 1);\r
+\r
+               if(myhealth_prev < 1)\r
+               {\r
+                       if(myhealth >= 1)\r
+                       {\r
+                               myhealth_flash = 0; // just spawned, clear the flash immediately\r
+                               myhealth_flash_temp = 0;\r
+                       }\r
+                       else\r
+                       {\r
+                               myhealth_flash += cvar("hud_damage_fade_rate") * frametime; // dead\r
+                       }\r
+               }\r
+\r
+               if(spectatee_status == -1 || intermission)\r
+               {\r
+                       myhealth_flash = 0; // observing, or match ended\r
+                       myhealth_flash_temp = 0;\r
+               }\r
+\r
+               myhealth_prev = myhealth;\r
+\r
+               if(cvar("cl_gentle_damage") || cvar("cl_gentle"))\r
+               {\r
+                       if(cvar("cl_gentle_damage") == 2)\r
+                       {\r
+                               if(myhealth_flash < pain_threshold) // only randomize when the flash is gone\r
+                               {\r
+                                       myhealth_gentlergb = '1 0 0' * random() + '0 1 0' * random() + '0 0 1' * random();\r
+                               }\r
+                       }\r
+                       else\r
+                               myhealth_gentlergb = stov(cvar_string("hud_damage_gentle_color"));\r
+\r
+                       drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, myhealth_gentlergb, cvar("hud_damage_gentle_alpha_multiplier") * bound(0, myhealth_flash_temp, 1) * cvar("hud_damage"), DRAWFLAG_NORMAL);\r
+               }\r
+               else\r
+                       drawpic('0 0 0', "gfx/blood", '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, stov(cvar_string("hud_damage_color")), bound(0, myhealth_flash_temp, 1) * cvar("hud_damage"), DRAWFLAG_NORMAL);\r
+       }\r
+\r
        // Draw the mouse cursor\r
        // NOTE: drawpic must happen after R_RenderScene for some reason\r
        //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);\r