]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index 04107188696d4c1c1f8879caafa5c80cb9e4b383..6648b7ecbf557922991c0e7373caebefc3eef5b9 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <common/vehicles/all.qh>
 #include <common/weapons/_all.qh>
+#include <common/mutators/mutator/overkill/okvortex.qh>
 #include <common/viewloc.qh>
 #include <common/minigames/cl_minigames.qh>
 #include <common/minigames/cl_minigames_hud.qh>
@@ -326,7 +327,7 @@ void viewmodel_draw(entity this)
                        this.viewmodel_angles = this.angles;
                }
                anim_update(this);
-               if (!this.animstate_override && !this.animstate_looping)
+               if ((!this.animstate_override && !this.animstate_looping) || time > this.animstate_endtime)
                        anim_set(this, this.anim_idle, true, false, false);
        }
        float f = 0; // 0..1; 0: fully active
@@ -356,6 +357,7 @@ void viewmodel_draw(entity this)
        this.angles = this.viewmodel_angles;
        this.angles_x = (-90 * f * f);
        viewmodel_animate(this);
+       MUTATOR_CALLHOOK(DrawViewModel, this);
        setorigin(this, this.origin);
 }
 
@@ -466,7 +468,7 @@ vector GetCurrentFov(float fov)
                {
                        entity wepent = viewmodels[slot];
                        if(wepent.switchweapon == wepent.activeweapon)
-                       if((wepent.activeweapon == WEP_VORTEX && !WEP_CVAR(vortex, secondary)) || (wepent.activeweapon == WEP_RIFLE && !WEP_CVAR(rifle, secondary))) // do NOT use switchweapon here
+                       if((wepent.activeweapon == WEP_VORTEX && !WEP_CVAR(vortex, secondary)) || (wepent.activeweapon == WEP_RIFLE && !WEP_CVAR(rifle, secondary)) || (wepent.activeweapon == WEP_OVERKILL_VORTEX && !WEP_CVAR(okvortex, secondary))) // do NOT use switchweapon here
                                zoomdir += button_attack2;
                }
        }
@@ -522,7 +524,7 @@ vector GetCurrentFov(float fov)
                current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
 
        if(zoomsensitivity < 1)
-               setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
+               setsensitivityscale(current_viewzoom ** (1 - zoomsensitivity));
        else
                setsensitivityscale(1);
 
@@ -658,6 +660,7 @@ float TrueAimCheck(entity wepent)
                case WEP_MORTAR: // toss curve
                        return SHOTTYPE_HITWORLD;
                case WEP_VORTEX:
+               case WEP_OVERKILL_VORTEX:
                case WEP_VAPORIZER:
                        mv = MOVE_NORMAL;
                        break;
@@ -666,7 +669,7 @@ float TrueAimCheck(entity wepent)
                        mv = MOVE_NORMAL;
                        if(zoomscript_caught)
                        {
-                               tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
+                               tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * max_shot_distance, mv, ta);
                                return EnemyHitCheck();
                        }
                        break;
@@ -692,7 +695,7 @@ float TrueAimCheck(entity wepent)
 
        vecs = decompressShotOrigin(STAT(SHOTORG));
 
-       traceline(traceorigin, traceorigin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
+       traceline(traceorigin, traceorigin + view_forward * max_shot_distance, mv, ta);
        trueaimpoint = trace_endpos;
 
        if(vdist((trueaimpoint - traceorigin), <, g_trueaim_minrange))
@@ -759,7 +762,7 @@ bool WantEventchase(entity this)
 {
        if(autocvar_cl_orthoview)
                return false;
-       if(intermission)
+       if(STAT(GAME_STOPPED) || intermission)
                return true;
        if(this.viewloc)
                return true;
@@ -875,6 +878,14 @@ void HitSound()
                sound(NULL, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
                typehit_time_prev = typehit_time;
        }
+
+       static float kill_time_prev = 0;
+       float kill_time = STAT(KILL_TIME);
+       if (COMPARE_INCREASING(kill_time, kill_time_prev) > autocvar_cl_hitsound_antispam_time)
+       {
+               sound(NULL, CH_INFO, SND_KILL, VOL_BASE, ATTN_NONE);
+               kill_time_prev = kill_time;
+       }
 }
 
 vector crosshair_getcolor(entity this, float health_stat)
@@ -961,7 +972,7 @@ void HUD_Crosshair(entity this)
 {
        float f, i, j;
        vector v;
-       if(!scoreboard_active && !camera_active && intermission != 2 &&
+       if(!scoreboard_active && !camera_active && intermission != 2 && !STAT(GAME_STOPPED) &&
                spectatee_status != -1 && !csqcplayer.viewloc && !MUTATOR_CALLHOOK(DrawCrosshair) &&
                !HUD_MinigameMenu_IsOpened() )
        {
@@ -993,7 +1004,7 @@ void HUD_Crosshair(entity this)
                float shottype;
 
                // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
-               wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
+               wcross_origin = project_3d_to_2d(view_origin + max_shot_distance * view_forward);
                wcross_origin.z = 0;
                if(autocvar_crosshair_hittest)
                {
@@ -1172,6 +1183,10 @@ void HUD_Crosshair(entity this)
                                vortex_charge = STAT(VORTEX_CHARGE);
                                vortex_chargepool = STAT(VORTEX_CHARGEPOOL);
 
+                               float okvortex_charge, okvortex_chargepool;
+                               okvortex_charge = STAT(OVERKILL_VORTEX_CHARGE);
+                               okvortex_chargepool = STAT(OVERKILL_VORTEX_CHARGEPOOL);
+
                                float arc_heat = STAT(ARC_HEAT);
 
                                if(vortex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
@@ -1200,6 +1215,26 @@ void HUD_Crosshair(entity this)
                                        ring_rgb = wcross_color;
                                        ring_image = "gfx/crosshair_ring_nexgun.tga";
                                }
+                               else if (autocvar_crosshair_ring && (wepent.activeweapon == WEP_OVERKILL_VORTEX) && okvortex_charge && autocvar_crosshair_ring_vortex)
+                               {
+                                       if (okvortex_chargepool || use_vortex_chargepool) {
+                                               use_vortex_chargepool = 1;
+                                               ring_inner_value = okvortex_chargepool;
+                                       } else {
+                                               vortex_charge_movingavg = (1 - autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate) * vortex_charge_movingavg + autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate * okvortex_charge;
+                                               ring_inner_value = bound(0, autocvar_crosshair_ring_vortex_currentcharge_scale * (okvortex_charge - vortex_charge_movingavg), 1);
+                                       }
+
+                                       ring_inner_alpha = autocvar_crosshair_ring_vortex_inner_alpha;
+                                       ring_inner_rgb = eX * autocvar_crosshair_ring_vortex_inner_color_red + eY * autocvar_crosshair_ring_vortex_inner_color_green + eZ * autocvar_crosshair_ring_vortex_inner_color_blue;
+                                       ring_inner_image = "gfx/crosshair_ring_inner.tga";
+
+                                       // draw the outer ring to show the current charge of the weapon
+                                       ring_value = okvortex_charge;
+                                       ring_alpha = autocvar_crosshair_ring_vortex_alpha;
+                                       ring_rgb = wcross_color;
+                                       ring_image = "gfx/crosshair_ring_nexgun.tga";
+                               }
                                else if (autocvar_crosshair_ring && wepent.activeweapon == WEP_MINE_LAYER && WEP_CVAR(minelayer, limit) && autocvar_crosshair_ring_minelayer)
                                {
                                        ring_value = bound(0, STAT(LAYED_MINES) / WEP_CVAR(minelayer, limit), 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to.
@@ -1346,6 +1381,8 @@ void HUD_Draw(entity this)
        if(!gametype)
                return;
 
+       Hud_Dynamic_Frame();
+
        if(!intermission)
        if (MUTATOR_CALLHOOK(HUD_Draw_overlay))
        {
@@ -1355,6 +1392,8 @@ void HUD_Draw(entity this)
        {
                drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, ((STAT(REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * STAT(REVIVE_PROGRESS)) + ('0 1 1' * STAT(REVIVE_PROGRESS) * -1)) : '0.25 0.90 1'), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
        }
+
+       HUD_Scale_Enable();
        if(!intermission)
        if(STAT(NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death
        {
@@ -1371,6 +1410,7 @@ void HUD_Draw(entity this)
                DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
                drawstring_aspect(eY * 0.64 * vid_conheight, _("Revival progress"), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL);
        }
+       HUD_Scale_Disable();
 
        if(autocvar_r_letterbox == 0)
                if(autocvar_viewsize < 120)
@@ -1735,7 +1775,7 @@ void CSQC_UpdateView(entity this, float w, float h)
 
                t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
                r = t * blurtest_radius;
-               f = 1 / pow(t, blurtest_power) - 1;
+               f = 1 / (t ** blurtest_power) - 1;
 
                cvar_set("r_glsl_postprocess", "1");
                cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
@@ -1762,8 +1802,8 @@ void CSQC_UpdateView(entity this, float w, float h)
        if(!postinit)
                PostInit();
 
-       if(intermission && !gameover_time)
-               gameover_time = time;
+       if(intermission && !intermission_time)
+               intermission_time = time;
 
        if(intermission && !isdemo() && !(calledhooks & HOOK_END))
        {
@@ -1953,7 +1993,7 @@ void CSQC_UpdateView(entity this, float w, float h)
 
        if(autocvar_cl_reticle)
        {
-               string reticle_image = "";
+               string reticle_image = string_null;
                bool wep_zoomed = false;
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
@@ -1962,7 +2002,7 @@ void CSQC_UpdateView(entity this, float w, float h)
                        if(wep != WEP_Null && wep.wr_zoom)
                        {
                                bool do_zoom = wep.wr_zoom(wep, NULL);
-                               if(wep.w_reticle && wep.w_reticle != "")
+                               if(!reticle_image && wep.w_reticle && wep.w_reticle != "")
                                        reticle_image = wep.w_reticle;
                                wep_zoomed += do_zoom;
                        }
@@ -1978,7 +2018,7 @@ void CSQC_UpdateView(entity this, float w, float h)
                }
                else if(wep_zoomed && autocvar_cl_reticle_weapon)
                {
-                       if(reticle_image && reticle_image != "") { reticle_type = 2; }
+                       if(reticle_image) { reticle_type = 2; }
                        else { reticle_type = 0; }
                }
                else if(button_zoom || zoomscript_caught)
@@ -2014,7 +2054,7 @@ void CSQC_UpdateView(entity this, float w, float h)
                                switch(reticle_type)
                                {
                                        case 1: drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * autocvar_cl_reticle_normal_alpha, DRAWFLAG_NORMAL); break;
-                                       case 2: drawpic(reticle_pos, reticle_image, reticle_size, '1 1 1', f * autocvar_cl_reticle_weapon_alpha, DRAWFLAG_NORMAL); break;
+                                       case 2: if(reticle_image) drawpic(reticle_pos, reticle_image, reticle_size, '1 1 1', f * autocvar_cl_reticle_weapon_alpha, DRAWFLAG_NORMAL); break;
                                }
                        }
                }
@@ -2237,7 +2277,9 @@ void CSQC_UpdateView(entity this, float w, float h)
        // draw 2D entities
        IL_EACH(g_drawables_2d, it.draw2d, it.draw2d(it));
        Draw_ShowNames_All();
+#ifdef DEBUGDRAW
        Debug_Draw();
+#endif
 
        scoreboard_active = Scoreboard_WouldDraw();