void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
{
- float stat, pps_ratio;
+ float dom_pps, dom_pps_ratio;
string pic;
vector color;
switch(i)
{
case 0:
- stat = getstatf(STAT_DOM_PPS_RED);
+ dom_pps = dom_pps_red;
pic = "dom_icon_red";
color = '1 0 0';
break;
case 1:
- stat = getstatf(STAT_DOM_PPS_BLUE);
+ dom_pps = dom_pps_blue;
pic = "dom_icon_blue";
color = '0 0 1';
break;
case 2:
- stat = getstatf(STAT_DOM_PPS_YELLOW);
+ dom_pps = dom_pps_yellow;
pic = "dom_icon_yellow";
color = '1 1 0';
break;
case 3:
- stat = getstatf(STAT_DOM_PPS_PINK);
+ dom_pps = dom_pps_pink;
pic = "dom_icon_pink";
color = '1 0 1';
}
- pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
+ dom_pps_ratio = dom_pps / dom_total_pps;
if(mySize_x/mySize_y > aspect_ratio)
{
if (layout) // show text too
{
//draw the text
- color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
+ color *= 0.5 + dom_pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
if (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);
+ drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(dom_pps, 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);
+ drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(dom_pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
}
//draw the icon
drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
- if (stat > 0)
+ if (dom_pps > 0)
{
- drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
+ drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - dom_pps_ratio), mySize_y, mySize_y * dom_pps_ratio);
drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
drawresetcliparea();
}
.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(void)
+float dom_total_pps;
+float dom_pps_red;
+float dom_pps_blue;
+float dom_pps_yellow;
+float dom_pps_pink;
+void send_CSQC_dom_state()
{
- // BIG ugly hack to make stat sending work
- self.dom_total_pps = total_pps;
- self.dom_pps_red = pps_red;
- self.dom_pps_blue = pps_blue;
- if(c3 >= 0)
- {
- self.dom_pps_yellow = pps_yellow;
- }
- if(c4 >= 0)
- {
- self.dom_pps_pink = pps_pink;
- }
+ WriteByte(MSG_ALL, SVC_TEMPENTITY);
+ WriteByte(MSG_ALL, TE_CSQC_DOM);
+ WriteShort(MSG_ALL, dom_pps_red * 100.0);
+ WriteShort(MSG_ALL, dom_pps_blue * 100.0);
+ if (c3 >= 0) WriteShort(MSG_ALL, dom_pps_yellow * 100.0);
+ if (c4 >= 0) WriteShort(MSG_ALL, dom_pps_pink * 100.0);
+}
+//Must be called ONLY when a client connects to send total pps and state
+//If yellow/pink team doesn't exist sends a negative dom_pps_yellow/dom_pps_pink
+//to let know the client to not read these values anymore
+void send_CSQC_dom_all()
+{
+ WriteByte(MSG_ALL, SVC_TEMPENTITY);
+ WriteByte(MSG_ALL, TE_CSQC_DOM);
+ WriteShort(MSG_ALL, dom_total_pps * 100.0);
+ WriteShort(MSG_ALL, dom_pps_red * 100.0);
+ WriteShort(MSG_ALL, dom_pps_blue * 100.0);
+ WriteShort(MSG_ALL, dom_pps_yellow * 100.0);
+ WriteShort(MSG_ALL, dom_pps_pink * 100.0);
}
void() dom_controlpoint_setup;
{
// "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;
+ dom_pps_red -= (points/wait_time);
+ if (dom_pps_red < 0) dom_pps_red = 0;
break;
case COLOR_TEAM2:
- pps_blue -= (points/wait_time);
- if (pps_blue < 0) pps_blue = 0;
+ dom_pps_blue -= (points/wait_time);
+ if (dom_pps_blue < 0) dom_pps_blue = 0;
break;
case COLOR_TEAM3:
- pps_yellow -= (points/wait_time);
- if (pps_yellow < 0) pps_yellow = 0;
+ dom_pps_yellow -= (points/wait_time);
+ if (dom_pps_yellow < 0) dom_pps_yellow = 0;
break;
case COLOR_TEAM4:
- pps_pink -= (points/wait_time);
- if (pps_pink < 0) pps_pink = 0;
+ dom_pps_pink -= (points/wait_time);
+ if (dom_pps_pink < 0) dom_pps_pink = 0;
}
switch(self.goalentity.team)
{
- // "fix" pps when slightly over total_pps because of approximation errors
+ // "fix" pps when slightly over dom_total_pps because of approximation errors
case COLOR_TEAM1:
- pps_red += (points/wait_time);
- if (pps_red > total_pps) pps_red = total_pps;
+ dom_pps_red += (points/wait_time);
+ if (dom_pps_red > dom_total_pps) dom_pps_red = dom_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;
+ dom_pps_blue += (points/wait_time);
+ if (dom_pps_blue > dom_total_pps) dom_pps_blue = dom_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;
+ dom_pps_yellow += (points/wait_time);
+ if (dom_pps_yellow > dom_total_pps) dom_pps_yellow = dom_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;
+ dom_pps_pink += (points/wait_time);
+ if (dom_pps_pink > dom_total_pps) dom_pps_pink = dom_total_pps;
WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", "");
}
- FOR_EACH_PLAYER(self)
- set_dom_state();
+ send_CSQC_dom_state();
WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
WaypointSprite_Ping(self.sprite);
else
waittime = self.wait;
- total_pps += points/waittime;
+ dom_total_pps += points/waittime;
if(!self.t_width)
self.t_width = 0.02; // frame animation rate
}
}
}
+ if (c3 == -1) dom_pps_yellow = -1;
+ if (c4 == -1) dom_pps_pink = -1;
ScoreRules_dom();
};
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");