r2496 - in branches/nexuiz-2.0/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat May 5 16:02:15 EDT 2007


Author: div0
Date: 2007-05-05 16:02:15 -0400 (Sat, 05 May 2007)
New Revision: 2496

Modified:
   branches/nexuiz-2.0/data/default.cfg
   branches/nexuiz-2.0/data/game_reset.cfg
   branches/nexuiz-2.0/data/qcsrc/server/bots.qc
   branches/nexuiz-2.0/data/qcsrc/server/cl_player.qc
   branches/nexuiz-2.0/data/qcsrc/server/defs.qh
   branches/nexuiz-2.0/data/qcsrc/server/runematch.qc
   branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc
Log:
make minplayers only check active players; gib eye fix; keyhunt fixes


Modified: branches/nexuiz-2.0/data/default.cfg
===================================================================
--- branches/nexuiz-2.0/data/default.cfg	2007-05-05 19:29:21 UTC (rev 2495)
+++ branches/nexuiz-2.0/data/default.cfg	2007-05-05 20:02:15 UTC (rev 2496)
@@ -724,7 +724,7 @@
 
 // key hunt
 set g_keyhunt 0
-set g_balance_keyhunt_delay_return 30
+set g_balance_keyhunt_delay_return 60
 set g_balance_keyhunt_delay_round 5
 set g_balance_keyhunt_delay_tracking 10
 set g_balance_keyhunt_delay_fadeout 2

Modified: branches/nexuiz-2.0/data/game_reset.cfg
===================================================================
--- branches/nexuiz-2.0/data/game_reset.cfg	2007-05-05 19:29:21 UTC (rev 2495)
+++ branches/nexuiz-2.0/data/game_reset.cfg	2007-05-05 20:02:15 UTC (rev 2496)
@@ -21,4 +21,9 @@
 set g_respawn_mapsettings_delay 0
 set g_respawn_mapsettings_waves 0
 
+// prepare for loading a mapcfg
+set timelimit 0
+set fraglimit 0
+set g_keyhunt_teams 0
+
 set exit_cfg empty.cfg

Modified: branches/nexuiz-2.0/data/qcsrc/server/bots.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/bots.qc	2007-05-05 19:29:21 UTC (rev 2495)
+++ branches/nexuiz-2.0/data/qcsrc/server/bots.qc	2007-05-05 20:02:15 UTC (rev 2496)
@@ -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;
@@ -2021,7 +2075,8 @@
 float botframe_nextthink;
 void() bot_serverframe =
 {
-	float realplayers, bots;
+	float realplayers, bots, activerealplayers;
+	entity head;
 
 	if (intermission_running)
 		return;
@@ -2029,12 +2084,21 @@
 	if (time < 2)
 		return;
 
-	realplayers = player_count - currentbots;
+	activerealplayers = 0;
+	realplayers = 0;
 
+	FOR_EACH_REALCLIENT(head)
+	{
+		if(head.classname == "player")
+			++activerealplayers;
+		++realplayers;
+	}
+
 	// add/remove bots if needed to make sure there are at least
 	// 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;
@@ -2045,7 +2109,9 @@
 		realminbots = cvar("bot_number");
 		minbots = max(0, floor(realminbots));
 
-		bots = min(max(minbots, minplayers - realplayers), maxclients - realplayers);
+		bots = min(max(minbots, minplayers - activerealplayers), maxclients - realplayers);
+		if(bots > minbots)
+			bots_would_leave = TRUE;
 	}
 	else
 	{

Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_player.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_player.qc	2007-05-05 19:29:21 UTC (rev 2495)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_player.qc	2007-05-05 20:02:15 UTC (rev 2496)
@@ -44,6 +44,8 @@
 	self.solid = oldself.solid;
 	self.takedamage = oldself.takedamage;
 	self.think = oldself.think;
+	self.gibrandom = oldself.gibrandom;
+	self.customizeentityforclient = oldself.customizeentityforclient;
 	if (keepvelocity == 1)
 		self.velocity = oldself.velocity;
 	self.oldvelocity = self.velocity;

Modified: branches/nexuiz-2.0/data/qcsrc/server/defs.qh
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/defs.qh	2007-05-05 19:29:21 UTC (rev 2495)
+++ branches/nexuiz-2.0/data/qcsrc/server/defs.qh	2007-05-05 20:02:15 UTC (rev 2496)
@@ -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: branches/nexuiz-2.0/data/qcsrc/server/runematch.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/runematch.qc	2007-05-05 19:29:21 UTC (rev 2495)
+++ branches/nexuiz-2.0/data/qcsrc/server/runematch.qc	2007-05-05 20:02:15 UTC (rev 2496)
@@ -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: branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc	2007-05-05 19:29:21 UTC (rev 2495)
+++ branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc	2007-05-05 20:02:15 UTC (rev 2496)
@@ -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