self.angles_y = ReadByte() * 360.0 / 256;
self.angles_x = self.angles_z = 0;
}
+ if(sf & 8)
+ self.healthvalue = ReadByte() * 10;
+ if(sf & 16)
+ self.armorvalue = ReadByte() * 10;
+ if(sf & 128) // same team
+ self.sameteam = TRUE;
+ else
+ self.sameteam = FALSE;
entcs_receiver[self.sv_entnum] = self;
self.entremove = Ent_RemoveEntCS;
+ self.draw2d = Draw_ShowNames;
InterpolateOrigin_Note();
}
}
}
-void Ent_ShowNames()
-{
- float sf;
-
- // entity init, TODO can this be done only once somehow?
- self.the_entnum = ReadByte(); // TODO: fixme to only send once somehow
- self.draw2d = Draw_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();
-
- if(sf & 1)
- {
- self.healthvalue = ReadByte() * 10;
- }
- if(sf & 2)
- {
- self.armorvalue = ReadByte() * 10;
- }
-
- if(sf & 128) // same team
- self.sameteam = TRUE;
- else
- self.sameteam = FALSE;
-}
-
// CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
// The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
void Ent_RadarLink();
case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
- case ENT_CLIENT_SHOWNAMES: Ent_ShowNames(); break;
default:
//error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
if(!autocvar_hud_shownames)
return;
- if(self.the_entnum == player_localentnum && !autocvar_chase_active)
+ if(self.sv_entnum == player_localentnum && !autocvar_chase_active)
return;
if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
{
- self.origin = getplayerorigin(self.the_entnum-1);
+ self.origin = getplayerorigin(self.sv_entnum-1);
self.origin_z += autocvar_hud_shownames_offset;
if(!self.sameteam)
}
string s;
- s = GetPlayerName(self.the_entnum-1);
+ s = GetPlayerName(self.sv_entnum-1);
if((autocvar_hud_shownames_decolorize == 1 && teamplay) || autocvar_hud_shownames_decolorize == 2)
- s = playername(s, GetPlayerColor(self.the_entnum-1));
+ s = playername(s, GetPlayerColor(self.sv_entnum-1));
drawfontscale = '1 1 0' * resize;
s = textShortenToWidth(s, namewidth, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
float autocvar_sv_airstopaccelerate;
float autocvar_sv_airstrafeaccel_qw;
float autocvar_sv_airstrafeaccelerate;
-float autocvar_sv_allow_shownames;
float autocvar_sv_autoscreenshot;
float autocvar_sv_cheats;
float autocvar_sv_curl_serverpackages_auto;
float autocvar_welcome_message_time;
float autocvar_sv_gameplayfix_gravityunaffectedbyticrate;
float autocvar_g_trueaim_minrange;
-float autocvar_sv_shownames_cull_distance;
}
else
self.frags = FRAGS_SPECTATOR;
-
- if(self.shownames)
- remove(self.shownames);
}
void FixPlayermodel()
PutObserverInServer ();
}
- if(!self.shownames)
- {
- self.shownames = spawn();
- self.shownames.owner = self;
- self.shownames.think = shownames_think;
- self.shownames.nextthink = time;
- Net_LinkEntity(self.shownames, FALSE, 0, SendEntity_ShowNames);
- }
-
//if(g_ctf)
// ctf_playerchanged();
}
self.playerid = 0;
ReadyCount();
- remove(self.shownames);
-
// free cvars
GetCvars(-1);
}
}
}
-// sendflags use: 1 = health (value is 0 or 1 for dead/alive on enemies), 2 = 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 if(self.owner.health >= 1)
- the_health = 1;
-
- WriteByte(MSG_ENTITY, sendflags);
- if(sendflags & 1)
- {
- WriteByte(MSG_ENTITY, the_health);
- }
- if(sendflags & 2)
- {
- WriteByte(MSG_ENTITY, self.armorvalue);
- }
- return TRUE;
-}
-
-void shownames_think()
-{
- self.origin = self.owner.origin + '0 0 1' * 48;
- if(self.health != max(0, ceil(self.owner.health/10)))
- {
- self.health = max(0, ceil(self.owner.health/10));
- self.SendFlags |= 1;
- }
- if(self.armorvalue != max(0, ceil(self.owner.armorvalue/10)))
- {
- self.armorvalue = max(0, ceil(self.owner.armorvalue/10));
- self.SendFlags |= 2;
- }
- self.nextthink = time;
-}
-
.float muted; // to be used by prvm_edictset server playernumber muted 1
float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol)
// message "": do not say, just test flood control
.entity muzzle_flash;
.float misc_bulletcounter; // replaces uzi & hlac bullet counter.
-
-.entity shownames;
-void shownames_think();
float entcs_send(entity to, float sf)
{
- entity o;
- o = self.owner;
+ sf |= 128;
+ if(teams_matter && !radar_showennemies)
+ if(to.team != self.team)
+ sf &~= (8 | 16 | 128); // don't send h/a for enemies
+
WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS);
WriteByte(MSG_ENTITY, sf);
if(sf & 1)
- WriteByte(MSG_ENTITY, num_for_edict(o));
+ WriteByte(MSG_ENTITY, num_for_edict(self.owner));
if(sf & 2)
{
- WriteShort(MSG_ENTITY, o.origin_x);
- WriteShort(MSG_ENTITY, o.origin_y);
- WriteShort(MSG_ENTITY, o.origin_z);
+ WriteShort(MSG_ENTITY, self.origin_x);
+ WriteShort(MSG_ENTITY, self.origin_y);
+ WriteShort(MSG_ENTITY, self.origin_z);
}
if(sf & 4)
- WriteByte(MSG_ENTITY, o.angles_y * 256.0 / 360);
+ WriteByte(MSG_ENTITY, self.angles_y * 256.0 / 360);
+ if(sf & 8)
+ WriteByte(MSG_ENTITY, self.health / 10); // FIXME use a better scale?
+ if(sf & 16)
+ WriteByte(MSG_ENTITY, self.armorvalue / 10); // FIXME use a better scale?
return TRUE;
};
self.angles = o.angles;
self.SendFlags |= 4;
}
+ if(o.health != self.health)
+ {
+ self.health = o.health;
+ self.SendFlags |= 8;
+ }
+ if(o.armorvalue != self.armorvalue)
+ {
+ self.armorvalue = o.armorvalue;
+ self.SendFlags |= 16;
+ }
};
entity attach_entcs()