]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Merge branch 'terencehill/lms_itemtimes_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index a05407e9023d1b8df08e2d289aac957577f9dfe9..4eab4c5c551d2b9dcfffc41a2ec21bd662e60260 100644 (file)
 #include "../common/constants.qh"
 #include "../common/debug.qh"
 #include "../common/mapinfo.qh"
-#include "../common/gamemodes/all.qh"
+#include <common/gamemodes/all.qh>
 #include "../common/physics/player.qh"
 #include "../common/stats.qh"
 #include "../common/triggers/target/music.qh"
 #include "../common/teams.qh"
 
-#include "../common/vehicles/all.qh"
-#include "../common/weapons/all.qh"
+#include <common/vehicles/all.qh>
+#include <common/weapons/all.qh>
 #include "../common/viewloc.qh"
 #include "../common/minigames/cl_minigames.qh"
 #include "../common/minigames/cl_minigames_hud.qh"
@@ -293,7 +293,7 @@ void viewmodel_draw(entity this)
                e.colormap = 256 + c;  // colormap == 0 is black, c == 0 is white
                e.glowmod = g;
                e.csqcmodel_effects = fx;
-               WITH(entity, self, e, CSQCModel_Effects_Apply());
+               CSQCModel_Effects_Apply(e);
        }
        {
                static string name_last;
@@ -745,19 +745,19 @@ vector liquidcolor_prev;
 
 float eventchase_current_distance;
 float eventchase_running;
-bool WantEventchase()
-{SELFPARAM();
+bool WantEventchase(entity this)
+{
        if(autocvar_cl_orthoview)
                return false;
        if(intermission)
                return true;
-       if(self.viewloc)
+       if(this.viewloc)
                return true;
        if(spectatee_status >= 0)
        {
                if(hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0))
                        return true;
-               if(MUTATOR_CALLHOOK(WantEventchase, self))
+               if(MUTATOR_CALLHOOK(WantEventchase, this))
                        return true;
                if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
                        return true;
@@ -766,7 +766,7 @@ bool WantEventchase()
                        if(autocvar_cl_eventchase_death == 2)
                        {
                                // don't stop eventchase once it's started (even if velocity changes afterwards)
-                               if(self.velocity == '0 0 0' || eventchase_running)
+                               if(this.velocity == '0 0 0' || eventchase_running)
                                        return true;
                        }
                        else return true;
@@ -779,7 +779,7 @@ void HUD_Crosshair_Vehicle()
 {
        if(hud != HUD_BUMBLEBEE_GUN)
        {
-               Vehicle info = get_vehicleinfo(hud);
+               Vehicle info = Vehicles_from(hud);
                info.vr_crosshair(info);
        }
 }
@@ -864,7 +864,7 @@ void HUD_Crosshair()
 {SELFPARAM();
        static float rainbow_last_flicker;
        static vector rainbow_prev_color;
-       entity e = self;
+       entity e = this;
        float f, i, j;
        vector v;
        if(!scoreboard_active && !camera_active && intermission != 2 &&
@@ -1404,8 +1404,8 @@ void CSQC_UpdateView(float w, float h)
        else
                view_quality = 1;
 
-       button_attack2 = PHYS_INPUT_BUTTON_ATCK2(self);
-       button_zoom = PHYS_INPUT_BUTTON_ZOOM(self);
+       button_attack2 = PHYS_INPUT_BUTTON_ATCK2(this);
+       button_zoom = PHYS_INPUT_BUTTON_ZOOM(this);
 
        vf_size = getpropertyvec(VF_SIZE);
        vf_min = getpropertyvec(VF_MIN);
@@ -1459,6 +1459,19 @@ void CSQC_UpdateView(float w, float h)
                float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && STAT(ROUNDLOST));
                entity gen = world;
 
+               float vehicle_viewdist = 0;
+               vector vehicle_viewofs = '0 0 0';
+
+               if(vehicle_chase)
+               {
+                       if(hud != HUD_BUMBLEBEE_GUN)
+                       {
+                               Vehicle info = Vehicles_from(hud);
+                               vehicle_viewdist = info.height;
+                               vehicle_viewofs = info.view_ofs;
+                       }
+               }
+
                if(ons_roundlost)
                {
                        FOREACH_ENTITY_CLASS("onslaught_generator", it.health <= 0, LAMBDA(
@@ -1468,17 +1481,27 @@ void CSQC_UpdateView(float w, float h)
                        if(!gen)
                                ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
                }
-               if(WantEventchase() || (!autocvar_cl_orthoview && ons_roundlost))
+               if(WantEventchase(self) || (!autocvar_cl_orthoview && ons_roundlost))
                {
                        eventchase_running = true;
 
+                       entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1));
+                       if(!local_player)
+                               local_player = self; // fall back!
+
                        // 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.)
                        vector current_view_origin = (csqcplayer ? csqcplayer.origin : pmove_org);
                        if(ons_roundlost) { current_view_origin = gen.origin; }
 
                        // detect maximum viewoffset and use it
                        vector view_offset = autocvar_cl_eventchase_viewoffset;
-                       if(vehicle_chase && autocvar_cl_eventchase_vehicle_viewoffset) { view_offset = autocvar_cl_eventchase_vehicle_viewoffset; }
+                       if(vehicle_chase)
+                       {
+                               if(vehicle_viewofs)
+                                       view_offset = vehicle_viewofs;
+                               else
+                                       view_offset = autocvar_cl_eventchase_vehicle_viewoffset;
+                       }
                        if(ons_roundlost) { view_offset = autocvar_cl_eventchase_generator_viewoffset; }
 
                        if(view_offset)
@@ -1495,7 +1518,13 @@ void CSQC_UpdateView(float w, float h)
 
                        // make the camera smooth back
                        float chase_distance = autocvar_cl_eventchase_distance;
-                       if(vehicle_chase && autocvar_cl_eventchase_vehicle_distance) { chase_distance = autocvar_cl_eventchase_vehicle_distance; }
+                       if(vehicle_chase)
+                       {
+                               if(vehicle_viewofs)
+                                       chase_distance = vehicle_viewdist;
+                               else
+                                       chase_distance = autocvar_cl_eventchase_vehicle_distance;
+                       }
                        if(ons_roundlost) { chase_distance = autocvar_cl_eventchase_generator_distance; }
 
                        if(autocvar_cl_eventchase_speed && eventchase_current_distance < chase_distance)
@@ -1509,7 +1538,7 @@ void CSQC_UpdateView(float w, float h)
                        WarpZone_TraceBox(current_view_origin, autocvar_cl_eventchase_mins, autocvar_cl_eventchase_maxs, eventchase_target_origin, MOVE_WORLDONLY, self);
 
                        // If the boxtrace fails, revert back to line tracing.
-                       if(!self.viewloc)
+                       if(!local_player.viewloc)
                        if(trace_startsolid)
                        {
                                eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_distance));
@@ -1518,7 +1547,7 @@ void CSQC_UpdateView(float w, float h)
                        }
                        else { setproperty(VF_ORIGIN, trace_endpos); }
 
-                       if(!self.viewloc)
+                       if(!local_player.viewloc)
                                setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles));
                }
                else if(autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
@@ -1810,7 +1839,7 @@ void CSQC_UpdateView(float w, float h)
           mousepos = mousepos*0.5 + getmousepos();
         */
 
-       FOREACH_ENTITY(it.draw, LAMBDA(WITH(entity, self, it, it.draw(it))));
+       FOREACH_ENTITY(it.draw, LAMBDA(it.draw(it)));
 
        addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
        renderscene();
@@ -2140,7 +2169,7 @@ void CSQC_UpdateView(float w, float h)
          } else */
 
        // draw 2D entities
-       FOREACH_ENTITY(it.draw2d, LAMBDA(WITH(entity, self, it, it.draw2d(it))));
+       FOREACH_ENTITY(it.draw2d, LAMBDA(it.draw2d(it)));
        Draw_ShowNames_All();
        Debug_Draw();