From: Martin Taibr Date: Sat, 19 Nov 2016 23:04:06 +0000 (+0100) Subject: size based on amount of damage X-Git-Tag: xonotic-v0.8.2~169^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b7a8c1f24d2c536af367bf966a0aa931188f71ed;p=xonotic%2Fxonotic-data.pk3dir.git size based on amount of damage --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 5ca7f4e54..cb9aebd32 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -789,7 +789,10 @@ seta cl_damagetext_format_verbose 0 "{health} shows {potential_health} too when seta cl_damagetext_format_hide_redundant 0 "hide {armor} if 0; hide {potential} and {potential_health} when same as actual" seta cl_damagetext_color "1 1 0" "Damage text color" seta cl_damagetext_color_per_weapon "0" "Damage text uses weapon color" -seta cl_damagetext_size "8" "Damage text font size" +seta cl_damagetext_size_min 8 "Damage text font size for small damage" +seta cl_damagetext_size_min_damage 0 "How much damage is considered small" +seta cl_damagetext_size_max 16 "Damage text font size for large damage" +seta cl_damagetext_size_max_damage 100 "How much damage is considered large" 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 "0 0 20" "Damage text move direction" diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc index 900e42897..a5c60c9a9 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -23,7 +23,10 @@ STATIC_INIT(DamageText_LegacyFormat) { } AUTOCVAR_SAVE(cl_damagetext_color, vector, '1 1 0', "Damage text color"); AUTOCVAR_SAVE(cl_damagetext_color_per_weapon, bool, false, "Damage text uses weapon color"); -AUTOCVAR_SAVE(cl_damagetext_size, float, 8, "Damage text font size"); +AUTOCVAR_SAVE(cl_damagetext_size_min, float, 8, "Damage text font size for small damage"); +AUTOCVAR_SAVE(cl_damagetext_size_min_damage, float, 0, "How much damage is considered small"); +AUTOCVAR_SAVE(cl_damagetext_size_max, float, 16, "Damage text font size for large damage"); +AUTOCVAR_SAVE(cl_damagetext_size_max_damage, float, 100, "How much damage is considered large"); AUTOCVAR_SAVE(cl_damagetext_alpha_start, float, 1, "Damage text initial alpha"); AUTOCVAR_SAVE(cl_damagetext_alpha_lifetime, float, 3, "Damage text lifetime in seconds"); AUTOCVAR_SAVE(cl_damagetext_velocity, vector, '0 0 20', "Damage text move direction"); @@ -38,7 +41,7 @@ AUTOCVAR_SAVE(cl_damagetext_friendlyfire_color, vector, '1 0 0', "Damage CLASS(DamageText, Object) ATTRIB(DamageText, m_color, vector, autocvar_cl_damagetext_color); ATTRIB(DamageText, m_color_friendlyfire, vector, autocvar_cl_damagetext_friendlyfire_color); - ATTRIB(DamageText, m_size, float, autocvar_cl_damagetext_size); + ATTRIB(DamageText, m_size, float, autocvar_cl_damagetext_size_min); ATTRIB(DamageText, alpha, float, autocvar_cl_damagetext_alpha_start); ATTRIB(DamageText, fade_rate, float, 1 / autocvar_cl_damagetext_alpha_lifetime); ATTRIB(DamageText, velocity, vector, autocvar_cl_damagetext_velocity); @@ -119,6 +122,17 @@ CLASS(DamageText, Object) ), s); if (this.text) strunzone(this.text); this.text = strzone(s); + + if (potential < autocvar_cl_damagetext_size_min_damage) { + this.m_size = autocvar_cl_damagetext_size_min; + } else if (potential > autocvar_cl_damagetext_size_max_damage) { + this.m_size = autocvar_cl_damagetext_size_max; + } else { + float size_range = autocvar_cl_damagetext_size_max - autocvar_cl_damagetext_size_min; + float damage_range = autocvar_cl_damagetext_size_max_damage - autocvar_cl_damagetext_size_min_damage; + float scale_factor = size_range / damage_range; + this.m_size = (potential - autocvar_cl_damagetext_size_min_damage) * scale_factor + autocvar_cl_damagetext_size_min; + } } CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor, int _potential_damage, int _deathtype, bool _friendlyfire) { @@ -251,9 +265,14 @@ CLASS(XonoticDamageTextSettings, XonoticTab) this.gotoRC(this, 0, 1); this.setFirstColumn(this, this.currentColumn); this.TD(this, 1, 3, makeXonoticCheckBox(0, "cl_damagetext", _("Draw damage numbers"))); this.TR(this); - this.TD(this, 1, 1, e = makeXonoticTextLabel(0, _("Font size:"))); + this.TD(this, 1, 1, e = makeXonoticTextLabel(0, _("Font size minimum:"))); + setDependent(e, "cl_damagetext", 1, 1); + this.TD(this, 1, 2, e = makeXonoticSlider(0, 50, 1, "cl_damagetext_size_min")); + setDependent(e, "cl_damagetext", 1, 1); + this.TR(this); + this.TD(this, 1, 1, e = makeXonoticTextLabel(0, _("Font size maximum:"))); setDependent(e, "cl_damagetext", 1, 1); - this.TD(this, 1, 2, e = makeXonoticSlider(0, 50, 1, "cl_damagetext_size")); + this.TD(this, 1, 2, e = makeXonoticSlider(0, 50, 1, "cl_damagetext_size_max")); setDependent(e, "cl_damagetext", 1, 1); this.TR(this); this.TD(this, 1, 1, e = makeXonoticTextLabel(0, _("Accumulate range:")));