From 9e684977974f9a983e2486c00a35daed362b8e88 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sat, 9 Jul 2011 04:29:27 +0300 Subject: [PATCH] Only show the health and armor of team mates, not enemies. Sadly, the health of all players needs to be sent to the client, and hacked clients could still spy on enemy health / armor. --- data/qcsrc/client/Main.qc | 5 +++-- data/qcsrc/client/main.qh | 1 + data/qcsrc/client/shownames.qc | 21 +++++++++++++-------- data/qcsrc/client/shownames.qh | 1 - data/qcsrc/server/cl_client.qc | 5 +++++ data/qcsrc/server/ent_cs.qc | 4 ++-- 6 files changed, 24 insertions(+), 13 deletions(-) diff --git a/data/qcsrc/client/Main.qc b/data/qcsrc/client/Main.qc index f7b08497..7686d9ec 100644 --- a/data/qcsrc/client/Main.qc +++ b/data/qcsrc/client/Main.qc @@ -683,9 +683,9 @@ void Ent_ReadEntCS() self.angles_x = self.angles_z = 0; } if(sf & 8) - self.healthvalue = ReadByte() * 10; + self.healthvalue = ReadCoord(); if(sf & 16) - self.armorvalue = ReadByte() * 10; + self.armorvalue = ReadCoord(); if(sf & 32) self.predator = ReadByte(); @@ -1060,6 +1060,7 @@ void Ent_Init() g_healthsize = ReadCoord(); armor_max = ReadCoord(); + teamheal_max = ReadCoord(); if(!postinit) PostInit(); diff --git a/data/qcsrc/client/main.qh b/data/qcsrc/client/main.qh index f1e52b94..ccf46ac4 100644 --- a/data/qcsrc/client/main.qh +++ b/data/qcsrc/client/main.qh @@ -170,6 +170,7 @@ float g_vore; float g_balance_vore_swallow_limit; float g_healthsize; float armor_max; +float teamheal_max; //hooks float calledhooks; diff --git a/data/qcsrc/client/shownames.qc b/data/qcsrc/client/shownames.qc index 7dac25a5..fe8f7684 100644 --- a/data/qcsrc/client/shownames.qc +++ b/data/qcsrc/client/shownames.qc @@ -3,7 +3,6 @@ // self.healthvalue // self.armorvalue // self.eaten -// self.sameteam = player is on same team as local client // const float SHOWNAMES_FADESPEED = 4; void Draw_ShowNames(entity ent) @@ -17,7 +16,11 @@ void Draw_ShowNames(entity ent) if(ent.predator) // don't show names for prey return; - if(ent.sameteam || (!ent.sameteam && cvar("hud_shownames_enemies"))) + float sameteam; + if(teamplay && (GetPlayerColor(player_localentnum - 1) == GetPlayerColor(ent.sv_entnum - 1))) + sameteam = TRUE; + + if(sameteam || (!sameteam && cvar("hud_shownames_enemies"))) { ent.origin_z += cvar("hud_shownames_offset"); @@ -25,7 +28,7 @@ void Draw_ShowNames(entity ent) if(g_healthsize) ent.origin_z -= (g_healthsize - ent.healthvalue) * cvar("hud_shownames_offset_healthsize"); - if(!ent.sameteam) + if(!sameteam) { /* WIP, why does trace_ent != ent not work as intended here? if(cvar("hud_shownames_enemies") != 2) // player has to point at enemy if so @@ -64,7 +67,7 @@ void Draw_ShowNames(entity ent) } } - if(!ent.sameteam && trace_endpos != view_origin) // out of view, fade out + if(!sameteam && trace_endpos != view_origin) // out of view, fade out ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime); else if(ent.healthvalue < 1) // dead player, fade out slowly ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * 0.25 * frametime); @@ -127,13 +130,17 @@ void Draw_ShowNames(entity ent) drawfontscale = '1 1 0' * resize; s = textShortenToWidth(s, namewidth, '1 1 0' * cvar("hud_shownames_fontsize"), stringwidth_colors); - if(cvar("hud_shownames_status") && teamplay) - if(ent.sameteam && ent.healthvalue > 0) + if(cvar("hud_shownames_status")) + if(sameteam && ent.healthvalue > 0) { if(ent.armorvalue) s = strcat(s, " (", ftos(ent.healthvalue), "|", ftos(ent.armorvalue), ")"); else s = strcat(s, " (", ftos(ent.healthvalue), ")"); + + // if team healing is enabled, mark the team mate as possible to heal + if(ent.healthvalue < teamheal_max) + s = strcat(s, " [HEAL]"); } float width; @@ -174,14 +181,12 @@ void Draw_ShowNames_All() { e.healthvalue = entcs.healthvalue; e.armorvalue = entcs.armorvalue; - e.sameteam = 1; /* (teamplay && (t == myteam)); */ e.predator = entcs.predator; } else { e.healthvalue = 2342; e.armorvalue = 0; - e.sameteam = 0; e.predator = 0; } diff --git a/data/qcsrc/client/shownames.qh b/data/qcsrc/client/shownames.qh index 0509dd3e..630f8e2e 100644 --- a/data/qcsrc/client/shownames.qh +++ b/data/qcsrc/client/shownames.qh @@ -1,4 +1,3 @@ .float healthvalue; .float armorvalue; .float predator; -.float sameteam; diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index d9b9437d..39b891f2 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -1052,6 +1052,11 @@ float ClientInit_SendEntity(entity to, float sf) armor_max = cvar("g_balance_armor_limit"); WriteCoord(MSG_ENTITY, armor_max); + float teamheal_max; + if(cvar("g_vore") && cvar("g_vore_teamvore") && cvar("g_balance_vore_teamheal")) + teamheal_max = cvar("g_balance_vore_teamheal_stable"); + WriteCoord(MSG_ENTITY, teamheal_max); + return TRUE; } diff --git a/data/qcsrc/server/ent_cs.qc b/data/qcsrc/server/ent_cs.qc index 9fc1ecb5..9bed96b7 100644 --- a/data/qcsrc/server/ent_cs.qc +++ b/data/qcsrc/server/ent_cs.qc @@ -48,9 +48,9 @@ float entcs_send(entity to, float sf) if(sf & 4) WriteByte(MSG_ENTITY, self.angles_y * 256.0 / 360); if(sf & 8) - WriteByte(MSG_ENTITY, self.health / 10); // FIXME use a better scale? + WriteCoord(MSG_ENTITY, self.health); if(sf & 16) - WriteByte(MSG_ENTITY, self.armorvalue / 10); // FIXME use a better scale? + WriteCoord(MSG_ENTITY, self.armorvalue); if(sf & 32) WriteByte(MSG_ENTITY, num_for_edict(self.predator)); return TRUE; -- 2.39.2