From: FruitieX Date: Sun, 1 May 2011 12:48:33 +0000 (+0300) Subject: Fade out tags of dead players, split health/armor values into two separate sendflags... X-Git-Tag: xonotic-v0.5.0~267 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bb996f6e8a57eff26bad32bed789bd7b5ee06313;p=xonotic%2Fxonotic-data.pk3dir.git Fade out tags of dead players, split health/armor values into two separate sendflags and send 1 as health value if player is enemy and alive --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 9897ebf01..ddace6382 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -930,6 +930,7 @@ void Ent_ShowNames() //self.movetype = MOVETYPE_FLY; // movetype needed so we can traceline? self.mins = '-20 -20 -24'; self.maxs = '20 20 45'; + self.classname = "shownames_tag"; sf = ReadByte(); @@ -942,6 +943,9 @@ void Ent_ShowNames() if(sf & 2) { self.healthvalue = ReadByte(); + } + if(sf & 4) + { self.armorvalue = ReadByte(); } diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index 1c3eeb629..ede0caa38 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -4,6 +4,7 @@ // self.armorvalue // self.sameteam = player is on same team as local client // +const float SHOWNAMES_FADESPEED = 4; void Draw_ShowNames() { if(!autocvar_hud_shownames) @@ -16,15 +17,6 @@ void Draw_ShowNames() if(!self.sameteam) { traceline(self.origin, view_origin, 1, self); - if(trace_endpos != view_origin) // fade out - { - self.alpha = max(0, self.alpha - 4 * frametime); - if(!self.alpha) - return; - } - else // fade in - self.alpha = min(1, self.alpha + 4 * frametime); - /* WIP, why does trace_ent != self not work as intended here? if(autocvar_hud_shownames_enemies != 2) // player has to point at enemy if so @@ -36,7 +28,15 @@ void Draw_ShowNames() }*/ } - // otherwise, increase alpha until 1 + if(!self.sameteam && trace_endpos != view_origin) // out of view, fade out + self.alpha = max(0, self.alpha - SHOWNAMES_FADESPEED * frametime); + else if(!self.healthvalue) // dead player, fade out slowly + self.alpha = max(0, self.alpha - SHOWNAMES_FADESPEED * 0.25 * frametime); + else // fade in + self.alpha = min(1, self.alpha + SHOWNAMES_FADESPEED * frametime); + + if(!self.alpha) + return; float dist; dist = vlen(self.origin - view_origin); @@ -82,7 +82,7 @@ void Draw_ShowNames() iconpos = myPos; - if(autocvar_hud_shownames_status) + if(autocvar_hud_shownames_status && teamplay) { if(self.sameteam) { @@ -104,7 +104,7 @@ void Draw_ShowNames() } drawresetcliparea(); } - else if(autocvar_hud_shownames_status == 2 && teamplay) + else if(autocvar_hud_shownames_status == 2) { iconsize = eX * 2 * mySize_y + eY * mySize_y; drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL); diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index ef3c67db1..27589fd32 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -732,17 +732,21 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht } } -// sendflags use: 1 = origin, 2 = health/armor, 0x80 = same team (includes health), 4 = entity out of range/culled +// sendflags use: 1 = origin, 2 = health (0 or 1 for dead/alive on enemies), 4 = armor, 0x80 = same team (includes health) float SendEntity_ShowNames(entity to, float sendflags) { + float the_health; + the_health = self.health; + WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES); WriteByte(MSG_ENTITY, num_for_edict(self.owner)); sendflags = sendflags & 127; if(teams_matter && self.owner.team == to.team) sendflags |= 128; - else - sendflags &~= 2; + else if(self.owner.health >= 1) + the_health = 1; + WriteByte(MSG_ENTITY, sendflags); if(sendflags & 1) { @@ -752,7 +756,10 @@ float SendEntity_ShowNames(entity to, float sendflags) } if(sendflags & 2) { - WriteByte(MSG_ENTITY, self.health); + WriteByte(MSG_ENTITY, the_health); + } + if(sendflags & 4) + { WriteByte(MSG_ENTITY, self.armorvalue); } return TRUE; @@ -772,6 +779,11 @@ void shownames_think() self.armorvalue = max(0, floor(self.owner.armorvalue)); self.SendFlags |= 2; } + if(self.armorvalue != max(0, floor(self.owner.armorvalue))) + { + self.armorvalue = max(0, floor(self.owner.armorvalue)); + self.SendFlags |= 4; + } self.nextthink = time; }