void BotTeamAI(bot_state_t *bs) {

	int numteammates;
	char netname[MAX_NETNAME];
	//cyr{
	int i;
	//cyr}

	//
	if ( gametype < GT_TEAM  )
		return;
	// make sure we've got a valid team leader
	if (!BotValidTeamLeader(bs)) {
		//
		if (qtrue){     // cyr (!FindHumanTeamLeader(bs)) {
			//
			if (!bs->askteamleader_time && !bs->becometeamleader_time) {
				if (bs->entergame_time + 10 > FloatTime()) {
					bs->askteamleader_time = FloatTime() + 5 + random() * 10;
				}
				else {
					bs->becometeamleader_time = FloatTime() + 5 + random() * 10;
				}
			}
			if (bs->askteamleader_time && bs->askteamleader_time < FloatTime()) {
				// if asked for a team leader and no response
				BotAI_BotInitialChat(bs, "whoisteamleader", NULL);
				trap_BotEnterChat(bs->cs, 0, CHAT_TEAM);
				bs->askteamleader_time = 0;
				bs->becometeamleader_time = FloatTime() + 8 + random() * 10;
			}
			if (bs->becometeamleader_time && bs->becometeamleader_time < FloatTime()) {
				BotAI_BotInitialChat(bs, "iamteamleader", NULL);
				trap_BotEnterChat(bs->cs, 0, CHAT_TEAM);
				ClientName(bs->client, netname, sizeof(netname));
				strncpy(bs->teamleader, netname, sizeof(bs->teamleader));
				bs->teamleader[sizeof(bs->teamleader)] = '\0';
				bs->becometeamleader_time = 0;
			}
			return;
		}
	}
	bs->askteamleader_time = 0;
	bs->becometeamleader_time = 0;

	//return if this bot is NOT the team leader
	ClientName(bs->client, netname, sizeof(netname));
	if (Q_stricmp(netname, bs->teamleader) != 0) return;
	//
	numteammates = BotNumTeamMates(bs);
	//give orders
	switch(gametype) {
		case GT_TEAM:
		{
			if (bs->numteammates != numteammates || bs->forceorders) {
				bs->teamgiveorders_time = FloatTime();
				bs->numteammates = numteammates;
				bs->forceorders = qfalse;
			}
			//if it's time to give orders
			if (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 5) {
				BotTeamOrders(bs);
				//give orders again after 120 seconds
				bs->teamgiveorders_time = FloatTime() + 120;
			}
			break;
		}
//cyr{
		case GT_BALLOON:
		{
			// team changed ? someone needs orders ?
			if (bs->numteammates != numteammates || bs->forceorders) {
				bs->teamgiveorders_time = FloatTime();
				bs->numteammates = numteammates;
				bs->forceorders = qfalse;
			}
			// balloon status changed since last frame?
			for(i = 0; i < MAX_BALLOONS; i++){
				if(lastballoonstate[i] != level.balloonState[i]){
					lastballoonstate[i] = level.balloonState[i];
					bs->teamgiveorders_time = FloatTime();	// orders für "balloon attacked" überspringen wenns geht
				}
			}

			//if it's time to give orders
			if (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 2) {
                BotBalloonOrders(bs);
                //give orders again
                bs->teamgiveorders_time = FloatTime() + 5;
            }
			break;
		}
//cyr}
	}

}
Ejemplo n.º 2
0
/*
==================
BotTeamAI
==================
*/
void BotTeamAI(bot_state_t *bs) {
    int numteammates, flagstatus;
    char netname[MAX_NETNAME];

    if(!bs) return;

    //
    if (gametype != GT_TEAM && gametype != GT_CTF) return;
    //make sure we've got a valid team leader
    if (!BotValidTeamLeader(bs)) {
        //
        if (!bs->askteamleader_time && !bs->becometeamleader_time) {
            if (bs->entergame_time + 10 > trap_AAS_Time()) {
                bs->askteamleader_time = trap_AAS_Time() + 5 + random() * 10;
            }
            else {
                bs->becometeamleader_time = trap_AAS_Time() + 5 + random() * 10;
            }
        }
        if (bs->askteamleader_time && bs->askteamleader_time < trap_AAS_Time()) {
            //if asked for a team leader and no repsonse
            BotAI_BotInitialChat(bs, "whoisteamleader", NULL);
            trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
            bs->askteamleader_time = 0;
            bs->becometeamleader_time = trap_AAS_Time() + 15 + random() * 10;
        }
        if (bs->becometeamleader_time && bs->becometeamleader_time < trap_AAS_Time()) {
            BotAI_BotInitialChat(bs, "iamteamleader", NULL);
            trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
            ClientName(bs->client, netname, sizeof(netname));
            strncpy(bs->teamleader, netname, sizeof(bs->teamleader));
            bs->teamleader[sizeof(bs->teamleader)-1] = '\0';
            bs->becometeamleader_time = 0;
        }
        return;
    }
    bs->askteamleader_time = 0;
    bs->becometeamleader_time = 0;

    //return if this bot is NOT the team leader
    ClientName(bs->client, netname, sizeof(netname));
    if (Q_stricmp(netname, bs->teamleader) != 0) return;
    //
    //if the game starts OR a new player comes onto the team OR a player leaves the team
    //
    numteammates = BotNumTeamMates(bs);
    //give orders
    switch(gametype) {
    case GT_TEAM:
    {
        if (bs->numteammates != numteammates || bs->forceorders) {
            bs->teamgiveorders_time = trap_AAS_Time();
            bs->numteammates = numteammates;
            bs->forceorders = qfalse;
        }
        //if it's time to give orders
        if (bs->teamgiveorders_time < trap_AAS_Time() - 5) {
            BotTeamOrders(bs);
            //
            bs->teamgiveorders_time = 0;
        }
        break;
    }
    case GT_CTF:
    {
        //if the number of team mates changed or the flag status changed
        //or someone wants to know what to do
        if (bs->numteammates != numteammates || bs->flagstatuschanged || bs->forceorders) {
            bs->teamgiveorders_time = trap_AAS_Time();
            bs->numteammates = numteammates;
            bs->flagstatuschanged = qfalse;
            bs->forceorders = qfalse;
        }
        //if there were no flag captures the last 3 minutes
        if (bs->lastflagcapture_time < trap_AAS_Time() - 240) {
            bs->lastflagcapture_time = trap_AAS_Time();
            //randomly change the CTF strategy
            if (random() < 0.4) {
                bs->ctfstrategy ^= CTFS_PASSIVE;
                bs->teamgiveorders_time = trap_AAS_Time();
            }
        }
        //if it's time to give orders
        if (bs->teamgiveorders_time && bs->teamgiveorders_time < trap_AAS_Time() - 3) {
            //
            if (BotCTFTeam(bs) == CTF_TEAM_RED) flagstatus = bs->redflagstatus * 2 + bs->blueflagstatus;
            else flagstatus = bs->blueflagstatus * 2 + bs->redflagstatus;
            //
            switch(flagstatus) {
            case 0:
                BotCTFOrders_BothFlagsAtBase(bs);
                break;
            case 1:
                BotCTFOrders_EnemyFlagNotAtBase(bs);
                break;
            case 2:
                BotCTFOrders_FlagNotAtBase(bs);
                break;
            case 3:
                BotCTFOrders_BothFlagsNotAtBase(bs);
                break;
            }
            //
            bs->teamgiveorders_time = 0;
        }
        break;
    }
    }
}
Ejemplo n.º 3
0
/*
==================
BotTeamAI
==================
*/
void BotTeamAI(bot_state_t *bs)
{
    int numteammates;
    char netname[MAX_NETNAME];

    //
    if ( gametype < GT_TEAM  )
        return;
    // make sure we've got a valid team leader
    if (!BotValidTeamLeader(bs))
    {
        //
        if (!FindHumanTeamLeader(bs))
        {
            //
            if (!bs->askteamleader_time && !bs->becometeamleader_time)
            {
                if (bs->entergame_time + 10 > FloatTime())
                {
                    bs->askteamleader_time = FloatTime() + 5 + random() * 10;
                }
                else
                {
                    bs->becometeamleader_time = FloatTime() + 5 + random() * 10;
                }
            }
            if (bs->askteamleader_time && bs->askteamleader_time < FloatTime())
            {
                // if asked for a team leader and no response
                BotAI_BotInitialChat(bs, "whoisteamleader", NULL);
                botlib_export->ai.BotEnterChat(bs->cs, 0, CHAT_TEAM);
                bs->askteamleader_time = 0;
                bs->becometeamleader_time = FloatTime() + 8 + random() * 10;
            }
            if (bs->becometeamleader_time && bs->becometeamleader_time < FloatTime())
            {
                BotAI_BotInitialChat(bs, "iamteamleader", NULL);
                botlib_export->ai.BotEnterChat(bs->cs, 0, CHAT_TEAM);
                BotSayVoiceTeamOrder(bs, -1, VOICECHAT_STARTLEADER);
                ClientName(bs->client, netname, sizeof(netname));
                strncpy(bs->teamleader, netname, sizeof(bs->teamleader));
                bs->teamleader[sizeof(bs->teamleader)] = '\0';
                bs->becometeamleader_time = 0;
            }
            return;
        }
    }
    bs->askteamleader_time = 0;
    bs->becometeamleader_time = 0;

    //return if this bot is NOT the team leader
    ClientName(bs->client, netname, sizeof(netname));
    if (Q_stricmp(netname, bs->teamleader) != 0) return;
    //
    numteammates = BotNumTeamMates(bs);
    //give orders
    switch(gametype)
    {
    case GT_TEAM:
        {
            if (bs->numteammates != numteammates || bs->forceorders)
            {
                bs->teamgiveorders_time = FloatTime();
                bs->numteammates = numteammates;
                bs->forceorders = qfalse;
            }
            //if it's time to give orders
            if (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 5)
            {
                BotTeamOrders(bs);
                //give orders again after 120 seconds
                bs->teamgiveorders_time = FloatTime() + 120;
            }
            break;
        }
    case GT_CTF:
        {
            //if the number of team mates changed or the flag status changed
            //or someone wants to know what to do
            if (bs->numteammates != numteammates || bs->flagstatuschanged || bs->forceorders)
            {
                bs->teamgiveorders_time = FloatTime();
                bs->numteammates = numteammates;
                bs->flagstatuschanged = qfalse;
                bs->forceorders = qfalse;
            }
            //if there were no flag captures the last 3 minutes
            if (bs->lastflagcapture_time < FloatTime() - 240)
            {
                bs->lastflagcapture_time = FloatTime();
                //randomly change the CTF strategy
                if (random() < 0.4)
                {
                    bs->ctfstrategy ^= CTFS_AGRESSIVE;
                    bs->teamgiveorders_time = FloatTime();
                }
            }
            //if it's time to give orders
            if (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 3)
            {
                BotCTFOrders(bs);
                //
                bs->teamgiveorders_time = 0;
            }
            break;
        }
    }
}