]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'origin/mirceakitsune/scoreboard_respawn_info'
authorSamual Lenks <samual@xonotic.org>
Sun, 2 Dec 2012 18:57:06 +0000 (13:57 -0500)
committerSamual Lenks <samual@xonotic.org>
Sun, 2 Dec 2012 18:57:06 +0000 (13:57 -0500)
qcsrc/client/scoreboard.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc

index 48a7217fc703a08b3b7f7fdfab3bc58efea36c2e..913a0bfb34b2eef4d87dc640ae0636b9e199681b 100644 (file)
@@ -1374,9 +1374,30 @@ void HUD_DrawScoreboard()
                }
        }
 
-
        pos_y += 1.2 * hud_fontsize_y;
        drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, hud_fontsize)), str, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
 
+       // print information about respawn status
+       float respawn_time = getstatf(STAT_RESPAWN_TIME);
+       if(respawn_time)
+       {
+               if(respawn_time < 0)
+               {
+                       // a negative number means we are awaiting respawn, time value is still the same
+                       respawn_time *= -1; // remove mark now that we checked it
+                       if(time >= respawn_time) // don't show a negative value while the server is respawning the player (lag)
+                               str = strcat("^1Respawning...");
+                       else
+                               str = strcat("^1Respawning in ^3", ftos_decimals(respawn_time - time, 2), "^1 seconds...");
+               }
+               else if(time < respawn_time)
+                       str = strcat("You are dead, wait ^3", ftos_decimals(respawn_time - time, 2), "^7 seconds before respawning");
+               else if(time >= respawn_time)
+                       str = strcat("You are dead, press ^2", getcommandkey("primary fire", "+fire"), "^7 to respawn");
+
+               pos_y += 1.2 * hud_fontsize_y;
+               drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, hud_fontsize)), str, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+       }
+
        scoreboard_bottom = pos_y + 2 * hud_fontsize_y;
 }
index c270b61a96efa51308b779c733231f2e6284dd47..75f5a0bde762037387dbeb344989a47b1409bc01 100644 (file)
@@ -179,6 +179,8 @@ const float STAT_VEHICLESTAT_RELOAD2 = 66;
 const float STAT_SECRETS_TOTAL = 70;
 const float STAT_SECRETS_FOUND = 71;
 
+const float STAT_RESPAWN_TIME = 72;
+
 // mod stats (1xx)
 const float STAT_REDALIVE = 100;
 const float STAT_BLUEALIVE = 101;
index 9d6bcf798d8b3026e6fb542731491923ba99b715..101e35cae2718d4702f43301b7061a4dbd138ae8 100644 (file)
@@ -2167,6 +2167,7 @@ void SpectateCopy(entity spectatee) {
        self.dmg_inflictor = spectatee.dmg_inflictor;
        self.v_angle = spectatee.v_angle;
        self.angles = spectatee.v_angle;
+       self.stat_respawn_time = spectatee.stat_respawn_time;
        if(!self.BUTTON_USE)
                self.fixangle = TRUE;
        setorigin(self, spectatee.origin);
@@ -2558,6 +2559,11 @@ void PlayerPreThink (void)
        self.stat_allow_oldnexbeam = autocvar_g_allow_oldnexbeam;
        self.stat_leadlimit = autocvar_leadlimit;
 
+       if(g_arena || (g_ca && !allowed_to_spawn))
+               self.stat_respawn_time = 0;
+       else
+               self.stat_respawn_time = self.respawn_time;
+
        if(frametime)
        {
                // physics frames: update anticheat stuff
@@ -2730,6 +2736,11 @@ void PlayerPreThink (void)
                                }
                                ShowRespawnCountdown();
                        }
+
+                       // if respawning, invert stat_respawn_time to indicate this, the client translates it
+                       if(self.deadflag == DEAD_RESPAWNING && self.stat_respawn_time > 0)
+                               self.stat_respawn_time *= -1;
+
                        return;
                }
                // FIXME from now on self.deadflag is always 0 (and self.health is never < 1)
index 9068fa75bf53e95400df5e635e8551faa3ae3a2c..d7772e5090d0fda499eb14eee8f3544b298bf007 100644 (file)
@@ -647,6 +647,8 @@ float serverflags;
 .entity muzzle_flash;
 .float misc_bulletcounter;     // replaces uzi & hlac bullet counter.
 
+.float stat_respawn_time; // shows respawn time, and is negative when awaiting respawn
+
 void PlayerUseKey();
 
 typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t;
index 4cd5cc810a1c9f456bc372c0e8106e9b2d274488..69bf57d51b4af98e37a6f79e55d45cdc4cffe841 100644 (file)
@@ -830,6 +830,9 @@ void spawnfunc_worldspawn (void)
        // secrets
        addstat(STAT_SECRETS_TOTAL, AS_FLOAT, stat_secrets_total);
        addstat(STAT_SECRETS_FOUND, AS_FLOAT, stat_secrets_found);
+
+       // misc
+       addstat(STAT_RESPAWN_TIME, AS_FLOAT, stat_respawn_time);
        
        next_pingtime = time + 5;