#include "announcer.qh"
-#include "hook.qh"
#include "hud/all.qh"
#include "mapvoting.qh"
#include "scoreboard.qh"
#include "../common/constants.qh"
#include "../common/debug.qh"
#include "../common/mapinfo.qh"
-#include "../common/gamemodes/all.qh"
-#include "../common/physics.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"
float autocvar_cl_leanmodel_up_lowpass;
float autocvar_cl_leanmodel_up_limit;
-#define lowpass(value, frac, ref_store, ret) do \
+#define lowpass(value, frac, ref_store, ret) MACRO_BEGIN \
{ \
float __frac = bound(0, frac, 1); \
ret = ref_store = ref_store * (1 - __frac) + (value) * __frac; \
-} while (0)
+} MACRO_END
-#define lowpass_limited(value, frac, limit, ref_store, ret) do \
+#define lowpass_limited(value, frac, limit, ref_store, ret) MACRO_BEGIN \
{ \
float __ignore; lowpass(value, frac, ref_store, __ignore); \
ret = ref_store = bound((value) - (limit), ref_store, (value) + (limit)); \
-} while (0)
+} MACRO_END
-#define highpass(value, frac, ref_store, ret) do \
+#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; \
-} while (0)
+} MACRO_END
-#define highpass_limited(value, frac, limit, ref_store, ret) do \
+#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; \
-} while (0)
+} MACRO_END
-#define lowpass3(value, fracx, fracy, fracz, ref_store, ref_out) do \
+#define lowpass3(value, fracx, fracy, fracz, ref_store, ref_out) MACRO_BEGIN \
{ \
lowpass(value.x, fracx, ref_store.x, ref_out.x); \
lowpass(value.y, fracy, ref_store.y, ref_out.y); \
lowpass(value.z, fracz, ref_store.z, ref_out.z); \
-} while (0)
+} MACRO_END
-#define highpass3(value, fracx, fracy, fracz, ref_store, ref_out) do \
+#define highpass3(value, fracx, fracy, fracz, ref_store, ref_out) MACRO_BEGIN \
{ \
highpass(value.x, fracx, ref_store.x, ref_out.x); \
highpass(value.y, fracy, ref_store.y, ref_out.y); \
highpass(value.z, fracz, ref_store.z, ref_out.z); \
-} while (0)
+} MACRO_END
-#define highpass3_limited(value, fracx, limitx, fracy, limity, fracz, limitz, ref_store, ref_out) do \
+#define highpass3_limited(value, fracx, limitx, fracy, limity, fracz, limitz, ref_store, ref_out) MACRO_BEGIN \
{ \
highpass_limited(value.x, fracx, limitx, ref_store.x, ref_out.x); \
highpass_limited(value.y, fracy, limity, ref_store.y, ref_out.y); \
highpass_limited(value.z, fracz, limitz, ref_store.z, ref_out.z); \
-} while (0)
+} MACRO_END
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;
{
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;
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;
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)
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;
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;
{
if(hud != HUD_BUMBLEBEE_GUN)
{
- Vehicle info = get_vehicleinfo(hud);
+ Vehicle info = Vehicles_from(hud);
info.vr_crosshair(info);
}
}
{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 &&
}
#define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
- do \
- { \
+ MACRO_BEGIN { \
if(wcross_blur > 0) \
{ \
for(i = -2; i <= 2; ++i) \
{ \
M(0,0,sz,wcross_name,wcross_alpha); \
} \
- } \
- while(0)
+ } MACRO_END
#define CROSSHAIR_DRAW_SINGLE(i,j,sz,wcross_name,wcross_alpha) \
drawpic(wcross_origin - ('0.5 0 0' * (sz * wcross_size.x + i * wcross_blur) + '0 0.5 0' * (sz * wcross_size.y + j * wcross_blur)), wcross_name, sz * wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL)
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);
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)
// 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)
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));
}
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
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)
{
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();
} 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();
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');
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));