From: MirceaKitsune Date: Sat, 6 Oct 2012 14:39:02 +0000 (+0300) Subject: Scoreboard respawn info from my code in Xonotic X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cc045f9d09b57e3ce32ee45f807b18438e410380;p=voretournament%2Fvoretournament.git Scoreboard respawn info from my code in Xonotic --- diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc index 64f428c4..be1cc1e7 100644 --- a/data/qcsrc/client/hud.qc +++ b/data/qcsrc/client/hud.qc @@ -1516,6 +1516,29 @@ void Sbar_DrawScoreboard() pos_y += 1.2 * sbar_fontsize_y; drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL); + // print information about respawn status + float respawn_time = getstatf(STAT_RESPAWN_TIME); + dprint(strcat(ftos(respawn_time), " --------\n")); + 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 * sbar_fontsize_y; + drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL); + } + scoreboard_bottom = pos_y + 2 * sbar_fontsize_y; } diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index 8a3ae4d6..56a50b94 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -294,7 +294,8 @@ const float STAT_SBRING1_TYPE = 61; const float STAT_SBRING1_CLIP = 62; const float STAT_SBRING2_TYPE = 63; const float STAT_SBRING2_CLIP = 64; -const float STAT_HUD = 65; +const float STAT_RESPAWN_TIME = 65; +const float STAT_HUD = 66; const float HUD_NORMAL = 0; const float CTF_STATE_ATTACK = 1; const float CTF_STATE_DEFEND = 2; diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index b41bb1d0..aedf04db 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -2222,6 +2222,7 @@ void SpectateCopy(entity spectatee) { self.stat_sbring1_clip = spectatee.stat_sbring1_clip; self.stat_sbring2_type = spectatee.stat_sbring2_type; self.stat_sbring2_clip = spectatee.stat_sbring2_clip; + self.stat_respawn_time = spectatee.stat_respawn_time; setorigin(self, spectatee.origin); setsize(self, spectatee.mins, spectatee.maxs); SetZoomState(spectatee.zoomstate); @@ -2556,6 +2557,11 @@ void PlayerPreThink (void) self.stat_allow_oldnexbeam = cvar("g_allow_oldnexbeam"); self.stat_leadlimit = cvar("leadlimit"); + if(g_arena || (g_ca && !allowed_to_spawn)) + self.stat_respawn_time = 0; + else + self.stat_respawn_time = self.death_time; + if(frametime) { // physics frames: update anticheat stuff @@ -2793,6 +2799,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; } diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index 85f3e5f7..0109de5e 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -615,6 +615,8 @@ string matchid; .float stat_leadlimit; +.float stat_respawn_time; // shows respawn time, and is negative when awaiting respawn + #ifdef PROFILING float client_cefc_accumulator; float client_cefc_accumulatortime; diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index f3484218..93a16bdd 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -671,6 +671,7 @@ void spawnfunc_worldspawn (void) addstat(STAT_SBRING1_CLIP, AS_FLOAT, stat_sbring1_clip); addstat(STAT_SBRING2_TYPE, AS_INT, stat_sbring2_type); addstat(STAT_SBRING2_CLIP, AS_FLOAT, stat_sbring2_clip); + addstat(STAT_RESPAWN_TIME, AS_FLOAT, stat_respawn_time); next_pingtime = time + 5; InitializeEntity(self, cvar_changes_init, INITPRIO_CVARS);