Exemple #1
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;
	}
	}
}
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 #3
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_BothFlagsAtBase(bot_state_t *bs) {
    int numteammates, defenders, attackers, i;
    int teammates[MAX_CLIENTS];
    char name[MAX_NETNAME];

    //sort team mates by travel time to base
    numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
    //sort team mates by CTF preference
    BotSortTeamMatesByCTFPreference(bs, teammates, numteammates);
    //agressive
    //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 others should go for the enemy flag
        ClientName(teammates[1], name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
        BotSayTeamOrder(bs, teammates[1]);
        //
        ClientName(teammates[2], name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
        BotSayTeamOrder(bs, teammates[2]);
        break;
    }
    default:
    {
        defenders = (int) (float) numteammates * 0.4 + 0.5;
        if (defenders > 1) defenders = 1;
        attackers = (int) (float) numteammates * 0.5 + 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 #4
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_EnemyFlagNotAtBase(bot_state_t *bs) {
    int numteammates, defenders, attackers, i, other;
    int teammates[MAX_CLIENTS];
    char name[MAX_NETNAME], carriername[MAX_NETNAME];

    numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
    BotSortTeamMatesByCTFPreference(bs, teammates, numteammates);
    //different orders based on the number of team mates
    switch(numteammates) {
    case 1:
        break;
    case 2:
    {
        //tell the one not carrying the flag to defend the base
        if (teammates[0] == bs->flagcarrier) other = teammates[1];
        else other = teammates[0];
        ClientName(other, name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
        BotSayTeamOrder(bs, other);
        break;
    }
    case 3:
    {
        //tell the one closest to the base not carrying the flag to defend the base
        if (teammates[0] != bs->flagcarrier) other = teammates[0];
        else other = teammates[1];
        ClientName(other, name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
        BotSayTeamOrder(bs, other);
        //tell the one furthest from the base not carrying the flag to accompany the flag carrier
        if (teammates[2] != bs->flagcarrier) other = teammates[2];
        else other = teammates[1];
        ClientName(other, name, sizeof(name));
        ClientName(bs->flagcarrier, carriername, sizeof(carriername));
        if (bs->flagcarrier == bs->client) {
            BotAI_BotInitialChat(bs, "cmd_accompanyme", name, NULL);
        }
        else {
            BotAI_BotInitialChat(bs, "cmd_accompany", name, carriername, NULL);
        }
        BotSayTeamOrder(bs, other);
        break;
    }
    default:
    {
        //40% will defend the base
        defenders = (int) (float) numteammates * 0.4 + 0.5;
        if (defenders > 1) defenders = 1;
        //50% accompanies the flag carrier
        attackers = (int) (float) numteammates * 0.5 + 0.5;
        for (i = 0; i < defenders; i++) {
            //
            if (teammates[i] == bs->flagcarrier) {
                continue;
            }
            ClientName(teammates[i], name, sizeof(name));
            BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
            BotSayTeamOrder(bs, teammates[i]);
        }
        ClientName(bs->flagcarrier, carriername, sizeof(carriername));
        for (i = 0; i < attackers; i++) {
            //
            if (teammates[numteammates - i - 1] == bs->flagcarrier) {
                continue;
            }
            //
            ClientName(teammates[numteammates - i - 1], name, sizeof(name));
            if (bs->flagcarrier == bs->client) {
                BotAI_BotInitialChat(bs, "cmd_accompanyme", name, NULL);
            }
            else {
                BotAI_BotInitialChat(bs, "cmd_accompany", name, carriername, NULL);
            }
            BotSayTeamOrder(bs, teammates[numteammates - i - 1]);
        }
        //
        break;
    }
    }
}
Exemple #5
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_FlagNotAtBase(bot_state_t *bs) {
    int numteammates, defenders, attackers, i;
    int teammates[MAX_CLIENTS];
    char name[MAX_NETNAME];

    numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
    BotSortTeamMatesByCTFPreference(bs, teammates, numteammates);
    //agressive
    //different orders based on the number of team mates
    switch(bs->numteammates)
    {
    case 1:
        break;
    case 2:
    {
        //both will go for the enemy flag
        ClientName(teammates[0], name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
        BotSayTeamOrder(bs, teammates[0]);
        //
        ClientName(teammates[1], name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
        BotSayTeamOrder(bs, teammates[1]);
        break;
    }
    case 3:
    {
        //everyone go for the flag
        ClientName(teammates[0], name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
        BotSayTeamOrder(bs, teammates[0]);
        //
        ClientName(teammates[1], name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
        BotSayTeamOrder(bs, teammates[1]);
        //
        ClientName(teammates[2], name, sizeof(name));
        BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
        BotSayTeamOrder(bs, teammates[2]);
        break;
    }
    default:
    {
        //keep some people near the base for when the flag is returned
        defenders = (int) (float) numteammates * 0.2 + 0.5;
        if (defenders > 1) defenders = 1;
        attackers = (int) (float) numteammates * 0.7 + 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 #6
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_BothFlagsAtBase(bot_state_t *bs)
{
    int numteammates, defenders, attackers, i;
    int teammates[MAX_CLIENTS];
    char name[MAX_NETNAME];

    //sort team mates by travel time to base
    numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
    //sort team mates by CTF preference
    BotSortTeamMatesByTaskPreference(bs, teammates, numteammates);
    //passive strategy
    if (!(bs->ctfstrategy & CTFS_AGRESSIVE))
    {
        //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]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);
                //the other will get the flag
                ClientName(teammates[1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[1]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);
                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]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);
                //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]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);
                //the other will get the flag
                ClientName(teammates[2], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[2]);
                BotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);
                break;
            }
        default:
            {
                defenders = (int)((float) numteammates * 0.5 + 0.5);
                if (defenders > 5) defenders = 5;
                attackers = (int)((float) numteammates * 0.4 + 0.5);
                if (attackers > 4) attackers = 4;
                for (i = 0; i < defenders; i++)
                {
                    //
                    ClientName(teammates[i], name, sizeof(name));
                    BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                    BotSayTeamOrder(bs, teammates[i]);
                    BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);
                }
                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]);
                    BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);
                }
                //
                break;
            }
        }
    }
    else
    {
        //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]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);
                //the other will get the flag
                ClientName(teammates[1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[1]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);
                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]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);
                //the others should go for the enemy flag
                ClientName(teammates[1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[1]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);
                //
                ClientName(teammates[2], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[2]);
                BotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);
                break;
            }
        default:
            {
                defenders = (int)((float) numteammates * 0.4 + 0.5);
                if (defenders > 4) defenders = 4;
                attackers = (int)((float) numteammates * 0.5 + 0.5);
                if (attackers > 5) attackers = 5;
                for (i = 0; i < defenders; i++)
                {
                    //
                    ClientName(teammates[i], name, sizeof(name));
                    BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                    BotSayTeamOrder(bs, teammates[i]);
                    BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);
                }
                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]);
                    BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);
                }
                //
                break;
            }
        }
    }
}
Exemple #7
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_EnemyFlagNotAtBase(bot_state_t *bs)
{
    int numteammates, defenders, attackers, i, other;
    int teammates[MAX_CLIENTS];
    char name[MAX_NETNAME], carriername[MAX_NETNAME];

    numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
    BotSortTeamMatesByTaskPreference(bs, teammates, numteammates);
    //different orders based on the number of team mates
    switch(numteammates)
    {
    case 1:
        break;
    case 2:
        {
            //tell the one not carrying the flag to defend the base
            if (teammates[0] == bs->flagcarrier) other = teammates[1];
            else other = teammates[0];
            ClientName(other, name, sizeof(name));
            BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
            BotSayTeamOrder(bs, other);
            BotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);
            break;
        }
    case 3:
        {
            //tell the one closest to the base not carrying the flag to defend the base
            if (teammates[0] != bs->flagcarrier) other = teammates[0];
            else other = teammates[1];
            ClientName(other, name, sizeof(name));
            BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
            BotSayTeamOrder(bs, other);
            BotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);
            //tell the other also to defend the base
            if (teammates[2] != bs->flagcarrier) other = teammates[2];
            else other = teammates[1];
            ClientName(other, name, sizeof(name));
            BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
            BotSayTeamOrder(bs, other);
            BotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);
            break;
        }
    default:
        {
            //60% will defend the base
            defenders = (int)((float) numteammates * 0.6 + 0.5);
            if (defenders > 6) defenders = 6;
            //30% accompanies the flag carrier
            attackers = (int)((float) numteammates * 0.3 + 0.5);
            if (attackers > 3) attackers = 3;
            for (i = 0; i < defenders; i++)
            {
                //
                if (teammates[i] == bs->flagcarrier)
                {
                    continue;
                }
                ClientName(teammates[i], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                BotSayTeamOrder(bs, teammates[i]);
                BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);
            }
            // if we have a flag carrier
            if ( bs->flagcarrier != -1 )
            {
                ClientName(bs->flagcarrier, carriername, sizeof(carriername));
                for (i = 0; i < attackers; i++)
                {
                    //
                    if (teammates[numteammates - i - 1] == bs->flagcarrier)
                    {
                        continue;
                    }
                    //
                    ClientName(teammates[numteammates - i - 1], name, sizeof(name));
                    if (bs->flagcarrier == bs->client)
                    {
                        BotAI_BotInitialChat(bs, "cmd_accompanyme", name, NULL);
                        BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWME);
                    }
                    else
                    {
                        BotAI_BotInitialChat(bs, "cmd_accompany", name, carriername, NULL);
                        BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWFLAGCARRIER);
                    }
                    BotSayTeamOrder(bs, teammates[numteammates - i - 1]);
                }
            }
            else
            {
                for (i = 0; i < attackers; i++)
                {
                    //
                    if (teammates[numteammates - i - 1] == bs->flagcarrier)
                    {
                        continue;
                    }
                    //
                    ClientName(teammates[numteammates - i - 1], name, sizeof(name));
                    BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                    BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);
                    BotSayTeamOrder(bs, teammates[numteammates - i - 1]);
                }
            }
            //
            break;
        }
    }
}
Exemple #8
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_FlagNotAtBase(bot_state_t *bs)
{
    int numteammates, defenders, attackers, i;
    int teammates[MAX_CLIENTS];
    char name[MAX_NETNAME];

    numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
    BotSortTeamMatesByTaskPreference(bs, teammates, numteammates);
    //passive strategy
    if (!(bs->ctfstrategy & CTFS_AGRESSIVE))
    {
        //different orders based on the number of team mates
        switch(bs->numteammates)
        {
        case 1:
            break;
        case 2:
            {
                //both will go for the enemy flag
                ClientName(teammates[0], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                BotSayTeamOrder(bs, teammates[0]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);
                //
                ClientName(teammates[1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[1]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);
                break;
            }
        case 3:
            {
                //keep one near the base for when the flag is returned
                ClientName(teammates[0], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                BotSayTeamOrder(bs, teammates[0]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);
                //the other two get the flag
                ClientName(teammates[1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[1]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);
                //
                ClientName(teammates[2], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[2]);
                BotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);
                break;
            }
        default:
            {
                //keep some people near the base for when the flag is returned
                defenders = (int)((float) numteammates * 0.3 + 0.5);
                if (defenders > 3) defenders = 3;
                attackers = (int)((float) numteammates * 0.7 + 0.5);
                if (attackers > 6) attackers = 6;
                for (i = 0; i < defenders; i++)
                {
                    //
                    ClientName(teammates[i], name, sizeof(name));
                    BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                    BotSayTeamOrder(bs, teammates[i]);
                    BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);
                }
                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]);
                    BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);
                }
                //
                break;
            }
        }
    }
    else
    {
        //different orders based on the number of team mates
        switch(bs->numteammates)
        {
        case 1:
            break;
        case 2:
            {
                //both will go for the enemy flag
                ClientName(teammates[0], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[0]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);
                //
                ClientName(teammates[1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[1]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);
                break;
            }
        case 3:
            {
                //everyone go for the flag
                ClientName(teammates[0], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                BotSayTeamOrder(bs, teammates[0]);
                BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);
                //
                ClientName(teammates[1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[1]);
                BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);
                //
                ClientName(teammates[2], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[2]);
                BotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);
                break;
            }
        default:
            {
                //keep some people near the base for when the flag is returned
                defenders = (int)((float) numteammates * 0.2 + 0.5);
                if (defenders > 2) defenders = 2;
                attackers = (int)((float) numteammates * 0.7 + 0.5);
                if (attackers > 7) attackers = 7;
                for (i = 0; i < defenders; i++)
                {
                    //
                    ClientName(teammates[i], name, sizeof(name));
                    BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
                    BotSayTeamOrder(bs, teammates[i]);
                    BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);
                }
                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]);
                    BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);
                }
                //
                break;
            }
        }
    }
}
Exemple #9
0
/*
==================
BotCTFOrders
==================
*/
void BotCTFOrders_BothFlagsNotAtBase(bot_state_t *bs)
{
    int numteammates, defenders, attackers, i, other;
    int teammates[MAX_CLIENTS];
    char name[MAX_NETNAME], carriername[MAX_NETNAME];

    numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
    BotSortTeamMatesByTaskPreference(bs, teammates, numteammates);
    //different orders based on the number of team mates
    switch(bs->numteammates)
    {
    case 1:
        break;
    case 2:
        {
            //tell the one not carrying the flag to attack the enemy base
            if (teammates[0] != bs->flagcarrier) other = teammates[0];
            else other = teammates[1];
            ClientName(other, name, sizeof(name));
            BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
            BotSayTeamOrder(bs, other);
            BotSayVoiceTeamOrder(bs, other, VOICECHAT_GETFLAG);
            break;
        }
    case 3:
        {
            //tell the one closest to the base not carrying the flag to accompany the flag carrier
            if (teammates[0] != bs->flagcarrier) other = teammates[0];
            else other = teammates[1];
            ClientName(other, name, sizeof(name));
            if ( bs->flagcarrier != -1 )
            {
                ClientName(bs->flagcarrier, carriername, sizeof(carriername));
                if (bs->flagcarrier == bs->client)
                {
                    BotAI_BotInitialChat(bs, "cmd_accompanyme", name, NULL);
                    BotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWME);
                }
                else
                {
                    BotAI_BotInitialChat(bs, "cmd_accompany", name, carriername, NULL);
                    BotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWFLAGCARRIER);
                }
            }
            else
            {
                //
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayVoiceTeamOrder(bs, other, VOICECHAT_GETFLAG);
            }
            BotSayTeamOrder(bs, other);
            //tell the one furthest from the the base not carrying the flag to get the enemy flag
            if (teammates[2] != bs->flagcarrier) other = teammates[2];
            else other = teammates[1];
            ClientName(other, name, sizeof(name));
            BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
            BotSayTeamOrder(bs, other);
            BotSayVoiceTeamOrder(bs, other, VOICECHAT_RETURNFLAG);
            break;
        }
    default:
        {
            defenders = (int)((float) numteammates * 0.4 + 0.5);
            if (defenders > 4) defenders = 4;
            attackers = (int)((float) numteammates * 0.5 + 0.5);
            if (attackers > 5) attackers = 5;
            if (bs->flagcarrier != -1)
            {
                ClientName(bs->flagcarrier, carriername, sizeof(carriername));
                for (i = 0; i < defenders; i++)
                {
                    //
                    if (teammates[i] == bs->flagcarrier)
                    {
                        continue;
                    }
                    //
                    ClientName(teammates[i], name, sizeof(name));
                    if (bs->flagcarrier == bs->client)
                    {
                        BotAI_BotInitialChat(bs, "cmd_accompanyme", name, NULL);
                        BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_FOLLOWME);
                    }
                    else
                    {
                        BotAI_BotInitialChat(bs, "cmd_accompany", name, carriername, NULL);
                        BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_FOLLOWFLAGCARRIER);
                    }
                    BotSayTeamOrder(bs, teammates[i]);
                }
            }
            else
            {
                for (i = 0; i < defenders; i++)
                {
                    //
                    if (teammates[i] == bs->flagcarrier)
                    {
                        continue;
                    }
                    //
                    ClientName(teammates[i], name, sizeof(name));
                    BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                    BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_GETFLAG);
                    BotSayTeamOrder(bs, teammates[i]);
                }
            }
            for (i = 0; i < attackers; i++)
            {
                //
                if (teammates[numteammates - i - 1] == bs->flagcarrier)
                {
                    continue;
                }
                //
                ClientName(teammates[numteammates - i - 1], name, sizeof(name));
                BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
                BotSayTeamOrder(bs, teammates[numteammates - i - 1]);
                BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_RETURNFLAG);
            }
            //
            break;
        }
    }
}