]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/newpanelhud-dom_points
authorterencehill <piuntn@gmail.com>
Wed, 20 Oct 2010 22:09:40 +0000 (00:09 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 20 Oct 2010 22:09:40 +0000 (00:09 +0200)
Conflicts:
qcsrc/server/cl_client.qc

13 files changed:
defaultXonotic.cfg
gfx/hud/old/dom_icon_blue-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_blue.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_pink-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_pink.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_red-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_red.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_yellow-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_yellow.tga [new file with mode: 0644]
qcsrc/client/hud.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/domination.qc

index 050a2915df005d8183456c873e5d9adfb720ccc2..1746535c951c47d2416a98f9aeb51c3ba0e98649 100644 (file)
@@ -1383,6 +1383,8 @@ seta hud_panel_weapons_timeout_effect "1" "disappearance effect: 0) no effect; 1
 seta hud_panel_notify_time 10 "time that a new entry stays until it fades out"
 seta hud_panel_notify_fadetime 3 "fade out time"
 
+seta hud_panel_modicons_dom_layout 0 "3 possible layouts: 0) only icons; 1) icons and percentage of average pps (points per second); 2) icons and average pps"
+
 seta hud_panel_timer_increment 0 "show elapsed time instead of remaining time"
 
 seta hud_panel_radar_scale 4096 "distance you can see on the team radar"
diff --git a/gfx/hud/old/dom_icon_blue-highlighted.tga b/gfx/hud/old/dom_icon_blue-highlighted.tga
new file mode 100644 (file)
index 0000000..a1ee2f0
Binary files /dev/null and b/gfx/hud/old/dom_icon_blue-highlighted.tga differ
diff --git a/gfx/hud/old/dom_icon_blue.tga b/gfx/hud/old/dom_icon_blue.tga
new file mode 100644 (file)
index 0000000..9524e70
Binary files /dev/null and b/gfx/hud/old/dom_icon_blue.tga differ
diff --git a/gfx/hud/old/dom_icon_pink-highlighted.tga b/gfx/hud/old/dom_icon_pink-highlighted.tga
new file mode 100644 (file)
index 0000000..748e2ad
Binary files /dev/null and b/gfx/hud/old/dom_icon_pink-highlighted.tga differ
diff --git a/gfx/hud/old/dom_icon_pink.tga b/gfx/hud/old/dom_icon_pink.tga
new file mode 100644 (file)
index 0000000..504c849
Binary files /dev/null and b/gfx/hud/old/dom_icon_pink.tga differ
diff --git a/gfx/hud/old/dom_icon_red-highlighted.tga b/gfx/hud/old/dom_icon_red-highlighted.tga
new file mode 100644 (file)
index 0000000..fcfef52
Binary files /dev/null and b/gfx/hud/old/dom_icon_red-highlighted.tga differ
diff --git a/gfx/hud/old/dom_icon_red.tga b/gfx/hud/old/dom_icon_red.tga
new file mode 100644 (file)
index 0000000..bedc8bb
Binary files /dev/null and b/gfx/hud/old/dom_icon_red.tga differ
diff --git a/gfx/hud/old/dom_icon_yellow-highlighted.tga b/gfx/hud/old/dom_icon_yellow-highlighted.tga
new file mode 100644 (file)
index 0000000..02e7fb8
Binary files /dev/null and b/gfx/hud/old/dom_icon_yellow-highlighted.tga differ
diff --git a/gfx/hud/old/dom_icon_yellow.tga b/gfx/hud/old/dom_icon_yellow.tga
new file mode 100644 (file)
index 0000000..ef8fa8d
Binary files /dev/null and b/gfx/hud/old/dom_icon_yellow.tga differ
index 69459256f0a22acd972fa7aea299402905a518e9..131d113c818d60081dd8ef9d6ded2a28cc7fa133 100644 (file)
@@ -4329,6 +4329,105 @@ void HUD_Mod_Race(vector pos, vector mySize)
        drawfont = hud_font;
 }
 
+void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float i)
+{
+       float stat, pps_ratio;
+       string pic;
+       vector color;
+       switch(i)
+       {
+               case 0:
+                       stat = getstatf(STAT_DOM_PPS_RED);
+                       pic = "dom_icon_red";
+                       color = '1 0 0';
+                       break;
+               case 1:
+                       stat = getstatf(STAT_DOM_PPS_BLUE);
+                       pic = "dom_icon_blue";
+                       color = '0 0 1';
+                       break;
+               case 2:
+                       stat = getstatf(STAT_DOM_PPS_YELLOW);
+                       pic = "dom_icon_yellow";
+                       color = '1 1 0';
+                       break;
+               case 3:
+                       stat = getstatf(STAT_DOM_PPS_PINK);
+                       pic = "dom_icon_pink";
+                       color = '1 0 1';
+       }
+       pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
+
+       if(mySize_x/mySize_y > aspect_ratio)
+       {
+               i = aspect_ratio * mySize_y;
+               myPos_x = myPos_x + (mySize_x - i) / 2;
+               mySize_x = i;
+       }
+       else
+       {
+               i = 1/aspect_ratio * mySize_x;
+               myPos_y = myPos_y + (mySize_y - i) / 2;
+               mySize_y = i;
+       }
+
+       if (cvar("hud_panel_modicons_dom_layout")) // show text too
+       {
+               //draw the text
+               drawfont = hud_bigfont;
+               color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
+               if (cvar("hud_panel_modicons_dom_layout") == 2) // average pps
+                       drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               else // percentage of average pps
+                       drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawfont = hud_font;
+       }
+
+       //draw the icon
+       drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       if (stat > 0)
+       {
+               drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
+               drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawresetcliparea();
+       }
+}
+
+void HUD_Mod_Dom(vector myPos, vector mySize)
+{
+       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, aspect_ratio;
+       rows = mySize_y/mySize_x;
+       aspect_ratio = (cvar("hud_panel_modicons_dom_layout")) ? 3 : 1;
+       rows = bound(1, floor((sqrt((4 * aspect_ratio * 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);
+
+               DrawDomItem(pos, size, aspect_ratio, 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
@@ -4338,7 +4437,7 @@ void HUD_ModIcons(void)
        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;
@@ -4375,6 +4474,8 @@ void HUD_ModIcons(void)
                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)
index 6f0eccfafb8af72f94a556ad5709a0554c0ccfab..417526e78ea9d2b64d18522bc4a57162c9bbb5a1 100644 (file)
@@ -311,6 +311,12 @@ const float STAT_LEADLIMIT = 47;
 const float STAT_BULLETS_LOADED = 48;
 const float STAT_NEX_CHARGE = 49;
 
+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;
index df6c8d4b2a3f41e0793e271d8aae9a9b54512692..6cc10bcd6bb767d1307cb38a52d896f49e76d03e 100644 (file)
@@ -1397,6 +1397,7 @@ Called when a client connects to the server
 string ColoredTeamName(float t);
 void DecodeLevelParms (void);
 //void dom_player_join_team(entity pl);
+void set_dom_state(entity e, float connecting);
 void ClientConnect (void)
 {
        float t;
@@ -1597,6 +1598,8 @@ void ClientConnect (void)
        else if(cvar("sv_teamnagger") && !(cvar("bot_vs_human") && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
                send_CSQC_teamnagger();
 
+       if (g_domination)
+               set_dom_state(self, TRUE);
        send_CSQC_cr_maxbullets(self);
 
        CheatInitClient();
index 3e5bed8b25f23c35247fa2cf1c50c14da053dc3c..17e2e5fe0bbaabfefd1f8dd4790129b5778a035e 100644 (file)
@@ -24,6 +24,26 @@ float g_domination_point_rate;
 .entity sprite;
 .float captime;
 
+// pps: points per second
+.float dom_total_pps;
+.float dom_pps_red;
+.float dom_pps_blue;
+.float dom_pps_yellow;
+.float dom_pps_pink;
+float total_pps;
+float pps_red;
+float pps_blue;
+float pps_yellow;
+float pps_pink;
+void set_dom_state(entity e, float connecting)
+{
+       if(connecting)  e.dom_total_pps = total_pps;
+                                       e.dom_pps_red = pps_red;
+                                       e.dom_pps_blue = pps_blue;
+       if(c3 >= 0)             e.dom_pps_yellow = pps_yellow;
+       if(c4 >= 0)             e.dom_pps_pink = pps_pink;
+}
+
 void() dom_controlpoint_setup;
 
 void LogDom(string mode, float team_before, entity actor)
@@ -110,21 +130,53 @@ void dompoint_captured ()
        self.delay = old_delay;
        self.team = old_team;
 
+       switch(self.team)
+       {
+               // "fix" pps when slightly under 0 because of approximation errors
+               case COLOR_TEAM1:
+                       pps_red -= (points/wait_time);
+                       if (pps_red < 0) pps_red = 0;
+                       break;
+               case COLOR_TEAM2:
+                       pps_blue -= (points/wait_time);
+                       if (pps_blue < 0) pps_blue = 0;
+                       break;
+               case COLOR_TEAM3:
+                       pps_yellow -= (points/wait_time);
+                       if (pps_yellow < 0) pps_yellow = 0;
+                       break;
+               case COLOR_TEAM4:
+                       pps_pink -= (points/wait_time);
+                       if (pps_pink < 0) pps_pink = 0;
+       }
+
        switch(self.goalentity.team)
        {
+               // "fix" pps when slightly over total_pps because of approximation errors
                case COLOR_TEAM1:
+                       pps_red += (points/wait_time);
+                       if (pps_red > total_pps) pps_red = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-red", "", "");
                        break;
                case COLOR_TEAM2:
+                       pps_blue += (points/wait_time);
+                       if (pps_blue > total_pps) pps_blue = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-blue", "", "");
                        break;
                case COLOR_TEAM3:
+                       pps_yellow += (points/wait_time);
+                       if (pps_yellow > total_pps) pps_yellow = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-yellow", "", "");
                        break;
                case COLOR_TEAM4:
+                       pps_pink += (points/wait_time);
+                       if (pps_pink > total_pps) pps_pink = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", "");
-                       break;
        }
+
+       FOR_EACH_CLIENT(head)
+               set_dom_state(head, FALSE);
+
        WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
        WaypointSprite_Ping(self.sprite);
 
@@ -160,9 +212,6 @@ void dompointthink()
        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
@@ -549,6 +598,17 @@ void spawnfunc_dom_controlpoint()
        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
@@ -655,6 +715,15 @@ void dom_init()
        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);
+       if(c3 >= 0) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow);
+       if(c4 >= 0) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink);
+
+       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");