]> git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Use setproperty instead of R_SetView
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index 113d8c5423b290f4ca6ed6fd447cac7c92599481..3e48e2d36fc871205507a80f4a954362b5860732 100644 (file)
@@ -244,7 +244,6 @@ void PostInit(void);
 void CSQC_Demo_Camera();\r
 float Sbar_WouldDrawScoreboard ();\r
 float last_health, last_spectatee;\r
-float view_set;\r
 float camera_mode;\r
 float reticle_type;\r
 float chase_active_old;\r
@@ -255,10 +254,9 @@ float myhealth, myhealth_prev, myhealth_flash;
 float contentavgalpha, liquidalpha_prev;\r
 float old_blurradius, old_bluralpha, old_cartoon_intensity;\r
 float stomachsplash_alpha;\r
-float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2;\r
-float volume_modify_changed_1, volume_modify_changed_2;\r
 float eventchase_current_distance;\r
 float helper_pause, helper_health, helper_armor, helper_ammo, helper_speed, helper_stomachload;\r
+vector freeze_org, freeze_ang;\r
 vector myhealth_gentlergb;\r
 vector liquidcolor_prev;\r
 vector damage_blurpostprocess, content_blurpostprocess;\r
@@ -309,6 +307,7 @@ void CSQC_UpdateView(float w, float h)
                        helper_health = TRUE;\r
                        helper_armor = TRUE;\r
                        helper_ammo = TRUE;\r
+                       helper_stomachload = TRUE;\r
                }\r
                else if(helper_pause <= time)\r
                {\r
@@ -383,10 +382,13 @@ void CSQC_UpdateView(float w, float h)
        // event chase camera\r
        if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped\r
        {\r
-               if(!getstati(STAT_VORE_EATEN) && spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission))\r
+               if(spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission && !getstati(STAT_VORE_EATEN)) || intermission)\r
                {\r
+                       // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)\r
+                       vector current_view_origin = getpropertyvec(VF_ORIGIN);\r
+                       \r
                        // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing).\r
-                       // Ideally, there should be another way to enable third person cameras, such as through R_SetView()\r
+                       // Ideally, there should be another way to enable third person cameras, such as through setproperty()\r
                        if(!cvar("chase_active"))\r
                                cvar_set("chase_active", "-1"); // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1)\r
 \r
@@ -399,15 +401,15 @@ void CSQC_UpdateView(float w, float h)
                        vector eventchase_target_origin;\r
                        makevectors(view_angles);\r
                        // pass 1, used to check where the camera would go and obtain the trace_fraction\r
-                       eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance;\r
-\r
-                       traceline(pmove_org, eventchase_target_origin, MOVE_WORLDONLY, self);\r
+                       eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance;\r
+                       WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);\r
                        // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls\r
                        // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through\r
-                       eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1);\r
+                       eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance * (trace_fraction - 0.1);\r
+                       WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);\r
 \r
-                       R_SetView(VF_ORIGIN, eventchase_target_origin);\r
-                       R_SetView(VF_ANGLES, view_angles);\r
+                       setproperty(VF_ORIGIN, trace_endpos);\r
+                       setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles));\r
                }\r
                else if(cvar("chase_active") < 0) // time to disable chase_active if it was set by this code\r
                {\r
@@ -416,13 +418,13 @@ void CSQC_UpdateView(float w, float h)
                }\r
        }\r
 \r
-       float apply_fov;\r
-       if(cvar("cl_healthsize_fov") && frametime)\r
+       if(frametime)\r
        {\r
+               float apply_fov;\r
                apply_fov = cvar("menu_fov");\r
-               if(g_healthsize_center && spectatee_status >= 0)\r
+               if(g_healthsize_center >= 0 && cvar("cl_healthsize_fov") && spectatee_status >= 0)\r
                        apply_fov += (g_healthsize_center - bound(g_healthsize_min, getstati(STAT_HEALTH), g_healthsize_max)) * cvar("cl_healthsize_fov");\r
-               if(cvar("gov") != apply_fov)\r
+               if(cvar("fov") != apply_fov)\r
                        cvar_set("fov", ftos(apply_fov));\r
        }\r
 \r
@@ -446,17 +448,25 @@ void CSQC_UpdateView(float w, float h)
                        cvar_set("v_idlescale", ftos(apply_idlescale));\r
        }\r
 \r
-       // Render the Scene\r
-       if(!intermission || !view_set)\r
+       // do lockview after event chase camera so that it still applies whenever necessary.\r
+       if(intermission > 1)\r
        {\r
-               view_origin = pmove_org + vo;\r
-               view_angles = input_angles;\r
-               makevectors(view_angles);\r
-               view_forward = v_forward;\r
-               view_right = v_right;\r
-               view_up = v_up;\r
-               view_set = 1;\r
+               setproperty(VF_ORIGIN, freeze_org);\r
+               setproperty(VF_ANGLES, freeze_ang);\r
        }\r
+       else\r
+       {\r
+               freeze_org = getpropertyvec(VF_ORIGIN);\r
+               freeze_ang = getpropertyvec(VF_ANGLES);\r
+       }\r
+\r
+       // Render the Scene\r
+       view_origin = getpropertyvec(VF_ORIGIN);\r
+       view_angles = getpropertyvec(VF_ANGLES);\r
+       makevectors(view_angles);\r
+       view_forward = v_forward;\r
+       view_right = v_right;\r
+       view_up = v_up;\r
 \r
        vid_width = w;\r
        vid_height = h;\r
@@ -546,9 +556,15 @@ void CSQC_UpdateView(float w, float h)
        // ALWAYS Clear Current Scene First\r
        R_ClearScene();\r
 \r
+       if(checkextension("DP_CSQC_ROTATEMOVES"))\r
+       {\r
+               setproperty(VF_ORIGIN, view_origin);\r
+               setproperty(VF_ANGLES, view_angles);\r
+       }\r
+\r
        // Assign Standard Viewflags\r
        // Draw the World (and sky)\r
-       R_SetView(VF_DRAWWORLD, 1);\r
+       setproperty(VF_DRAWWORLD, 1);\r
 \r
        // Set the console size vars\r
        vid_conwidth = cvar("vid_conwidth");\r
@@ -576,7 +592,7 @@ void CSQC_UpdateView(float w, float h)
                        power_boot = time;\r
        }\r
 \r
-       R_SetView(VF_FOV, GetCurrentFov(fov));\r
+       setproperty(VF_FOV, GetCurrentFov(fov));\r
 \r
        // Camera for demo playback\r
        if(camera_active)\r
@@ -607,10 +623,10 @@ void CSQC_UpdateView(float w, float h)
        // Draw the Crosshair\r
        float scoreboard_active;\r
        scoreboard_active = Sbar_WouldDrawScoreboard();\r
-       R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden\r
+       setproperty(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden\r
 \r
        // Draw the Engine Status Bar (the default Quake HUD)\r
-       R_SetView(VF_DRAWENGINESBAR, 0);\r
+       setproperty(VF_DRAWENGINESBAR, 0);\r
 \r
        // fetch this one only once per frame\r
        sbar_showbinds = cvar("sbar_showbinds");\r
@@ -961,63 +977,32 @@ void CSQC_UpdateView(float w, float h)
                        cvar_set("r_glsl_saturation", "1");\r
        }\r
 \r
-       // volume cutting\r
-       if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1 && frametime)\r
+       float target_volume;\r
+       if(cvar("cl_vore_cutvolume_sound") && frametime)\r
        {\r
-               float volume_modify_1_target, volume_modify_2_target, volume_modify_fade;\r
-\r
-               if(volume_modify_changed_1 != cvar("menu_volume") || volume_modify_changed_2 != cvar("menu_bgmvolume"))\r
-               {\r
-                       // An ugly hack to allow the cutvolume feature to work with the menu audio sliders.\r
-                       // Without it, adjusting the music or master sound sliders while fading that volume would have bad results.\r
-                       // This needs to be done in a better way! Currently, changing the volume sliders will just reset the fading.\r
-\r
-                       volume_modify_default_1 = cvar("menu_volume");\r
-                       volume_modify_default_2 = cvar("menu_bgmvolume");\r
-\r
-                       volume_modify_changed_1 = cvar("menu_volume");\r
-                       volume_modify_changed_2 = cvar("menu_bgmvolume");\r
-               }\r
-               else\r
-               {\r
-                       if(spectatee_status == -1 || intermission)\r
-                       {\r
-                               volume_modify_1_target = volume_modify_default_1;\r
-                               volume_modify_2_target = volume_modify_default_2;\r
-                       }\r
-                       else if(getstati(STAT_VORE_EATEN))\r
-                       {\r
-                               volume_modify_1_target = volume_modify_default_1 * cvar("cl_vore_cutvolume_sound");\r
-                               volume_modify_2_target = volume_modify_default_2 * cvar("cl_vore_cutvolume_music");\r
-                       }\r
-                       else\r
-                       {\r
-                               volume_modify_1_target = volume_modify_default_1;\r
-                               volume_modify_2_target = volume_modify_default_2;\r
-                       }\r
-                       volume_modify_fade = cvar("cl_vore_cutvolume_fade") * frametime;\r
-\r
-                       if(volume_modify_1 != volume_modify_1_target || volume_modify_2 != volume_modify_2_target)\r
-                       {\r
-                               if (volume_modify_1 > volume_modify_1_target + volume_modify_fade)\r
-                                       volume_modify_1 -= volume_modify_fade;\r
-                               else if (volume_modify_1 < volume_modify_1_target - volume_modify_fade)\r
-                                       volume_modify_1 += volume_modify_fade;\r
-                               else\r
-                                       volume_modify_1 = volume_modify_1_target;\r
-\r
-                               if (volume_modify_2 > volume_modify_2_target + volume_modify_fade)\r
-                                       volume_modify_2 -= volume_modify_fade;\r
-                               else if (volume_modify_2 < volume_modify_2_target - volume_modify_fade)\r
-                                       volume_modify_2 += volume_modify_fade;\r
-                               else\r
-                                       volume_modify_2 = volume_modify_2_target;\r
-\r
-                               cvar_set("volume", ftos(volume_modify_1));\r
-                               cvar_set("bgmvolume", ftos(volume_modify_2));\r
-                               // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way\r
-                       }\r
-               }\r
+               // sound volume cutting\r
+               target_volume = 0;\r
+               if(getstatf(STAT_VORE_PROGRESS_PREY))\r
+                       target_volume = getstatf(STAT_VORE_PROGRESS_PREY);\r
+               else if(getstati(STAT_VORE_EATEN))\r
+                       target_volume = 1;\r
+               target_volume = cvar("menu_volume") * (1 - target_volume * cvar("cl_vore_cutvolume_sound"));\r
+\r
+               if(cvar("volume") != target_volume) // reduce cvar_set spam as much as possible\r
+                       cvar_set("volume", ftos(target_volume));\r
+       }\r
+       if(cvar("cl_vore_cutvolume_music") && frametime)\r
+       {\r
+               // music volume cutting\r
+               target_volume = 0;\r
+               if(getstatf(STAT_VORE_PROGRESS_PREY))\r
+                       target_volume = getstatf(STAT_VORE_PROGRESS_PREY);\r
+               else if(getstati(STAT_VORE_EATEN))\r
+                       target_volume = 1;\r
+               target_volume = cvar("menu_bgmvolume") * (1 - target_volume * cvar("cl_vore_cutvolume_music"));\r
+\r
+               if(cvar("bgmvolume") != target_volume) // reduce cvar_set spam as much as possible\r
+                       cvar_set("bgmvolume", ftos(target_volume));\r
        }\r
 \r
        // Draw the mouse cursor\r
@@ -1482,11 +1467,11 @@ void CSQC_UpdateView(float w, float h)
                string w0, h0;\r
                w0 = cvar_string("vid_conwidth");\r
                h0 = cvar_string("vid_conheight");\r
-               //R_SetView(VF_VIEWPORT, '0 0 0', '640 480 0');\r
-               //R_SetView(VF_FOV, '90 90 0');\r
-               R_SetView(VF_ORIGIN, '0 0 0');\r
-               R_SetView(VF_ANGLES, '0 0 0');\r
-               R_SetView(VF_PERSPECTIVE, 1);\r
+               //setproperty(VF_VIEWPORT, '0 0 0', '640 480 0');\r
+               //setproperty(VF_FOV, '90 90 0');\r
+               setproperty(VF_ORIGIN, '0 0 0');\r
+               setproperty(VF_ANGLES, '0 0 0');\r
+               setproperty(VF_PERSPECTIVE, 1);\r
                makevectors('0 0 0');\r
                vector v1, v2;\r
                cvar_set("vid_conwidth", "800");\r
@@ -1680,6 +1665,6 @@ void CSQC_Demo_Camera()
                current_position = current_origin + current_camera_offset;\r
        }\r
 \r
-       R_SetView(VF_ANGLES, current_angles);\r
-       R_SetView(VF_ORIGIN, current_position);\r
+       setproperty(VF_ANGLES, current_angles);\r
+       setproperty(VF_ORIGIN, current_position);\r
 }\r