当前位置: 首页>>代码示例>>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;未经允许,请勿转载。