r2493 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat May 5 08:02:30 EDT 2007
Author: div0
Date: 2007-05-05 08:02:29 -0400 (Sat, 05 May 2007)
New Revision: 2493
Modified:
trunk/data/qcsrc/server/bots.qc
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/runematch.qc
trunk/data/qcsrc/server/teamplay.qc
Log:
correctly handle bots now between spectate/unspectate...
Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc 2007-05-05 11:01:25 UTC (rev 2492)
+++ trunk/data/qcsrc/server/bots.qc 2007-05-05 12:02:29 UTC (rev 2493)
@@ -1899,10 +1899,64 @@
return bot;
};
+void CheckAllowedTeams(); void GetTeamCounts(entity other); float c1, c2, c3, c4;
+void() bot_removefromlargestteam =
+{
+ local float besttime, bestcount, thiscount;
+ local entity best, head;
+ CheckAllowedTeams();
+ GetTeamCounts(world);
+ dprint("c1 = ", ftos(c1), "\n");
+ dprint("c2 = ", ftos(c2), "\n");
+ dprint("c3 = ", ftos(c3), "\n");
+ dprint("c4 = ", ftos(c4), "\n");
+ head = findchainfloat(isbot, TRUE);
+ if (!head)
+ return;
+ best = head;
+ besttime = head.createdtime;
+ bestcount = 0;
+ while (head)
+ {
+ if(head.team == COLOR_TEAM1)
+ thiscount = c1;
+ else if(head.team == COLOR_TEAM2)
+ thiscount = c2;
+ else if(head.team == COLOR_TEAM3)
+ thiscount = c3;
+ else if(head.team == COLOR_TEAM4)
+ thiscount = c4;
+ else
+ thiscount = 0;
+ if (thiscount > bestcount)
+ {
+ bestcount = thiscount;
+ besttime = head.createdtime;
+ best = head;
+ }
+ else if (thiscount == bestcount && besttime < head.createdtime)
+ {
+ besttime = head.createdtime;
+ best = head;
+ }
+ head = head.chain;
+ }
+ currentbots = currentbots - 1;
+ dprint("Removing from a ", ftos(bestcount), " players team!\n");
+ dropclient(best);
+};
+
void() bot_removenewest =
{
local float besttime;
local entity best, head;
+
+ if(teams_matter)
+ {
+ bot_removefromlargestteam();
+ return;
+ }
+
head = findchainfloat(isbot, TRUE);
if (!head)
return;
@@ -2044,6 +2098,7 @@
// minplayers+bot_number, or remove all bots if no one is playing
// But don't remove bots immediately on level change, as the real players
// usually haven't rejoined yet
+ bots_would_leave = FALSE;
if (realplayers || cvar("bot_join_empty") || (currentbots > 0 && time < 5))
{
float realminplayers, minplayers;
@@ -2055,6 +2110,8 @@
minbots = max(0, floor(realminbots));
bots = min(max(minbots, minplayers - activerealplayers), maxclients - realplayers);
+ if(bots > minbots)
+ bots_would_leave = TRUE;
}
else
{
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2007-05-05 11:01:25 UTC (rev 2492)
+++ trunk/data/qcsrc/server/defs.qh 2007-05-05 12:02:29 UTC (rev 2493)
@@ -7,6 +7,7 @@
float player_count;
float currentbots;
+float bots_would_leave;
float lms_lowest_lives;
float lms_next_place;
float() LMS_NewPlayerLives;
Modified: trunk/data/qcsrc/server/runematch.qc
===================================================================
--- trunk/data/qcsrc/server/runematch.qc 2007-05-05 11:01:25 UTC (rev 2492)
+++ trunk/data/qcsrc/server/runematch.qc 2007-05-05 12:02:29 UTC (rev 2493)
@@ -342,7 +342,7 @@
entity rune, curse;
float rcount, ccount, r, c, rand, prevent_same, numtodrop, tries;
- entity c1, r1, c2, r2;
+ entity curse1, rune1, curse2, rune2;
rune = curse = world;
rcount = ccount = r = c = 0;
@@ -400,29 +400,29 @@
// pair rune and curse
- r1 = rune;
- c1 = curse;
- r2 = c1.enemy;
- c2 = r1.enemy;
+ rune1 = rune;
+ curse1 = curse;
+ rune2 = curse1.enemy;
+ curse2 = rune1.enemy;
- if(r1 != r2) // not already attached to each other
+ if(rune1 != rune2) // not already attached to each other
{
- r1.enemy = c1;
- c1.enemy = r1;
- setattachment(c1, r1, "");
- r2.enemy = c2;
- c2.enemy = r2;
- setattachment(c2, r2, "");
- //DropRune(pl, r2);
+ rune1.enemy = curse1;
+ curse1.enemy = rune1;
+ setattachment(curse1, rune1, "");
+ rune2.enemy = curse2;
+ curse2.enemy = rune2;
+ setattachment(curse2, rune2, "");
+ //DropRune(pl, rune2);
//ccount = ccount - 1;
//rcount = rcount - 1;
}
- DropRune(pl, r1);
+ DropRune(pl, rune1);
if(numtodrop <=0)
{
- r1.think = rune_respawn;
- r1.nextthink = time;
+ rune1.think = rune_respawn;
+ rune1.nextthink = time;
}
numtodrop = numtodrop - 1;
Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc 2007-05-05 11:01:25 UTC (rev 2492)
+++ trunk/data/qcsrc/server/teamplay.qc 2007-05-05 12:02:29 UTC (rev 2493)
@@ -579,7 +579,7 @@
void GetTeamCounts(entity ignore)
{
entity head;
- float value;
+ float value, bvalue;
// 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)
@@ -590,12 +590,16 @@
if(head != ignore)// && head.netname != "")
{
value = PlayerValue(head);
+ if(clienttype(head) == CLIENTTYPE_BOT)
+ bvalue = value;
+ else
+ bvalue = 0;
if(head.team == COLOR_TEAM1)
{
if(c1 >= 0)
{
c1 = c1 + value;
- cb1 = cb1 + value;
+ cb1 = cb1 + bvalue;
}
}
if(head.team == COLOR_TEAM2)
@@ -603,7 +607,7 @@
if(c2 >= 0)
{
c2 = c2 + value;
- cb2 = cb2 + value;
+ cb2 = cb2 + bvalue;
}
}
if(head.team == COLOR_TEAM3)
@@ -611,7 +615,7 @@
if(c3 >= 0)
{
c3 = c3 + value;
- cb3 = cb3 + value;
+ cb3 = cb3 + bvalue;
}
}
if(head.team == COLOR_TEAM4)
@@ -619,7 +623,7 @@
if(c4 >= 0)
{
c4 = c4 + value;
- cb4 = cb4 + value;
+ cb4 = cb4 + bvalue;
}
}
}
@@ -676,6 +680,16 @@
// 2 doesn't seem to work though...
balance_type = 1;
+ if(bots_would_leave)
+ if(pl.classname != "player")
+ if(clienttype(pl) != CLIENTTYPE_BOT)
+ {
+ c1 -= cb1 * 255.0/256;
+ c2 -= cb2 * 255.0/256;
+ c3 -= cb3 * 255.0/256;
+ c4 -= cb4 * 255.0/256;
+ }
+
if(balance_type == 1)
{
if(c1 >= 0 && (c1 < smallestteam_count || (c1 <= smallestteam_count && team1_score < smallestteam_score)))
More information about the nexuiz-commits
mailing list