Exemplo n.º 1
0
/*
==================
BotVoiceChat_WantOnOffense
==================
*/
void BotVoiceChat_WantOnOffense(bot_state_t *bs, int client, int mode) {
	char netname[MAX_NETNAME];
	int preference;

	preference = BotGetTeamMateTaskPreference(bs, client);
	preference &= ~TEAMTP_DEFENDER;
	preference |= TEAMTP_ATTACKER;
	BotSetTeamMateTaskPreference(bs, client, preference);
	//
	EasyClientName(client, netname, sizeof(netname));
	BotAI_BotInitialChat(bs, "keepinmind", netname, NULL);
	trap_BotEnterChat(bs->cs, client, CHAT_TELL);
	BotVoiceChatOnly(bs, client, VOICECHAT_YES);
	trap_EA_Action(bs->client, ACTION_AFFIRMATIVE);
}
Exemplo n.º 2
0
/*
==================
BotVoiceChat_WantOnDefense
==================
*/
void BotVoiceChat_WantOnDefense(bot_state_t *bs, int playernum, int mode) {
	char netname[MAX_NETNAME];
	int preference;

	preference = BotGetTeamMateTaskPreference(bs, playernum);
	preference &= ~TEAMTP_ATTACKER;
	preference |= TEAMTP_DEFENDER;
	BotSetTeamMateTaskPreference(bs, playernum, preference);
	//
	EasyPlayerName(playernum, netname, sizeof(netname));
	BotAI_BotInitialChat(bs, "keepinmind", netname, NULL);
	BotEnterChat(bs->cs, playernum, CHAT_TELL);
	BotVoiceChatOnly(bs, playernum, VOICECHAT_YES);
	EA_Action(bs->playernum, ACTION_AFFIRMATIVE);
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
/*
==================
BotSortTeamMatesByTaskPreference
==================
*/
int BotSortTeamMatesByTaskPreference(bot_state_t *bs, int *teammates, int numteammates)
{
    int defenders[MAX_CLIENTS], numdefenders;
    int attackers[MAX_CLIENTS], numattackers;
    int roamers[MAX_CLIENTS], numroamers;
    int i, preference;

    numdefenders = numattackers = numroamers = 0;
    for (i = 0; i < numteammates; i++)
    {
        preference = BotGetTeamMateTaskPreference(bs, teammates[i]);
        if (preference & TEAMTP_DEFENDER)
        {
            defenders[numdefenders++] = teammates[i];
        }
        else if (preference & TEAMTP_ATTACKER)
        {
            attackers[numattackers++] = teammates[i];
        }
        else
        {
            roamers[numroamers++] = teammates[i];
        }
    }
    numteammates = 0;
    //defenders at the front of the list
    memcpy(&teammates[numteammates], defenders, numdefenders * sizeof(int));
    numteammates += numdefenders;
    //roamers in the middle
    memcpy(&teammates[numteammates], roamers, numroamers * sizeof(int));
    numteammates += numroamers;
    //attacker in the back of the list
    memcpy(&teammates[numteammates], attackers, numattackers * sizeof(int));
    numteammates += numattackers;

    return numteammates;
}