]> de.git.xonotic.org Git - voretournament/voretournament.git/commitdiff
Scoreboard respawn info from my code in Xonotic
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 6 Oct 2012 14:39:02 +0000 (17:39 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 6 Oct 2012 14:39:02 +0000 (17:39 +0300)
data/qcsrc/client/hud.qc
data/qcsrc/common/constants.qh
data/qcsrc/server/cl_client.qc
data/qcsrc/server/defs.qh
data/qcsrc/server/g_world.qc

index 64f428c4e603a02611a081013fc4d67e39ac252f..be1cc1e7204dfac692a3734e36eca97c3e4cbbfe 100644 (file)
@@ -1516,6 +1516,29 @@ void Sbar_DrawScoreboard()
        pos_y += 1.2 * sbar_fontsize_y;\r
        drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
+       // print information about respawn status\r
+       float respawn_time = getstatf(STAT_RESPAWN_TIME);\r
+       dprint(strcat(ftos(respawn_time), " --------\n"));\r
+       if(respawn_time)\r
+       {\r
+               if(respawn_time < 0)\r
+               {\r
+                       // a negative number means we are awaiting respawn, time value is still the same\r
+                       respawn_time *= -1; // remove mark now that we checked it\r
+                       if(time >= respawn_time) // don't show a negative value while the server is respawning the player (lag)\r
+                               str = strcat("^1Respawning...");\r
+                       else\r
+                               str = strcat("^1Respawning in ^3", ftos_decimals(respawn_time - time, 2), "^1 seconds...");\r
+               }\r
+               else if(time < respawn_time)\r
+                       str = strcat("You are dead, wait ^3", ftos_decimals(respawn_time - time, 2), "^7 seconds before respawning");\r
+               else if(time >= respawn_time)\r
+                       str = strcat("You are dead, press ^2", getcommandkey("primary fire", "+fire"), "^7 to respawn");\r
+\r
+               pos_y += 1.2 * sbar_fontsize_y;\r
+               drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+       }\r
+\r
        scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;\r
 }\r
 \r
index 8a3ae4d62648276cb5c6dd385f4193adc0a192f1..56a50b94937b8ae2d7e98c7334cf7d6d95d87d17 100644 (file)
@@ -294,7 +294,8 @@ const float STAT_SBRING1_TYPE = 61;
 const float STAT_SBRING1_CLIP = 62;\r
 const float STAT_SBRING2_TYPE = 63;\r
 const float STAT_SBRING2_CLIP = 64;\r
-const float STAT_HUD = 65;\r
+const float STAT_RESPAWN_TIME = 65;\r
+const float STAT_HUD = 66;\r
 const float HUD_NORMAL = 0;\r
 const float CTF_STATE_ATTACK = 1;\r
 const float CTF_STATE_DEFEND = 2;\r
index b41bb1d06110f9aedd67ab6ba17801398635a783..aedf04dbb1acbc944352f4edabeb54cdd8debddf 100644 (file)
@@ -2222,6 +2222,7 @@ void SpectateCopy(entity spectatee) {
        self.stat_sbring1_clip = spectatee.stat_sbring1_clip;\r
        self.stat_sbring2_type = spectatee.stat_sbring2_type;\r
        self.stat_sbring2_clip = spectatee.stat_sbring2_clip;\r
+       self.stat_respawn_time = spectatee.stat_respawn_time;\r
        setorigin(self, spectatee.origin);\r
        setsize(self, spectatee.mins, spectatee.maxs);\r
        SetZoomState(spectatee.zoomstate);\r
@@ -2556,6 +2557,11 @@ void PlayerPreThink (void)
        self.stat_allow_oldnexbeam = cvar("g_allow_oldnexbeam");\r
        self.stat_leadlimit = cvar("leadlimit");\r
 \r
+       if(g_arena || (g_ca && !allowed_to_spawn))\r
+               self.stat_respawn_time = 0;\r
+       else\r
+               self.stat_respawn_time = self.death_time;\r
+\r
        if(frametime)\r
        {\r
                // physics frames: update anticheat stuff\r
@@ -2793,6 +2799,11 @@ void PlayerPreThink (void)
                                }\r
                                ShowRespawnCountdown();\r
                        }\r
+\r
+                       // if respawning, invert stat_respawn_time to indicate this, the client translates it\r
+                       if(self.deadflag == DEAD_RESPAWNING && self.stat_respawn_time > 0)\r
+                               self.stat_respawn_time *= -1;\r
+\r
                        return;\r
                }\r
 \r
index 85f3e5f7e5dbc4d2abf2babd6bfb3c13b3434506..0109de5eb9dc8d6b05de27a7534385311416fcb7 100644 (file)
@@ -615,6 +615,8 @@ string matchid;
 \r
 .float stat_leadlimit;\r
 \r
+.float stat_respawn_time; // shows respawn time, and is negative when awaiting respawn\r
+\r
 #ifdef PROFILING\r
 float client_cefc_accumulator;\r
 float client_cefc_accumulatortime;\r
index f34842182bd8be2e49eb1c6d48cab100e2015fca..93a16bdd98c9b75bc714caacb553087c850c872f 100644 (file)
@@ -671,6 +671,7 @@ void spawnfunc_worldspawn (void)
        addstat(STAT_SBRING1_CLIP, AS_FLOAT, stat_sbring1_clip);\r
        addstat(STAT_SBRING2_TYPE, AS_INT, stat_sbring2_type);\r
        addstat(STAT_SBRING2_CLIP, AS_FLOAT, stat_sbring2_clip);\r
+       addstat(STAT_RESPAWN_TIME, AS_FLOAT, stat_respawn_time);\r
        next_pingtime = time + 5;\r
        InitializeEntity(self, cvar_changes_init, INITPRIO_CVARS);\r
 \r