當前位置: 首頁>>代碼示例>>C++>>正文


C++ BotSameTeam函數代碼示例

本文整理匯總了C++中BotSameTeam函數的典型用法代碼示例。如果您正苦於以下問題:C++ BotSameTeam函數的具體用法?C++ BotSameTeam怎麽用?C++ BotSameTeam使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BotSameTeam函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: FindEnemyByName

/*
=======================================================================================================================================
FindEnemyByName
=======================================================================================================================================
*/
int FindEnemyByName(bot_state_t *bs, char *name) {
	int i;
	char buf[MAX_INFO_STRING];
	static int maxclients;

	if (!maxclients) {
		maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
	}

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		if (BotSameTeam(bs, i)) {
			continue;
		}

		ClientName(i, buf, sizeof(buf));

		if (!Q_stricmp(buf, name)) {
			return i;
		}
	}

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		if (BotSameTeam(bs, i)) {
			continue;
		}

		ClientName(i, buf, sizeof(buf));

		if (stristr(buf, name)) {
			return i;
		}
	}

	return -1;
}
開發者ID:ioid3-games,項目名稱:ioid3-rtcw,代碼行數:40,代碼來源:ai_cmd.c

示例2: trap_GetConfigstring

/*
==================
BotRandomOpponentName
==================
*/
char *BotRandomOpponentName(bot_state_t *bs) {
	int i, count;
	char buf[MAX_INFO_STRING];
	int opponents[MAX_CLIENTS], numopponents;
	static char name[32];

	numopponents = 0;
	opponents[0] = 0;
	for (i = 0; i < level.maxclients; i++) {
		if (i == bs->client) continue;
		//
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
		//skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
		//skip team mates
		if (BotSameTeam(bs, i)) continue;
		//
		opponents[numopponents] = i;
		numopponents++;
	}
	count = random() * numopponents;
	for (i = 0; i < numopponents; i++) {
		count--;
		if (count <= 0) {
			EasyClientName(opponents[i], name, sizeof(name));
			return name;
		}
	}
	EasyClientName(opponents[0], name, sizeof(name));
	return name;
}
開發者ID:MAN-AT-ARMS,項目名稱:ioq3,代碼行數:38,代碼來源:ai_chat.c

示例3: BotMatch_WrongWall

void BotMatch_WrongWall(bot_state_t* bs, bot_match_t *match){
	char netname[MAX_MESSAGE_SIZE];
	char buf[MAX_INFO_STRING];
	int client;

	if(gametype != GT_SPRAY)
		return;

	// talking about me ? (avoid clientfromname, its ambiguous)
	trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
	trap_GetConfigstring(CS_PLAYERS + bs->client, buf, sizeof(buf));
	Q_CleanStr( buf );
	if (!Q_stricmp(Info_ValueForKey(buf, "n"), netname)){
		// could be someone with same name, so make (more) sure
		if( ClientInSprayroom(bs->client) ){
			bs->which_wall = BotChooseCorrectWall(bs);
			bs->enemy = -1;
			// chat
			BotAI_BotInitialChat(bs, "wall_missed", NULL);
			trap_BotEnterChat(bs->cs, 0, CHAT_ALL);
			return;
		}
	}
	// check if opposite team
	client = ClientFromName(netname);
	if(!BotSameTeam(bs, client)){
		float rnd;
		// flame
		rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_INSULT, 0, 1);
		if(random() > rnd) return;	
		BotAI_BotInitialChat(bs, "wall_insult", netname, NULL);
		trap_BotEnterChat(bs->cs, 0, CHAT_ALL);
	}
}
開發者ID:PadWorld-Entertainment,項目名稱:wop-gamesource,代碼行數:34,代碼來源:ai_cmd.c

示例4: FindHumanTeamLeader

/*
==================
FindHumanTeamLeader
==================
*/
int FindHumanTeamLeader(bot_state_t *bs)
{
    int i;

    for (i = 0; i < MAX_CLIENTS; i++)
    {
        if ( g_entities[i].inuse )
        {
            // if this player is not a bot
            if ( !(g_entities[i].r.svFlags & SVF_BOT) )
            {
                // if this player is ok with being the leader
                if (!notleader[i])
                {
                    // if this player is on the same team
                    if ( BotSameTeam(bs, i) )
                    {
                        ClientName(i, bs->teamleader, sizeof(bs->teamleader));
                        // if not yet ordered to do anything
                        if ( !BotSetLastOrderedTask(bs) )
                        {
                            // go on defense by default
                            BotVoiceChat_Defend(bs, i, SAY_TELL);
                        }
                        return qtrue;
                    }
                }
            }
        }
    }
    return qfalse;
}
開發者ID:zturtleman,項目名稱:recoil,代碼行數:37,代碼來源:ai_team.c

示例5: BotChat_Kill

/*
==================
BotChat_Kill
==================
*/
int BotChat_Kill(bot_state_t *bs) {
	char name[32];
	float rnd;

	if (bot_nochat.integer) return qfalse;
	if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
	rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_KILL, 0, 1);
	// don't chat in tournament mode
	if (gametype == GT_TOURNAMENT) return qfalse;
	//if fast chat is off
	if (!bot_fastchat.integer) {
		if (random() > rnd) return qfalse;
	}
	if (bs->lastkilledplayer == bs->client) return qfalse;
	if (BotNumActivePlayers() <= 1) return qfalse;
	if (!BotValidChatPosition(bs)) return qfalse;
	//
	if (BotVisibleEnemies(bs)) return qfalse;
	//
	EasyClientName(bs->lastkilledplayer, name, 32);
	//
	bs->chatto = CHAT_ALL;
	if (TeamPlayIsOn() && BotSameTeam(bs, bs->lastkilledplayer)) {
		BotAI_BotInitialChat(bs, "kill_teammate", name, NULL);
		bs->chatto = CHAT_TEAM;
	}
	else
	{
		//don't chat in teamplay
		if (TeamPlayIsOn()) {
#ifdef MISSIONPACK
			trap_EA_Command(bs->client, "vtaunt");
#endif
			return qfalse;			// don't wait
		}
		//
		if (bs->enemydeathtype == MOD_GAUNTLET) {
			BotAI_BotInitialChat(bs, "kill_gauntlet", name, NULL);
		}
		else if (bs->enemydeathtype == MOD_RAILGUN) {
			BotAI_BotInitialChat(bs, "kill_rail", name, NULL);
		}
		else if (bs->enemydeathtype == MOD_TELEFRAG) {
			BotAI_BotInitialChat(bs, "kill_telefrag", name, NULL);
		}
#ifdef MISSIONPACK
		else if (bs->botdeathtype == MOD_KAMIKAZE && trap_BotNumInitialChats(bs->cs, "kill_kamikaze"))
			BotAI_BotInitialChat(bs, "kill_kamikaze", name, NULL);
#endif
		//choose between insult and praise
		else if (random() < trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_INSULT, 0, 1)) {
			BotAI_BotInitialChat(bs, "kill_insult", name, NULL);
		}
		else {
			BotAI_BotInitialChat(bs, "kill_praise", name, NULL);
		}
	}
	bs->lastchat_time = FloatTime();
	return qtrue;
}
開發者ID:MAN-AT-ARMS,項目名稱:ioq3,代碼行數:65,代碼來源:ai_chat.c

示例6: BotVisibleEnemies

/*
==================
BotVisibleEnemies
==================
*/
int BotVisibleEnemies(bot_state_t *bs) {
	float vis;
	int i;
	aas_entityinfo_t entinfo;

	for (i = 0; i < MAX_CLIENTS; i++) {

		if (i == bs->client) continue;
		//
		BotEntityInfo(i, &entinfo);
		//
		if (!entinfo.valid) continue;
		//if the enemy isn't dead and the enemy isn't the bot self
		if (EntityIsDead(&entinfo) || entinfo.number == bs->entitynum) continue;
		//if the enemy is invisible and not shooting
		if (EntityIsInvisible(&entinfo) && !EntityIsShooting(&entinfo)) {
			continue;
		}
		//if on the same team
		if (BotSameTeam(bs, i)) continue;
		//check if the enemy is visible
		vis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i);
		if (vis > 0) return qtrue;
	}
	return qfalse;
}
開發者ID:MAN-AT-ARMS,項目名稱:ioq3,代碼行數:31,代碼來源:ai_chat.c

示例7: BotNumTeamMates

/*
==================
BotNumTeamMates
==================
*/
int BotNumTeamMates( bot_state_t *bs ) {
	int i, numplayers;
	char buf[MAX_INFO_STRING];
	static int maxclients;

	if ( !maxclients ) {
		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
	}

	numplayers = 0;
	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
		//if no config string or no name
		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
			continue;
		}
		//skip spectators
		if ( atoi( Info_ValueForKey( buf, "t" ) ) == TEAM_SPECTATOR ) {
			continue;
		}
		//
		if ( BotSameTeam( bs, i ) ) {
			numplayers++;
		}
	}
	return numplayers;
}
開發者ID:bibendovsky,項目名稱:rtcw,代碼行數:32,代碼來源:ai_team.cpp

示例8: BotAddressedToBot

/*
==================
BotAddressedToBot
==================
*/
int BotAddressedToBot( bot_state_t *bs, bot_match_t *match ) {
	char addressedto[MAX_MESSAGE_SIZE];
	char netname[MAX_MESSAGE_SIZE];
	char name[MAX_MESSAGE_SIZE];
	char botname[128];
	int client;
	bot_match_t addresseematch;

	trap_BotMatchVariable( match, NETNAME, netname, sizeof( netname ) );
	client = ClientFromName( netname );
	if ( client < 0 ) {
		return qfalse;
	}
	if ( !BotSameTeam( bs, client ) ) {
		return qfalse;
	}
	//if the message is addressed to someone
	if ( match->subtype & ST_ADDRESSED ) {
		trap_BotMatchVariable( match, ADDRESSEE, addressedto, sizeof( addressedto ) );
		//the name of this bot
		ClientName( bs->client, botname, 128 );
		//
		while ( trap_BotFindMatch( addressedto, &addresseematch, MTCONTEXT_ADDRESSEE ) ) {
			if ( addresseematch.type == MSG_EVERYONE ) {
				return qtrue;
			} else if ( addresseematch.type == MSG_MULTIPLENAMES )     {
				trap_BotMatchVariable( &addresseematch, TEAMMATE, name, sizeof( name ) );
				if ( strlen( name ) ) {
					if ( stristr( botname, name ) ) {
						return qtrue;
					}
					if ( stristr( bs->subteam, name ) ) {
						return qtrue;
					}
				}
				trap_BotMatchVariable( &addresseematch, MORE, addressedto, MAX_MESSAGE_SIZE );
			} else {
				trap_BotMatchVariable( &addresseematch, TEAMMATE, name, MAX_MESSAGE_SIZE );
				if ( strlen( name ) ) {
					if ( stristr( botname, name ) ) {
						return qtrue;
					}
					if ( stristr( bs->subteam, name ) ) {
						return qtrue;
					}
				}
				break;
			}
		}
		//Com_sprintf(buf, sizeof(buf), "not addressed to me but %s", addressedto);
		//trap_EA_Say(bs->client, buf);
		return qfalse;
	} else {
		//make sure not everyone reacts to this message
		if ( random() > (float ) 1.0 / ( NumPlayersOnSameTeam( bs ) - 1 ) ) {
			return qfalse;
		}
	}
	return qtrue;
}
開發者ID:JackalFrost,項目名稱:RTCW-WSGF,代碼行數:65,代碼來源:ai_cmd.c

示例9: BotTeamCarrierVisible

int BotTeamCarrierVisible( bot_state_t *bs ) {
	int	i;
	float	vis;
	aas_entityinfo_t	entinfo;
	gentity_t	*ent;
	float	f, alertness;
	float	squaredist;
	vec3_t	dir;
	int	areanum;

	alertness = trap_Characteristic_BFloat( bs->character, CHARACTERISTIC_ALERTNESS, 0, 1 );

	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
		if ( i == bs->client ) continue;
		ent = &g_entities[ i ];
		if ( !ent->inuse || !ent->target_ent ) continue;
		BotEntityInfo( ent->target_ent->s.number, &entinfo );
		if ( !entinfo.valid || !( entinfo.powerups & ( 1 << PW_BATTLESUIT ) ) ) continue;
		if ( !BotSameTeam( bs, i ) ) continue;
		VectorSubtract( entinfo.origin, bs->origin, dir );
		squaredist = VectorLengthSquared( dir );
		if ( squaredist > Square( 900.0 + alertness * 4000.0 ) ) continue;
		f = 90 + 90 - ( 90 - ( squaredist > Square( 810 ) ? Square( 810 ) : squaredist ) / ( 810 * 9 ) );
		vis = BotEntityVisible( bs->entitynum, bs->eye, bs->viewangles, f, entinfo.number );
		if ( vis <= 0 ) continue;
		areanum = BotPointAreaNum( entinfo.origin );
		if ( trap_AAS_AreaTravelTimeToGoalArea( bs->areanum, bs->origin, areanum, bs->tfl ) ) {
			return entinfo.number;
		}
	}
	return -1;
}
開發者ID:xzero450,項目名稱:revolution,代碼行數:32,代碼來源:ai_freeze.c

示例10: BotVoiceChatCommand

int BotVoiceChatCommand(bot_state_t *bs, int mode, char *voiceChat) {
    int i, clientNum;
    char *ptr, buf[MAX_MESSAGE_SIZE], *cmd,*cmd2;

    if (!TeamPlayIsOn()) {
        return qfalse;
    }

    if ( mode == SAY_ALL ) {
        return qfalse;
    }

    Q_strncpyz(buf, voiceChat, sizeof(buf));

    cmd = buf;
    ptr = strchr(buf,' ');
    *ptr++ = 0;
    clientNum = atoi(ptr);
    cmd2 = ptr+2;
    ptr = strchr(cmd2,' ');
    *ptr = 0;

    if (!BotSameTeam(bs, clientNum)) {
        return qfalse;
    }

    for (i = 0; voiceCommands[i].cmd; i++) {
        if (!Q_stricmp(cmd2, voiceCommands[i].cmd)) {
            voiceCommands[i].func(bs, clientNum, mode);
            return qtrue;
        }
    }
    return qfalse;
}
開發者ID:UberGames,項目名稱:EF2GameSource,代碼行數:34,代碼來源:ai_vcmd.cpp

示例11: FindEnemyByName

/*
==================
FindEnemyByName
==================
*/
int FindEnemyByName(bot_state_t *bs, char *name) {
	int i;
	char buf[MAX_INFO_STRING];

	for (i = 0; i < level.maxplayers; i++) {
		if (BotSameTeam(bs, i)) continue;
		PlayerName(i, buf, sizeof(buf));
		if (!Q_stricmp(buf, name)) return i;
	}
	for (i = 0; i < level.maxplayers; i++) {
		if (BotSameTeam(bs, i)) continue;
		PlayerName(i, buf, sizeof(buf));
		if (stristr(buf, name)) return i;
	}
	return -1;
}
開發者ID:coltongit,項目名稱:mint-arena,代碼行數:21,代碼來源:ai_cmd.c

示例12: BotGetTeammates

int BotGetTeammates(bot_state_t *bs, int *teammates, int maxteammates) {

	int i, numteammates;
	char buf[MAX_INFO_STRING];
	static int maxclients;


	if (!maxclients)
		maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");

	//G_Printf("mates: ");

	numteammates = 0;
	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
		//skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
		//
		if (BotSameTeam(bs, i)) {
			//
			teammates[numteammates++] = i;
			if (numteammates >= maxteammates) break;
			//G_Printf("/%s ", Info_ValueForKey(buf, "n"));
		}
	}
	//G_Printf("\n %d mates \n", numteammates);
	return numteammates;
}
開發者ID:PadWorld-Entertainment,項目名稱:wop-gamesource,代碼行數:30,代碼來源:ai_team.c

示例13: BotChat_Kill

/*
==================
BotChat_Kill
==================
*/
int BotChat_Kill( bot_state_t *bs ) {
	char name[32];
	float rnd;

	if ( bot_nochat.integer ) {
		return qfalse;
	}
	if ( bs->lastchat_time > trap_AAS_Time() - 3 ) {
		return qfalse;
	}
	rnd = trap_Characteristic_BFloat( bs->character, CHARACTERISTIC_CHAT_KILL, 0, 1 );
	//if fast chat is off
	if ( !bot_fastchat.integer ) {
		if ( random() > rnd ) {
			return qfalse;
		}
	}
	if ( bs->lastkilledplayer == bs->client ) {
		return qfalse;
	}
	if ( BotNumActivePlayers() <= 1 ) {
		return qfalse;
	}
	if ( !BotValidChatPosition( bs ) ) {
		return qfalse;
	}
	//
	EasyClientName( bs->lastkilledplayer, name, 32 );
	//
	bs->chatto = CHAT_ALL;
	if ( TeamPlayIsOn() && BotSameTeam( bs, bs->lastkilledplayer ) ) {
		BotAI_BotInitialChat( bs, "kill_teammate", name, NULL );
		bs->chatto = CHAT_TEAM;
	} else
	{
		//don't chat in teamplay
		if ( TeamPlayIsOn() ) {
			return qfalse;
		}
		//
		if ( bs->enemydeathtype == MOD_GAUNTLET ) {
			BotAI_BotInitialChat( bs, "kill_gauntlet", name, NULL );
		} else if ( bs->enemydeathtype == MOD_RAILGUN )     {
			BotAI_BotInitialChat( bs, "kill_rail", name, NULL );
		} else if ( bs->enemydeathtype == MOD_TELEFRAG )     {
			BotAI_BotInitialChat( bs, "kill_telefrag", name, NULL );
		}
		//choose between insult and praise
		else if ( random() < trap_Characteristic_BFloat( bs->character, CHARACTERISTIC_CHAT_INSULT, 0, 1 ) ) {
			BotAI_BotInitialChat( bs, "kill_insult", name, NULL );
		} else {
			BotAI_BotInitialChat( bs, "kill_praise", name, NULL );
		}
	}
	bs->lastchat_time = trap_AAS_Time();
	return qtrue;
}
開發者ID:chegestar,項目名稱:omni-bot,代碼行數:62,代碼來源:ai_chat.c

示例14: BotMatch_NewLeader

void BotMatch_NewLeader(bot_state_t *bs, bot_match_t *match) {
	int playernum;
	char netname[MAX_NETNAME];

	BotMatchVariable(match, NETNAME, netname, sizeof(netname));
	playernum = FindPlayerByName(netname);
	if (!BotSameTeam(bs, playernum))
		return;
	Q_strncpyz(bs->teamleader, netname, sizeof(bs->teamleader));
}
開發者ID:coltongit,項目名稱:mint-arena,代碼行數:10,代碼來源:ai_cmd.c

示例15: BotMatch_NewLeader

void BotMatch_NewLeader(bot_state_t *bs, bot_match_t *match) {
	int client;
	char netname[MAX_NETNAME];

	trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
	client = FindClientByName(netname);
	if (!BotSameTeam(bs, client))
		return;
	Q_strncpyz(bs->teamleader, netname, sizeof(bs->teamleader));
}
開發者ID:AHPlankton,項目名稱:Quake-III-Arena,代碼行數:10,代碼來源:ai_cmd.c


注:本文中的BotSameTeam函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。