X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fstrafehud.qc;h=e4e339c44a53497c54e60485d00ce88b23468134;hp=2f0df08213ec3c599888571f4063b77fe99185a8;hb=af2f0cb624aaf967708b22e1303d113668af5114;hpb=9e814be01b75fd862cd3b0a7f413798253bba623 diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 2f0df0821..e4e339c44 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -4,13 +4,13 @@ #include #include -#include #include #include #include #include #include #include +#include #include // StrafeHUD (#25) @@ -37,12 +37,6 @@ bool state_fwd_prev = true; float state_fwd_time = 0; float starttime = 0; float startspeed = -1; -float jumptime = 0; -float jumpheight = -1; -float jumpheight_persistent = -1; -float jumpheight_prev = 0; -float jumpspeed_prev = 0; -bool jumprestart = true; // provide basic panel cvars to old clients // TODO remove them after a future release (0.8.2+) @@ -655,58 +649,35 @@ void HUD_StrafeHUD() startspeed = -1; } - // experimental: show height achieved by a single jump (doesn't work in low gravity and may not be 100% accurate) - if(autocvar_hud_panel_strafehud_jumpheight_fade > 0) + // show height achieved by a single jump + if(autocvar_hud_panel_strafehud_jumpheight_fade > 0 && autocvar_hud_panel_strafehud_jumpheight_size > 0) { - float text_alpha = 0; - float jumpheight_min = max(autocvar_hud_panel_strafehud_jumpheight_min, 0); - float jumpheight_current = strafeplayer.origin.z; - float jumpspeed_current = strafeplayer.velocity.z; - if(jumpspeed_prev <= jumpspeed_current || jumpheight_prev > jumpheight_current || IS_ONGROUND(strafeplayer) || swimming || IS_DEAD(strafeplayer) || spectating) + static float height_min = 0, height_max = 0; // ground and peak of jump z coordinates + static float jumpheight = 0, jumptime = 0; // displayed value and timestamp for fade out + + // tries to catch kill and spectate but those are not reliable, should just hook to kill/spectate/teleport and reset jump height there + if((strafeplayer.velocity.z <= 0 && height_max >= strafeplayer.origin.z) || IS_ONGROUND(strafeplayer) || swimming || IS_DEAD(strafeplayer) || spectating) { - // tries to catch kill and spectate but those are not reliable, should just hook to kill/spectate/teleport and reset jump height there - jumprestart = true; + height_min = height_max = strafeplayer.origin.z; } - else + else if(strafeplayer.origin.z > height_max) { - if(jumpheight < 0 || jumprestart) - { - jumprestart = false; - jumpheight = 0; - } - else - { - jumpheight += jumpheight_current - jumpheight_prev; - } - if((jumpheight * length_conversion_factor) > jumpheight_min && jumpheight > jumpheight_persistent) - { + height_max = strafeplayer.origin.z; + jumpheight = (height_max - height_min) * length_conversion_factor; + + if(jumpheight > max(autocvar_hud_panel_strafehud_jumpheight_min, 0)) jumptime = time; - jumpheight_persistent = jumpheight; - } - } - jumpheight_prev = jumpheight_current; - jumpspeed_prev = jumpspeed_current; - if(jumpheight_persistent > 0) - { - text_alpha = cos(((time - jumptime) / autocvar_hud_panel_strafehud_jumpheight_fade) * 90 * DEG2RAD); // fade non-linear like the physics panel does - if((time - jumptime) > autocvar_hud_panel_strafehud_jumpheight_fade) - { - jumpheight_persistent = -1; - } } - if(jumpheight_persistent > 0 && text_alpha > 0 && autocvar_hud_panel_strafehud_jumpheight_size > 0) + + if((time - jumptime) <= autocvar_hud_panel_strafehud_jumpheight_fade) { + float text_alpha = cos(((time - jumptime) / autocvar_hud_panel_strafehud_jumpheight_fade) * 90 * DEG2RAD); // fade non-linear like the physics panel does vector jumpheight_size = panel_size; jumpheight_size.y = panel_size.y * min(autocvar_hud_panel_strafehud_jumpheight_size, 5); string length_unit = GetLengthUnit(autocvar_hud_panel_strafehud_unit); - drawstring_aspect(panel_pos - eY * jumpheight_size.y, strcat(ftos_decimals(jumpheight_persistent * length_conversion_factor, length_decimals), autocvar_hud_panel_strafehud_unit_show ? length_unit : ""), jumpheight_size, autocvar_hud_panel_strafehud_jumpheight_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(panel_pos - eY * jumpheight_size.y, strcat(ftos_decimals(jumpheight, length_decimals), autocvar_hud_panel_strafehud_unit_show ? length_unit : ""), jumpheight_size, autocvar_hud_panel_strafehud_jumpheight_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } } - else - { - jumpheight_prev = jumpspeed_prev = 0; - jumpheight = jumpheight_persistent = -1; - } draw_endBoldFont(); if(speed < (maxspeed + antiflicker_speed) && !immobile)