]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Port blood effect from Xonotic code. When your health is under a certain amount,...
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index 203907d88e7d68b0df231b71ec7d83e9855fece6..07321ed6228c6922a20e1309ce94d50228a84b69 100644 (file)
@@ -251,6 +251,14 @@ float Sbar_WouldDrawScoreboard ();
 float view_set;\r
 float camera_mode;\r
 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
 string NextFrameCommand;\r
 void CSQC_UpdateView(float w, float h)\r
 {\r
@@ -259,6 +267,8 @@ void CSQC_UpdateView(float w, float h)
        float f, i, j;\r
        vector v, vo;\r
 \r
+       vector artwork_pos, artwork_size;\r
+\r
        WaypointSprite_Load();\r
 \r
        if(spectatee_status)\r
@@ -321,11 +331,13 @@ void CSQC_UpdateView(float w, float h)
        if(!postinit)\r
                PostInit();\r
 \r
-       if(intermission && !isdemo() && !(calledgrabbers & GRABBER_END))\r
-               if(calledgrabbers & GRABBER_START)\r
+       if(intermission && !isdemo() && !(calledhooks & HOOK_END))\r
+               if(calledhooks & HOOK_START)\r
                {\r
                        localcmd("\ncl_hook_gameend;");\r
-                       calledgrabbers |= GRABBER_END;\r
+                       if(g_campaign)\r
+                               localcmd("\ncl_hook_campaign_gameend;");\r
+                       calledhooks |= HOOK_END;\r
                }\r
 \r
        CheckForGamestartChange();\r
@@ -443,6 +455,115 @@ void CSQC_UpdateView(float w, float h)
        // next R_RenderScene call\r
        drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);\r
 \r
+       if(cvar("hud_contents"))\r
+       {\r
+               float contentalpha_temp, incontent, liquidalpha, contentfadetime;\r
+               vector liquidcolor;\r
+               \r
+               switch(pointcontents(view_origin))\r
+               {\r
+                       case CONTENT_WATER:\r
+                               liquidalpha = cvar("hud_contents_water_alpha");\r
+                               liquidcolor = stov(cvar_string("hud_contents_water_color"));\r
+                               incontent = 1;\r
+                               break;\r
+                               \r
+                       case CONTENT_LAVA:\r
+                               liquidalpha = cvar("hud_contents_lava_alpha");\r
+                               liquidcolor = stov(cvar_string("hud_contents_lava_color"));\r
+                               incontent = 1;\r
+                               break;  \r
+                                                       \r
+                       case CONTENT_SLIME:\r
+                               liquidalpha = cvar("hud_contents_slime_alpha");\r
+                               liquidcolor = stov(cvar_string("hud_contents_slime_color"));\r
+                               incontent = 1;\r
+                               break;\r
+                               \r
+                       default:\r
+                               liquidalpha = 0;\r
+                               liquidcolor = '0 0 0';\r
+                               incontent = 0;\r
+                               break;\r
+               }\r
+               \r
+               if(incontent) // fade in/out at different speeds so you can do e.g. instant fade when entering water and slow when leaving it.\r
+               { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content\r
+                       contentfadetime = cvar("hud_contents_fadeintime");\r
+                       liquidalpha_prev = liquidalpha;\r
+                       liquidcolor_prev = liquidcolor;\r
+               }\r
+               else\r
+                       contentfadetime = cvar("hud_contents_fadeouttime");\r
+                       \r
+               contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);\r
+               contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;\r
+               \r
+               if(contentavgalpha)\r
+                       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
@@ -484,6 +605,84 @@ void CSQC_UpdateView(float w, float h)
          )\r
                teamradar_view();\r
 \r
+       // Draw artwork and play intermission music\r
+       if(intermission && !isdemo() && gametype != GAME_RPG && !spectatee_status) // the match has ended. Don't do this for RPG because no one wins or loses there\r
+       {\r
+               if(cvar("cl_artwork"))\r
+               {\r
+                       if(artwork_image == "")\r
+                       {\r
+                               if(getstati(STAT_WINNING)) // we are the winner\r
+                               {\r
+                                       if(cvar("cl_artwork_win"))\r
+                                       {\r
+                                               artwork_image = strcat("gfx/artwork_won_", ftos(floor(1 + (random() * cvar("cl_artwork_win")))));\r
+                                               artwork_image = strzone(artwork_image);\r
+                                       }\r
+                               }\r
+                               else // we have lost\r
+                               {\r
+                                       if(cvar("cl_artwork_lose"))\r
+                                       {\r
+                                               artwork_image = strcat("gfx/artwork_lost_", ftos(floor(1 + (random() * cvar("cl_artwork_lose")))));\r
+                                               artwork_image = strzone(artwork_image);\r
+                                       }\r
+                               }\r
+                       }\r
+\r
+                       if(cvar("cl_artwork_stretch"))\r
+                       {\r
+                               artwork_size_x = vid_conwidth;\r
+                               artwork_size_y = vid_conheight;\r
+                               artwork_pos_x = 0;\r
+                               artwork_pos_y = 0;\r
+                       }\r
+                       else\r
+                       {\r
+                               artwork_size_x = max(vid_conwidth, vid_conheight);\r
+                               artwork_size_y = max(vid_conwidth, vid_conheight);\r
+                               artwork_pos_x = (vid_conwidth - artwork_size_x) / 2;\r
+                               artwork_pos_y = (vid_conheight - artwork_size_y) / 2;\r
+                       }\r
+\r
+                       if(artwork_fade < cvar("cl_artwork_alpha") && cvar("cl_artwork_fade"))\r
+                               artwork_fade += frametime * cvar("cl_artwork_fade");\r
+                       else\r
+                               artwork_fade = cvar("cl_artwork_alpha");\r
+\r
+                       if(artwork_image != "")\r
+                               drawpic(artwork_pos, artwork_image, artwork_size, '1 1 1', artwork_fade, DRAWFLAG_NORMAL);\r
+               }\r
+\r
+               if(cvar("cl_intermission") && intermission_song == "") // don't start the song each frame\r
+               {\r
+                       if(getstati(STAT_WINNING))\r
+                               intermission_song = cvar_string("cl_intermission_cdtrack_win");\r
+                       else\r
+                               intermission_song = cvar_string("cl_intermission_cdtrack_lose");\r
+                       if(intermission_song != "")\r
+                       {\r
+                               localcmd(strcat("\ncd play ", intermission_song, "\n"));\r
+                               intermission_song = strzone(intermission_song);\r
+                       }\r
+               }\r
+       }\r
+       else\r
+       {\r
+               artwork_fade = 0;\r
+               if(artwork_image != "")\r
+               {\r
+                       strunzone(artwork_image);\r
+                       artwork_image = "";\r
+               }\r
+\r
+               if(intermission_song != "")\r
+               {\r
+                       strunzone(intermission_song);\r
+                       intermission_song = "";\r
+               }\r
+       }\r
+\r
        // draw sbar\r
        if(cvar("r_letterbox") == 0) {\r
                if (cvar("cl_showpressedkeys")) { // draw pressed keys when spectating and playing\r
@@ -506,7 +705,7 @@ void CSQC_UpdateView(float w, float h)
                if(cvar("viewsize") < 120)\r
                        CSQC_common_hud();\r
 \r
-       if not(getstati(STAT_STOMACH_EATEN)) // crosshair is useless if we're in the stomach\r
+       if not(getstati(STAT_VORE_EATEN)) // crosshair is useless if we're in the stomach\r
        {\r
                // crosshair goes VERY LAST\r
                if(!scoreboard_active && !ons_showmap && !camera_active) {\r
@@ -560,6 +759,22 @@ void CSQC_UpdateView(float w, float h)
                                        wcross_scale = 1;\r
                                }\r
 \r
+                               if(cvar("crosshair_pickup"))\r
+                               {\r
+                                       if(pickup_crosshair_time < getstatf(STAT_LAST_PICKUP))\r
+                                       {\r
+                                               pickup_crosshair_size = 1;\r
+                                               pickup_crosshair_time = getstatf(STAT_LAST_PICKUP);\r
+                                       }\r
+\r
+                                       if(pickup_crosshair_size > 0)\r
+                                               pickup_crosshair_size -= cvar("crosshair_pickup_speed") * frametime;\r
+                                       else\r
+                                               pickup_crosshair_size = 0;\r
+\r
+                                       wcross_scale += sin(pickup_crosshair_size) * cvar("crosshair_pickup");\r
+                               }\r
+\r
                                if(shottype == SHOTTYPE_HITENEMY)\r
                                        wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0\r
                                if(shottype == SHOTTYPE_HITTEAM)\r