float pps_pink;
void set_dom_state(entity e)
{
- // BIG ugly hack to make stat sending work
e.dom_total_pps = total_pps;
e.dom_pps_red = pps_red;
e.dom_pps_blue = pps_blue;
void dompoint_captured ()
{
- local entity head;
- local float old_delay, old_team, real_team;
+ entity head;
+ float old_delay, old_team, real_team;
// now that the delay has expired, switch to the latest team to lay claim to this point
head = self.owner;
if (head.noise != "")
if(self.enemy)
- asound(self.enemy, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM);
+ sound(self.enemy, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM);
else
- asound(self, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM);
+ sound(self, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM);
if (head.noise1 != "")
play2all(head.noise1);
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", "", "");
}
+ total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
+ for(head = world; (head = find(head, classname, "dom_controlpoint")) != world; )
+ {
+ if (autocvar_g_domination_point_amt)
+ points = autocvar_g_domination_point_amt;
+ else
+ points = head.frags;
+ if (autocvar_g_domination_point_rate)
+ wait_time = autocvar_g_domination_point_rate;
+ else
+ wait_time = head.wait;
+ switch(head.goalentity.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;
+ }
+ total_pps += points/wait_time;
+ }
+
WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
WaypointSprite_Ping(self.sprite);
FOR_EACH_REALCLIENT(head)
set_dom_state(head);
-};
+}
void AnimateDomPoint()
{
void dompointthink()
{
- local float fragamt;
+ float fragamt;
self.nextthink = time + 0.1;
void dompointtouch()
{
- local entity head;
+ entity head;
if (other.classname != "player")
return;
if (other.health < 1)
self.enemy = other; // individual player scoring
self.enemy_playerid = other.playerid;
dompoint_captured();
-};
+}
/*QUAKED spawnfunc_dom_team (0 .5 .8) (-32 -32 -24) (32 32 32)
Team declaration for Domination gameplay, this allows you to decide what team
// this would have to be changed if used in quakeworld
if(self.cnt)
self.team = self.cnt + 1; // WHY are these different anyway?
-};
+}
void dom_controlpoint_setup()
{
- local entity head;
+ entity head;
// find the spawnfunc_dom_team representing unclaimed points
head = find(world, classname, "dom_team");
while(head && head.netname != "")
self.wait = 5;
float points, waittime;
- if (autocvar_g_domination_point_rate)
- points = autocvar_g_domination_point_rate;
+ if (autocvar_g_domination_point_amt)
+ points = autocvar_g_domination_point_amt;
else
points = self.frags;
- if (autocvar_g_domination_point_amt)
- waittime = autocvar_g_domination_point_amt;
+ if (autocvar_g_domination_point_rate)
+ waittime = autocvar_g_domination_point_rate;
else
waittime = self.wait;
waypoint_spawnforitem(self);
WaypointSprite_SpawnFixed("dom-neut", self.origin + '0 0 32', self, sprite, RADARICON_DOMPOINT, '0 1 1');
-};
-
-
-
-// player has joined game, get him on a team
-// depreciated
-/*void dom_player_join_team(entity pl)
-{
- entity head;
- float c1, c2, c3, c4, totalteams, smallestteam, smallestteam_count, selectedteam;
- float balance_teams, force_balance, balance_type;
-
- balance_teams = autocvar_g_balance_teams;
- balance_teams = autocvar_g_balance_teams_force;
-
- c1 = c2 = c3 = c4 = -1;
- totalteams = 0;
-
- // first find out what teams are allowed
- head = find(world, classname, "dom_team");
- while(head)
- {
- if(head.netname != "")
- {
- //if(head.team == pl.team)
- // selected = head;
- if(head.team == COLOR_TEAM1)
- {
- c1 = 0;
- }
- if(head.team == COLOR_TEAM2)
- {
- c2 = 0;
- }
- if(head.team == COLOR_TEAM3)
- {
- c3 = 0;
- }
- if(head.team == COLOR_TEAM4)
- {
- c4 = 0;
- }
- }
- head = find(head, classname, "dom_team");
- }
-
- // make sure there are at least 2 teams to join
- if(c1 >= 0)
- totalteams = totalteams + 1;
- if(c2 >= 0)
- totalteams = totalteams + 1;
- if(c3 >= 0)
- totalteams = totalteams + 1;
- if(c4 >= 0)
- totalteams = totalteams + 1;
-
- if(totalteams <= 1)
- error("dom_player_join_team: Too few teams available for domination\n");
-
- // whichever teams that are available are set to 0 instead of -1
-
- // if we don't care what team he ends up on, put him on whatever team he entered as.
- // if he's not on a valid team, then put him on the smallest team
- if(!balance_teams && !force_balance)
- {
- if( c1 >= 0 && pl.team == COLOR_TEAM1)
- selectedteam = pl.team;
- else if(c2 >= 0 && pl.team == COLOR_TEAM2)
- selectedteam = pl.team;
- else if(c3 >= 0 && pl.team == COLOR_TEAM3)
- selectedteam = pl.team;
- else if(c4 >= 0 && pl.team == COLOR_TEAM4)
- selectedteam = pl.team;
- else
- selectedteam = -1;
- if(selectedteam > 0)
- {
- SetPlayerColors(pl, selectedteam - 1);
- return;
- }
- // otherwise end up on the smallest team (handled below)
- }
-
- // now count how many players are on each team already
-
- head = find(world, classname, "player");
- while(head)
- {
- //if(head.netname != "")
- {
- if(head.team == COLOR_TEAM1)
- {
- if(c1 >= 0)
- c1 = c1 + 1;
- }
- if(head.team == COLOR_TEAM2)
- {
- if(c2 >= 0)
- c2 = c2 + 1;
- }
- if(head.team == COLOR_TEAM3)
- {
- if(c3 >= 0)
- c3 = c3 + 1;
- }
- if(head.team == COLOR_TEAM4)
- {
- if(c4 >= 0)
- c4 = c4 + 1;
- }
- }
- head = find(head, classname, "player");
- }
-
- // c1...c4 now have counts of each team
- // figure out which is smallest, giving priority to the team the player is already on as a tie-breaker
-
- smallestteam = 0;
- smallestteam_count = 999;
-
- // 2 gives priority to what team you're already on, 1 goes in order
- balance_type = 1;
+}
- if(balance_type == 1)
- {
- if(c1 >= 0 && c1 < smallestteam_count)
- {
- smallestteam = 1;
- smallestteam_count = c1;
- }
- if(c2 >= 0 && c2 < smallestteam_count)
- {
- smallestteam = 2;
- smallestteam_count = c2;
- }
- if(c3 >= 0 && c3 < smallestteam_count)
- {
- smallestteam = 3;
- smallestteam_count = c3;
- }
- if(c4 >= 0 && c4 < smallestteam_count)
- {
- smallestteam = 4;
- smallestteam_count = c4;
- }
- }
- else
- {
- if(c1 >= 0 && (c1 < smallestteam_count ||
- (c1 == smallestteam_count && self.team == COLOR_TEAM1) ) )
- {
- smallestteam = 1;
- smallestteam_count = c1;
- }
- if(c2 >= 0 && c2 < (c2 < smallestteam_count ||
- (c2 == smallestteam_count && self.team == COLOR_TEAM2) ) )
- {
- smallestteam = 2;
- smallestteam_count = c2;
- }
- if(c3 >= 0 && c3 < (c3 < smallestteam_count ||
- (c3 == smallestteam_count && self.team == COLOR_TEAM3) ) )
- {
- smallestteam = 3;
- smallestteam_count = c3;
- }
- if(c4 >= 0 && c4 < (c4 < smallestteam_count ||
- (c4 == smallestteam_count && self.team == COLOR_TEAM4) ) )
- {
- smallestteam = 4;
- smallestteam_count = c4;
- }
- }
- if(smallestteam == 1)
- {
- selectedteam = COLOR_TEAM1 - 1;
- }
- if(smallestteam == 2)
- {
- selectedteam = COLOR_TEAM2 - 1;
- }
- if(smallestteam == 3)
- {
- selectedteam = COLOR_TEAM3 - 1;
- }
- if(smallestteam == 4)
- {
- selectedteam = COLOR_TEAM4 - 1;
- }
- SetPlayerColors(pl, selectedteam);
-}
-*/
/*QUAKED spawnfunc_dom_controlpoint (0 .5 .8) (-16 -16 -24) (16 16 32)
Control point for Domination gameplay.
*/
self.effects = self.effects | EF_LOWPRECISION;
if (autocvar_g_domination_point_fullbright)
self.effects |= EF_FULLBRIGHT;
-};
+}
// code from here on is just to support maps that don't have control point and team entities
void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, string capsound, string capnarration, string capmessage)
{
- local entity oldself;
+ entity oldself;
oldself = self;
self = spawn();
self.classname = "dom_team";
//eprint(self);
self = oldself;
-};
+}
void dom_spawnpoint(vector org)
{
- local entity oldself;
+ entity oldself;
oldself = self;
self = spawn();
self.classname = "dom_controlpoint";
setorigin(self, org);
spawnfunc_dom_controlpoint();
self = oldself;
-};
+}
// spawn some default teams if the map is not set up for domination
void dom_spawnteams()
if(numteams > 3)
dom_spawnteam("Pink", COLOR_TEAM4-1, "models/domination/dom_pink.md3", 0, "domination/claim.wav", "", "Pink team has captured a control point");
dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, "", "", "");
-};
+}
void dom_delayedinit()
{
- local entity head;
+ entity head;
// if no teams are found, spawn defaults, if custom teams are set, use them
if (find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
}
ScoreRules_dom();
-};
+}
void dom_init()
{
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);
-};
+}