示例#1
0
文件: p_client.c 项目: ZwS/qudos
/*
=====================
ClientBeginDeathmatch

A client has just connected to the server in 
deathmatch mode, so clear everything out before starting them.
=====================
*/
void ClientBeginDeathmatch (edict_t *ent)
{
#ifdef WITH_ACEBOT
// ACEBOT_ADD
	static char current_map[55];
// ACEBOT_END
#endif
	G_InitEdict (ent);
#ifdef WITH_ACEBOT
// ACEBOT_ADD
	ACEIT_PlayerAdded(ent);
// ACEBOT_END
#endif
	InitClientResp (ent->client);

	// locate ent at a spawn point
	PutClientInServer (ent);

	// send effect
	gi.WriteByte (svc_muzzleflash);
	gi.WriteShort (ent-g_edicts);
	gi.WriteByte (MZ_LOGIN);
	gi.multicast (ent->s.origin, MULTICAST_PVS);
#ifdef WITH_ACEBOT
	safe_bprintf (PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname);
	safe_centerprintf(ent,"\nQ2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2\n\nZaero Bots\n\n\n'sv addbot' to add a new bot.\n\n'sv removebot <name>' to remove bot.\n\n\nhttp://qudos.quakedev.com\n\n\nQ2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2\n\n");
	// If the map changes on us, init and reload the nodes
	if(strcmp(level.mapname,current_map))
	{
		
		ACEND_InitNodes();
		ACEND_LoadNodes();
		if (botauto_respawn->value) {
			ACESP_LoadBots();
		}
		strcpy(current_map,level.mapname);
	}

	safe_bprintf (PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname);
// ACEBOT_END
#else
	gi.bprintf (PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname);
#endif	

	// make sure all view stuff is valid
	ClientEndServerFrame (ent);
}
示例#2
0
文件: acebot_spawn.c 项目: ZwS/qudos
///////////////////////////////////////////////////////////////////////
// Spawn the bot
///////////////////////////////////////////////////////////////////////
void ACESP_SpawnBot (char *team, char *name, char *skin, char *userinfo)
{
	edict_t	*bot;
	
	bot = ACESP_FindFreeClient ();
	
	if (!bot)
	{
		safe_bprintf (PRINT_MEDIUM, "Server is full, increase Maxclients.\n");
		return;
	}

	bot->yaw_speed = 100; // yaw speed
	bot->inuse = true;
	bot->is_bot = true;

	// To allow bots to respawn
	if(userinfo == NULL)
		ACESP_SetName(bot, name, skin, team);
	else
		ClientConnect (bot, userinfo);
	
	G_InitEdict (bot);

	InitClientResp (bot->client);
	
	// locate ent at a spawn point
    /*if(ctf->value)
	{
		if (team != NULL && strcmp(team,"red")==0)
			ACESP_PutClientInServer (bot,false, CTF_TEAM1);
		else
			ACESP_PutClientInServer (bot,false, CTF_TEAM2);
	}
	else*/
 		ACESP_PutClientInServer (bot,false,0);

	// make sure all view stuff is valid
	ClientEndServerFrame (bot);
	
	ACEIT_PlayerAdded (bot); // let the world know we added another

	ACEAI_PickLongRangeGoal(bot); // pick a new goal

}
示例#3
0
///////////////////////////////////////////////////////////////////////
// Spawn the bot
///////////////////////////////////////////////////////////////////////
void ACESP_SpawnBot(char *team, char *name, char *skin, char *userinfo)
{
	edict_t *bot = ACESP_FindFreeClient();
	
	if (!bot)
	{
		safe_bprintf(PRINT_MEDIUM, "Server is full, increase Maxclients.\n");
		return;
	}

	bot->yaw_speed = 100; // yaw speed
	bot->inuse = true;
	bot->is_bot = true;

	// To allow bots to respawn
	if (userinfo == NULL)
		ACESP_SetName(bot, name, skin, team);
	else
		ClientConnect (bot, userinfo);
	
	G_InitEdict (bot);

	InitClientResp (bot->client);
	
	// locate ent at a spawn point
	if (ctf->value)
	{
		// Knightmare- rewrote this
		int team1count = 0, team2count = 0, team3count = 0;
		int jointeam;
		const float r = random();

		for (int i = 1; i <= maxclients->value; i++)
		{
			edict_t *player = &g_edicts[i];
			if (!player->inuse || !player->client || player == bot)
				continue;

			switch (player->client->resp.ctf_team)
			{
			case CTF_TEAM1:
				team1count++;
				break;
			case CTF_TEAM2:
				team2count++;
				break;
			case CTF_TEAM3: 
				team3count++;
				break;
			}
		}

		if (ttctf->value)
		{
			if (team != NULL && strcmp(team,"red")==0)
				jointeam = CTF_TEAM1;
			else if (team != NULL && strcmp(team,"blue")==0)
				jointeam = CTF_TEAM2;
			else if (team != NULL && strcmp(team,"green")==0)
				jointeam = CTF_TEAM3;
			// join either of the outnumbered teams
			else if (team1count == team2count && team1count < team3count)
				jointeam = (r < 0.5) ? CTF_TEAM1 : CTF_TEAM2;
			else if (team1count == team3count && team1count < team2count)
				jointeam = (r < 0.5) ? CTF_TEAM1 : CTF_TEAM3;
			else if (team2count == team3count && team2count < team1count)
				jointeam = (r < 0.5) ? CTF_TEAM2 : CTF_TEAM3;
			// join outnumbered team
			else if (team1count < team2count && team1count < team3count)
				jointeam = CTF_TEAM1;
			else if (team2count < team1count &&  team2count < team3count) 
				jointeam = CTF_TEAM2;
			else if (team3count < team1count &&  team3count < team2count) 
				jointeam = CTF_TEAM3;
			// pick random team
			else if (r < 0.33)
				jointeam = CTF_TEAM1;
			else if (r < 0.66)
				jointeam = CTF_TEAM2;
			else
				jointeam = CTF_TEAM3;
		}
		else
		{
			if (team != NULL && strcmp(team,"red")==0)
				jointeam = CTF_TEAM1;
			else if (team != NULL && strcmp(team,"blue")==0)
				jointeam = CTF_TEAM2;
			// join outnumbered team
			else if (team1count < team2count)
				jointeam = CTF_TEAM1;
			else if (team2count < team1count)
				jointeam = CTF_TEAM2;
			// pick random team
			else if (r < 0.5)
				jointeam = CTF_TEAM1;
			else
				jointeam = CTF_TEAM2;
		}
		ACESP_PutClientInServer (bot,false, jointeam);
	}
	else
 		ACESP_PutClientInServer (bot,false,0);

	// make sure all view stuff is valid
	ClientEndServerFrame(bot);
	ACEIT_PlayerAdded(bot); // let the world know we added another
	ACEAI_PickLongRangeGoal(bot); // pick a new goal
}