X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fview.qc;h=4eab4c5c551d2b9dcfffc41a2ec21bd662e60260;hb=068324d293df795dbc41de75f38256b8c6c35607;hp=8602ef26a24eb179ebf0aee8599393f3e25dff67;hpb=678a61b45f332fcd560083b01e6b0bf5a5ae268c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 8602ef26a..4eab4c5c5 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1,6 +1,5 @@ #include "announcer.qh" -#include "hook.qh" #include "hud/all.qh" #include "mapvoting.qh" #include "scoreboard.qh" @@ -13,14 +12,14 @@ #include "../common/constants.qh" #include "../common/debug.qh" #include "../common/mapinfo.qh" -#include "../common/gamemodes/all.qh" -#include "../common/physics.qh" +#include +#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 +#include #include "../common/viewloc.qh" #include "../common/minigames/cl_minigames.qh" #include "../common/minigames/cl_minigames_hud.qh" @@ -77,13 +76,13 @@ float autocvar_cl_leanmodel_up_limit; #define highpass(value, frac, ref_store, ret) MACRO_BEGIN \ { \ - float __f; lowpass(value, frac, ref_store, __f); \ + float __f = 0; lowpass(value, frac, ref_store, __f); \ ret = (value) - __f; \ } MACRO_END #define highpass_limited(value, frac, limit, ref_store, ret) MACRO_BEGIN \ { \ - float __f; lowpass_limited(value, frac, limit, ref_store, __f); \ + float __f = 0; lowpass_limited(value, frac, limit, ref_store, __f); \ ret = (value) - __f; \ } MACRO_END @@ -230,7 +229,7 @@ void viewmodel_animate(entity this) // Sajt: I tried to smooth out the transitions between bob and no bob, which works // for the most part, but for some reason when you go through a message trigger or // pick up an item or anything like that it will momentarily jolt the gun. - vector forward, right, up; + vector forward, right = '0 0 0', up = '0 0 0'; float bspeed; float t = 1; float s = time * autocvar_cl_bobmodel_speed; @@ -274,6 +273,11 @@ void viewmodel_draw(entity this) { int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL; float a = this.alpha; + static bool wasinvehicle; + bool invehicle = player_localentnum > maxclients; + if (invehicle) a = -1; + else if (wasinvehicle) a = 1; + wasinvehicle = invehicle; int c = stof(getplayerkeyvalue(current_player, "colors")); vector g; Weapon wep = activeweapon; @@ -289,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; @@ -679,7 +683,7 @@ float TrueAimCheck() traceline(traceorigin, traceorigin + view_forward * MAX_SHOT_DISTANCE, mv, ta); trueaimpoint = trace_endpos; - if(vlen(trueaimpoint - traceorigin) < g_trueaim_minrange) + if(vdist((trueaimpoint - traceorigin), <, g_trueaim_minrange)) trueaimpoint = traceorigin + view_forward * g_trueaim_minrange; if(vecs.x > 0) @@ -741,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; @@ -762,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; @@ -775,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); } } @@ -860,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 && @@ -1400,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); @@ -1455,31 +1459,49 @@ void CSQC_UpdateView(float w, float h) float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && STAT(ROUNDLOST)); entity gen = world; - if(ons_roundlost) + float vehicle_viewdist = 0; + vector vehicle_viewofs = '0 0 0'; + + if(vehicle_chase) { - entity e; - for(e = world; (e = find(e, classname, "onslaught_generator")); ) + if(hud != HUD_BUMBLEBEE_GUN) { - if(e.health <= 0) - { - gen = e; - break; - } + 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( + gen = it; + break; + )); if(!gen) - ons_roundlost = FALSE; // don't enforce the 3rd person camera if there is no dead generator to show + 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) @@ -1496,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) @@ -1510,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)); @@ -1519,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 @@ -1577,14 +1605,14 @@ void CSQC_UpdateView(float w, float h) float ov_furthest = 0; float dist = 0; - if((dist = vlen(vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } - if((dist = vlen(vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } - if((dist = vlen(vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } - if((dist = vlen(vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } - if((dist = vlen(vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } - if((dist = vlen(vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } - if((dist = vlen(vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } - if((dist = vlen(vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } + if((dist = vdist((vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; } if(!ov_enabled) { @@ -1811,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(); @@ -2141,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(); @@ -2192,6 +2220,8 @@ void CSQC_UpdateView(float w, float h) HUD_Radar_Mouse(); cl_notice_run(); + unpause_update(); + Net_Flush(); // let's reset the view back to normal for the end setproperty(VF_MIN, '0 0 0'); @@ -2238,7 +2268,7 @@ void CSQC_Demo_Camera() else { tmp = getmousepos() * 0.1; - if(vlen(tmp)>autocvar_camera_mouse_threshold) + if(vdist(tmp, >, autocvar_camera_mouse_threshold)) { mouse_angles.x += tmp.y * cos(mouse_angles.z * DEG2RAD) + (tmp.x * sin(mouse_angles.z * DEG2RAD)); mouse_angles.y -= tmp.x * cos(mouse_angles.z * DEG2RAD) + (tmp.y * -sin(mouse_angles.z * DEG2RAD));