// self.armorvalue
// self.sameteam = player is on same team as local client
//
+const float SHOWNAMES_FADESPEED = 4;
void Draw_ShowNames()
{
if(!autocvar_hud_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
}*/
}
- // 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);
iconpos = myPos;
- if(autocvar_hud_shownames_status)
+ if(autocvar_hud_shownames_status && teamplay)
{
if(self.sameteam)
{
}
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);
}
}
-// 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)
{
}
if(sendflags & 2)
{
- WriteByte(MSG_ENTITY, self.health);
+ WriteByte(MSG_ENTITY, the_health);
+ }
+ if(sendflags & 4)
+ {
WriteByte(MSG_ENTITY, self.armorvalue);
}
return TRUE;
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;
}