float autocvar_hud_dock_alpha;
string autocvar_hud_dock_color;
bool autocvar_hud_dock_color_team;
+ bool autocvar_hud_panel_weapons_dynamichud = true;
+ bool autocvar_hud_panel_ammo_dynamichud = true;
+ bool autocvar_hud_panel_powerups_dynamichud = true;
+ bool autocvar_hud_panel_healtharmor_dynamichud = true;
+ bool autocvar_hud_panel_notify_dynamichud = true;
+ bool autocvar_hud_panel_timer_dynamichud = true;
+ bool autocvar_hud_panel_radar_dynamichud = true;
+ bool autocvar_hud_panel_score_dynamichud = true;
+ bool autocvar_hud_panel_racetimer_dynamichud = true;
+ bool autocvar_hud_panel_vote_dynamichud = true;
+ bool autocvar_hud_panel_modicons_dynamichud = true;
+ bool autocvar_hud_panel_pressedkeys_dynamichud = true;
+ bool autocvar_hud_panel_engineinfo_dynamichud = true;
+ bool autocvar_hud_panel_infomessages_dynamichud = false;
+ bool autocvar_hud_panel_physics_dynamichud = true;
+ bool autocvar_hud_panel_centerprint_dynamichud = true;
+ bool autocvar_hud_panel_itemstime_dynamichud = true;
bool autocvar_hud_panel_ammo;
bool autocvar_hud_panel_ammo_iconalign;
int autocvar_hud_panel_ammo_maxammo;
bool autocvar_hud_panel_weapons_onlyowned;
float autocvar_hud_panel_weapons_noncurrent_alpha = 1;
float autocvar_hud_panel_weapons_noncurrent_scale = 1;
+float autocvar_hud_panel_weapons_selection_radius = 0;
+float autocvar_hud_panel_weapons_selection_speed = 10;
float autocvar_hud_panel_weapons_timeout;
int autocvar_hud_panel_weapons_timeout_effect;
float autocvar_hud_panel_weapons_timeout_fadebgmin;
string autocvar_hud_skin;
float autocvar_menu_mouse_speed;
string autocvar_menu_skin;
+ float autocvar_r_drawviewmodel;
int autocvar_r_fakelight;
int autocvar_r_fullbright;
float autocvar_r_letterbox;
float autocvar_scoreboard_offset_right;
float autocvar_scoreboard_offset_vertical;
float autocvar_scoreboard_respawntime_decimals;
+ float autocvar_scoreboard_dynamichud = 1;
bool autocvar_v_flipped;
float autocvar_vid_conheight;
float autocvar_vid_conwidth;
float autocvar_cl_hitsound_nom_damage = 25;
float autocvar_cl_hitsound_antispam_time;
int autocvar_cl_eventchase_death = 1;
-int autocvar_cl_eventchase_nexball = 1;
vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
float autocvar_cl_eventchase_generator_distance = 400;
float autocvar_cl_eventchase_distance = 140;
vector weapon_pos, weapon_size = '0 0 0';
vector color;
+ entity panel_switchweapon = NULL;
+
// check to see if we want to continue
if(hud != HUD_NORMAL) return;
FOREACH(Weapons, it != WEP_Null && it.impulse >= 0 && (it.impulse % 3 != 0) && j < 6, {
if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
{
+ if(!panel_switchweapon || j < 4)
+ panel_switchweapon = it;
weapons_stat |= it.m_wepset;
++j;
}
}
// draw the background, then change the virtual size of it to better fit other items inside
+ if (autocvar_hud_panel_weapons_dynamichud)
+ HUD_Scale_Enable();
+ else
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
if(center.x == -1)
// draw items
row = column = 0;
vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
- vector noncurrent_pos = '0 0 0';
- vector noncurrent_size = weapon_size * bound(0, autocvar_hud_panel_weapons_noncurrent_scale, 1);
+ vector noncurrent_size = weapon_size * bound(0.01, autocvar_hud_panel_weapons_noncurrent_scale, 1);
float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1);
bool isCurrent;
+ static vector weapon_pos_current = '-1 0 0';
+ if(weapon_pos_current.x == -1)
+ weapon_pos_current = panel_pos;
+
+ float switch_speed;
+ if(autocvar_hud_panel_weapons_selection_speed <= 0 || autocvar__hud_configure)
+ switch_speed = 999;
+ else
+ switch_speed = frametime * autocvar_hud_panel_weapons_selection_speed;
+ vector radius_size = weapon_size * (autocvar_hud_panel_weapons_selection_radius + 1);
+
+ if(!panel_switchweapon)
+ panel_switchweapon = switchweapon;
+
+ // draw background behind currently selected weapon
+ // do it earlier to make sure bg is drawn behind every weapon icons while it's moving
+ if(panel_switchweapon)
+ drawpic_aspect_skin(weapon_pos_current, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
{
// figure out the drawing position of weapon
weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y);
- noncurrent_pos.x = weapon_pos.x + (weapon_size.x - noncurrent_size.x) / 2;
- noncurrent_pos.y = weapon_pos.y + (weapon_size.y - noncurrent_size.y) / 2;
- // draw background behind currently selected weapon
- isCurrent = (it == switchweapon);
+ // update position of the currently selected weapon
+ isCurrent = (it == panel_switchweapon);
if(isCurrent)
- drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ {
+ if(weapon_pos_current.y > weapon_pos.y)
+ weapon_pos_current.y = max(weapon_pos.y, weapon_pos_current.y - switch_speed * (weapon_pos_current.y - weapon_pos.y));
+ else if(weapon_pos_current.y < weapon_pos.y)
+ weapon_pos_current.y = min(weapon_pos.y, weapon_pos_current.y + switch_speed * (weapon_pos.y - weapon_pos_current.y));
+ if(weapon_pos_current.x > weapon_pos.x)
+ weapon_pos_current.x = max(weapon_pos.x, weapon_pos_current.x - switch_speed * (weapon_pos_current.x - weapon_pos.x));
+ else if(weapon_pos_current.x < weapon_pos.x)
+ weapon_pos_current.x = min(weapon_pos.x, weapon_pos_current.x + switch_speed * (weapon_pos.x - weapon_pos_current.x));
+ }
// draw the weapon accuracy
if(autocvar_hud_panel_weapons_accuracy)
}
}
+ vector weapon_size_real = noncurrent_size;
+ float weapon_alpha_real = noncurrent_alpha;
+ float radius_factor_x = 1 - bound(0, fabs(weapon_pos.x - weapon_pos_current.x) / radius_size.x, 1);
+ float radius_factor_y = 1 - bound(0, fabs(weapon_pos.y - weapon_pos_current.y) / radius_size.y, 1);
+ if(radius_factor_x || radius_factor_y)
+ {
+ weapon_size_real.x += (weapon_size.x - noncurrent_size.x) * radius_factor_x;
+ weapon_size_real.y += (weapon_size.y - noncurrent_size.y) * radius_factor_y;
+ weapon_alpha_real += (panel_fg_alpha - noncurrent_alpha) * min(radius_factor_x, radius_factor_y);
+ }
+
+ vector weapon_pos_real = weapon_pos;
+ weapon_pos_real.x = weapon_pos.x + (weapon_size.x - weapon_size_real.x) / 2;
+ weapon_pos_real.y = weapon_pos.y + (weapon_size.y - weapon_size_real.y) / 2;
+
// drawing all the weapon items
if(weapons_stat & WepSet_FromWeapon(it))
{
// draw the weapon image
- if(isCurrent)
- drawpic_aspect_skin(weapon_pos, it.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
- else
- drawpic_aspect_skin(noncurrent_pos, it.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(weapon_pos_real, it.model2, weapon_size_real, '1 1 1', weapon_alpha_real, DRAWFLAG_NORMAL);
// draw weapon label string
switch(autocvar_hud_panel_weapons_label)
}
else // draw a "ghost weapon icon" if you don't have the weapon
{
- drawpic_aspect_skin(noncurrent_pos, it.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(weapon_pos_real, it.model2, weapon_size_real, '0.2 0.2 0.2', weapon_alpha_real * 0.5, DRAWFLAG_NORMAL);
}
// draw the complain message
highpass(value.z, frac, ref_store.z, ref_out.z); \
} MACRO_END
- void viewmodel_animate(entity this)
+ void calc_followmodel_ofs(entity view)
{
- static float prevtime;
- float frametime = (time - prevtime);
- prevtime = time;
+ if(cl_followmodel_time == time)
+ return; // cl_followmodel_ofs already calculated for this frame
- if (autocvar_chase_active) return;
- if (STAT(HEALTH) <= 0) return;
+ float frac;
+ vector gunorg = '0 0 0';
+ static vector vel_average;
+ static vector gunorg_prev = '0 0 0';
+ static vector gunorg_adjustment_highpass;
+ static vector gunorg_adjustment_lowpass;
+
+ vector vel;
+ if (autocvar_cl_followmodel_velocity_absolute)
+ vel = view.velocity;
+ else
+ {
+ vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
+ vel.x = view.velocity * forward;
+ vel.y = view.velocity * right * -1;
+ vel.z = view.velocity * up;
+ }
- entity view = CSQCModel_server2csqc(player_localentnum - 1);
+ vel.x = bound(vel_average.x - autocvar_cl_followmodel_limit, vel.x, vel_average.x + autocvar_cl_followmodel_limit);
+ vel.y = bound(vel_average.y - autocvar_cl_followmodel_limit, vel.y, vel_average.y + autocvar_cl_followmodel_limit);
+ vel.z = bound(vel_average.z - autocvar_cl_followmodel_limit, vel.z, vel_average.z + autocvar_cl_followmodel_limit);
+
+ frac = avg_factor(autocvar_cl_followmodel_velocity_lowpass);
+ lowpass3(vel, frac, vel_average, gunorg);
+
+ gunorg *= -autocvar_cl_followmodel_speed * 0.042;
+
+ // perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
+ // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
+ frac = avg_factor(autocvar_cl_followmodel_highpass);
+ highpass3(gunorg, frac, gunorg_adjustment_highpass, gunorg);
+ frac = avg_factor(autocvar_cl_followmodel_lowpass);
+ lowpass3(gunorg, frac, gunorg_adjustment_lowpass, gunorg);
+
+ if (autocvar_cl_followmodel_velocity_absolute)
+ {
+ vector fixed_gunorg;
+ vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
+ fixed_gunorg.x = gunorg * forward;
+ fixed_gunorg.y = gunorg * right * -1;
+ fixed_gunorg.z = gunorg * up;
+ gunorg = fixed_gunorg;
+ }
+
+ cl_followmodel_ofs = gunorg;
+ cl_followmodel_time = time;
+ }
+
+ vector leanmodel_ofs(entity view)
+ {
+ float frac;
+ vector gunangles = '0 0 0';
+ static vector gunangles_prev = '0 0 0';
+ static vector gunangles_highpass = '0 0 0';
+ static vector gunangles_adjustment_highpass;
+ static vector gunangles_adjustment_lowpass;
+
+ if (view.csqcmodel_teleported)
+ gunangles_prev = view_angles;
+
+ // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
+ gunangles_highpass += gunangles_prev;
+ PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
+ YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
+ ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
+ frac = avg_factor(autocvar_cl_leanmodel_highpass1);
+ highpass2_limited(view_angles, frac, autocvar_cl_leanmodel_limit, gunangles_highpass, gunangles);
+ gunangles_prev = view_angles;
+ gunangles_highpass -= gunangles_prev;
+ PITCH(gunangles) *= -autocvar_cl_leanmodel_speed;
+ YAW(gunangles) *= -autocvar_cl_leanmodel_speed;
+
+ // we assume here: PITCH = 0, YAW = 1, ROLL = 2
+ frac = avg_factor(autocvar_cl_leanmodel_highpass);
+ highpass2(gunangles, frac, gunangles_adjustment_highpass, gunangles);
+ frac = avg_factor(autocvar_cl_leanmodel_lowpass);
+ lowpass2(gunangles, frac, gunangles_adjustment_lowpass, gunangles);
+
+ gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
+
+ return gunangles;
+ }
+
+ vector bobmodel_ofs(entity view)
+ {
bool clonground = !(view.anim_implicit_state & ANIMIMPLICITSTATE_INAIR);
static bool oldonground;
static float hitgroundtime;
}
oldonground = clonground;
-
- bool teleported = view.csqcmodel_teleported;
-
- float frac;
- if(autocvar_cl_followmodel)
+ // calculate for swinging gun model
+ // the gun bobs when running on the ground, but doesn't bob when you're in the air.
+ vector gunorg = '0 0 0';
+ static float bobmodel_scale = 0;
+ static float time_ofs = 0; // makes the effect always restart in the same way
+ if (clonground)
{
- vector gunorg = '0 0 0';
- static vector vel_average;
- static vector gunorg_prev = '0 0 0';
- static vector gunorg_adjustment_highpass;
- static vector gunorg_adjustment_lowpass;
-
- vector vel;
- if(autocvar_cl_followmodel_velocity_absolute)
- vel = view.velocity;
- else
- {
- vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
- MAKEVECTORS(makevectors, view_angles, forward, right, up);
- vel.x = view.velocity * forward;
- vel.y = view.velocity * right * -1;
- vel.z = view.velocity * up;
- }
-
- vel.x = bound(vel_average.x - autocvar_cl_followmodel_limit, vel.x, vel_average.x + autocvar_cl_followmodel_limit);
- vel.y = bound(vel_average.y - autocvar_cl_followmodel_limit, vel.y, vel_average.y + autocvar_cl_followmodel_limit);
- vel.z = bound(vel_average.z - autocvar_cl_followmodel_limit, vel.z, vel_average.z + autocvar_cl_followmodel_limit);
-
- frac = avg_factor(autocvar_cl_followmodel_velocity_lowpass);
- lowpass3(vel, frac, vel_average, gunorg);
-
- gunorg *= -autocvar_cl_followmodel_speed * 0.042;
-
- // perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
- // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
- frac = avg_factor(autocvar_cl_followmodel_highpass);
- highpass3(gunorg, frac, gunorg_adjustment_highpass, gunorg);
- frac = avg_factor(autocvar_cl_followmodel_lowpass);
- lowpass3(gunorg, frac, gunorg_adjustment_lowpass, gunorg);
-
- if(autocvar_cl_followmodel_velocity_absolute)
- {
- vector fixed_gunorg;
- vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
- MAKEVECTORS(makevectors, view_angles, forward, right, up);
- fixed_gunorg.x = gunorg * forward;
- fixed_gunorg.y = gunorg * right * -1;
- fixed_gunorg.z = gunorg * up;
- gunorg = fixed_gunorg;
- }
-
- this.origin += gunorg;
+ if (time - hitgroundtime > 0.05)
+ bobmodel_scale = min(1, bobmodel_scale + frametime * 5);
}
+ else
+ bobmodel_scale = max(0, bobmodel_scale - frametime * 5);
- if(autocvar_cl_leanmodel)
+ float xyspeed = bound(0, vlen(vec2(view.velocity)), 400);
+ if (bobmodel_scale && xyspeed)
{
- vector gunangles = '0 0 0';
- static vector gunangles_prev = '0 0 0';
- static vector gunangles_highpass = '0 0 0';
- static vector gunangles_adjustment_highpass;
- static vector gunangles_adjustment_lowpass;
-
- if (teleported)
- gunangles_prev = view_angles;
-
- // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
- gunangles_highpass += gunangles_prev;
- PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
- YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
- ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
- frac = avg_factor(autocvar_cl_leanmodel_highpass1);
- highpass2_limited(view_angles, frac, autocvar_cl_leanmodel_limit, gunangles_highpass, gunangles);
- gunangles_prev = view_angles;
- gunangles_highpass -= gunangles_prev;
+ float bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale;
+ float s = (time - time_ofs) * autocvar_cl_bobmodel_speed;
+ gunorg.y = bspeed * autocvar_cl_bobmodel_side * sin(s);
+ gunorg.z = bspeed * autocvar_cl_bobmodel_up * cos(s * 2);
+ }
+ else
+ time_ofs = time;
- PITCH(gunangles) *= -autocvar_cl_leanmodel_speed;
- YAW(gunangles) *= -autocvar_cl_leanmodel_speed;
+ return gunorg;
+ }
- // we assume here: PITCH = 0, YAW = 1, ROLL = 2
- frac = avg_factor(autocvar_cl_leanmodel_highpass);
- highpass2(gunangles, frac, gunangles_adjustment_highpass, gunangles);
- frac = avg_factor(autocvar_cl_leanmodel_lowpass);
- lowpass2(gunangles, frac, gunangles_adjustment_lowpass, gunangles);
+ void viewmodel_animate(entity this)
+ {
+ if (autocvar_chase_active) return;
+ if (STAT(HEALTH) <= 0) return;
+
+ entity view = CSQCModel_server2csqc(player_localentnum - 1);
- gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
- this.angles += gunangles;
+ if (autocvar_cl_followmodel)
+ {
+ calc_followmodel_ofs(view);
+ this.origin += cl_followmodel_ofs;
}
- float xyspeed = bound(0, vlen(vec2(view.velocity)), 400);
+ if (autocvar_cl_leanmodel)
+ this.angles += leanmodel_ofs(view);
// vertical view bobbing code
// TODO: cl_bob
// gun model bobbing code
if (autocvar_cl_bobmodel)
- {
- // calculate for swinging gun model
- // the gun bobs when running on the ground, but doesn't bob when you're in the air.
- static float bobmodel_scale = 0;
- static float time_ofs = 0; // makes the effect always restart in the same way
- if (clonground)
- {
- if (time - hitgroundtime > 0.05)
- bobmodel_scale = min(1, bobmodel_scale + frametime * 5);
- }
- else
- bobmodel_scale = max(0, bobmodel_scale - frametime * 5);
- if(bobmodel_scale && xyspeed)
- {
- float bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale;
- float s = (time - time_ofs) * autocvar_cl_bobmodel_speed;
- vector gunorg = '0 0 0';
- gunorg.y = bspeed * autocvar_cl_bobmodel_side * sin(s);
- gunorg.z = bspeed * autocvar_cl_bobmodel_up * cos(s * 2);
-
- this.origin += gunorg;
- }
- else
- time_ofs = time;
- }
+ this.origin += bobmodel_ofs(view);
}
.vector viewmodel_origin, viewmodel_angles;
void viewmodel_draw(entity this)
{
- if(!activeweapon)
+ if(!activeweapon || !autocvar_r_drawviewmodel)
return;
int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
float a = this.alpha;
return true;
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 && (STAT(HEALTH) <= 0))
{
if(autocvar_cl_eventchase_death == 2)
return wcross_color;
}
-void HUD_Crosshair()
-{SELFPARAM();
- entity e = this;
+void HUD_Crosshair(entity this)
+{
float f, i, j;
vector v;
if(!scoreboard_active && !camera_active && intermission != 2 &&
string wcross_name = "";
float wcross_scale, wcross_blur;
+ entity e = this; // wtf?
if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
{
e = switchingweapon;
}
}
-void HUD_Draw()
+void HUD_Draw(entity this)
{
if(!intermission)
if (MUTATOR_CALLHOOK(HUD_Draw_overlay))
HUD_Main();
HUD_DrawScoreboard();
+ HUD_Scale_Disable();
}
// crosshair goes VERY LAST
UpdateDamage();
- HUD_Crosshair();
+ HUD_Crosshair(this);
HitSound();
}
float vh_notice_time;
void WaypointSprite_Load();
void CSQC_UpdateView(float w, float h)
-{SELFPARAM();
+{
+ SELFPARAM();
TC(int, w); TC(int, h);
entity e;
float fov;
lasthud = hud;
+ HUD_Scale_Disable();
+
if(autocvar__hud_showbinds_reload) // menu can set this one
{
db_close(binddb);
view_quality = 1;
// this needs to be updated manually now due to the destruction of engine physics stats
- if(autocvar_slowmo != STAT(MOVEVARS_TIMESCALE))
+ if(!isdemo() && autocvar_slowmo != STAT(MOVEVARS_TIMESCALE))
cvar_set("slowmo", ftos(STAT(MOVEVARS_TIMESCALE)));
button_attack2 = PHYS_INPUT_BUTTON_ATCK2(this);
scoreboard_active = HUD_WouldDrawScoreboard();
- HUD_Draw();
+ HUD_Draw(this);
if(NextFrameCommand)
{