From: Mario Date: Sun, 12 Jul 2020 19:28:26 +0000 (+1000) Subject: Update survival status to not use a 0 value for survivors, allows the HUD to properly... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=073fbf90e9d24c6cf3916dd3af9a1b3978d56ee7;p=xonotic%2Fxonotic-data.pk3dir.git Update survival status to not use a 0 value for survivors, allows the HUD to properly display when a player hasn't been assigned a role yet --- diff --git a/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc b/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc index a7899dadb..a766b29fb 100644 --- a/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc +++ b/qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc @@ -6,15 +6,28 @@ void HUD_Mod_Survival(vector pos, vector mySize) { mod_active = 1; // survival should always show the mod HUD - // since survivor state is the default value, spectators are considered survivors - // so we must hide them manually here - if(entcs_GetSpecState(player_localnum) == ENTCS_SPEC_PURE) - return; // no icon while spectating - int mystatus = entcs_receiver(player_localnum).survival_status; - //string player_icon = ((mystatus == SURV_STATUS_HUNTER) ? "player_red" : "player_neutral"); - string player_text = ((mystatus == SURV_STATUS_HUNTER) ? _("Hunter") : _("Survivor")); - vector player_color = ((mystatus == SURV_STATUS_HUNTER) ? '1 0 0' : '0 1 0'); + string player_text = ""; + vector player_color = '1 1 1'; + //string player_icon = ""; + if(mystatus == SURV_STATUS_HUNTER) + { + player_text = _("Hunter"); + player_color = '1 0 0'; + //player_icon = "player_red"; + } + else if(mystatus == SURV_STATUS_PREY) + { + player_text = _("Survivor"); + player_color = '0 1 0'; + //player_icon = "player_neutral"; + } + else + { + // if the player has no valid status, don't draw anything + return; + } + //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); } @@ -31,9 +44,9 @@ MUTATOR_HOOKFUNCTION(cl_surv, ForcePlayercolors_Skip) int surv_status = ((e) ? e.survival_status : 0); int mystatus = entcs_receiver(player_localnum).survival_status; - int plcolor = SURV_COLOR_PREY; // green + int plcolor = SURV_COLOR_PREY; // default to survivor if((mystatus == SURV_STATUS_HUNTER || intermission || STAT(GAME_STOPPED)) && surv_status == SURV_STATUS_HUNTER) - plcolor = SURV_COLOR_HUNTER; // red + plcolor = SURV_COLOR_HUNTER; player.colormap = 1024 + plcolor; return true; diff --git a/qcsrc/common/gamemodes/gamemode/survival/survival.qh b/qcsrc/common/gamemodes/gamemode/survival/survival.qh index 314ec629e..53763575b 100644 --- a/qcsrc/common/gamemodes/gamemode/survival/survival.qh +++ b/qcsrc/common/gamemodes/gamemode/survival/survival.qh @@ -2,8 +2,8 @@ // shared state signalling the player's survival status .int survival_status; -const int SURV_STATUS_PREY = 0; -const int SURV_STATUS_HUNTER = 1; +const int SURV_STATUS_PREY = 1; +const int SURV_STATUS_HUNTER = 2; // hardcoded player colors for survival const int SURV_COLOR_PREY = 51; // green diff --git a/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc index 982f38b87..6a747ad7c 100644 --- a/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc +++ b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc @@ -114,7 +114,11 @@ float Surv_CheckWinner() void Surv_RoundStart() { allowed_to_spawn = boolean(warmup_stage); - FOREACH_CLIENT(true, { it.survival_status = SURV_STATUS_PREY; it.survival_validkills = 0; }); + FOREACH_CLIENT(true, + { + it.survival_status = ((IS_PLAYER(it) && !IS_DEAD(it)) ? SURV_STATUS_PREY : 0); + it.survival_validkills = 0; + }); Surv_count_alive_players(); int hunter_count = bound(1, ((autocvar_g_survival_hunter_count >= 1) ? autocvar_g_survival_hunter_count : floor(total_players * autocvar_g_survival_hunter_count)), total_players - 1); // 20%, but ensure at least 1 and less than total int total_hunters = 0; @@ -210,7 +214,7 @@ MUTATOR_HOOKFUNCTION(surv, PlayerSpawn) { entity player = M_ARGV(0, entity); - player.survival_status = SURV_STATUS_PREY; + player.survival_status = 0; player.caplayer = 1; if (!warmup_stage) eliminatedPlayers.SendFlags |= 1;