From: Samual Date: Tue, 10 Jan 2012 17:47:24 +0000 (-0500) Subject: Make showname tags fade out when a player is dead (according to csqcplayers) X-Git-Tag: xonotic-v0.6.0~188^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2dccec3be006cca9a59b9ad8402a94a6f9290a1e;p=xonotic%2Fxonotic-data.pk3dir.git Make showname tags fade out when a player is dead (according to csqcplayers) --- diff --git a/qcsrc/client/Defs.qc b/qcsrc/client/Defs.qc index 5282910a2..e4519b2b3 100644 --- a/qcsrc/client/Defs.qc +++ b/qcsrc/client/Defs.qc @@ -271,3 +271,5 @@ float nex_charge_movingavg; float serverflags; float uid2name_dialog; + +.float csqcmodel_isdead; // used by shownames and miscfunctions (float getplayerisdead(float) {}) to know when a player is dead \ No newline at end of file diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 7204981bd..60a56ad5a 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -207,8 +207,6 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer) .float csqcmodel_saveframe4; .float csqcmodel_framecount; -.float csqcmodel_isdead; // for utility code - #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1) void CSQCPlayer_FallbackFrame_PreUpdate(void) { diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 2bc20e951..93a47f50e 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -591,3 +591,14 @@ vector getplayerorigin(float pl) return GETPLAYERORIGIN_ERROR; } + +float getplayerisdead(float pl) +{ + entity e; + + e = CSQCModel_server2csqc(pl + 1); + if(e) + return e.csqcmodel_isdead; + + return FALSE; +} \ No newline at end of file diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index d5e24888d..c2bff62c8 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -5,7 +5,8 @@ // self.sameteam = player is on same team as local client // self.fadedelay = time to wait before name tag starts fading in for enemies // self.pointtime = last time you pointed at this player -// +// self.csqcmodel_isdead = value of csqcmodel_isdead to know when the player is dead or not + const float SHOWNAMES_FADESPEED = 4; const float SHOWNAMES_FADEDELAY = 0.4; void Draw_ShowNames(entity ent) @@ -90,7 +91,7 @@ void Draw_ShowNames(entity ent) ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime); ent.fadedelay = 0; // reset fade in delay, enemy has left the view } - else if(ent.healthvalue < 1) // dead player, fade out slowly + else if(ent.csqcmodel_isdead) // dead player, fade out slowly ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * 0.25 * frametime); else if(overlap) // tag overlap detected, fade out ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime); @@ -217,6 +218,8 @@ void Draw_ShowNames_All() e.origin = getplayerorigin(i); if(e.origin == GETPLAYERORIGIN_ERROR) continue; + + e.csqcmodel_isdead = getplayerisdead(i); Draw_ShowNames(e); } diff --git a/qcsrc/client/shownames.qh b/qcsrc/client/shownames.qh index adbfa5712..6e3f899dd 100644 --- a/qcsrc/client/shownames.qh +++ b/qcsrc/client/shownames.qh @@ -2,4 +2,4 @@ .float armorvalue; .float sameteam; .float fadedelay; -.float pointtime; +.float pointtime; \ No newline at end of file