]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/miscfunctions.qc
Attempt to port the shownames feature from Xonotic (floating names above players...
[voretournament/voretournament.git] / data / qcsrc / client / miscfunctions.qc
index 0d72bfec0ec4d9be8e9326f88c87a083170455fb..5e098d9a089f037ea718e1c73c9c7b3b83c5954f 100644 (file)
@@ -390,6 +390,33 @@ string ColorTranslateRGB(string s)
                return s;\r
 }\r
 \r
                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
 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_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