Exemple #1
0
/*
=======================================================================================================================================
FindClientByName
=======================================================================================================================================
*/
int FindClientByName(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++) {
		ClientName(i, buf, sizeof(buf));

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

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		ClientName(i, buf, sizeof(buf));

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

	return -1;
}
Exemple #2
0
/*
=======================================================================================================================================
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;
}
Exemple #3
0
Bridge::Bridge(ulen num_clients)
 : server(*this),
   clients(DoReserve,num_clients),
   masters(DoReserve,num_clients+1),
   msem("Bridge"),
   mutex("Bridge"),
   running(false)
 {
  masters.append_fill(server,ServerName());

  for(ulen i=0; i<num_clients ;i++)
    {
     Client *client=clients.append_fill(*this,i+1);

     masters.append_fill(*client,ClientName(i+1).str);
    }

  drop_rate=0;
  drop_den=1;

  to_server_format.prefix=11;
  to_server_format.max_data=1100;
  to_server_format.suffix=10;

  to_client_format.prefix=13;
  to_client_format.max_data=1000;
  to_client_format.suffix=15;
 }
Exemple #4
0
/*
==================
BotGetTeamMateCTFPreference
==================
*/
void BotSetTeamMateCTFPreference(bot_state_t *bs, int teammate, int preference) {
    char teammatename[MAX_NETNAME];

    ctftaskpreferences[teammate].preference = preference;
    ClientName(teammate, teammatename, sizeof(teammatename));
    strcpy(ctftaskpreferences[teammate].name, teammatename);
}
/*
==================
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;
	//char buf[MAX_MESSAGE_SIZE];

	trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
	client = ClientOnSameTeamFromName(bs, netname);
	if (client < 0) return qfalse;
	
	//if the message is addressed to someone
	if (match->subtype & ST_ADDRESSED) {

		// compare addressee with botname
		trap_BotMatchVariable(match, ADDRESSEE, addressedto, sizeof(addressedto));
		ClientName(bs->client, botname, 128);

		// is that me?
		if ( strlen(addressedto) && (stristr(botname, addressedto)) ){
			return qtrue;
		}

		// no its not!
		if( bot_developer.integer & AIDBG_CHAT){
			//Com_sprintf(buf, sizeof(buf), "not addressed to me but %s", addressedto);
			//trap_EA_Say(bs->client, buf);
		}

		return qfalse;
	}
	// not addressed, take it
	return qtrue;
}
Exemple #6
0
/*
==================
BotChat_HitNoKill
==================
*/
int BotChat_HitNoKill(bot_state_t *bs) {
	char name[32], *weap;
	float rnd;
	aas_entityinfo_t entinfo;

	if (bot_nochat.integer) return qfalse;
	if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
	if (BotNumActivePlayers() <= 1) return qfalse;
	rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_HITNOKILL, 0, 1);
	//don't chat in teamplay
	if (TeamPlayIsOn()) return qfalse;
	// don't chat in tournament mode
	if (gametype == GT_TOURNAMENT) return qfalse;
	//if fast chat is off
	if (!bot_fastchat.integer) {
		if (random() > rnd * 0.5) return qfalse;
	}
	if (!BotValidChatPosition(bs)) return qfalse;
	//
	if (BotVisibleEnemies(bs)) return qfalse;
	//
	BotEntityInfo(bs->enemy, &entinfo);
	if (EntityIsShooting(&entinfo)) return qfalse;
	//
	ClientName(bs->enemy, name, sizeof(name));
	weap = BotWeaponNameForMeansOfDeath(g_entities[bs->enemy].client->lasthurt_mod);
	//
	BotAI_BotInitialChat(bs, "hit_nokill", name, weap, NULL);
	bs->lastchat_time = FloatTime();
	bs->chatto = CHAT_ALL;
	return qtrue;
}
Exemple #7
0
/*
==================
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;
}
Exemple #8
0
/*
=======================================================================================================================================
BotMatch_StopTeamLeaderShip
=======================================================================================================================================
*/
void BotMatch_StopTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
	int client;
	char teammate[MAX_MESSAGE_SIZE];
	char netname[MAX_MESSAGE_SIZE];

	if (!TeamPlayIsOn()) {
		return;
	}
	// get the team mate that stops being the team leader
	trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
	// if chats for him or herself
	if (match->subtype & ST_I) {
		trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
		client = FindClientByName(netname);
	}
	// chats for someone else
	else {
		client = FindClientByName(teammate);
	}

	if (client >= 0) {
		if (!Q_stricmp(bs->teamleader, ClientName(client, netname, sizeof(netname)))) {
			bs->teamleader[0] = '\0';
		}
	}
}
Exemple #9
0
/*
==================
BotVoiceChat_StartLeader
==================
*/
void BotVoiceChat_StartLeader(bot_state_t *bs, int client, int mode) {

	/* LQ3A */
	UNREFERENCED_PARAMETER(mode);

	ClientName(client, bs->teamleader, sizeof(bs->teamleader));
}
Exemple #10
0
/*
==================
BotChat_HitTalking
==================
*/
int BotChat_HitTalking(bot_state_t *bs) {
	char name[32], *weap;
	int lasthurt_client;
	float rnd;

	if (bot_nochat.integer) return qfalse;
	if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
	if (BotNumActivePlayers() <= 1) return qfalse;
	lasthurt_client = g_entities[bs->client].client->lasthurt_client;
	if (!lasthurt_client) return qfalse;
	if (lasthurt_client == bs->client) return qfalse;
	//
	if (lasthurt_client < 0 || lasthurt_client >= MAX_CLIENTS) return qfalse;
	//
	rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_HITTALKING, 0, 1);
	//don't chat in teamplay
	if (TeamPlayIsOn()) return qfalse;
	// don't chat in tournament mode
	if (gametype == GT_TOURNAMENT) return qfalse;
	//if fast chat is off
	if (!bot_fastchat.integer) {
		if (random() > rnd * 0.5) return qfalse;
	}
	if (!BotValidChatPosition(bs)) return qfalse;
	//
	ClientName(g_entities[bs->client].client->lasthurt_client, name, sizeof(name));
	weap = BotWeaponNameForMeansOfDeath(g_entities[bs->client].client->lasthurt_mod);
	//
	BotAI_BotInitialChat(bs, "hit_talking", name, weap, NULL);
	bs->lastchat_time = FloatTime();
	bs->chatto = CHAT_ALL;
	return qtrue;
}
Exemple #11
0
/*
==================
BotChat_HitNoDeath
==================
*/
int BotChat_HitNoDeath( bot_state_t *bs ) {
	char name[32];
    const char* weap;
	float rnd;
	int lasthurt_client;
	aas_entityinfo_t entinfo;

	lasthurt_client = g_entities[bs->client].client->lasthurt_client;
	if ( !lasthurt_client ) {
		return qfalse;
	}
	if ( lasthurt_client == bs->client ) {
		return qfalse;
	}
	//
	if ( lasthurt_client < 0 || lasthurt_client >= MAX_CLIENTS ) {
		return qfalse;
	}
	//
	if ( bot_nochat.integer ) {
		return qfalse;
	}
	if ( bs->lastchat_time > trap_AAS_Time() - 3 ) {
		return qfalse;
	}
	if ( BotNumActivePlayers() <= 1 ) {
		return qfalse;
	}
	rnd = trap_Characteristic_BFloat( bs->character, CHARACTERISTIC_CHAT_HITNODEATH, 0, 1 );
	//don't chat in teamplay
	if ( TeamPlayIsOn() ) {
		return qfalse;
	}
	//if fast chat is off
	if ( !bot_fastchat.integer ) {
		if ( random() > rnd * 0.5 ) {
			return qfalse;
		}
	}
	if ( !BotValidChatPosition( bs ) ) {
		return qfalse;
	}
	//if the enemy is visible
	if ( BotEntityVisible( bs->client, bs->eye, bs->viewangles, 360, bs->enemy ) ) {
		return qfalse;
	}
	//
	BotEntityInfo( bs->enemy, &entinfo );
	if ( EntityIsShooting( &entinfo ) ) {
		return qfalse;
	}
	//
	ClientName( lasthurt_client, name, sizeof( name ) );
	weap = BotWeaponNameForMeansOfDeath( g_entities[bs->client].client->lasthurt_mod );
	//
	BotAI_BotInitialChat( bs, "hit_nodeath", name, weap, NULL );
	bs->lastchat_time = trap_AAS_Time();
	bs->chatto = CHAT_ALL;
	return qtrue;
}
Exemple #12
0
/*
==================
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;
}
Exemple #13
0
/*
==================
BotMatch_WhatIsMyCommand
==================
*/
void BotMatch_WhatIsMyCommand(bot_state_t *bs, bot_match_t *match) {
	char netname[MAX_NETNAME];

	ClientName(bs->client, netname, sizeof(netname));
	if (Q_stricmp(netname, bs->teamleader) != 0) return;
	bs->forceorders = qtrue;
}
Exemple #14
0
/*
=======================================================================================================================================
BotMatch_StartTeamLeaderShip
=======================================================================================================================================
*/
void BotMatch_StartTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
	int client;
	char teammate[MAX_MESSAGE_SIZE];

	if (!TeamPlayIsOn()) {
		return;
	}
	// if chats for him or herself
	if (match->subtype & ST_I) {
		// get the team mate that will be the team leader
		trap_BotMatchVariable(match, NETNAME, teammate, sizeof(teammate));
		strncpy(bs->teamleader, teammate, sizeof(bs->teamleader));
		bs->teamleader[sizeof(bs->teamleader) - 1] = '\0';
	}
	// chats for someone else
	else {
		// get the team mate that will be the team leader
		trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
		client = FindClientByName(teammate);

		if (client >= 0) {
			ClientName(client, bs->teamleader, sizeof(bs->teamleader));
		}
	}
}
Exemple #15
0
/*
==================
BotGetTeamMateCTFPreference
==================
*/
int BotGetTeamMateCTFPreference(bot_state_t *bs, int teammate) {
    char teammatename[MAX_NETNAME];

    if (!ctftaskpreferences[teammate].preference) return 0;
    ClientName(teammate, teammatename, sizeof(teammatename));
    if (Q_stricmp(teammatename, ctftaskpreferences[teammate].name)) return 0;
    return ctftaskpreferences[teammate].preference;
}
/*
==================
BotVoiceChat_StopLeader
==================
*/
void BotVoiceChat_StopLeader(bot_state_t *bs, int client, int mode) {
	char netname[MAX_MESSAGE_SIZE];

	if (!Q_stricmp(bs->teamleader, ClientName(client, netname, sizeof(netname)))) {
		bs->teamleader[0] = '\0';
		notleader[client] = qtrue;
	}
}
Exemple #17
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_BothFlagsAtBase( bot_state_t *bs ) {
	int numteammates, defenders, attackers, i;
	int teammates[MAX_CLIENTS];
	char name[MAX_NETNAME];
//	char buf[MAX_MESSAGE_SIZE];

	numteammates = BotSortTeamMatesByBaseTravelTime( bs, teammates, sizeof( teammates ) );
	//different orders based on the number of team mates
	switch ( numteammates ) {
	case 1: break;
	case 2:
	{
		//the one closest to the base will defend the base
		ClientName( teammates[0], name, sizeof( name ) );
		BotAI_BotInitialChat( bs, "cmd_defendbase", name, NULL );
		BotSayTeamOrder( bs, teammates[0] );
		//the other will get the flag
		ClientName( teammates[1], name, sizeof( name ) );
		BotAI_BotInitialChat( bs, "cmd_getflag", name, NULL );
		BotSayTeamOrder( bs, teammates[1] );
		break;
	}
	case 3:
	{
		//the one closest to the base will defend the base
		ClientName( teammates[0], name, sizeof( name ) );
		BotAI_BotInitialChat( bs, "cmd_defendbase", name, NULL );
		BotSayTeamOrder( bs, teammates[0] );
		//the second one closest to the base will defend the base
		ClientName( teammates[1], name, sizeof( name ) );
		BotAI_BotInitialChat( bs, "cmd_defendbase", name, NULL );
		BotSayTeamOrder( bs, teammates[1] );
		//the other will get the flag
		ClientName( teammates[2], name, sizeof( name ) );
		BotAI_BotInitialChat( bs, "cmd_getflag", name, NULL );
		BotSayTeamOrder( bs, teammates[2] );
		break;
	}
	default:
	{
		defenders = (int) ( float ) numteammates * 0.5 + 0.5;
		attackers = (int) ( float ) numteammates * 0.3 + 0.5;
		for ( i = 0; i < defenders; i++ ) {
			//
			ClientName( teammates[i], name, sizeof( name ) );
			BotAI_BotInitialChat( bs, "cmd_defendbase", name, NULL );
			BotSayTeamOrder( bs, teammates[i] );
		}
		for ( i = 0; i < attackers; i++ ) {
			//
			ClientName( teammates[numteammates - i - 1], name, sizeof( name ) );
			BotAI_BotInitialChat( bs, "cmd_getflag", name, NULL );
			BotSayTeamOrder( bs, teammates[numteammates - i - 1] );
		}
		//
		break;
	}
	}
}
Exemple #18
0
/*
==================
BotMatch_WhoIsTeamLeader
==================
*/
void BotMatch_WhoIsTeamLeader(bot_state_t *bs, bot_match_t *match) {
	char netname[MAX_MESSAGE_SIZE];

	if (!TeamPlayIsOn()) return;

	ClientName(bs->client, netname, sizeof(netname));
	//if this bot IS the team leader
	if (!Q_stricmp(netname, bs->teamleader)) {
		trap_EA_SayTeam(bs->client, "I'm the team leader\n");
	}
}
Exemple #19
0
/*
==================
BotCreateGroup
==================
*/
void BotCreateGroup(bot_state_t *bs, int *teammates, int groupsize)
{
    char name[MAX_NETNAME], leadername[MAX_NETNAME];
    int i;

    // the others in the group will follow the teammates[0]
    ClientName(teammates[0], leadername, sizeof(leadername));
    for (i = 1; i < groupsize; i++)
    {
        ClientName(teammates[i], name, sizeof(name));
        if (teammates[0] == bs->client)
        {
            BotAI_BotInitialChat(bs, "cmd_accompanyme", name, NULL);
        }
        else
        {
            BotAI_BotInitialChat(bs, "cmd_accompany", name, leadername, NULL);
        }
        BotSayTeamOrderAlways(bs, teammates[i]);
    }
}
/*
==================
BotVoiceChat_WhoIsLeader
==================
*/
void BotVoiceChat_WhoIsLeader(bot_state_t *bs, int client, int mode) {
	char netname[MAX_MESSAGE_SIZE];

	if (!TeamPlayIsOn()) return;

	ClientName(bs->client, netname, sizeof(netname));
	//if this bot IS the team leader
	if (!Q_stricmp(netname, bs->teamleader)) {
		BotAI_BotInitialChat(bs, "iamteamleader", NULL);
		trap_BotEnterChat(bs->cs, 0, CHAT_TEAM);
		BotVoiceChatOnly(bs, -1, VOICECHAT_STARTLEADER);
	}
}
Exemple #21
0
/*
==================
BotSayTeamOrders
==================
*/
void BotSayTeamOrder( bot_state_t *bs, int toclient ) {
	char teamchat[MAX_MESSAGE_SIZE];
	char buf[MAX_MESSAGE_SIZE];
	char name[MAX_NETNAME];

	//if the bot is talking to itself
	if ( bs->client == toclient ) {
		//don't show the message just put it in the console message queue
		trap_BotGetChatMessage( bs->cs, buf, sizeof( buf ) );
		ClientName( bs->client, name, sizeof( name ) );
		Com_sprintf( teamchat, sizeof( teamchat ), "(%s): %s", name, buf );
		trap_BotQueueConsoleMessage( bs->cs, CMS_CHAT, teamchat );
	} else {
		trap_BotEnterChat( bs->cs, bs->client, CHAT_TEAM );
	}
}
void BotInstructMate(bot_state_t* bs, int client ,int goal){
    char name[MAX_NETNAME];

	ClientName(client, name, sizeof(name));
	//G_Printf("ordering %s",name);	// cyr 20055
    if( g_entities[client].r.svFlags & SVF_BOT )
            BotAI_BotInitialChat(bs, "cmd_accompany", name, va("%d", goal), NULL);
    else{
		if(lastorderedgoal[client] == goal+1) return;	//dont bother humans with the same MSG
		lastorderedgoal[client] = goal+1;

        if( goal >= 0)
            BotAI_BotInitialChat(bs, "cmd_accompany", name,
            va("the %s",g_entities[ balloongoal[goal].entitynum ].message ), NULL);
        else
            BotAI_BotInitialChat(bs, "cmd_accompany", name, va("nothing, just roam"), NULL);
    }
    BotSayTeamOrder(bs, client);
}
Exemple #23
0
/*
==================
BotMatch_TaskPreference
==================
*/
void BotMatch_TaskPreference(bot_state_t *bs, bot_match_t *match) {
	char netname[MAX_NETNAME];
	char teammatename[MAX_MESSAGE_SIZE];
	int teammate, preference;

	ClientName(bs->client, netname, sizeof(netname));
	if (Q_stricmp(netname, bs->teamleader) != 0) return;

	trap_BotMatchVariable(match, NETNAME, teammatename, sizeof(teammatename));
	teammate = ClientFromName(teammatename);
	if (teammate < 0) return;

	preference = BotGetTeamMateTaskPreference(bs, teammate);
	switch(match->subtype)
	{
		case ST_DEFENDER:
		{
			preference &= ~TEAMTP_ATTACKER;
			preference |= TEAMTP_DEFENDER;
			break;
		}
		case ST_ATTACKER:
		{
			preference &= ~TEAMTP_DEFENDER;
			preference |= TEAMTP_ATTACKER;
			break;
		}
		case ST_ROAMER:
		{
			preference &= ~(TEAMTP_ATTACKER|TEAMTP_DEFENDER);
			break;
		}
	}
	BotSetTeamMateTaskPreference(bs, teammate, preference);
	//
	EasyClientName(teammate, teammatename, sizeof(teammatename));
	BotAI_BotInitialChat(bs, "keepinmind", teammatename, NULL);
	trap_BotEnterChat(bs->cs, teammate, CHAT_TELL);
	BotVoiceChatOnly(bs, teammate, VOICECHAT_YES);
	trap_EA_Action(bs->client, ACTION_AFFIRMATIVE);
}
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));
						return qtrue;
					}
				}
			}
		}
	}
	return qfalse;

}
Exemple #25
0
/*
==================
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 );
	}
}
Exemple #26
0
/*
==================
BotSetInfoConfigString
==================
*/
void BotSetInfoConfigString(bot_state_t *bs) {
	char goalname[MAX_MESSAGE_SIZE];
	char netname[MAX_MESSAGE_SIZE];
	char action[MAX_MESSAGE_SIZE];
	char *leader, carrying[32], *cs;
	bot_goal_t goal;
	//
	ClientName(bs->client, netname, sizeof(netname));
	if (Q_stricmp(netname, bs->teamleader) == 0) leader = "L";
	else leader = " ";

	strcpy(carrying, "  ");
	if (gametype == GT_CTF) {
		if (BotCTFCarryingFlag(bs)) {
			strcpy(carrying, "F ");
		}
	}
#if 1  //def MPACK
	else if (gametype == GT_1FCTF) {
		if (Bot1FCTFCarryingFlag(bs)) {
			strcpy(carrying, "F ");
		}
	}
	else if (gametype == GT_HARVESTER) {
		if (BotHarvesterCarryingCubes(bs)) {
			if (BotTeam(bs) == TEAM_RED) Com_sprintf(carrying, sizeof(carrying), "%2d", bs->inventory[INVENTORY_REDCUBE]);
			else Com_sprintf(carrying, sizeof(carrying), "%2d", bs->inventory[INVENTORY_BLUECUBE]);
		}
	}
#endif

	switch(bs->ltgtype) {
		case LTG_TEAMHELP:
		{
			EasyClientName(bs->teammate, goalname, sizeof(goalname));
			Com_sprintf(action, sizeof(action), "helping %s", goalname);
			break;
		}
		case LTG_TEAMACCOMPANY:
		{
			EasyClientName(bs->teammate, goalname, sizeof(goalname));
			Com_sprintf(action, sizeof(action), "accompanying %s", goalname);
			break;
		}
		case LTG_DEFENDKEYAREA:
		{
			trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
			Com_sprintf(action, sizeof(action), "defending %s", goalname);
			break;
		}
		case LTG_GETITEM:
		{
			trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
			Com_sprintf(action, sizeof(action), "getting item %s", goalname);
			break;
		}
		case LTG_KILL:
		{
			ClientName(bs->teamgoal.entitynum, goalname, sizeof(goalname));
			Com_sprintf(action, sizeof(action), "killing %s", goalname);
			break;
		}
		case LTG_CAMP:
		case LTG_CAMPORDER:
		{
			Com_sprintf(action, sizeof(action), "camping");
			break;
		}
		case LTG_PATROL:
		{
			Com_sprintf(action, sizeof(action), "patrolling");
			break;
		}
		case LTG_GETFLAG:
		{
			Com_sprintf(action, sizeof(action), "capturing flag");
			break;
		}
		case LTG_RUSHBASE:
		{
			Com_sprintf(action, sizeof(action), "rushing base");
			break;
		}
		case LTG_RETURNFLAG:
		{
			Com_sprintf(action, sizeof(action), "returning flag");
			break;
		}
		case LTG_ATTACKENEMYBASE:
		{
			Com_sprintf(action, sizeof(action), "attacking the enemy base");
			break;
		}
		case LTG_HARVEST:
		{
			Com_sprintf(action, sizeof(action), "harvesting");
			break;
		}
		default:
		{
			trap_BotGetTopGoal(bs->gs, &goal);
			trap_BotGoalName(goal.number, goalname, sizeof(goalname));
			Com_sprintf(action, sizeof(action), "roaming %s", goalname);
			break;
		}
	}
  	cs = va("l\\%s\\c\\%s\\a\\%s",
				leader,
				carrying,
				action);
  	trap_SetConfigstring (CS_BOTINFO + bs->client, cs);
}
Exemple #27
0
/*
==================
BotReportStatus
==================
*/
void BotReportStatus(bot_state_t *bs) {
	char goalname[MAX_MESSAGE_SIZE];
	char netname[MAX_MESSAGE_SIZE];
	char *leader, flagstatus[32];
	//
	ClientName(bs->client, netname, sizeof(netname));
	if (Q_stricmp(netname, bs->teamleader) == 0) leader = "L";
	else leader = " ";

	strcpy(flagstatus, "  ");
	if (gametype == GT_CTF) {
		if (BotCTFCarryingFlag(bs)) {
			if (BotTeam(bs) == TEAM_RED) strcpy(flagstatus, S_COLOR_RED"F ");
			else strcpy(flagstatus, S_COLOR_BLUE"F ");
		}
	}
#if 1  //def MPACK
	else if (gametype == GT_1FCTF) {
		if (Bot1FCTFCarryingFlag(bs)) {
			if (BotTeam(bs) == TEAM_RED) strcpy(flagstatus, S_COLOR_RED"F ");
			else strcpy(flagstatus, S_COLOR_BLUE"F ");
		}
	}
	else if (gametype == GT_HARVESTER) {
		if (BotHarvesterCarryingCubes(bs)) {
			if (BotTeam(bs) == TEAM_RED) Com_sprintf(flagstatus, sizeof(flagstatus), S_COLOR_RED"%2d", bs->inventory[INVENTORY_REDCUBE]);
			else Com_sprintf(flagstatus, sizeof(flagstatus), S_COLOR_BLUE"%2d", bs->inventory[INVENTORY_BLUECUBE]);
		}
	}
#endif

	switch(bs->ltgtype) {
		case LTG_TEAMHELP:
		{
			EasyClientName(bs->teammate, goalname, sizeof(goalname));
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: helping %s\n", netname, leader, flagstatus, goalname);
			break;
		}
		case LTG_TEAMACCOMPANY:
		{
			EasyClientName(bs->teammate, goalname, sizeof(goalname));
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: accompanying %s\n", netname, leader, flagstatus, goalname);
			break;
		}
		case LTG_DEFENDKEYAREA:
		{
			trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: defending %s\n", netname, leader, flagstatus, goalname);
			break;
		}
		case LTG_GETITEM:
		{
			trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: getting item %s\n", netname, leader, flagstatus, goalname);
			break;
		}
		case LTG_KILL:
		{
			ClientName(bs->teamgoal.entitynum, goalname, sizeof(goalname));
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: killing %s\n", netname, leader, flagstatus, goalname);
			break;
		}
		case LTG_CAMP:
		case LTG_CAMPORDER:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: camping\n", netname, leader, flagstatus);
			break;
		}
		case LTG_PATROL:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: patrolling\n", netname, leader, flagstatus);
			break;
		}
		case LTG_GETFLAG:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: capturing flag\n", netname, leader, flagstatus);
			break;
		}
		case LTG_RUSHBASE:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: rushing base\n", netname, leader, flagstatus);
			break;
		}
		case LTG_RETURNFLAG:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: returning flag\n", netname, leader, flagstatus);
			break;
		}
		case LTG_ATTACKENEMYBASE:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: attacking the enemy base\n", netname, leader, flagstatus);
			break;
		}
		case LTG_HARVEST:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: harvesting\n", netname, leader, flagstatus);
			break;
		}
		default:
		{
			BotAI_Print(PRT_MESSAGE, "%-20s%s%s: roaming\n", netname, leader, flagstatus);
			break;
		}
	}
}
void BotVoiceChat_StartLeader(bot_state_t *bs, int client, int mode) {
	ClientName(client, bs->teamleader, sizeof(bs->teamleader));
}
Exemple #29
0
/*
=======================================================================================================================================
BotPrintTeamGoal
=======================================================================================================================================
*/
void BotPrintTeamGoal(bot_state_t *bs) {
	char netname[MAX_NETNAME];
	float t;

	ClientName(bs->client, netname, sizeof(netname));
	t = bs->teamgoal_time - trap_AAS_Time();

	switch (bs->ltgtype) {
	case LTG_TEAMHELP:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna help a team mate for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_TEAMACCOMPANY:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna accompany a team mate for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_GETFLAG:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna get the flag for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_RUSHBASE:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna rush to the base for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_RETURNFLAG:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna try to return the flag for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_DEFENDKEYAREA:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna defend a key area for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_GETITEM:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna get an item for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_KILL:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna kill someone for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_CAMP:
	case LTG_CAMPORDER:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna camp for %1.0f secs\n", netname, t);
		break;
	}

	case LTG_PATROL:
	{
		BotAI_Print(PRT_MESSAGE, "%s: I'm gonna patrol for %1.0f secs\n", netname, t);
		break;
	}

	default:
	{
		if (bs->ctfroam_time > trap_AAS_Time()) {
			t = bs->ctfroam_time - trap_AAS_Time();
			BotAI_Print(PRT_MESSAGE, "%s: I'm gonna roam for %1.0f secs\n", netname, t);
		} else {
			BotAI_Print(PRT_MESSAGE, "%s: I've got a regular goal\n", netname);
		}
	}
	}
}
Exemple #30
0
/*
=======================================================================================================================================
BotMatch_WhatAreYouDoing
=======================================================================================================================================
*/
void BotMatch_WhatAreYouDoing(bot_state_t *bs, bot_match_t *match) {
	char netname[MAX_MESSAGE_SIZE];
	char goalname[MAX_MESSAGE_SIZE];
	// if not addressed to this bot
	if (!BotAddressedToBot(bs, match)) {
		return;
	}

	switch (bs->ltgtype) {
	case LTG_TEAMHELP:
	{
		trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
		EasyClientName(bs->teammate, netname, MAX_MESSAGE_SIZE);
		BotAI_BotInitialChat(bs, "helping", netname, NULL);
		break;
	}

	case LTG_TEAMACCOMPANY:
	{
		trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
		EasyClientName(bs->teammate, netname, MAX_MESSAGE_SIZE);
		BotAI_BotInitialChat(bs, "accompanying", netname, NULL);
		break;
	}

	case LTG_DEFENDKEYAREA:
	{
		trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
		BotAI_BotInitialChat(bs, "defending", goalname, NULL);
		break;
	}

	case LTG_GETITEM:
	{
		trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
		BotAI_BotInitialChat(bs, "gettingitem", goalname, NULL);
		break;
	}

	case LTG_KILL:
	{
		ClientName(bs->teamgoal.entitynum, netname, sizeof(netname));
		BotAI_BotInitialChat(bs, "killing", netname, NULL);
		break;
	}

	case LTG_CAMP:
	case LTG_CAMPORDER:
	{
		BotAI_BotInitialChat(bs, "camping", NULL);
		break;
	}

	case LTG_PATROL:
	{
		BotAI_BotInitialChat(bs, "patrolling", NULL);
		break;
	}

	case LTG_GETFLAG:
	{
		BotAI_BotInitialChat(bs, "capturingflag", NULL);
		break;
	}

	case LTG_RUSHBASE:
	{
		BotAI_BotInitialChat(bs, "rushingbase", NULL);
		break;
	}

	case LTG_RETURNFLAG:
	{
		BotAI_BotInitialChat(bs, "returningflag", NULL);
		break;
	}

	default:
	{
		BotAI_BotInitialChat(bs, "roaming", NULL);
		break;
	}
	}
	// chat what the bot is doing
	trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
}