From ba8c0a42cf65276f45f229c0f5bf501dabffe1d7 Mon Sep 17 00:00:00 2001 From: drjaska Date: Tue, 26 Nov 2024 00:32:16 +0200 Subject: [PATCH] Implement cl_viewmodel_alpha_while_invisible --- qcsrc/client/view.qc | 10 +++++++++- xonotic-client.cfg | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 261fd1b01..b07aa5b97 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -41,6 +41,7 @@ #include float autocvar_cl_viewmodel_alpha = 1; +float autocvar_cl_viewmodel_alpha_while_invisible; bool autocvar_cl_bobmodel; float autocvar_cl_bobmodel_speed; @@ -293,7 +294,14 @@ void viewmodel_animate(entity this) void viewmodel_draw(entity this) { int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL; - float a = ((autocvar_cl_viewmodel_alpha) ? bound(-1, autocvar_cl_viewmodel_alpha, this.m_alpha) : this.m_alpha); + float a; + if (this.m_alpha == 1) // check visibility + a = bound(-1, autocvar_cl_viewmodel_alpha, this.m_alpha); + else + if (!autocvar_cl_viewmodel_alpha_while_invisible) // check if unset 0 + a = bound(-1, autocvar_cl_viewmodel_alpha, this.m_alpha); + else + a = bound(-1, autocvar_cl_viewmodel_alpha_while_invisible, 1); int wepskin = this.m_skin; bool invehicle = player_localentnum > maxclients; if (invehicle) a = -1; diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 332c4b741..4ddd0e2cf 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -805,7 +805,8 @@ seta cl_forcemyplayercolors 0 "set to the color value (encoding is same as _cl_c seta cl_movement_errorcompensation 1 "try to compensate for prediction errors and reduce perceived lag" seta cl_movement_intermissionrunning 0 "keep velocity after the match ends, players may appear to continue running while stationary" -seta cl_viewmodel_alpha 1 "Maximum opacity of the view model, use a value between 0 and 1" +seta cl_viewmodel_alpha 1 "Maximum opacity of the viewmodel, use a value between 0 and 1" +seta cl_viewmodel_alpha_while_invisible 0 "Overrides the opacity of the viewmodel if invisible; -1 forces invisibility, 0 disables this override, and any value between 0 and 1 enables it with the value as opacity" set debugdraw 0 set debugdraw_filter "" -- 2.39.2