]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Keep damage text always vertically centered (noticeable when it's stationary)
authorterencehill <piuntn@gmail.com>
Sat, 3 Nov 2018 14:17:54 +0000 (15:17 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 3 Nov 2018 14:17:54 +0000 (15:17 +0100)
qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc
xonotic-client.cfg

index c6cc40effeda874c00bafb3f4c949c28e280e2f1..c6fef763350f3c6ac9b766287bfbb048f94b428e 100644 (file)
@@ -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;
         }
index c229ea3c81c418aafe4ecfff6cbac082dcacd19e..a074ea71a6afe16d224c0b02b332f285ef34c3d6 100644 (file)
@@ -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"