Example #1
0
File: bot.c Project: icanhas/yantar
/*
 * G_CheckMinimumPlayers
 */
void
G_CheckMinimumPlayers(void)
{
	int	minplayers;
	int	humanplayers, botplayers;
	static int checkminimumplayers_time;

	if(level.intermissiontime) return;
	/* only check once each 10 seconds */
	if(checkminimumplayers_time > level.time - 10000)
		return;
	checkminimumplayers_time = level.time;
	trap_cvarupdate(&bot_minplayers);
	minplayers = bot_minplayers.integer;
	if(minplayers <= 0) return;

	if(g_gametype.integer >= GT_TEAM){
		if(minplayers >= g_maxclients.integer / 2)
			minplayers = (g_maxclients.integer / 2) -1;

		humanplayers = G_CountHumanPlayers(TEAM_RED);
		botplayers = G_CountBotPlayers(TEAM_RED);
		if(humanplayers + botplayers < minplayers)
			G_AddRandomBot(TEAM_RED);
		else if(humanplayers + botplayers > minplayers && botplayers)
			G_RemoveRandomBot(TEAM_RED);
		humanplayers = G_CountHumanPlayers(TEAM_BLUE);
		botplayers = G_CountBotPlayers(TEAM_BLUE);
		if(humanplayers + botplayers < minplayers)
			G_AddRandomBot(TEAM_BLUE);
		else if(humanplayers + botplayers > minplayers && botplayers)
			G_RemoveRandomBot(TEAM_BLUE);
	}else if(g_gametype.integer == GT_TOURNAMENT){
		if(minplayers >= g_maxclients.integer)
			minplayers = g_maxclients.integer-1;
		humanplayers = G_CountHumanPlayers(-1);
		botplayers = G_CountBotPlayers(-1);
		if(humanplayers + botplayers < minplayers)
			G_AddRandomBot(TEAM_FREE);
		else if(humanplayers + botplayers > minplayers && botplayers)
			/* try to remove spectators first */
			if(!G_RemoveRandomBot(TEAM_SPECTATOR))
				/* just remove the bot that is playing */
				G_RemoveRandomBot(-1);
	}else if(g_gametype.integer == GT_FFA){
		if(minplayers >= g_maxclients.integer)
			minplayers = g_maxclients.integer-1;
		humanplayers = G_CountHumanPlayers(TEAM_FREE);
		botplayers = G_CountBotPlayers(TEAM_FREE);
		if(humanplayers + botplayers < minplayers)
			G_AddRandomBot(TEAM_FREE);
		else if(humanplayers + botplayers > minplayers && botplayers)
			G_RemoveRandomBot(TEAM_FREE);
	}
}
Example #2
0
/*
===============
G_CheckMinimumPlayers
===============
 */
void G_CheckMinimumPlayers(void) {
    int minplayers;
    int humanplayers, botplayers;
    static int checkminimumplayers_time;

    if (level.intermissiontime) return;
    //only check once each 10 seconds
    if (checkminimumplayers_time > level.time - 10000) {
        return;
    }
    checkminimumplayers_time = level.time;
    trap_Cvar_Update(&bot_minplayers);
    minplayers = bot_minplayers.integer;
    if (minplayers <= 0) return;

    if (g_gametype.integer == GT_TEAMSURVIVOR) {
        if (minplayers >= g_maxclients.integer / 2) {
            minplayers = (g_maxclients.integer / 2) - 1;
        }

        humanplayers = G_CountHumanPlayers(TEAM_RED);
        botplayers = G_CountBotPlayers(TEAM_RED);
        //
        if (humanplayers + botplayers < minplayers) {
            G_AddRandomBot(TEAM_RED);
        } else if (humanplayers + botplayers > minplayers && botplayers) {
            G_RemoveRandomBot(TEAM_RED);
        }
        //
        humanplayers = G_CountHumanPlayers(TEAM_BLUE);
        botplayers = G_CountBotPlayers(TEAM_BLUE);
        //
        if (humanplayers + botplayers < minplayers) {
            G_AddRandomBot(TEAM_BLUE);
        } else if (humanplayers + botplayers > minplayers && botplayers) {
            G_RemoveRandomBot(TEAM_BLUE);
        }
    } else if (g_gametype.integer == GT_FFA) {
        if (minplayers >= g_maxclients.integer) {
            minplayers = g_maxclients.integer - 1;
        }
        humanplayers = G_CountHumanPlayers(TEAM_FREE);
        botplayers = G_CountBotPlayers(TEAM_FREE);
        //
        if (humanplayers + botplayers < minplayers) {
            G_AddRandomBot(TEAM_FREE);
        } else if (humanplayers + botplayers > minplayers && botplayers) {
            G_RemoveRandomBot(TEAM_FREE);
        }
    }
}
Example #3
0
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int minplayers;
	int humanplayers, botplayers;
	static int checkminimumplayers_time;

	if (g_gametype.integer == GT_SIEGE)
	{
		return;
	}

	if (level.intermissiontime) return;
	//only check once each 10 seconds
	if (checkminimumplayers_time > level.time - 10000) {
		return;
	}
	checkminimumplayers_time = level.time;
	trap_Cvar_Update(&bot_minplayers);
	minplayers = bot_minplayers.integer;
	if (minplayers <= 0) return;

	if (minplayers > g_maxclients.integer)
	{
		minplayers = g_maxclients.integer;
	}

	humanplayers = G_CountHumanPlayers( -1 );
	botplayers = G_CountBotPlayers(	-1 );

	if ((humanplayers+botplayers) < minplayers)
	{
		G_AddRandomBot(-1);
	}
	else if ((humanplayers+botplayers) > minplayers && botplayers)
	{
		// try to remove spectators first
		if (!G_RemoveRandomBot(TEAM_SPECTATOR))
		{
			// just remove the bot that is playing
			G_RemoveRandomBot(-1);
		}
	}
}
Example #4
0
File: g_bot.c Project: Geptun/japp
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int humanplayers, botplayers;
	static int checkminimumplayers_time;

	if ( level.gametype == GT_SIEGE )
		return;

	if ( level.intermissiontime )
		return;

	//only check once each 10 seconds
	if ( checkminimumplayers_time > level.time - (bot_addDelay.integer*1000) )
		return;

	checkminimumplayers_time = level.time;

	if ( bot_minplayers.integer <= 0 )
		return;

	if ( bot_minplayers.integer > sv_maxclients.integer ) {
		trap->Cvar_Set( "bot_minplayers", sv_maxclients.string );
		trap->Cvar_Update( &bot_minplayers );
	}

	humanplayers = G_CountHumanPlayers( -1 );
	botplayers = G_CountBotPlayers(	-1 );

	// if numPlayers < minPlayers and (maxBots and numPlayers < maxBots)
	//	then addbot
	if ( (humanplayers+botplayers) < bot_minplayers.integer
		&& (!bot_maxbots.integer || (humanplayers+botplayers) < bot_maxbots.integer) )
	{
		G_AddRandomBot( -1 );
	}
	else if ( ((humanplayers+botplayers) > bot_minplayers.integer && botplayers)
		|| (botplayers > bot_maxbots.integer && botplayers && bot_maxbots.integer) )
	{
		// try to remove spectators first
		if ( !G_RemoveRandomBot( TEAM_SPECTATOR ) )
			G_RemoveRandomBot( -1 );
	}
}
Example #5
0
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int minplayers;
	int humanplayers, botplayers;
	static int checkminimumplayers_time;

	if (level.intermissiontime) return;
	//only check once each 10 seconds
	//if (checkminimumplayers_time > level.time - 10000) {
	if (checkminimumplayers_time > level.time - (1000 + (bot_minplayersTime.integer * 100))) { // leilei - faster time

		return;
	}
	checkminimumplayers_time = level.time;
	trap_Cvar_Update(&bot_minplayers);

	minplayers = bot_minplayers.integer;
	if (minplayers <= 0) return;

        if (!trap_AAS_Initialized())
        {
            minplayers = 0;
            checkminimumplayers_time = level.time+600*1000;
            return; //If no AAS then don't even try
        }

	if (g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
		if (minplayers >= g_maxclients.integer / 2) {
			minplayers = (g_maxclients.integer / 2) -1;
		}

		humanplayers = G_CountHumanPlayers( TEAM_RED );
		botplayers = G_CountBotPlayers(	TEAM_RED );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_RED );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_RED );
		}
		//
		humanplayers = G_CountHumanPlayers( TEAM_BLUE );
		botplayers = G_CountBotPlayers( TEAM_BLUE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_BLUE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_BLUE );
		}
	}
	else if (g_gametype.integer == GT_TOURNAMENT ) {
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( -1 );
		botplayers = G_CountBotPlayers( -1 );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			// try to remove spectators first
			if (!G_RemoveRandomBot( TEAM_SPECTATOR )) {
				// just remove the bot that is playing
				G_RemoveRandomBot( -1 );
			}
		}
	}
	else if (g_gametype.integer == GT_FFA || g_gametype.integer == GT_LMS) {
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_FREE );
		botplayers = G_CountBotPlayers( TEAM_FREE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_FREE );
		}
	}
}
Example #6
0
//[/BotTweaks]
//RACC - Adds/removes bots to maintain the minimum player limit.
void G_CheckMinimumPlayers( void ) {
	int minplayers;
	int humanplayers, botplayers;
	//[BotTweaks]
	int humanplayers2, botplayers2;
	//[/BotTweaks]
	static int checkminimumplayers_time;

	//[TABBot]
	//We want the minimum players system to work in siege.
	/*
	if (g_gametype.integer == GT_SIEGE)
	{
		return;
	}
	*/
	//[/TABBot]

	//[NewGameTypes][EnhancedImpliment]
	/*
	if (g_gametype.integer == GT_RPG)// MJN - Not implementing this for RPG
	{
		return;
	}
	*/
	//[/NewGameTypes]

	//[TABBots]
	if(level.time - level.startTime < 10000)
	{//don't spawn in new bots for 10 seconds.  Otherwise we're going to be adding/removing
		//bots before the original ones spawn in.
		return;
	}
	//[/TABBots]

	if (level.intermissiontime) return;
	//only check once each 10 seconds
	if (checkminimumplayers_time > level.time - 10000) {
		return;
	}
	checkminimumplayers_time = level.time;
	trap_Cvar_Update(&bot_minplayers);
	minplayers = bot_minplayers.integer;

	//[BotTweaks]	
	//MJN - All that new fancy bot auto limiting code. :)
	if(g_allowBotLimit.integer == 0)
	{
		if (minplayers <= 0) 
			return;
	}

	if(g_allowBotLimit.integer == 1)
	{
		if ( g_minHumans.integer < 0 )
		{//clamp g_minHumans to positive values.
			g_minHumans.integer = 0;
		}
			
		if(g_maxBots.integer <= 0) 
		{//just don't do anything if g_maxBots is zero or negative.
			return;
		}
	}
	
	if(g_allowBotLimit.integer == 1)
	{//use the new bot code that Chosen One did for us.
		// Teams each get Max Bots specified
		if (g_gametype.integer >= GT_TEAM) 
		{//team gametypes
			// MJN - Make sure numbers don't exceed maxclients
			if (minplayers >= g_maxclients.integer / 2) 
			{
				minplayers = (g_maxclients.integer / 2) -1;
			}
			if (g_maxBots.integer >= g_maxclients.integer / 2) 
			{
				g_maxBots.integer = (g_maxclients.integer / 2) -1;
			}
			if (g_minHumans.integer >= g_maxclients.integer / 2) 
			{
				g_minHumans.integer = (g_maxclients.integer / 2) -1;
			}

			//Handle Red Team Count

			//[AdminSys]
			humanplayers = G_CountHumanPlayers( -1, TEAM_RED );
			//humanplayers = G_CountHumanPlayers( TEAM_RED );
			//[/AdminSys]
			botplayers = G_CountBotPlayers(	TEAM_RED );

			if(botplayers < g_maxBots.integer && humanplayers < g_minHumans.integer )
			{
				G_AddRandomBot( TEAM_RED );
			}
			else if (humanplayers + botplayers > g_maxBots.integer 
						&& humanplayers >= g_minHumans.integer ) 
			{
				G_RemoveRandomBot( TEAM_RED );
			} 

			//Handle Blue Team Count
			//[AdminSys]
			humanplayers2 = G_CountHumanPlayers( -1, TEAM_BLUE );
			//humanplayers2 = G_CountHumanPlayers( TEAM_BLUE );
			//[/AdminSys]
			botplayers2 = G_CountBotPlayers( TEAM_BLUE );

			// MJN - Max Bots/Min Humans added here	
			if(botplayers2 < g_maxBots.integer && humanplayers2 < g_minHumans.integer)
			{
				G_AddRandomBot( TEAM_BLUE );
			}
			else if (humanplayers2 + botplayers2 > g_maxBots.integer 
						&& humanplayers2 >= g_minHumans.integer) 
			{
				G_RemoveRandomBot( TEAM_BLUE );
			} 
		}
		else if (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL) 
		{//duel gametypes
			// MJN - Make sure numbers don't exceed maxclients
			if (minplayers >= g_maxclients.integer) 
			{
				minplayers = g_maxclients.integer-1;
			}
			if (g_maxBots.integer >= g_maxclients.integer) 
			{
				g_maxBots.integer = g_maxclients.integer-1;
			}
			if (g_minHumans.integer >= g_maxclients.integer) 
			{
				g_minHumans.integer = g_maxclients.integer-1;
			}

			//[AdminSys]
			humanplayers = G_CountHumanPlayers( -1, -1 );
			//humanplayers = G_CountHumanPlayers( -1 );
			//[/AdminSys]
			botplayers = G_CountBotPlayers( -1 );

			if(botplayers < g_maxBots.integer && humanplayers < g_minHumans.integer)
			{
				G_AddRandomBot( TEAM_FREE );
			}
			else if (humanplayers + botplayers > g_maxBots.integer 
						&& humanplayers >= g_minHumans.integer) 
			{
				// try to remove spectators first
				if (!G_RemoveRandomBot( TEAM_SPECTATOR )) 
				{
					// just remove the bot that is playing
					G_RemoveRandomBot( -1 );
				}
			} 
		}
		else if (g_gametype.integer == GT_FFA) 
		{//ffa gametype
			// MJN - Make sure numbers don't exceed maxclients
			if (minplayers >= g_maxclients.integer) 
			{
				minplayers = g_maxclients.integer-1;
			}
			if (g_maxBots.integer >= g_maxclients.integer) 
			{
				g_maxBots.integer = g_maxclients.integer-1;
			}
			if (g_minHumans.integer >= g_maxclients.integer) 
			{
				g_minHumans.integer = g_maxclients.integer-1;
			}

			//[AdminSys]
			humanplayers = G_CountHumanPlayers( -1, TEAM_FREE );
			//humanplayers = G_CountHumanPlayers( TEAM_FREE );
			//[/AdminSys]
			botplayers = G_CountBotPlayers( TEAM_FREE );

			if(botplayers < g_maxBots.integer && humanplayers < g_minHumans.integer)
			{
				G_AddRandomBot( TEAM_FREE );
			}
			else if (humanplayers + botplayers > g_maxBots.integer 
						&& humanplayers >= g_minHumans.integer) 
			{
				G_RemoveRandomBot( TEAM_FREE );
			} 
		}
		else if (g_gametype.integer == GT_HOLOCRON || g_gametype.integer == GT_JEDIMASTER) 
		{//special ffa gametypes
			// MJN - Make sure numbers don't exceed maxclients
			if (minplayers >= g_maxclients.integer) 
			{
				minplayers = g_maxclients.integer-1;
			}

			if (g_maxBots.integer >= g_maxclients.integer) 
			{
				g_maxBots.integer = g_maxclients.integer-1;
			}
			if (g_minHumans.integer >= g_maxclients.integer) 
			{
				g_minHumans.integer = g_maxclients.integer-1;
			}

			//[AdminSys]
			humanplayers = G_CountHumanPlayers( -1, TEAM_FREE );
			//humanplayers = G_CountHumanPlayers( TEAM_FREE );
			//[/AdminSys]
			botplayers = G_CountBotPlayers( TEAM_FREE );
			
			if(botplayers < g_maxBots.integer && humanplayers < g_minHumans.integer)
			{
				G_AddRandomBot( TEAM_FREE );
			}else if (humanplayers + botplayers > g_maxBots.integer 
						&& humanplayers >= g_minHumans.integer) 
			{
				G_RemoveRandomBot( TEAM_FREE );
			} 
		}
	}
	else
	{//use the basejka system for redundency's sake.
		if (minplayers <= 0) return;

		if (minplayers > g_maxclients.integer)
		{
			minplayers = g_maxclients.integer;
		}

		//[AdminSys]
		humanplayers = G_CountHumanPlayers( -1, -1 );
		//humanplayers = G_CountHumanPlayers( -1 );
		//[/AdminSys]
		botplayers = G_CountBotPlayers(	-1 );

		if ((humanplayers+botplayers) < minplayers)
		{
			G_AddRandomBot(-1);
		}
		else if ((humanplayers+botplayers) > minplayers && botplayers)
		{
			// try to remove spectators first
			if (!G_RemoveRandomBot(TEAM_SPECTATOR))
			{
				//[AdminSys]
				if(g_gametype.integer < GT_TEAM)
				{//no teams, just remove a bot.
					G_RemoveRandomBot(-1);
				}
				else if( g_teamForceBalance.integer > 1 )
				{//team game, determine which team to pull from.
					int botRemoveTeam = -1;
					int	counts[TEAM_NUM_TEAMS];

					counts[TEAM_BLUE] = TeamCount( -1, TEAM_BLUE );
					counts[TEAM_RED] = TeamCount( -1, TEAM_RED );

					//always remove bot from the team with the most players on it.
					//that should always balance the teams properly, except for human/bot
					//balancing.
					if(counts[TEAM_RED] > counts[TEAM_BLUE])
					{//red team has too many players
						botRemoveTeam = TEAM_RED;
					}
					else if(counts[TEAM_BLUE] > counts[TEAM_RED])
					{//blue team has too many players
						botRemoveTeam = TEAM_BLUE;
					}

					if(botRemoveTeam == -1 || !G_RemoveRandomBot(botRemoveTeam))
					{//didn't have a specific team to remove from or we couldn't remove from the team
						//we wanted.
						G_RemoveRandomBot(-1);
					}
				}

				// just remove the bot that is playing
				//G_RemoveRandomBot(-1);
				//[/AdminSys]
			}
		}
	}

	/* basejka code
	if (minplayers <= 0) return;

	if (minplayers > g_maxclients.integer)
	{
		minplayers = g_maxclients.integer;
	}

	humanplayers = G_CountHumanPlayers( -1 );
	botplayers = G_CountBotPlayers(	-1 );

	if ((humanplayers+botplayers) < minplayers)
	{
		G_AddRandomBot(-1);
	}
	else if ((humanplayers+botplayers) > minplayers && botplayers)
	{
		// try to remove spectators first
		if (!G_RemoveRandomBot(TEAM_SPECTATOR))
		{
			// just remove the bot that is playing
			G_RemoveRandomBot(-1);
		}
	}
	*/
	//[/BotTweaks]

	/*
	if (g_gametype.integer >= GT_TEAM) {
		int humanplayers2, botplayers2;
		if (minplayers >= g_maxclients.integer / 2) {
			minplayers = (g_maxclients.integer / 2) -1;
		}

		humanplayers = G_CountHumanPlayers( TEAM_RED );
		botplayers = G_CountBotPlayers(	TEAM_RED );
		humanplayers2 = G_CountHumanPlayers( TEAM_BLUE );
		botplayers2 = G_CountBotPlayers( TEAM_BLUE );
		//
		if ((humanplayers+botplayers+humanplayers2+botplayers) < minplayers)
		{
			if ((humanplayers+botplayers) < (humanplayers2+botplayers2))
			{
				G_AddRandomBot( TEAM_RED );
			}
			else
			{
				G_AddRandomBot( TEAM_BLUE );
			}
		}
		else if ((humanplayers+botplayers+humanplayers2+botplayers) > minplayers && botplayers)
		{
			if ((humanplayers+botplayers) < (humanplayers2+botplayers2))
			{
				G_RemoveRandomBot( TEAM_BLUE );
			}
			else
			{
				G_RemoveRandomBot( TEAM_RED );
			}
		}
	}
	else if (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL) {
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( -1 );
		botplayers = G_CountBotPlayers( -1 );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			// try to remove spectators first
			if (!G_RemoveRandomBot( TEAM_SPECTATOR )) {
				// just remove the bot that is playing
				G_RemoveRandomBot( -1 );
			}
		}
	}
	else if (g_gametype.integer == GT_FFA) {
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_FREE );
		botplayers = G_CountBotPlayers( TEAM_FREE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_FREE );
		}
	}
	else if (g_gametype.integer == GT_HOLOCRON || g_gametype.integer == GT_JEDIMASTER) {
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_FREE );
		botplayers = G_CountBotPlayers( TEAM_FREE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_FREE );
		}
	}
	*/
}
Example #7
0
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int minplayers;
	int humanplayers, botplayers;
	static int checkminimumplayers_time;

	if (level.intermissiontime) return;
	//only check once each 10 seconds
	if (checkminimumplayers_time > level.time - 10000) {
		return;
	}
	checkminimumplayers_time = level.time;
	trap_Cvar_Update(&bot_minplayers);
	minplayers = bot_minplayers.integer;
	if (minplayers <= 0) return;

	if (g_gametype.integer >= GT_TEAM) {
		if (minplayers >= g_maxclients.integer / 2) {
			minplayers = (g_maxclients.integer / 2) -1;
		}

		humanplayers = G_CountHumanPlayers( TEAM_RED );
		botplayers = G_CountBotPlayers(	TEAM_RED );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_RED );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_RED );
		}
		//
		humanplayers = G_CountHumanPlayers( TEAM_BLUE );
		botplayers = G_CountBotPlayers( TEAM_BLUE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_BLUE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_BLUE );
		}
	}
    else {
        if (minplayers >= g_maxclients.integer) {
            minplayers = g_maxclients.integer - 1;
        }

        if (g_gametype.integer == GT_TOURNAMENT) {
            humanplayers = G_CountHumanPlayers(-1);
            botplayers = G_CountBotPlayers(-1);
            //
            if (humanplayers + botplayers < minplayers) {
                G_AddRandomBot(TEAM_FREE);
            }
            else if (humanplayers + botplayers > minplayers && botplayers) {
                // try to remove spectators first
                if (!G_RemoveRandomBot(TEAM_SPECTATOR)) {
                    // just remove the bot that is playing
                    G_RemoveRandomBot(-1);
                }
            }
        }
        else if (g_gametype.integer == GT_LASTMANSTANDING) {
            humanplayers = G_CountHumanPlayers(-1);
            botplayers = G_CountBotPlayers(-1);
            //
            if (humanplayers + botplayers < minplayers) {
                G_AddRandomBot(TEAM_SPECTATOR);
            }
            else if (humanplayers + botplayers > minplayers && botplayers) {
                // try to remove spectators first
                if (!G_RemoveRandomBot(TEAM_SPECTATOR)) {
                    // just remove the bot that is playing
                    G_RemoveRandomBot(-1);
                }
            }
        }
        else if (g_gametype.integer == GT_FFA || g_gametype.integer == GT_KINGOFTHEHILL) {
            humanplayers = G_CountHumanPlayers(TEAM_FREE);
            botplayers = G_CountBotPlayers(TEAM_FREE);
            //
            if (humanplayers + botplayers < minplayers) {
                G_AddRandomBot(TEAM_FREE);
            }
            else if (humanplayers + botplayers > minplayers && botplayers) {
                G_RemoveRandomBot(TEAM_FREE);
            }
        }
    }
}
Example #8
0
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int minplayers;
	int humanplayers, botplayers;
	static int checkminimumplayers_time;

	if (level.gametype == GT_SIEGE)
	{
		return;
	}

	if (level.intermissiontime) return;
	//only check once each 10 seconds
	if (checkminimumplayers_time > level.time - 10000) {
		return;
	}
	checkminimumplayers_time = level.time;
	trap->Cvar_Update(&bot_minplayers);
	minplayers = bot_minplayers.integer;
	if (minplayers <= 0) return;

	if (minplayers > sv_maxclients.integer)
	{
		minplayers = sv_maxclients.integer;
	}

	humanplayers = G_CountHumanPlayers( -1 );
	botplayers = G_CountBotPlayers(	-1 );

	if ((humanplayers+botplayers) < minplayers)
	{
		G_AddRandomBot(-1);
	}
	else if ((humanplayers+botplayers) > minplayers && botplayers)
	{
		// try to remove spectators first
		if (!G_RemoveRandomBot(TEAM_SPECTATOR))
		{
			// just remove the bot that is playing
			G_RemoveRandomBot(-1);
		}
	}

	/*
	if (level.gametype >= GT_TEAM) {
		int humanplayers2, botplayers2;
		if (minplayers >= sv_maxclients.integer / 2) {
			minplayers = (sv_maxclients.integer / 2) -1;
		}

		humanplayers = G_CountHumanPlayers( TEAM_RED );
		botplayers = G_CountBotPlayers(	TEAM_RED );
		humanplayers2 = G_CountHumanPlayers( TEAM_BLUE );
		botplayers2 = G_CountBotPlayers( TEAM_BLUE );
		//
		if ((humanplayers+botplayers+humanplayers2+botplayers) < minplayers)
		{
			if ((humanplayers+botplayers) < (humanplayers2+botplayers2))
			{
				G_AddRandomBot( TEAM_RED );
			}
			else
			{
				G_AddRandomBot( TEAM_BLUE );
			}
		}
		else if ((humanplayers+botplayers+humanplayers2+botplayers) > minplayers && botplayers)
		{
			if ((humanplayers+botplayers) < (humanplayers2+botplayers2))
			{
				G_RemoveRandomBot( TEAM_BLUE );
			}
			else
			{
				G_RemoveRandomBot( TEAM_RED );
			}
		}
	}
	else if (level.gametype == GT_DUEL || level.gametype == GT_POWERDUEL) {
		if (minplayers >= sv_maxclients.integer) {
			minplayers = sv_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( -1 );
		botplayers = G_CountBotPlayers( -1 );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			// try to remove spectators first
			if (!G_RemoveRandomBot( TEAM_SPECTATOR )) {
				// just remove the bot that is playing
				G_RemoveRandomBot( -1 );
			}
		}
	}
	else if (level.gametype == GT_FFA) {
		if (minplayers >= sv_maxclients.integer) {
			minplayers = sv_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_FREE );
		botplayers = G_CountBotPlayers( TEAM_FREE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_FREE );
		}
	}
	else if (level.gametype == GT_HOLOCRON || level.gametype == GT_JEDIMASTER) {
		if (minplayers >= sv_maxclients.integer) {
			minplayers = sv_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_FREE );
		botplayers = G_CountBotPlayers( TEAM_FREE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_FREE );
		}
	}
	*/
}
Example #9
0
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int minplayers, noBR, noDuel;
	int humanplayers, botplayers;
	static int checkminimumplayers_time;

	if (level.intermissiontime) return;
	//only check once each 10 seconds
	if (checkminimumplayers_time > level.time - 10000) {
		return;
	}
	checkminimumplayers_time = level.time;
	trap_Cvar_Update(&bot_minplayers);
	minplayers = bot_minplayers.integer;
	trap_Cvar_Update(&bot_noBR);
	trap_Cvar_Update(&bot_noDuel);
	noBR = bot_noBR.integer;
	noDuel = bot_noDuel.integer;

	if (minplayers <= 0) return;

	if (g_gametype.integer >= GT_TEAM) {
		if (minplayers & 1) {
			minplayers += 1; // round up to even number
		}
		if (minplayers >= g_maxclients.integer - 1) {
			minplayers = g_maxclients.integer - 2;
		}
		minplayers /= 2; // half on each team

		humanplayers = G_CountHumanPlayers( TEAM_RED )
		               + G_CountHumanPlayers( TEAM_RED_SPECTATOR );
		botplayers = G_CountBotPlayers( TEAM_RED )
		             + G_CountBotPlayers( TEAM_RED_SPECTATOR );
		//
		if (humanplayers + botplayers < minplayers && !(g_gametype.integer == GT_BR && noBR)) {
			G_AddRandomBot( TEAM_RED );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_RED );
		}
		//
		humanplayers = G_CountHumanPlayers( TEAM_BLUE )
		               + G_CountHumanPlayers( TEAM_BLUE_SPECTATOR );
		botplayers = G_CountBotPlayers( TEAM_BLUE )
		             + G_CountBotPlayers( TEAM_BLUE_SPECTATOR );
		//
		if (humanplayers + botplayers < minplayers && !(g_gametype.integer == GT_BR && noBR)) {
			G_AddRandomBot( TEAM_BLUE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_BLUE );
		}
	}
	else if (g_gametype.integer == GT_DUEL ) {
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( -1 );
		botplayers = G_CountBotPlayers( -1 );
		//
		if (humanplayers + botplayers < minplayers  && !noDuel) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			// try to remove spectators first
			if (!G_RemoveRandomBot( TEAM_SPECTATOR )) {
				// just remove the bot that is playing
				G_RemoveRandomBot( -1 );
			}
		}
	}
	else if (g_gametype.integer == GT_FFA) {
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_FREE );
		botplayers = G_CountBotPlayers( TEAM_FREE );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_FREE );
		}
	}
}
Example #10
0
File: g_bot.c Project: GenaSG/ET
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int minplayers/*, weakestTeam, strongestTeam*/;
	int humanplayers[TEAM_NUM_TEAMS], botplayers[TEAM_NUM_TEAMS], players[TEAM_NUM_TEAMS];
	static int checkminimumplayers_time = 0;

	// wait until the system is ready
	if (!level.initStaticEnts) return;

	//only check once each second
	if (checkminimumplayers_time < level.time && checkminimumplayers_time > level.time - 1000) {
		return;
	}

	// More safety on initial load for MP
	if(!G_IsSinglePlayerGame() && level.time - level.startTime < 7500) {
		return;
	}

	humanplayers[TEAM_AXIS] = G_CountHumanPlayers( TEAM_AXIS );
	botplayers[TEAM_AXIS] = G_CountBotPlayers(	TEAM_AXIS );
	players[TEAM_AXIS] = humanplayers[TEAM_AXIS] + botplayers[TEAM_AXIS];

	//
	humanplayers[TEAM_ALLIES] = G_CountHumanPlayers( TEAM_ALLIES );
	botplayers[TEAM_ALLIES] = G_CountBotPlayers( TEAM_ALLIES );
	players[TEAM_ALLIES] = humanplayers[TEAM_ALLIES] + botplayers[TEAM_ALLIES];


	checkminimumplayers_time = level.time;
	trap_Cvar_Update(&bot_minplayers);
	minplayers = bot_minplayers.integer;


	if (minplayers >= g_maxclients.integer / 2) {
		minplayers = (g_maxclients.integer / 2) -1;
	}

	
		//
/*	if (players[TEAM_AXIS] < minplayers) {
		G_AddRandomBot( TEAM_AXIS );
		return;
	}



	//
	if (players[TEAM_ALLIES] < minplayers) {
		G_AddRandomBot( TEAM_ALLIES );
		return;
	}

	//
	trap_Cvar_Update(&bot_eventeams);
	if (bot_eventeams.integer) {
		if (players[TEAM_AXIS] < players[TEAM_ALLIES]) {
			weakestTeam = TEAM_AXIS;
			strongestTeam = TEAM_ALLIES;
		} else if (players[TEAM_AXIS] > players[TEAM_ALLIES]) {
			weakestTeam = TEAM_ALLIES;
			strongestTeam = TEAM_AXIS;
		} else {
			return;	// no changes required
		}
		//
		// even up the teams
		//
		if (!botplayers[strongestTeam] || (minplayers && players[weakestTeam] <= minplayers)) {
			// we have to add players to the weakestTeam
			G_AddRandomBot( weakestTeam );
			return;
		} else {
			// remove players from the strongestTeam
			G_RemoveRandomBot( strongestTeam );
			return;
		}
	} else if (minplayers) {
		// remove bots from teams with too many players
		if (players[TEAM_AXIS] > minplayers && botplayers[TEAM_AXIS]) {
			G_RemoveRandomBot( TEAM_AXIS );
			return;
		}
		if (players[TEAM_ALLIES] > minplayers && botplayers[TEAM_ALLIES]) {
			G_RemoveRandomBot( TEAM_ALLIES );
			return;
		}
	}*/
}
Example #11
0
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
	int minplayers;
	int humanplayers, botplayers;
	static int checkminimumplayers_time;

	if (level.intermissiontime) return;
	//only check once each 10 seconds
	if (checkminimumplayers_time > level.time - 10000) {
		return;
	}
	checkminimumplayers_time = level.time;
	trap_Cvar_Update(&bot_minplayers);
	minplayers = bot_minplayers.integer;
	if (minplayers <= 0) return;
	if (g_teamsize.integer && minplayers >= g_teamsize.integer) {
		minplayers = g_teamsize.integer;
	}

	switch (g_gametype.integer) {
	case GT_TEAM:
	case GT_CTF:
	case GT_CTY:
	case GT_CLANARENA:
		if (minplayers >= g_maxclients.integer / 2) {
			minplayers = (g_maxclients.integer / 2) -1;
		}

		humanplayers = G_CountHumanPlayers( TEAM_RED );
		botplayers = G_CountBotPlayers(	TEAM_RED );
		//
		if (humanplayers + botplayers < minplayers && !level.teamLock[TEAM_RED]) {
			G_AddRandomBot( TEAM_RED );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_RED );
		}
		//
		humanplayers = G_CountHumanPlayers( TEAM_BLUE );
		botplayers = G_CountBotPlayers( TEAM_BLUE );
		//
		if (humanplayers + botplayers < minplayers && !level.teamLock[TEAM_BLUE]) {
			G_AddRandomBot( TEAM_BLUE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_BLUE );
		}
		break;
	case GT_TOURNAMENT:
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( -1 );
		botplayers = G_CountBotPlayers( -1 );
		//
		if (humanplayers + botplayers < minplayers) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			// try to remove spectators first
			if (!G_RemoveRandomBot( TEAM_SPECTATOR )) {
				// just remove the bot that is playing
				G_RemoveRandomBot( -1 );
			}
		}
		break;
	case GT_FFA:
	case GT_HOLOCRON:
	case GT_JEDIMASTER:
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_FREE );
		botplayers = G_CountBotPlayers( TEAM_FREE );
		//
		if (humanplayers + botplayers < minplayers && !level.teamLock[TEAM_FREE]) {
			G_AddRandomBot( TEAM_FREE );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( TEAM_FREE );
		}
		break;
	case GT_REDROVER:
		minplayers *= 2;
		if (minplayers >= g_maxclients.integer) {
			minplayers = g_maxclients.integer-1;
		}
		humanplayers = G_CountHumanPlayers( TEAM_RED ) + G_CountHumanPlayers( TEAM_BLUE );
		botplayers = G_CountBotPlayers( TEAM_RED ) + G_CountBotPlayers( TEAM_BLUE );
		//
		if (humanplayers + botplayers < minplayers && !level.teamLock[TEAM_RED] && !level.teamLock[TEAM_BLUE]) {
			G_AddRandomBot( -1 );
		} else if (humanplayers + botplayers > minplayers && botplayers) {
			G_RemoveRandomBot( -1 );
		}
		break;
	}
}