#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/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"
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 &&
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();
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));