]> git.xonotic.org Git - voretournament/voretournament.git/commitdiff
Attempt to port the shownames feature from Xonotic (floating names above players...
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 8 Jul 2011 22:50:30 +0000 (01:50 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 8 Jul 2011 22:50:30 +0000 (01:50 +0300)
data/defaultVT.cfg
data/qcsrc/client/Main.qc
data/qcsrc/client/View.qc
data/qcsrc/client/main.qh
data/qcsrc/client/miscfunctions.qc
data/qcsrc/client/progs.src
data/qcsrc/server/ent_cs.qc

index 53935b2c6c66c3be90712f21cc09ac73ead0230c..1baa4ba7dd016215408a657a2fe2b00e5e918029 100644 (file)
@@ -335,6 +335,8 @@ net_connecttimeout 30
 sv_jumpstep 1 // step up stairs while jumping, makes it easier to reach ledges\r
 set ekg 0      "Throw huge amounts of gibs"\r
 \r
+seta sv_shownames_cull_distance 2500 "distance after which to not send origin/health/armor of another player"\r
+\r
 cl_movement 1\r
 cl_stairsmoothspeed 200\r
 cl_forwardspeed $sv_maxspeed\r
@@ -1146,6 +1148,21 @@ seta hud_contents_water_color "0.4 0.3 0.3"
 seta hud_contents_stomach_alpha 0.2 "alpha of the stomach color blend when inside it"\r
 seta hud_contents_stomach_color "0.3 0.2 0"\r
 \r
+seta hud_shownames 1 "draw names and health/armor of nearby players"\r
+seta hud_shownames_enemies 2 "1 = draw names of enemies you point at (TODO), 2 = draw names of all enemies in view"\r
+seta hud_shownames_status 1 "1 = draw health/armor status of teammates"\r
+seta hud_shownames_statusbar_height 4 "height of status bar"\r
+seta hud_shownames_aspect 8 "aspect ratio of total drawing area per name"\r
+seta hud_shownames_fontsize 12 "font size"\r
+seta hud_shownames_decolorize 1 "1 = decolorize name in team games, 2 = decolorize always"\r
+seta hud_shownames_alpha 0.7 "alpha"\r
+seta hud_shownames_resize 1 "enable resizing of the names, then the size cvars will correspond to the maximum size"\r
+seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance"\r
+seta hud_shownames_maxdistance 2500 "alpha/size is 0 at this distance"\r
+seta hud_shownames_antioverlap 1 "if two tags get too close to each other, fade out the one further away from you"\r
+seta hud_shownames_antioverlap_distance 125 "2d distance to other tag after which to fade out"\r
+seta hud_shownames_offset 52 "offset (along z-axis) tag from player origin by this many units"\r
+\r
 sbar_info_pos 50\r
 seta sbar_alpha_bg 0.8 "alpha value of the HUD background"\r
 seta sbar_alpha_fg 1 "alpha value of the HUD foreground items"\r
index e96c53b524adaa13fc19b1bf40d72ecf2ef697bd..cea3273d385a5249596a8d362f26e35609e51d1c 100644 (file)
@@ -657,17 +657,38 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 \r
 // --------------------------------------------------------------------------\r
 // BEGIN OPTIONAL CSQC FUNCTIONS\r
+void Ent_RemoveEntCS()\r
+{\r
+       entcs_receiver[self.sv_entnum] = world;\r
+}\r
 void Ent_ReadEntCS()\r
 {\r
+       float sf;\r
        InterpolateOrigin_Undo();\r
 \r
        self.classname = "entcs_receiver";\r
-       self.sv_entnum = ReadByte() - 1;\r
-       self.origin_x = ReadShort();\r
-       self.origin_y = ReadShort();\r
-       self.origin_z = ReadShort();\r
-       self.angles_y = ReadByte() * 360.0 / 256;\r
-       self.origin_z = self.angles_x = self.angles_z = 0;\r
+       sf = ReadByte();\r
+\r
+       if(sf & 1)\r
+               self.sv_entnum = ReadByte();\r
+       if(sf & 2)\r
+       {\r
+               self.origin_x = ReadShort();\r
+               self.origin_y = ReadShort();\r
+               self.origin_z = ReadShort();\r
+       }\r
+       if(sf & 4)\r
+       {\r
+               self.angles_y = ReadByte() * 360.0 / 256;\r
+               self.angles_x = self.angles_z = 0;\r
+       }\r
+       if(sf & 8)\r
+               self.healthvalue = ReadByte() * 10;\r
+       if(sf & 16)\r
+               self.armorvalue = ReadByte() * 10;\r
+\r
+       entcs_receiver[self.sv_entnum] = self;\r
+       self.entremove = Ent_RemoveEntCS;\r
 \r
        InterpolateOrigin_Note();\r
 }\r
index ae594dc83637c42a7f4f903864ed6dd4945e756f..8a5144fbc8dae7267fb47a60d54b30ee416082ba 100644 (file)
@@ -907,6 +907,7 @@ void CSQC_UpdateView(float w, float h)
                if(self.draw2d)\r
                        self.draw2d();\r
        self = e;\r
+       Draw_ShowNames_All();\r
 \r
        // draw radar\r
        if(\r
index a158bf27f443471ea95ce4fe5e864fefb1482600..eac98e3d9eef674008727965e322212b0259084c 100644 (file)
@@ -177,3 +177,5 @@ float calledhooks;
 \r
 .float ping, ping_packetloss, ping_movementloss;\r
 .float plhealth, plpredator;\r
+\r
+entity entcs_receiver[255]; // 255 is the engine limit on maxclients\r
index 0d72bfec0ec4d9be8e9326f88c87a083170455fb..5e098d9a089f037ea718e1c73c9c7b3b83c5954f 100644 (file)
@@ -390,6 +390,33 @@ string ColorTranslateRGB(string s)
                return s;\r
 }\r
 \r
+string Team_ColorCode(float teamid)\r
+{\r
+    if (teamid == COLOR_TEAM1)\r
+        return "^1";\r
+    else if (teamid == COLOR_TEAM2)\r
+        return "^4";\r
+    else if (teamid == COLOR_TEAM3)\r
+        return "^3";\r
+    else if (teamid == COLOR_TEAM4)\r
+        return "^6";\r
+    else\r
+        return "^7";\r
+}\r
+\r
+// decolorizes and team colors the player name when needed\r
+string playername(string thename, float teamid)\r
+{\r
+    string t;\r
+    if (teamplay)\r
+    {\r
+        t = Team_ColorCode(teamid);\r
+        return strcat(t, strdecolorize(thename));\r
+    }\r
+    else\r
+        return strdecolorize(thename);\r
+}\r
+\r
 float cvar_or(string cv, float v)\r
 {\r
        string s;\r
@@ -691,3 +718,20 @@ void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vect
                R_EndPolygon();\r
        }\r
 }\r
+\r
+const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map\r
+vector getplayerorigin(float pl)\r
+{\r
+       string s;\r
+       entity e;\r
+\r
+       s = getplayerkey(pl, "TEMPHACK_origin");\r
+       if(s != "")\r
+               return stov(s);\r
+\r
+       e = entcs_receiver[pl];\r
+       if(e)\r
+               return e.origin;\r
+\r
+       return GETPLAYERORIGIN_ERROR;\r
+}\r
index be85659422c708ee169a8c42ee81bd2083cd8f88..a5be8b3c39330b3542d7425f10c798fcec0e78f4 100644 (file)
@@ -26,6 +26,7 @@ movetypes.qh
 prandom.qh\r
 bgmscript.qh\r
 \r
+teamplay.qh\r
 main.qh\r
 \r
 sortlist.qc\r
@@ -50,6 +51,9 @@ wall.qc
 modeleffects.qc\r
 target_music.qc\r
 \r
+shownames.qh\r
+shownames.qc\r
+\r
 Main.qc\r
 View.qc\r
 interpolate.qc\r
index 6635689ebc8c304a552e31cb7a201d2724359e3a..128b14a1dc5d049305b29fcb91f7e8cbeca5f6cf 100644 (file)
@@ -31,7 +31,7 @@ float entcs_customize()
        if(other == o)\r
                return FALSE;\r
        if(other.classname == "player")\r
-               if(o.team != other.team)\r
+               if(!teamplay || o.team != other.team)\r
                        if not (radar_showennemies)\r
                                return FALSE;\r
        return TRUE;\r
@@ -39,29 +39,51 @@ float entcs_customize()
 \r
 float entcs_send(entity to, float sf)\r
 {\r
-       entity o;\r
-       o = self.owner;\r
        WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS);\r
-       WriteByte(MSG_ENTITY, num_for_edict(o));\r
-       WriteShort(MSG_ENTITY, o.origin_x);\r
-       WriteShort(MSG_ENTITY, o.origin_y);\r
-       WriteShort(MSG_ENTITY, o.origin_z);\r
-       WriteByte(MSG_ENTITY, o.angles_y * 256.0 / 360);\r
+       WriteByte(MSG_ENTITY, sf);\r
+       if(sf & 1)\r
+               WriteByte(MSG_ENTITY, num_for_edict(self.owner)-1);\r
+       if(sf & 2)\r
+       {\r
+               WriteShort(MSG_ENTITY, self.origin_x);\r
+               WriteShort(MSG_ENTITY, self.origin_y);\r
+               WriteShort(MSG_ENTITY, self.origin_z);\r
+       }\r
+       if(sf & 4)\r
+               WriteByte(MSG_ENTITY, self.angles_y * 256.0 / 360);\r
+       if(sf & 8)\r
+               WriteByte(MSG_ENTITY, self.health / 10); // FIXME use a better scale?\r
+       if(sf & 16)\r
+               WriteByte(MSG_ENTITY, self.armorvalue / 10); // FIXME use a better scale?\r
        return TRUE;\r
 };\r
 \r
 void entcs_think()\r
 {\r
-       self.nextthink = time;\r
+       self.nextthink = time + 0.033333333333; // increase this to like 0.15 once the client can do smoothing\r
 \r
        entity o;\r
        o = self.owner;\r
 \r
-       if(o.origin != self.origin || o.angles != self.angles)\r
+       if(o.origin != self.origin)\r
        {\r
                setorigin(self, o.origin);\r
+               self.SendFlags |= 2;\r
+       }\r
+       if(o.angles_y != self.angles_y)\r
+       {\r
                self.angles = o.angles;\r
-               self.SendFlags |= 1;\r
+               self.SendFlags |= 4;\r
+       }\r
+       if(o.health != self.health)\r
+       {\r
+               self.health = o.health;\r
+               self.SendFlags |= 8;\r
+       }\r
+       if(o.armorvalue != self.armorvalue)\r
+       {\r
+               self.armorvalue = o.armorvalue;\r
+               self.SendFlags |= 16;\r
        }\r
 };\r
 \r