]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Current dom state (average points per second obtained by each team) on the HUD.
authorterencehill <piuntn@gmail.com>
Mon, 26 Jul 2010 12:26:02 +0000 (14:26 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 26 Jul 2010 12:26:02 +0000 (14:26 +0200)
It can be shown in 2 ways, depending on hud_panel_modicons_dom_pps value:
0: pps percentage on max pps
1: just pps

TODO: add icons and percentage bars

qcsrc/client/hud.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/domination.qc

index ddc7848a4ebbb6009aceb3cdaf2b9ff7cad3fcab..487e4f6d49582c3a6c100f6a6480df25df6baa21 100644 (file)
@@ -4097,6 +4097,109 @@ void HUD_Mod_Race(vector pos, vector mySize)
        drawfont = hud_font;
 }
 
        drawfont = hud_font;
 }
 
+void DrawDomCP(vector myPos, vector mySize, float i)
+{
+       float stat;
+       vector color;
+       switch(i)
+       {
+               case 0:
+                       stat = getstatf(STAT_DOM_PPS_RED);
+                       color = '1 0 0';
+                       break;
+               case 1:
+                       stat = getstatf(STAT_DOM_PPS_BLUE);
+                       color = '0 0 1';
+                       break;
+               case 2:
+                       stat = getstatf(STAT_DOM_PPS_YELLOW);
+                       color = '1 1 0';
+                       break;
+               case 3:
+                       stat = getstatf(STAT_DOM_PPS_PINK);
+                       color = '1 0 1';
+       }
+
+       vector newSize, newPos;
+       if(mySize_x/mySize_y > 3)
+       {
+               newSize_x = 3 * mySize_y;
+               newSize_y = mySize_y;
+
+               newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
+               newPos_y = myPos_y;
+       }
+       else
+       {
+               newSize_y = 1/3 * mySize_x;
+               newSize_x = mySize_x;
+
+               newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
+               newPos_x = myPos_x;
+       }
+
+       vector picpos, numpos;
+       numpos = newPos + eX * newSize_y;
+       /*
+       if(autocvar_hud_panel_modicons_iconalign)
+       {
+               numpos = newPos;
+               picpos = newPos + eX * 2 * newSize_y;
+       }
+       else
+       {
+               numpos = newPos + eX * newSize_y;
+               picpos = newPos;
+       }
+       */
+
+       drawfont = hud_bigfont;
+       if (cvar("hud_panel_modicons_dom_pps")) // average pps
+               drawstring_aspect(numpos, ftos_decimals(stat, 2), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+       else // percentage of average pps
+               drawstring_aspect(numpos, strcat(ftos_decimals(stat*100 / getstatf(STAT_DOM_TOTAL_PPS), 0), "%"), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawfont = hud_font;
+
+       // TODO draw controlpoints icons with a bar
+       // representing the percentage of average pps
+       // and maybe show smaller strings
+}
+
+void HUD_Mod_Dom(vector myPos, vector mySize)
+{
+       print("test ", ftos(cvar("aaa")), "\n");
+       entity tm;
+       float teams_count;
+       for(tm = teams.sort_next; tm; tm = tm.sort_next)
+               if(tm.team != COLOR_SPECTATOR)
+                       ++teams_count;
+
+       float rows, columns;
+       rows = mySize_y/mySize_x;
+       rows = bound(1, floor((sqrt((4 * 1 * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
+       columns = ceil(teams_count/rows);
+
+       drawfont = hud_bigfont;
+       int i;
+       float row, column;
+       for(i=0; i<teams_count; ++i)
+       {
+               vector pos, size;
+               pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
+               size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+
+               DrawDomCP(pos, size, i);
+
+               ++row;
+               if(row >= rows)
+               {
+                       row = 0;
+                       ++column;
+               }
+       }
+       drawfont = hud_font;
+}
+
 float mod_prev; // previous state of mod_active to check for a change
 float mod_alpha;
 float mod_change; // "time" when mod_active changed
 float mod_prev; // previous state of mod_active to check for a change
 float mod_alpha;
 float mod_change; // "time" when mod_active changed
@@ -4106,7 +4209,7 @@ void HUD_ModIcons(void)
        if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
                return;
 
        if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
                return;
 
-       if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
+       if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_DOMINATION && !autocvar__hud_configure)
                return;
 
        active_panel = HUD_PANEL_MODICONS;
                return;
 
        active_panel = HUD_PANEL_MODICONS;
@@ -4143,6 +4246,8 @@ void HUD_ModIcons(void)
                HUD_Mod_NexBall(pos, mySize);
        else if(gametype == GAME_CTS || gametype == GAME_RACE)
                HUD_Mod_Race(pos, mySize);
                HUD_Mod_NexBall(pos, mySize);
        else if(gametype == GAME_CTS || gametype == GAME_RACE)
                HUD_Mod_Race(pos, mySize);
+       else if(gametype == GAME_DOMINATION)
+               HUD_Mod_Dom(pos, mySize);
 }
 
 // Draw pressed keys (#11)
 }
 
 // Draw pressed keys (#11)
index d48cff2227d02fdb0066aec51a8cfa3bb9cc6825..cd23444dcca6ea6fd6ef0e40d463be8b8a63acb7 100644 (file)
@@ -304,6 +304,12 @@ const float STAT_SHOTORG = 46; // compressShotOrigin
 const float STAT_LEADLIMIT = 47;
 const float STAT_BULLETS_LOADED = 48;
 
 const float STAT_LEADLIMIT = 47;
 const float STAT_BULLETS_LOADED = 48;
 
+const float STAT_DOM_TOTAL_PPS = 70;
+const float STAT_DOM_PPS_RED = 71;
+const float STAT_DOM_PPS_BLUE = 72;
+const float STAT_DOM_PPS_PINK = 73;
+const float STAT_DOM_PPS_YELLOW = 74;
+
 // see DP source, quakedef.h
 const float STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW = 222;
 const float STAT_MOVEVARS_AIRSTRAFEACCEL_QW = 223;
 // see DP source, quakedef.h
 const float STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW = 222;
 const float STAT_MOVEVARS_AIRSTRAFEACCEL_QW = 223;
index 1543ac156187e0f4c2497ca2b203dfc71293a5b6..4ef2bd4f48ca8ca102fc45df1a5f2877e285b7b7 100644 (file)
@@ -1379,6 +1379,8 @@ void DecodeLevelParms (void);
 .float uid_kicktime;
 .string uid;
 #endif
 .float uid_kicktime;
 .string uid;
 #endif
+float total_pps;
+.float dom_total_pps;
 void ClientConnect (void)
 {
        float t;
 void ClientConnect (void)
 {
        float t;
@@ -1585,6 +1587,9 @@ void ClientConnect (void)
        else if(cvar("sv_teamnagger") && !g_ca) // teamnagger is currently bad for ca
                send_CSQC_teamnagger();
 
        else if(cvar("sv_teamnagger") && !g_ca) // teamnagger is currently bad for ca
                send_CSQC_teamnagger();
 
+       if (g_domination)
+               self.dom_total_pps = total_pps;
+
        CheatInitClient();
 }
 
        CheatInitClient();
 }
 
index 5bf2b9ad86c531a5c611761c74341ec4fdb382ce..d0bffa1c4682cf38e5b4269a95244641a901fb99 100644 (file)
@@ -24,6 +24,16 @@ float g_domination_point_rate;
 .entity sprite;
 .float captime;
 
 .entity sprite;
 .float captime;
 
+// pps (points per second)
+.float dom_pps_red;
+.float dom_pps_blue;
+.float dom_pps_pink;
+.float dom_pps_yellow;
+float pps_red;
+float pps_blue;
+float pps_pink;
+float pps_yellow;
+
 void() dom_controlpoint_setup;
 
 void LogDom(string mode, float team_before, entity actor)
 void() dom_controlpoint_setup;
 
 void LogDom(string mode, float team_before, entity actor)
@@ -107,21 +117,49 @@ void dompoint_captured ()
        self.delay = old_delay;
        self.team = old_team;
 
        self.delay = old_delay;
        self.team = old_team;
 
+       switch(self.team)
+       {
+               case COLOR_TEAM1:
+                       pps_red -= (points/wait_time);
+                       break;
+               case COLOR_TEAM2:
+                       pps_blue -= (points/wait_time);
+                       break;
+               case COLOR_TEAM3:
+                       pps_yellow -= (points/wait_time);
+                       break;
+               case COLOR_TEAM4:
+                       pps_pink -= (points/wait_time);
+       }
+
        switch(self.goalentity.team)
        {
                case COLOR_TEAM1:
        switch(self.goalentity.team)
        {
                case COLOR_TEAM1:
+                       pps_red += (points/wait_time);
                        WaypointSprite_UpdateSprites(self.sprite, "dom-red", "", "");
                        break;
                case COLOR_TEAM2:
                        WaypointSprite_UpdateSprites(self.sprite, "dom-red", "", "");
                        break;
                case COLOR_TEAM2:
+                       pps_blue += (points/wait_time);
                        WaypointSprite_UpdateSprites(self.sprite, "dom-blue", "", "");
                        break;
                case COLOR_TEAM3:
                        WaypointSprite_UpdateSprites(self.sprite, "dom-blue", "", "");
                        break;
                case COLOR_TEAM3:
+                       pps_yellow += (points/wait_time);
                        WaypointSprite_UpdateSprites(self.sprite, "dom-yellow", "", "");
                        break;
                case COLOR_TEAM4:
                        WaypointSprite_UpdateSprites(self.sprite, "dom-yellow", "", "");
                        break;
                case COLOR_TEAM4:
+                       pps_pink += (points/wait_time);
                        WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", "");
                        WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", "");
-                       break;
        }
        }
+
+       entity player;
+       FOR_EACH_CLIENT(player)
+       {
+               player.dom_pps_red = pps_red;
+               player.dom_pps_blue = pps_blue;
+               player.dom_pps_yellow = pps_yellow;
+               player.dom_pps_pink = pps_pink;
+       }
+
        WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
        WaypointSprite_Ping(self.sprite);
 
        WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
        WaypointSprite_Ping(self.sprite);
 
@@ -157,9 +195,6 @@ void dompointthink()
        if (gameover || self.delay > time || time < game_starttime)     // game has ended, don't keep giving points
                return;
 
        if (gameover || self.delay > time || time < game_starttime)     // game has ended, don't keep giving points
                return;
 
-       g_domination_point_rate = cvar("g_domination_point_rate");
-       g_domination_point_amt = cvar("g_domination_point_amt");
-
        if(g_domination_point_rate)
                self.delay = time + g_domination_point_rate;
        else
        if(g_domination_point_rate)
                self.delay = time + g_domination_point_rate;
        else
@@ -546,6 +581,17 @@ void spawnfunc_dom_controlpoint()
        self.effects = self.effects | EF_LOWPRECISION;
        if (cvar("g_domination_point_fullbright"))
                self.effects |= EF_FULLBRIGHT;
        self.effects = self.effects | EF_LOWPRECISION;
        if (cvar("g_domination_point_fullbright"))
                self.effects |= EF_FULLBRIGHT;
+       
+       float points, waittime;
+       if (g_domination_point_rate)
+               points += g_domination_point_rate;
+       else
+               points += self.frags;
+       if (g_domination_point_amt)
+               waittime += g_domination_point_amt;
+       else
+               waittime += self.wait;
+       total_pps += points/waittime;
 };
 
 // code from here on is just to support maps that don't have control point and team entities
 };
 
 // code from here on is just to support maps that don't have control point and team entities
@@ -652,6 +698,15 @@ void dom_init()
        precache_sound("domination/claim.wav");
        InitializeEntity(world, dom_delayedinit, INITPRIO_GAMETYPE);
 
        precache_sound("domination/claim.wav");
        InitializeEntity(world, dom_delayedinit, INITPRIO_GAMETYPE);
 
+       addstat(STAT_DOM_TOTAL_PPS , AS_FLOAT, dom_total_pps);
+       addstat(STAT_DOM_PPS_RED   , AS_FLOAT, dom_pps_red);
+       addstat(STAT_DOM_PPS_BLUE  , AS_FLOAT, dom_pps_blue);
+       addstat(STAT_DOM_PPS_PINK  , AS_FLOAT, dom_pps_pink);
+       addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow);
+
+       g_domination_point_rate = cvar("g_domination_point_rate");
+       g_domination_point_amt = cvar("g_domination_point_amt");
+
        // teamplay is always on in domination, defaults to hurt self but not teammates
        //if(!teams_matter)
        //      cvar_set("teamplay", "3");
        // teamplay is always on in domination, defaults to hurt self but not teammates
        //if(!teams_matter)
        //      cvar_set("teamplay", "3");