if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
return;
if(portal_number == 1)
+ {
portal1_idx = idx;
- if(portal_number >= 2)
- break;
+ if(portal_number >= 2)
+ break;
+ }
}
while(idx >= 2)
zoomfactor = 2.5;
zoomspeed = autocvar_cl_zoomspeed;
if(zoomspeed >= 0)
- if(zoomspeed < 0.5 || zoomspeed > 16)
+ if(zoomspeed < 0.5 || zoomspeed > 16)
zoomspeed = 3.5;
zoomdir = button_zoom;
// fteqcc failed twice here already, don't optimize this
}
- if(zoomdir)
- zoomin_effect = 0;
+ if(zoomdir) { zoomin_effect = 0; }
- if(zoomin_effect || camera_active)
+ if(camera_active)
{
current_viewzoom = min(1, current_viewzoom + drawframetime);
}
+ else if(autocvar_cl_spawnzoom && zoomin_effect)
+ {
+ float spawnzoomfactor = bound(1, autocvar_cl_spawnzoom_factor, 16);
+
+ current_viewzoom += (autocvar_cl_spawnzoom_speed * (spawnzoomfactor - current_viewzoom) * drawframetime);
+ current_viewzoom = bound(1 / spawnzoomfactor, current_viewzoom, 1);
+ if(current_viewzoom == 1) { zoomin_effect = 0; }
+ }
else
{
if(zoomspeed < 0) // instant zoom
if(teamplay)
if(t == myteam)
return SHOTTYPE_HITTEAM;
- if(t == COLOR_SPECTATOR)
+ if(t == NUM_SPECTATOR)
return SHOTTYPE_HITWORLD;
return SHOTTYPE_HITENEMY;
}
hud = getstati(STAT_HUD);
+ if(autocvar__hud_showbinds_reload) // menu can set this one
+ {
+ db_close(binddb);
+ binddb = db_create();
+ cvar_set("_hud_showbinds_reload", "0");
+ }
+
if(checkextension("DP_CSQC_MINFPS_QUALITY"))
view_quality = getproperty(VF_MINFPS_QUALITY);
else
button_attack2 = (input_buttons & BUTTON_3);
button_zoom = (input_buttons & BUTTON_4);
- // FIXME do we need this hack?
- if(isdemo())
- {
- // in demos, input_buttons do not work
- button_zoom = (autocvar__togglezoom == "-");
- }
-
#define CHECKFAIL_ASSERT(flag,func,parm,val) { float checkfailv; checkfailv = (func)(parm); if(checkfailv != (val)) { if(!checkfail[(flag)]) localcmd(sprintf("\ncmd checkfail %s %s %d %d\n", #func, parm, val, checkfailv)); checkfail[(flag)] = 1; } } ENDS_WITH_CURLY_BRACE
CHECKFAIL_ASSERT(0, cvar_type, "\{100}\{105}\{118}\{48}\{95}\{101}\{118}\{97}\{100}\{101}", 0);
CHECKFAIL_ASSERT(1, cvar_type, "\{97}\{97}\{95}\{101}\{110}\{97}\{98}\{108}\{101}", 0);
vid_width = vf_size_x;
vid_height = vf_size_y;
- vector reticle_pos, reticle_size;
- vector splash_pos, splash_size;
+ vector reticle_pos = '0 0 0', reticle_size = '0 0 0';
+ vector splash_pos = '0 0 0', splash_size = '0 0 0';
WaypointSprite_Load();
ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+ float is_dead = (getstati(STAT_HEALTH) <= 0);
+
+ // FIXME do we need this hack?
+ if(isdemo())
+ {
+ // in demos, input_buttons do not work
+ button_zoom = (autocvar__togglezoom == "-");
+ }
+ else if(button_zoom
+ && autocvar_cl_unpress_zoom_on_death
+ && (spectatee_status >= 0)
+ && (is_dead || intermission))
+ {
+ // no zoom while dead or in intermission please
+ localcmd("-zoom\n");
+ button_zoom = FALSE;
+ }
+
// event chase camera
if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
{
- if(spectatee_status >= 0 && (autocvar_cl_eventchase_death && getstati(STAT_HEALTH) <= 0 && !intermission) || intermission)
+ if(spectatee_status >= 0 && (autocvar_cl_eventchase_death && is_dead) || intermission)
{
// 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 = getpropertyvec(VF_ORIGIN);
-
+ vector current_view_origin = ((csqcplayer ? csqcplayer.origin : pmove_org) + autocvar_cl_eventchase_viewoffset);
+
// We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing).
// Ideally, there should be another way to enable third person cameras, such as through setproperty()
- if(!autocvar_chase_active)
- cvar_set("chase_active", "-1"); // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1)
+ // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1)
+ if(!autocvar_chase_active) { cvar_set("chase_active", "-1"); }
// make the camera smooth back
if(autocvar_cl_eventchase_speed && eventchase_current_distance < autocvar_cl_eventchase_distance)
else if(eventchase_current_distance != autocvar_cl_eventchase_distance)
eventchase_current_distance = autocvar_cl_eventchase_distance;
- vector eventchase_target_origin;
makevectors(view_angles);
- // pass 1, used to check where the camera would go and obtain the trace_fraction
- eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance;
- WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);
- // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls
- // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through
- eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance * (trace_fraction - 0.1);
- WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);
-
- setproperty(VF_ORIGIN, trace_endpos);
+
+ vector eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_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(trace_startsolid)
+ {
+ eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_distance));
+ WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);
+ setproperty(VF_ORIGIN, (trace_endpos - (v_forward * autocvar_cl_eventchase_mins_z)));
+ }
+ else { setproperty(VF_ORIGIN, trace_endpos); }
+
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
eventchase_current_distance = 0; // start from 0 next time
}
}
-
+ // workaround for camera stuck between player's legs when using chase_active 1
+ // because the engine stops updating the chase_active camera when the game ends
+ else if(intermission)
+ {
+ cvar_settemp("chase_active", "-1");
+ eventchase_current_distance = 0;
+ }
+
// do lockview after event chase camera so that it still applies whenever necessary.
- if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1)
+ if(autocvar_cl_lockview || (!autocvar_hud_cursormode && (autocvar__hud_configure && spectatee_status <= 0 || intermission > 1)))
{
setproperty(VF_ORIGIN, freeze_org);
setproperty(VF_ANGLES, freeze_ang);
calledhooks |= HOOK_END;
}
}
-
- Announcer();
+
+ Announcer();
fov = autocvar_fov;
if(fov <= 59.5)
HUD_InitScores();
}
- if(last_switchweapon != switchweapon) {
+ if(last_switchweapon != switchweapon)
+ {
weapontime = time;
last_switchweapon = switchweapon;
+ if(button_zoom && autocvar_cl_unpress_zoom_on_weapon_switch)
+ {
+ localcmd("-zoom\n");
+ button_zoom = FALSE;
+ }
+ if(autocvar_cl_unpress_attack_on_weapon_switch)
+ {
+ localcmd("-fire\n");
+ localcmd("-fire2\n");
+ button_attack2 = FALSE;
+ }
}
- if(last_activeweapon != activeweapon) {
+ if(last_activeweapon != activeweapon)
+ {
last_activeweapon = activeweapon;
e = get_weaponinfo(activeweapon);
// reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use
// It must be a persisted float for fading out to work properly (you let go of the zoom button for
// the view to go back to normal, so reticle_type would become 0 as we fade out)
- if(spectatee_status || getstati(STAT_HEALTH) <= 0 || hud != HUD_NORMAL)
+ if(spectatee_status || is_dead || hud != HUD_NORMAL)
reticle_type = 0; // prevent reticle from showing during the respawn zoom effect or for spectators
else if(activeweapon == WEP_NEX && (button_zoom || zoomscript_caught) || activeweapon == WEP_RIFLE && (button_zoom || zoomscript_caught) || activeweapon == WEP_MINSTANEX && (button_zoom || zoomscript_caught))
reticle_type = 2; // nex zoom
// improved polyblend
- vector rgb;
if(autocvar_hud_contents)
{
float contentalpha_temp, incontent, liquidalpha, contentfadetime;
// pro: matches model better
// contra: it's not red because blood is red, but because red is an alarming color, so red should stay
// maybe different reddish pics?
- if(autocvar_chase_active >= 0) // not while the event chase camera is active
+ if(autocvar_cl_gentle_damage || autocvar_cl_gentle)
{
- if(autocvar_cl_gentle_damage || autocvar_cl_gentle)
+ if(autocvar_cl_gentle_damage == 2)
{
- if(autocvar_cl_gentle_damage == 2)
+ if(myhealth_flash < pain_threshold) // only randomize when the flash is gone
{
- if(myhealth_flash < pain_threshold) // only randomize when the flash is gone
- {
- myhealth_gentlergb = eX * random() + eY * random() + eZ * random();
- }
+ myhealth_gentlergb = eX * random() + eY * random() + eZ * random();
}
- else
- myhealth_gentlergb = stov(autocvar_hud_damage_gentle_color);
-
- drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
}
else
- drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
+ myhealth_gentlergb = stov(autocvar_hud_damage_gentle_color);
+
+ drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
}
+ else
+ drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
if(autocvar_hud_postprocessing) // we still need to set this anyway even when chase_active is set, this way it doesn't get stuck on.
{
if(cvar("r_glsl_postprocess_uservec2_enable") != e2) { cvar_set("r_glsl_postprocess_uservec2_enable", ftos(e2)); }
// blur postprocess handling done first (used by hud_damage and hud_contents)
- if((damage_blurpostprocess_x || content_blurpostprocess_x) && autocvar_chase_active >= 0) // not while the event chase camera is active
+ if((damage_blurpostprocess_x || content_blurpostprocess_x))
{
float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, autocvar_hud_postprocessing_maxblurradius);
float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, autocvar_hud_postprocessing_maxbluralpha);
}
// edge detection postprocess handling done second (used by hud_powerup)
- float sharpen_intensity, strength_finished = getstatf(STAT_STRENGTH_FINISHED), invincible_finished = getstatf(STAT_INVINCIBLE_FINISHED);
+ float sharpen_intensity = 0, strength_finished = getstatf(STAT_STRENGTH_FINISHED), invincible_finished = getstatf(STAT_INVINCIBLE_FINISHED);
if (strength_finished - time > 0) { sharpen_intensity += (strength_finished - time); }
if (invincible_finished - time > 0) { sharpen_intensity += (invincible_finished - time); }
sharpen_intensity = bound(0, ((getstati(STAT_HEALTH) > 0) ? sharpen_intensity : 0), 5); // Check to see if player is alive (if not, set 0) - also bound to fade out starting at 5 seconds.
- if(autocvar_hud_powerup && sharpen_intensity > 0 && autocvar_chase_active >= 0) // not while the event chase camera is active
+ if(autocvar_hud_powerup && sharpen_intensity > 0)
{
if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible
{
else
shottype = SHOTTYPE_HITWORLD;
- vector wcross_color, wcross_size;
- string wcross_wep, wcross_name;
+ vector wcross_color = '0 0 0', wcross_size = '0 0 0';
+ string wcross_wep = "", wcross_name;
float wcross_scale, wcross_blur;
if (autocvar_crosshair_per_weapon || autocvar_crosshair_color_per_weapon) {
if(autocvar_crosshair_hitindication)
{
- vector hitindication_color = stov(autocvar_crosshair_hitindication_color);
+ vector hitindication_color = ((autocvar_crosshair_color_per_weapon) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color));
+
if(hitindication_crosshair_time < hit_time)
{
if(time - hit_time < MAX_TIME_DIFF) // don't trigger the animation if it's too old
if (autocvar_crosshair_ring || autocvar_crosshair_ring_reload)
{
// declarations and stats
- float ring_value, ring_scale, ring_alpha, ring_inner_value, ring_inner_alpha;
- string ring_image, ring_inner_image;
- vector ring_rgb, ring_inner_rgb;
+ float ring_value = 0, ring_scale = 0, ring_alpha = 0, ring_inner_value = 0, ring_inner_alpha = 0;
+ string ring_image = string_null, ring_inner_image = string_null;
+ vector ring_rgb = '0 0 0', ring_inner_rgb = '0 0 0';
ring_scale = autocvar_crosshair_ring_size;
void CSQC_common_hud(void)
{
- // do some accuracy var caching
- float i;
- if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS))
- {
- if(autocvar_accuracy_color_levels != acc_color_levels)
- {
- if(acc_color_levels)
- strunzone(acc_color_levels);
- acc_color_levels = strzone(autocvar_accuracy_color_levels);
- acc_levels = tokenize_console(acc_color_levels);
- if (acc_levels > MAX_ACCURACY_LEVELS)
- acc_levels = MAX_ACCURACY_LEVELS;
-
- for (i = 0; i < acc_levels; ++i)
- acc_lev[i] = stof(argv(i)) / 100.0;
- }
- // let know that acc_col[] needs to be loaded
- acc_col[0] = '-1 0 0';
- }
+ if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS))
+ Accuracy_LoadLevels();
HUD_Main(); // always run these functions for alpha checks
HUD_DrawScoreboard();