]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Better HUD.
authorLyberta <lyberta@lyberta.net>
Sat, 18 Mar 2017 23:15:38 +0000 (02:15 +0300)
committerLyberta <lyberta@lyberta.net>
Sat, 18 Mar 2017 23:15:38 +0000 (02:15 +0300)
qcsrc/client/hud/panel/modicons.qc
qcsrc/common/stats.qh
qcsrc/server/mutators/mutator/gamemode_survival.qc

index 08732bf0168fa4cc4cec43eb89f651b20c89db5c..cd65063ba3d8a30dceb7e8e70ec470cd11b574d8 100644 (file)
@@ -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);
index b9c7fc40eb9ee2e0fce166a247ac484ae903f5e6..f1686a63b5e98970f53aebe73e2648db7097d68d 100644 (file)
@@ -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)
index 07b86bf1df2de85969d3a54e5f24f888c840c113..3013290591974138f32b7621259bb4efb412690d 100644 (file)
@@ -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);