From 6a3851fc945f292dbb1f1a5ef6266edc9c7f5ce3 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Sun, 19 Mar 2017 02:15:38 +0300 Subject: [PATCH] Better HUD. --- qcsrc/client/hud/panel/modicons.qc | 50 +++++++++++++++++-- qcsrc/common/stats.qh | 2 + .../mutators/mutator/gamemode_survival.qc | 34 +++++++++---- 3 files changed, 74 insertions(+), 12 deletions(-) diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 08732bf01..cd65063ba 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -737,15 +737,59 @@ void HUD_Mod_SURV(vector mypos, vector mysize) } HUD_Panel_DrawProgressBar(healthbarpos, healthbarsize, "progressbar", defenderhealth, false, 0, healthbarcolor, 0.50, DRAWFLAG_NORMAL); + // Draw defender picture + int defenderteam = STAT(SURV_DEFENDER_TEAM); + string defenderpic = ""; + vector defendercolor; + switch (defenderteam) + { + case 1: + { + defenderpic = "player_red"; + defendercolor = '1 0 0'; + break; + } + case 2: + { + defenderpic = "player_blue"; + defendercolor = '0 0 1'; + break; + } + default: + { + defendercolor = '1 1 1'; + break; + } + } + vector picpos = mypos; + vector picsize = mysize; + picsize.x = picsize.y; + drawpic_aspect_skin(picpos, defenderpic, picsize, '1 1 1', 1, + DRAWFLAG_NORMAL); + // Draw number of defenders + int numalive = STAT(SURV_DEFENDERS_ALIVE); + vector alivepos = mypos; + alivepos.x += picsize.x; + vector alivesize = picsize; + drawstring_aspect(alivepos, ftos(numalive), alivesize, defendercolor, 1, + DRAWFLAG_NORMAL); // Draw the time left float roundtime = STAT(SURV_ROUND_TIME); if (roundtime < 0) { roundtime = 0; } - drawstring_aspect(mypos, seconds_tostring(roundtime), mysize, '1 1 1', 1, - DRAWFLAG_NORMAL); - + vector roundtimepos = mypos; + roundtimepos.x += picsize.x * 2; + vector roundtimesize = mysize; + roundtimesize.x = mysize.x - picsize.x * 2; + drawstring_aspect(roundtimepos, seconds_tostring(roundtime), roundtimesize, + '1 1 1', 1, DRAWFLAG_NORMAL); + if (autocvar_developer == 0) + { + return; + } + // Debug info below int redalive = STAT(REDALIVE); int bluealive = STAT(BLUEALIVE); int yellowalive = STAT(YELLOWALIVE); diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index b9c7fc40e..f1686a63b 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -275,6 +275,8 @@ REGISTER_STAT(DOM_PPS_PINK, float) // Lyberta: survival REGISTER_STAT(SURV_ROUND_TIME, float) +REGISTER_STAT(SURV_DEFENDER_TEAM, int) +REGISTER_STAT(SURV_DEFENDERS_ALIVE, int) REGISTER_STAT(SURV_DEFENDER_HEALTH, float) REGISTER_STAT(TELEPORT_MAXSPEED, float, autocvar_g_teleport_maxspeed) diff --git a/qcsrc/server/mutators/mutator/gamemode_survival.qc b/qcsrc/server/mutators/mutator/gamemode_survival.qc index 07b86bf1d..301329059 100644 --- a/qcsrc/server/mutators/mutator/gamemode_survival.qc +++ b/qcsrc/server/mutators/mutator/gamemode_survival.qc @@ -120,6 +120,10 @@ float autocvar_g_surv_cannon_fodder_defense_scale; /// \brief A stat that is used to track the time left in the round. .float surv_round_time_stat = _STAT(SURV_ROUND_TIME); +/// \brief A stat that is used to track defender team. +.int surv_defender_team_stat = _STAT(SURV_DEFENDER_TEAM); +/// \brief A stat that is used to track number of defenders alive. +.int surv_defenders_alive_stat = _STAT(SURV_DEFENDERS_ALIVE); /// \brief A stat that is used to track the total health of defenders. .float surv_defender_health_stat = _STAT(SURV_DEFENDER_HEALTH); @@ -148,20 +152,20 @@ int surv_defenderteambit; ///< Holds the defender team bitmask. int surv_attackercolor; ///< Holds the color of attackers. int surv_defendercolor; ///< Holds the color of defenders. -int surv_numattackers = 0; ///< Holds the number of players in attacker team. -int surv_numdefenders = 0; ///< Holds the number of players in defender team. +int surv_numattackers; ///< Holds the number of players in attacker team. +int surv_numdefenders; ///< Holds the number of players in defender team. /// \brief Holds the number of humans in attacker team. -int surv_numattackerhumans = 0; +int surv_numattackerhumans; /// \brief Holds the number of humans in defender team. -int surv_numdefenderhumans = 0; +int surv_numdefenderhumans; /// \brief Holds the number of attacker players that are alive. -int surv_numattackersalive = 0; +int surv_numattackersalive; /// \brief Holds the number of defender players that are alive. -int surv_numdefendersalive = 0; +int surv_numdefendersalive; -bool surv_autobalance = true; ///< Holds whether autobalance is active. +bool surv_autobalance; ///< Holds whether autobalance is active. bool surv_allowed_to_spawn; ///< Holds whether players are allowed to spawn. //====================== Forward declarations ================================= @@ -217,6 +221,13 @@ void Surv_Initialize() surv_attackercolor = SURVIVAL_COLOR_BLUE; surv_defendercolor = SURVIVAL_COLOR_RED; } + surv_numattackers = 0; + surv_numdefenders = 0; + surv_numattackerhumans = 0; + surv_numdefenderhumans = 0; + surv_numattackersalive = 0; + surv_numdefendersalive = 0; + surv_autobalance = true; surv_allowed_to_spawn = true; precache_all_playermodels("models/ok_player/*.dpm"); WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED; @@ -655,11 +666,11 @@ void Surv_CountAlivePlayers() /// \return No return. void Surv_UpdateAliveStats() { + // Debug stuff if (surv_attackercolor == SURVIVAL_COLOR_RED) { redalive = surv_numattackersalive; bluealive = surv_numdefendersalive; - // Debug stuff yellowalive = surv_numattackers; pinkalive = surv_numdefenders; } @@ -667,12 +678,12 @@ void Surv_UpdateAliveStats() { bluealive = surv_numattackersalive; redalive = surv_numdefendersalive; - // Debug stuff pinkalive = surv_numattackers; yellowalive = surv_numdefenders; } FOREACH_CLIENT(IS_REAL_CLIENT(it), { + it.surv_defenders_alive_stat = surv_numdefendersalive; it.redalive_stat = redalive; it.bluealive_stat = bluealive; it.yellowalive_stat = yellowalive; @@ -832,6 +843,10 @@ void Surv_SwapTeams() } } }); + FOREACH_CLIENT(IS_REAL_CLIENT(it), + { + it.surv_defender_team_stat = Team_TeamToNumber(surv_defenderteam); + }); } /// \brief Gives player shells. @@ -1152,6 +1167,7 @@ MUTATOR_HOOKFUNCTION(surv, ClientConnect) entity player = M_ARGV(0, entity); LOG_TRACE("SURVIVAL: ClientConnect, player = ", player.netname); player.surv_savedplayermodel = player.playermodel; + player.surv_defender_team_stat = Team_TeamToNumber(surv_defenderteam); if (player.surv_role == SURVIVAL_ROLE_NONE) { Surv_AddPlayerToTeam(player, player.team); -- 2.39.5