From: Mario Date: Sun, 19 Jul 2020 14:16:33 +0000 (+1000) Subject: Display the remaining round time in the panel next to the Survivor/Hunter text, rathe... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=38b5fc529a1a324faf5cf8a15003b270ad5053d9;p=xonotic%2Fxonotic-data.pk3dir.git Display the remaining round time in the panel next to the Survivor/Hunter text, rather than faking the timelimit --- diff --git a/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc b/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc index 1fede80db..8aadbe23e 100644 --- a/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc +++ b/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc @@ -28,8 +28,30 @@ void HUD_Mod_Survival(vector pos, vector mySize) return; } + string time_text = string_null; + vector timer_color = '1 1 1'; + if(!STAT(GAME_STOPPED) && !warmup_stage && STAT(SURVIVAL_ROUNDTIMER) > 0) + { + float timeleft = max(0, STAT(SURVIVAL_ROUNDTIMER) - time); + timeleft = ceil(timeleft); + float minutesLeft = floor(timeleft / 60); + time_text = seconds_tostring(timeleft); + if(intermission_time || minutesLeft >= 5 || warmup_stage || STAT(SURVIVAL_ROUNDTIMER) == 0) + timer_color = '1 1 1'; //white + else if(minutesLeft >= 1) + timer_color = '1 1 0'; //yellow + else + timer_color = '1 0 0'; //red + } + //drawpic_aspect_skin(pos, player_icon, vec2(0.5 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos, player_text, vec2(mySize.x, mySize.y), player_color, panel_fg_alpha, DRAWFLAG_NORMAL); + if(!time_text) + drawstring_aspect(pos, player_text, vec2(mySize.x, mySize.y), player_color, panel_fg_alpha, DRAWFLAG_NORMAL); + else + { + drawstring_aspect(pos, player_text, vec2(0.5 * mySize.x, mySize.y), player_color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(pos + eX * (0.5 * mySize.x), time_text, vec2(0.5 * mySize.x, mySize.y), timer_color, panel_fg_alpha, DRAWFLAG_NORMAL); + } } REGISTER_MUTATOR(cl_sv, true); diff --git a/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc index 757044dbf..130813b99 100644 --- a/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc +++ b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc @@ -10,6 +10,7 @@ void surv_FakeTimeLimit(entity e, float t) { if(!IS_REAL_CLIENT(e)) return; +#if 0 msg_entity = e; WriteByte(MSG_ONE, 3); // svc_updatestat WriteByte(MSG_ONE, 236); // STAT_TIMELIMIT @@ -17,6 +18,9 @@ void surv_FakeTimeLimit(entity e, float t) WriteCoord(MSG_ONE, autocvar_timelimit); else WriteCoord(MSG_ONE, (t + 1) / 60); +#else + STAT(SURVIVAL_ROUNDTIMER, e) = t; +#endif } void nades_Clear(entity player); diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 9ecac9f7c..07b0354ca 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -396,3 +396,5 @@ REGISTER_STAT(GUNALIGN, int) #ifdef SVQC SPECTATE_COPYFIELD(_STAT(GUNALIGN)) #endif + +REGISTER_STAT(SURVIVAL_ROUNDTIMER, float)