Skip to content

Refactor damagetext to use a new linked list instead of proximity search and fix 2D and 3D damagetexts not accumulating

Dr. Jaska requested to merge drjaska/damagetext into master

3D DamageText entities are no longer searched for based on cl_damagetext_accumulate_range "30" "Damage text spawned within this range is accumulated", they are in a new IntrusiveList and identified by the receiving target identified by networked server entity ID.

2D DT entities are no longer in g_drawables_2d IL but in the same IL as 3D DT. I also fixed 2D and 3D DTs not accumulating by giving their constructor and updating functions a new parameter which dictates whether they are 2D or 3D, only the NET_HANDLE for them can change 2D type to 3D or vice versa and thus this should be safe as they do not reuse their old coordinates (3D world coordinates vs. on-screen 2D coordinates reuse the same variable) when converted.

DamageTexts are no longer made impure as they do not need to be searched for based on proximity.

Fixes #2861 (closed) and DP master is able to accumulate DTs.

Even better fix for #1994 (closed) than the better fix as it abolishes proximity searches even in div0-stable and moving targets accumulate damage consistently.

Re-enabled DTs for fire Damage over Time and Vengeance buffs as DT accumulation is much better now. "IIRC there used to be a bug where burning could cause a lot of 0 damage texts to be spammed (especially bad on a moving player due to that radius search). Maybe someone used the nuclear option to squash it..." -bones_was_here

DTs are now centered, I changed cl_damagetext_offset_world default value away from "0 0 0" to not introduce a major change as it tries to keep damage texts on the right side of the players still. Centering enables people to have them at the center above their heads or somewhere else even with more complicated format strings. Format strings also have their color codes and leading and trailing spaces ignored for centering so that for example cl_damagetext_format "^1{total}^3 {potential}" can display centered red80 or centered red20 yellow80. I thought about creating a new format string for differently colored %d (%d) as currently it's a choice between having different colors for them or () around potential but I haven't yet followed through with this.

Removed ancient outdated backwards compatibility from times where it was necessary to give players cl_damagetext* cvars as they didn't yet have them on stable builds. If cvar descriptions are updated now they only need to be updated in a single place.

It's debatable whether it's better to have all CSQC DTs in a single IntrusiveList which is looped over to find the right DT as it'll be a very small list for in-match players. There was an idea for having pointers from entities to their DTs but it runs into some problems with culling and I don't know if it'd be worth it or not to have for in-match players' frames VS. code readability. AFAIK it'd be a micro-optimization and probably a premature one.

Edited by Dr. Jaska

Merge request reports