r2242 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Mar 17 07:49:19 EDT 2007
Author: div0
Date: 2007-03-17 07:49:19 -0400 (Sat, 17 Mar 2007)
New Revision: 2242
Modified:
trunk/data/qcsrc/server/arena.qc
trunk/data/qcsrc/server/ctf.qc
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/domination.qc
trunk/data/qcsrc/server/g_damage.qc
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/runematch.qc
trunk/data/qcsrc/server/teamplay.qc
Log:
preparations for better team auto balancing;
TODO: make a PlayerValue function, and fix all existing team balance code to not rely on counts but on scores
Modified: trunk/data/qcsrc/server/arena.qc
===================================================================
--- trunk/data/qcsrc/server/arena.qc 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/arena.qc 2007-03-17 11:49:19 UTC (rev 2242)
@@ -60,7 +60,7 @@
}
if(champion)
- champion.frags += 1;
+ UpdateFrags(champion, +1);
}
void Spawnqueue_Insert(entity e)
Modified: trunk/data/qcsrc/server/ctf.qc
===================================================================
--- trunk/data/qcsrc/server/ctf.qc 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/ctf.qc 2007-03-17 11:49:19 UTC (rev 2242)
@@ -212,14 +212,14 @@
LogCTF("capture", other.flagcarried.team, other);
// give credit to the individual player
- other.frags = other.frags + cvar("g_ctf_flagscore_capture");//FLAGSCORE_CAPTURE;
+ UpdateFrags(other, cvar("g_ctf_flagscore_capture"));
// give credit to all players of the team (rewards large teams)
// NOTE: this defaults to 0
head = find(head, classname, "player");
while (head)
{
if (head.team == self.team)
- head.frags = head.frags + cvar("g_ctf_flagscore_capture_team");//FLAGSCORE_CAPTURE_TEAM;
+ UpdateFrags(head, cvar("g_ctf_flagscore_capture_team"));
head = find(head, classname, "player");
}
sound (self, CHAN_AUTO, self.noise2, 1, ATTN_NONE);
@@ -242,7 +242,7 @@
other.flagcarried = self;
self.cnt = FLAG_CARRY;
bprint(other.netname, "^7 got the ", self.netname, "\n");
- other.frags = other.frags + cvar("g_ctf_flagscore_pickup");//FLAGSCORE_PICKUP;
+ UpdateFrags(other, cvar("g_ctf_flagscore_pickup"));
LogCTF("steal", self.team, other);
sound (self, CHAN_AUTO, self.noise, 1, ATTN_NONE);
@@ -267,9 +267,9 @@
// return flag
bprint(other.netname, "^7 returned the ", self.netname, "\n");
if (other.team == 5 || other.team == 14)
- other.frags = other.frags + cvar("g_ctf_flagscore_return");//FLAGSCORE_RETURN;
+ UpdateFrags(other, cvar("g_ctf_flagscore_return"));
else
- other.frags = other.frags + cvar("g_ctf_flagscore_return_rogue");//FLAGSCORE_RETURNROGUE;
+ UpdateFrags(other, cvar("g_ctf_flagscore_return_rogue"));
LogCTF("return", self.team, other);
sound (self, CHAN_AUTO, self.noise1, 1, ATTN_NONE);
ReturnFlag(self);
@@ -283,7 +283,7 @@
other.flagcarried = self;
self.cnt = FLAG_CARRY;
bprint(other.netname, "^7 picked up the ", self.netname, "\n");
- other.frags = other.frags + cvar("g_ctf_flagscore_pickup");//FLAGSCORE_PICKUP;
+ UpdateFrags(other, cvar("g_ctf_flagscore_pickup"));
LogCTF("pickup", self.team, other);
sound (self, CHAN_AUTO, self.noise, 1, ATTN_NONE);
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/defs.qh 2007-03-17 11:49:19 UTC (rev 2242)
@@ -10,6 +10,9 @@
float lms_next_place;
float() LMS_NewPlayerLives;
+void(entity player, float f) UpdateFrags;
+.float totalfrags;
+
float team1_score, team2_score, team3_score, team4_score;
float maxclients;
@@ -60,6 +63,7 @@
.float count;
//.float cnt2;
+.float play_time;
.float death_time;
.float dead_time;
.float dead_frame;
Modified: trunk/data/qcsrc/server/domination.qc
===================================================================
--- trunk/data/qcsrc/server/domination.qc 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/domination.qc 2007-03-17 11:49:19 UTC (rev 2242)
@@ -129,7 +129,7 @@
while (head)
{
if (head.team == self.goalentity.team)
- head.frags = head.frags + teamfragamt;
+ UpdateFrags(head, teamfragamt);
head = find(head, classname, "player");
}
}
@@ -160,7 +160,7 @@
individualfragamt = cvar("g_domination_point_amt");
if(!individualfragamt)
individualfragamt = self.frags;
- self.enemy.frags = self.enemy.frags + individualfragamt;
+ UpdateFrags(self.enemy, individualfragamt);
}
};
Modified: trunk/data/qcsrc/server/g_damage.qc
===================================================================
--- trunk/data/qcsrc/server/g_damage.qc 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/g_damage.qc 2007-03-17 11:49:19 UTC (rev 2242)
@@ -1,6 +1,12 @@
float checkrules_firstblood;
+void(entity player, float f) UpdateFrags =
+{
+ player.frags += f;
+ player.totalfrags += f;
+}
+
void GiveFrags (entity attacker, entity targ, float f)
{
if(gameover) return;
@@ -39,7 +45,7 @@
}
if(f)
- attacker.frags = attacker.frags + f;
+ UpdateFrags(attacker, f);
}
string AppendItemcodes(string s, entity player)
@@ -161,7 +167,6 @@
LogDeath("suicide", deathtype, targ, targ);
GiveFrags(attacker, targ, -1);
}
- //targ.frags = targ.frags - 1;
if (targ.killcount > 2)
bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
}
@@ -172,7 +177,6 @@
centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
GiveFrags(attacker, targ, -1);
- //attacker.frags = attacker.frags - 1;
if (targ.killcount > 2)
bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a teammate!\n");
if (attacker.killcount > 2)
@@ -233,7 +237,6 @@
bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
GiveFrags(attacker, targ, 1);
- //attacker.frags = attacker.frags + 1;
if (targ.killcount > 2)
bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
attacker.killcount = attacker.killcount + 1;
@@ -303,7 +306,6 @@
stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
}
- //targ.frags = targ.frags - 1;
if (targ.killcount > 2)
bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/g_world.qc 2007-03-17 11:49:19 UTC (rev 2242)
@@ -900,6 +900,11 @@
*/
void() NextLevel =
{
+ float minTotalFrags;
+ float maxTotalFrags;
+ float score;
+ float f;
+
gameover = TRUE;
intermission_running = 1;
@@ -925,9 +930,17 @@
GameLogClose();
- other = findchainflags(flags, FL_CLIENT);
- while (other != world)
+ maxTotalFrags = 0;
+ for(other = world; (other = findflags(other, flags, FL_CLIENT)); )
{
+ if(maxTotalFrags < other.totalfrags)
+ maxTotalFrags = other.totalfrags;
+ if(minTotalFrags > other.totalfrags)
+ minTotalFrags = other.totalfrags;
+ }
+
+ for(other = world; (other = findflags(other, flags, FL_CLIENT)); )
+ {
//other.nextthink = time + 0.5;
other.takedamage = DAMAGE_NO;
other.solid = SOLID_NOT;
@@ -941,23 +954,12 @@
if(other.winning)
bprint(strcat(other.netname, " ^7wins.\n"));
- /*
- if (pos != world);
+ if(!currentbots)
{
- other.modelindex = 0;
- other.weaponentity = world; // remove weapon model
- other.view_ofs = '0 0 0';
- other.angles = other.v_angle = pos.mangle;
- if (!other.angles)
- {
- other.angles = other.v_angle = pos.angles;
- other.v_angle_x = other.v_angle_x * -1;
- }
- other.fixangle = TRUE; // turn this way immediately
- setorigin (other, pos.origin);
+ score = (other.frags - minTotalFrags) / max(maxTotalFrags - minTotalFrags, 1);
+ f = bound(0, other.play_time / max(time, 1), 1);
+ // store some statistics?
}
- */
- other = other.chain;
}
if(cvar("g_campaign"))
@@ -978,6 +980,9 @@
if (gameover) // someone else quit the game already
return;
+ if(self.deadflag == DEAD_NO)
+ self.play_time += frametime;
+
// fixme: don't check players; instead check dom_team and ctf_team entities
// (div0: and that in CheckRules_World please)
};
@@ -1314,11 +1319,14 @@
void PrintScoreboardFor(string name, string colorcode, float whichteam)
{
entity head;
+ float v;
+ float teamvalue;
float fragtotal;
string s;
float found;
found = FALSE;
head = find(world, classname, "player");
+ teamvalue = 0;
while(head)
{
if(!whichteam || head.team == whichteam)
@@ -1335,12 +1343,19 @@
s = strcat(s, "botms");
else
s = strcat(s, "ms");
+ v = PlayerValue(head);
+ teamvalue += v;
+ s = strcat(s, " / ", ftos(v));
ServerConsoleEcho(strcat(" ", colorcode, head.netname, colorcode, " (", s, ")"), TRUE);
}
head = find(head, classname, "player");
}
if(whichteam && found)
- ServerConsoleEcho(strcat(colorcode, " (total: ", ftos(fragtotal), ")"), FALSE);
+ {
+ s = ftos(fragtotal);
+ s = strcat(s, " / ", ftos(teamvalue));
+ ServerConsoleEcho(strcat(colorcode, " (total: ", s, ")"), FALSE);
+ }
}
void PrintScoreboard()
Modified: trunk/data/qcsrc/server/runematch.qc
===================================================================
--- trunk/data/qcsrc/server/runematch.qc 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/runematch.qc 2007-03-17 11:49:19 UTC (rev 2242)
@@ -659,7 +659,7 @@
if(rune.owner.classname == "player")
{
- rune.owner.frags = rune.owner.frags + cvar("g_runematch_pointamt");
+ UpdateFrags(rune.owner, cvar("g_runematch_pointamt"));
}
}while(rune);
}
Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc 2007-03-16 18:56:09 UTC (rev 2241)
+++ trunk/data/qcsrc/server/teamplay.qc 2007-03-17 11:49:19 UTC (rev 2242)
@@ -6,7 +6,6 @@
float GAME_LMS = 6;
float GAME_ARENA = 7;
-
// client counts for each team
float c1, c2, c3, c4;
// # of bots on those teams
@@ -16,6 +15,16 @@
float audit_teams_time;
+float() IsTeamBalanceForced() = {
+ if(cvar("g_campaign"))
+ return FALSE;
+ if(!cvar("g_balance_teams_force"))
+ return FALSE;
+ if(!cvar("teamplay"))
+ return FALSE;
+ return TRUE;
+}
+
void TeamchangeFrags(entity e)
{
if(e.classname == "player")
@@ -538,11 +547,19 @@
}
}
+float PlayerValue(entity p, entity to)
+{
+ if(IsTeamBalanceForced())
+ return 1;
+ return 1;
+}
+
// c1...c4 should be set to -1 (not allowed) or 0 (allowed).
// teams that are allowed will now have their player counts stored in c1...c4
void GetTeamCounts(entity ignore)
{
entity head;
+ float value;
// now count how many players are on each team already
// FIXME: also find and memorize the lowest-scoring bot on each team (in case players must be shuffled around)
@@ -553,36 +570,37 @@
{
if(head != ignore)// && head.netname != "")
{
+ value = PlayerValue(head, ignore);
if(head.team == COLOR_TEAM1)
{
if(c1 >= 0)
{
- c1 = c1 + 1;
- cb1 = cb1 + 1;
+ c1 = c1 + value;
+ cb1 = cb1 + value;
}
}
if(head.team == COLOR_TEAM2)
{
if(c2 >= 0)
{
- c2 = c2 + 1;
- cb2 = cb2 + 1;
+ c2 = c2 + value;
+ cb2 = cb2 + value;
}
}
if(head.team == COLOR_TEAM3)
{
if(c3 >= 0)
{
- c3 = c3 + 1;
- cb3 = cb3 + 1;
+ c3 = c3 + value;
+ cb3 = cb3 + value;
}
}
if(head.team == COLOR_TEAM4)
{
if(c4 >= 0)
{
- c4 = c4 + 1;
- cb4 = cb4 + 1;
+ c4 = c4 + value;
+ cb4 = cb4 + value;
}
}
}
@@ -1084,12 +1102,8 @@
void AuditTeams()
{
float numplayers, numteams, average;
- if(cvar("g_campaign"))
+ if(!IsTeamBalanceForced())
return;
- if(!cvar("g_balance_teams_force"))
- return;
- if(!cvar("teamplay"))
- return;
if(audit_teams_time > time)
return;
@@ -1129,7 +1143,7 @@
if(numteams < 2)
return; // don't bother shuffling if for some reason there aren't any teams
- average = ceil(numplayers / numteams);
+ average = (numplayers / numteams) + 1;
if(average <= 0)
return; // that's weird...
More information about the nexuiz-commits
mailing list