コード例 #1
0
ファイル: ai_chat.c プロジェクト: chegestar/omni-bot
/*
==================
BotChatTest
==================
*/
void BotChatTest( bot_state_t *bs ) {

	char name[32];
	char *weap;
	int num, i;

	num = trap_BotNumInitialChats( bs->cs, "game_enter" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "game_enter",
							  EasyClientName( bs->client, name, 32 ), // 0
							  BotRandomOpponentName( bs ),  // 1
							  "[invalid var]",          // 2
							  "[invalid var]",          // 3
							  BotMapTitle(),                // 4
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "game_exit" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "game_exit",
							  EasyClientName( bs->client, name, 32 ), // 0
							  BotRandomOpponentName( bs ),  // 1
							  "[invalid var]",          // 2
							  "[invalid var]",          // 3
							  BotMapTitle(),                // 4
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "level_start" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "level_start",
							  EasyClientName( bs->client, name, 32 ), // 0
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "level_end_victory" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "level_end_victory",
							  EasyClientName( bs->client, name, 32 ), // 0
							  BotRandomOpponentName( bs ), // 1
							  BotFirstClientInRankings(), // 2
							  BotLastClientInRankings(), // 3
							  BotMapTitle(),            // 4
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "level_end_lose" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "level_end_lose",
							  EasyClientName( bs->client, name, 32 ), // 0
							  BotRandomOpponentName( bs ), // 1
							  BotFirstClientInRankings(), // 2
							  BotLastClientInRankings(), // 3
							  BotMapTitle(),            // 4
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "level_end" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "level_end",
							  EasyClientName( bs->client, name, 32 ), // 0
							  BotRandomOpponentName( bs ), // 1
							  BotFirstClientInRankings(), // 2
							  BotLastClientInRankings(), // 3
							  BotMapTitle(),            // 4
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	EasyClientName( bs->lastkilledby, name, sizeof( name ) );
	num = trap_BotNumInitialChats( bs->cs, "death_drown" );
	for ( i = 0; i < num; i++ )
	{
		//
		BotAI_BotInitialChat( bs, "death_drown", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_slime" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_slime", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_lava" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_lava", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_cratered" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_cratered", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_suicide" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_suicide", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_telefrag" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_telefrag", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_gauntlet" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_gauntlet",
							  name,                                 // 0
							  BotWeaponNameForMeansOfDeath( bs->botdeathtype ), // 1
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_rail" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_rail",
							  name,                                 // 0
							  BotWeaponNameForMeansOfDeath( bs->botdeathtype ), // 1
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_bfg" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_bfg",
							  name,                                 // 0
							  BotWeaponNameForMeansOfDeath( bs->botdeathtype ), // 1
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_insult" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_insult",
							  name,                                     // 0
							  BotWeaponNameForMeansOfDeath( bs->botdeathtype ), // 1
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "death_praise" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "death_praise",
							  name,                                     // 0
							  BotWeaponNameForMeansOfDeath( bs->botdeathtype ), // 1
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	//
	EasyClientName( bs->lastkilledplayer, name, 32 );
	//
	num = trap_BotNumInitialChats( bs->cs, "kill_gauntlet" );
	for ( i = 0; i < num; i++ )
	{
		//
		BotAI_BotInitialChat( bs, "kill_gauntlet", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "kill_rail" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "kill_rail", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "kill_telefrag" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "kill_telefrag", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "kill_insult" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "kill_insult", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "kill_praise" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "kill_praise", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "enemy_suicide" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "enemy_suicide", name, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	ClientName( g_entities[bs->client].client->lasthurt_client, name, sizeof( name ) );
	weap = BotWeaponNameForMeansOfDeath( g_entities[bs->client].client->lasthurt_client );
	num = trap_BotNumInitialChats( bs->cs, "hit_talking" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "hit_talking", name, weap, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "hit_nodeath" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "hit_nodeath", name, weap, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "hit_nokill" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "hit_nokill", name, weap, NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	//
	if ( bs->lastkilledplayer == bs->client ) {
		strcpy( name, BotRandomOpponentName( bs ) );
	} else {
		EasyClientName( bs->lastkilledplayer, name, sizeof( name ) );
	}
	//
	num = trap_BotNumInitialChats( bs->cs, "random_misc" );
	for ( i = 0; i < num; i++ )
	{
		//
		BotAI_BotInitialChat( bs, "random_misc",
							  BotRandomOpponentName( bs ), // 0
							  name,             // 1
							  "[invalid var]", // 2
							  "[invalid var]", // 3
							  BotMapTitle(),    // 4
							  BotRandomWeaponName(), // 5
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
	num = trap_BotNumInitialChats( bs->cs, "random_insult" );
	for ( i = 0; i < num; i++ )
	{
		BotAI_BotInitialChat( bs, "random_insult",
							  BotRandomOpponentName( bs ), // 0
							  name,             // 1
							  "[invalid var]", // 2
							  "[invalid var]", // 3
							  BotMapTitle(),    // 4
							  BotRandomWeaponName(), // 5
							  NULL );
		trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL );
	}
}
コード例 #2
0
ファイル: ai_chat.c プロジェクト: chegestar/omni-bot
/*
==================
BotChat_Random
==================
*/
int BotChat_Random( bot_state_t *bs ) {
	float rnd;
	char name[32];

	if ( bot_nochat.integer ) {
		return qfalse;
	}
	if ( BotIsObserver( bs ) ) {
		return qfalse;
	}
	if ( bs->lastchat_time > trap_AAS_Time() - 3 ) {
		return qfalse;
	}
	//don't chat in teamplay
	if ( TeamPlayIsOn() ) {
		return qfalse;
	}
	//don't chat when doing something important :)
	if ( bs->ltgtype == LTG_TEAMHELP ||
		 bs->ltgtype == LTG_TEAMACCOMPANY ||
		 bs->ltgtype == LTG_RUSHBASE ) {
		return qfalse;
	}
	//
	rnd = trap_Characteristic_BFloat( bs->character, CHARACTERISTIC_CHAT_RANDOM, 0, 1 );
	if ( random() > bs->thinktime * 0.1 ) {
		return qfalse;
	}
	if ( !bot_fastchat.integer ) {
		if ( random() > rnd ) {
			return qfalse;
		}
		if ( random() > 0.25 ) {
			return qfalse;
		}
	}
	if ( BotNumActivePlayers() <= 1 ) {
		return qfalse;
	}
	if ( !BotValidChatPosition( bs ) ) {
		return qfalse;
	}
	//
	if ( bs->lastkilledplayer == bs->client ) {
		strcpy( name, BotRandomOpponentName( bs ) );
	} else {
		EasyClientName( bs->lastkilledplayer, name, sizeof( name ) );
	}
	//
	if ( random() < trap_Characteristic_BFloat( bs->character, CHARACTERISTIC_CHAT_MISC, 0, 1 ) ) {
		BotAI_BotInitialChat( bs, "random_misc",
							  BotRandomOpponentName( bs ), // 0
							  name,             // 1
							  "[invalid var]", // 2
							  "[invalid var]", // 3
							  BotMapTitle(),    // 4
							  BotRandomWeaponName(), // 5
							  NULL );
	} else {
		BotAI_BotInitialChat( bs, "random_insult",
							  BotRandomOpponentName( bs ), // 0
							  name,             // 1
							  "[invalid var]", // 2
							  "[invalid var]", // 3
							  BotMapTitle(),    // 4
							  BotRandomWeaponName(), // 5
							  NULL );
	}
	bs->lastchat_time = trap_AAS_Time();
	bs->chatto = CHAT_ALL;
	return qtrue;
}
コード例 #3
0
ファイル: ai_chat.c プロジェクト: MAN-AT-ARMS/ioq3
/*
==================
BotChat_Random
==================
*/
int BotChat_Random(bot_state_t *bs) {
	float rnd;
	char name[32];

	if (bot_nochat.integer) return qfalse;
	if (BotIsObserver(bs)) return qfalse;
	if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
	// don't chat in tournament mode
	if (gametype == GT_TOURNAMENT) return qfalse;
	//don't chat when doing something important :)
	if (bs->ltgtype == LTG_TEAMHELP ||
		bs->ltgtype == LTG_TEAMACCOMPANY ||
		bs->ltgtype == LTG_RUSHBASE) return qfalse;
	//
	rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_RANDOM, 0, 1);
	if (random() > bs->thinktime * 0.1) return qfalse;
	if (!bot_fastchat.integer) {
		if (random() > rnd) return qfalse;
		if (random() > 0.25) return qfalse;
	}
	if (BotNumActivePlayers() <= 1) return qfalse;
	//
	if (!BotValidChatPosition(bs)) return qfalse;
	//
	if (BotVisibleEnemies(bs)) return qfalse;
	//
	if (bs->lastkilledplayer == bs->client) {
		strcpy(name, BotRandomOpponentName(bs));
	}
	else {
		EasyClientName(bs->lastkilledplayer, name, sizeof(name));
	}
	if (TeamPlayIsOn()) {
#ifdef MISSIONPACK
		trap_EA_Command(bs->client, "vtaunt");
#endif
		return qfalse;			// don't wait
	}
	//
	if (random() < trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_MISC, 0, 1)) {
		BotAI_BotInitialChat(bs, "random_misc",
					BotRandomOpponentName(bs),	// 0
					name,						// 1
					"[invalid var]",			// 2
					"[invalid var]",			// 3
					BotMapTitle(),				// 4
					BotRandomWeaponName(),		// 5
					NULL);
	}
	else {
		BotAI_BotInitialChat(bs, "random_insult",
					BotRandomOpponentName(bs),	// 0
					name,						// 1
					"[invalid var]",			// 2
					"[invalid var]",			// 3
					BotMapTitle(),				// 4
					BotRandomWeaponName(),		// 5
					NULL);
	}
	bs->lastchat_time = FloatTime();
	bs->chatto = CHAT_ALL;
	return qtrue;
}