#define MUTATOR_DAMAGETEXT_H
#ifdef MENUQC
-#include <menu/xonotic/tab.qc>
+#include <menu/xonotic/tab.qh>
#endif
#endif
REGISTER_MUTATOR(damagetext, true);
#if defined(CSQC) || defined(MENUQC)
-AUTOCVAR_SAVE(cl_damagetext, bool, false, _("Draw damage dealt. 0: disabled, 1: enabled"));
-AUTOCVAR_SAVE(cl_damagetext_format, string, "-%3$$d", _("How to format the damage text. 1$ is health, 2$ is armor, 3$ is both"));
-AUTOCVAR_SAVE(cl_damagetext_color, vector, '1 1 0', _("Default 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_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"));
-AUTOCVAR_SAVE(cl_damagetext_offset, vector, '0 -40 0', _("Damage text offset"));
-AUTOCVAR_SAVE(cl_damagetext_accumulate_range, float, 30, _("Damage text spawned within this range is accumulated"));
+// no translatable cvar description please
+AUTOCVAR_SAVE(cl_damagetext, bool, false, "Draw damage dealt where you hit the enemy");
+AUTOCVAR_SAVE(cl_damagetext_format, string, "-{total}", "How to format the damage text. {health}, {armor}, {total}");
+STATIC_INIT(DamageText_LegacyFormat) {
+ if (strstrofs(autocvar_cl_damagetext_format, "{", 0) < 0) autocvar_cl_damagetext_format = "-{total}";
+}
+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_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");
+AUTOCVAR_SAVE(cl_damagetext_offset, vector, '0 -40 0', "Damage text offset");
+AUTOCVAR_SAVE(cl_damagetext_accumulate_range, float, 30, "Damage text spawned within this range is accumulated");
#endif
#ifdef CSQC
Weapon w = DEATH_WEAPONOF(this.m_deathtype);
if (w != WEP_Null) rgb = w.wpcolor;
}
- string s = sprintf(autocvar_cl_damagetext_format, this.m_damage, this.m_armordamage, this.m_damage + this.m_armordamage);
+ string s = autocvar_cl_damagetext_format;
+ s = strreplace("{health}", sprintf("%d", this.m_damage), s);
+ s = strreplace("{armor}", sprintf("%d", this.m_armordamage), s);
+ s = strreplace("{total}", sprintf("%d", this.m_damage + this.m_armordamage), s);
drawcolorcodedstring2(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
}
}
) {
msg_entity = it;
WriteHeader(MSG_ONE, damagetext);
- WriteShort(MSG_ONE, health);
- WriteShort(MSG_ONE, armor);
+ WriteShort(MSG_ONE, rint(health));
+ WriteShort(MSG_ONE, rint(armor));
WriteEntity(MSG_ONE, hit);
WriteCoord(MSG_ONE, location.x);
WriteCoord(MSG_ONE, location.y);