From 9a93c94b8672bee9f86d70c20a159484eb092a55 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 3 Nov 2018 15:17:54 +0100 Subject: [PATCH] Keep damage text always vertically centered (noticeable when it's stationary) --- qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc | 4 ++++ xonotic-client.cfg | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc index c6cc40eff..c6fef7633 100644 --- a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc @@ -69,6 +69,7 @@ CLASS(DamageText, Object) delete(this); return; } + vector screen_pos; if (this.m_screen_coords) { screen_pos = this.origin + since_hit * autocvar_cl_damagetext_2d_velocity; @@ -78,6 +79,8 @@ CLASS(DamageText, Object) vector world_pos = this.origin + world_offset.x * v_forward + world_offset.y * v_right + world_offset.z * v_up; screen_pos = project_3d_to_2d(world_pos) + since_hit * autocvar_cl_damagetext_velocity_screen + autocvar_cl_damagetext_offset_screen; } + screen_pos.y += size / 2; + if (screen_pos.z >= 0) { screen_pos.z = 0; vector rgb; @@ -93,6 +96,7 @@ CLASS(DamageText, Object) vector drawfontscale_save = drawfontscale; drawfontscale = (size / autocvar_cl_damagetext_size_max) * '1 1 0'; + screen_pos.y -= drawfontscale.x * size / 2; drawcolorcodedstring2_builtin(screen_pos, this.text, autocvar_cl_damagetext_size_max * '1 1 0', rgb, alpha_, DRAWFLAG_NORMAL); drawfontscale = drawfontscale_save; } diff --git a/xonotic-client.cfg b/xonotic-client.cfg index c229ea3c8..a074ea71a 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -431,7 +431,7 @@ seta cl_damagetext_alpha_start "1" "Damage text initial alpha" seta cl_damagetext_alpha_lifetime "3" "Damage text lifetime in seconds" seta cl_damagetext_velocity_screen "0 0 0" "Damage text move direction (screen coordinates)" seta cl_damagetext_velocity_world "0 0 20" "Damage text move direction (world coordinates relative to player's view)" -seta cl_damagetext_offset_screen "0 -40 0" "Damage text offset (screen coordinates)" +seta cl_damagetext_offset_screen "0 -45 0" "Damage text offset (screen coordinates)" seta cl_damagetext_offset_world "0 0 0" "Damage text offset (world coordinates relative to player's view)" seta cl_damagetext_accumulate_range "30" "Damage text spawned within this range is accumulated" seta cl_damagetext_accumulate_alpha_rel "0.65" "Only update existing damage text when it's above this much percentage (0 to 1) of the starting alpha" -- 2.39.2