/* ================== 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; }
int BotTeamCarrierVisible( bot_state_t *bs ) { int i; float vis; aas_entityinfo_t entinfo; gentity_t *ent; float f, alertness; float squaredist; vec3_t dir; int areanum; alertness = trap_Characteristic_BFloat( bs->character, CHARACTERISTIC_ALERTNESS, 0, 1 ); for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) { if ( i == bs->client ) continue; ent = &g_entities[ i ]; if ( !ent->inuse || !ent->target_ent ) continue; BotEntityInfo( ent->target_ent->s.number, &entinfo ); if ( !entinfo.valid || !( entinfo.powerups & ( 1 << PW_BATTLESUIT ) ) ) continue; if ( !BotSameTeam( bs, i ) ) continue; VectorSubtract( entinfo.origin, bs->origin, dir ); squaredist = VectorLengthSquared( dir ); if ( squaredist > Square( 900.0 + alertness * 4000.0 ) ) continue; f = 90 + 90 - ( 90 - ( squaredist > Square( 810 ) ? Square( 810 ) : squaredist ) / ( 810 * 9 ) ); vis = BotEntityVisible( bs->entitynum, bs->eye, bs->viewangles, f, entinfo.number ); if ( vis <= 0 ) continue; areanum = BotPointAreaNum( entinfo.origin ); if ( trap_AAS_AreaTravelTimeToGoalArea( bs->areanum, bs->origin, areanum, bs->tfl ) ) { return entinfo.number; } } return -1; }
/* ================== 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; }
/* ================== BotVisibleEnemies ================== */ int BotVisibleEnemies(bot_state_t *bs) { float vis; int i; aas_entityinfo_t entinfo; for (i = 0; i < MAX_CLIENTS; i++) { if (i == bs->client) continue; // BotEntityInfo(i, &entinfo); // if (!entinfo.valid) continue; //if the enemy isn't dead and the enemy isn't the bot self if (EntityIsDead(&entinfo) || entinfo.number == bs->entitynum) continue; //if the enemy is invisible and not shooting if (EntityIsInvisible(&entinfo) && !EntityIsShooting(&entinfo)) { continue; } //if on the same team if (BotSameTeam(bs, i)) continue; //check if the enemy is visible vis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i); if (vis > 0) return qtrue; } return qfalse; }
/* ================== BotVoiceChat_Camp ================== */ void BotVoiceChat_Camp(bot_state_t * bs, int client, int mode) { int areanum; aas_entityinfo_t entinfo; char netname[MAX_NETNAME]; // bs->teamgoal.entitynum = -1; BotEntityInfo(client, &entinfo); //if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum) { // && trap_AAS_AreaReachability(areanum)) { //NOTE: just assume the bot knows where the person is //if (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, client)) { bs->teamgoal.entitynum = client; bs->teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); //} } } //if the other is not visible if (bs->teamgoal.entitynum < 0) { BotAI_BotInitialChat(bs, "whereareyou", EasyClientName(client, netname, sizeof(netname)), NULL); trap_BotEnterChat(bs->cs, client, CHAT_TELL); return; } // bs->decisionmaker = client; bs->ordered = qtrue; bs->order_time = FloatTime(); //set the time to send a message to the team mates bs->teammessage_time = FloatTime() + 2 * random(); //set the ltg type bs->ltgtype = LTG_CAMPORDER; //get the team goal time bs->teamgoal_time = FloatTime() + TEAM_CAMP_TIME; //the teammate that requested the camping bs->teammate = client; //not arrived yet bs->arrive_time = 0; // BotSetTeamStatus(bs); // remember last ordered task BotRememberLastOrderedTask(bs); #ifdef DEBUG BotPrintTeamGoal(bs); #endif //DEBUG }
/* ================== BotVoiceChat_FollowMe ================== */ void BotVoiceChat_FollowMe(bot_state_t * bs, int client, int mode) { int areanum; aas_entityinfo_t entinfo; char netname[MAX_NETNAME]; bs->teamgoal.entitynum = -1; BotEntityInfo(client, &entinfo); //if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum) { // && trap_AAS_AreaReachability(areanum)) { bs->teamgoal.entitynum = client; bs->teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); } } //if the other is not visible if (bs->teamgoal.entitynum < 0) { BotAI_BotInitialChat(bs, "whereareyou", EasyClientName(client, netname, sizeof(netname)), NULL); trap_BotEnterChat(bs->cs, client, CHAT_TELL); return; } // bs->decisionmaker = client; bs->ordered = qtrue; bs->order_time = FloatTime(); //the team mate bs->teammate = client; //last time the team mate was assumed visible bs->teammatevisible_time = FloatTime(); //set the time to send a message to the team mates bs->teammessage_time = FloatTime() + 2 * random(); //get the team goal time bs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME; //set the ltg type bs->ltgtype = LTG_TEAMACCOMPANY; bs->formation_dist = 3.5 * 32; //3.5 meter bs->arrive_time = 0; // BotSetTeamStatus(bs); // remember last ordered task BotRememberLastOrderedTask(bs); #ifdef DEBUG BotPrintTeamGoal(bs); #endif //DEBUG }
/* ======================================================================================================================================= BotVisibleEnemies ======================================================================================================================================= */ int BotVisibleEnemies(bot_state_t *bs) { int i; aas_entityinfo_t entinfo; for (i = 0; i < level.maxclients; i++) { if (i == bs->client) { continue; } // if on the same team if (BotSameTeam(bs, i)) { continue; } // get the entity information BotEntityInfo(i, &entinfo); // if this player is active if (!entinfo.valid) { continue; } // if the entity isn't the bot self if (entinfo.number == bs->entitynum) { continue; } // if the entity isn't dead if (EntityIsDead(&entinfo)) { continue; } // if the enemy is invisible if (EntityIsInvisible(&entinfo)) { continue; } // check if the enemy is visible if (BotEntityVisible(&bs->cur_ps, 360, i)) { return qtrue; } } return qfalse; }
/* ======================================================================================================================================= BotMatch_Camp ======================================================================================================================================= */ void BotMatch_Camp(bot_state_t *bs, bot_match_t *match) { int client, areanum; char netname[MAX_MESSAGE_SIZE]; char itemname[MAX_MESSAGE_SIZE]; aas_entityinfo_t entinfo; if (!TeamPlayIsOn()) { return; } // if not addressed to this bot if (!BotAddressedToBot(bs, match)) { return; } trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname)); // asked for someone else client = FindClientByName(netname); // if there's no valid client with this name if (client < 0) { BotAI_BotInitialChat(bs, "whois", netname, NULL); trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } // get the match variable trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname)); // in CTF it could be the base if (match->subtype & ST_THERE) { // camp at the spot the bot is currently standing bs->teamgoal.entitynum = bs->entitynum; bs->teamgoal.areanum = bs->areanum; VectorCopy(bs->origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); } else if (match->subtype & ST_HERE) { // if this is the bot self if (client == bs->client) { return; } bs->teamgoal.entitynum = -1; BotEntityInfo(client, &entinfo); // if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum && trap_AAS_AreaReachability(areanum)) { // NOTE: just cheat and assume the bot knows where the person is // if (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, client)) { bs->teamgoal.entitynum = client; bs->teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); //} } } // if the other is not visible if (bs->teamgoal.entitynum < 0) { BotAI_BotInitialChat(bs, "whereareyou", netname, NULL); trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } } else if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) { // BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL); // trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } // set the time to send a message to the team mates bs->teammessage_time = trap_AAS_Time() + 2 * random(); // set the ltg type bs->ltgtype = LTG_CAMPORDER; // get the team goal time bs->teamgoal_time = BotGetTime(match); // set the team goal time if (!bs->teamgoal_time) { bs->teamgoal_time = trap_AAS_Time() + TEAM_CAMP_TIME; } // the teammate that requested the camping bs->teammate = client; // not arrived yet bs->arrive_time = 0; #ifdef DEBUG BotPrintTeamGoal(bs); #endif // DEBUG }
/* ======================================================================================================================================= BotMatch_HelpAccompany ======================================================================================================================================= */ void BotMatch_HelpAccompany(bot_state_t *bs, bot_match_t *match) { int client, other, areanum; char teammate[MAX_MESSAGE_SIZE], netname[MAX_MESSAGE_SIZE]; char itemname[MAX_MESSAGE_SIZE]; bot_match_t teammatematch; aas_entityinfo_t entinfo; if (!TeamPlayIsOn()) { return; } // if not addressed to this bot if (!BotAddressedToBot(bs, match)) { return; } // get the team mate name trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate)); // get the client to help if (trap_BotFindMatch(teammate, &teammatematch, MTCONTEXT_TEAMMATE) && // if someone asks for him or herself teammatematch.type == MSG_ME) { // get the netname trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname)); client = ClientFromName(netname); other = qfalse; } else { // asked for someone else client = FindClientByName(teammate); // if this is the bot self if (client == bs->client) { other = qfalse; } else if (!BotSameTeam(bs, client)) { // FIXME: say "I don't help the enemy" return; } else { other = qtrue; } } // if the bot doesn't know who to help (FindClientByName returned -1) if (client < 0) { if (other) { BotAI_BotInitialChat(bs, "whois", teammate, NULL); } else {BotAI_BotInitialChat(bs, "whois", netname, NULL);} trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } // don't help or accompany yourself if (client == bs->client) { return; } bs->teamgoal.entitynum = -1; BotEntityInfo(client, &entinfo); // if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum && trap_AAS_AreaReachability(areanum)) { bs->teamgoal.entitynum = client; bs->teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); } } // if no teamgoal yet if (bs->teamgoal.entitynum < 0) { // if near an item if (match->subtype & ST_NEARITEM) { // get the match variable trap_BotMatchVariable(match, ITEM, itemname, sizeof(itemname)); if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) { // BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL); // trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } } } if (bs->teamgoal.entitynum < 0) { if (other) { BotAI_BotInitialChat(bs, "whereis", teammate, NULL); } else {BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);} trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } // the team mate bs->teammate = client; // last time the team mate was assumed visible bs->teammatevisible_time = trap_AAS_Time(); // set the time to send a message to the team mates bs->teammessage_time = trap_AAS_Time() + 2 * random(); // get the team goal time bs->teamgoal_time = BotGetTime(match); // set the ltg type if (match->type == MSG_HELP) { bs->ltgtype = LTG_TEAMHELP; if (!bs->teamgoal_time) { bs->teamgoal_time = trap_AAS_Time() + TEAM_HELP_TIME; } } else { bs->ltgtype = LTG_TEAMACCOMPANY; if (!bs->teamgoal_time) { bs->teamgoal_time = trap_AAS_Time() + TEAM_ACCOMPANY_TIME; } bs->formation_dist = 3.5 * 32; // 3.5 meter bs->arrive_time = 0; } #ifdef DEBUG BotPrintTeamGoal(bs); #endif // DEBUG }
/* ======================================================================================================================================= BotMatch_LeadTheWay ======================================================================================================================================= */ void BotMatch_LeadTheWay(bot_state_t *bs, bot_match_t *match) { aas_entityinfo_t entinfo; char netname[MAX_MESSAGE_SIZE], teammate[MAX_MESSAGE_SIZE]; int client, areanum, other; if (!TeamPlayIsOn()) { return; } // if not addressed to this bot if (!BotAddressedToBot(bs, match)) { return; } // if someone asks for someone else if (match->subtype & ST_SOMEONE) { // get the team mate name trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate)); client = FindClientByName(teammate); // if this is the bot self if (client == bs->client) { other = qfalse; } else if (!BotSameTeam(bs, client)) { // FIXME: say "I don't help the enemy" return; } else { other = qtrue; } } else { // get the netname trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname)); client = ClientFromName(netname); other = qfalse; } // if the bot doesn't know who to help (FindClientByName returned -1) if (client < 0) { BotAI_BotInitialChat(bs, "whois", netname, NULL); trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } bs->lead_teamgoal.entitynum = -1; BotEntityInfo(client, &entinfo); // if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum && trap_AAS_AreaReachability(areanum)) { bs->lead_teamgoal.entitynum = client; bs->lead_teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->lead_teamgoal.origin); VectorSet(bs->lead_teamgoal.mins, -8, -8, -8); VectorSet(bs->lead_teamgoal.maxs, 8, 8, 8); } } if (bs->teamgoal.entitynum < 0) { if (other) { BotAI_BotInitialChat(bs, "whereis", teammate, NULL); } else {BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);} trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM); return; } bs->lead_teammate = client; bs->lead_time = trap_AAS_Time() + TEAM_LEAD_TIME; bs->leadvisible_time = 0; bs->leadmessage_time = -(trap_AAS_Time() + 2 * random()); }
void BotTeamSeekGoals( bot_state_t *bs ) { aas_entityinfo_t entinfo; int c; int areanum; if ( bs->ltgtype == LTG_TEAMACCOMPANY && !bs->ordered ) { BotEntityInfo( bs->teammate, &entinfo ); if ( !entinfo.valid || !( entinfo.powerups & ( 1 << PW_BATTLESUIT ) ) ) { bs->ltgtype = 0; return; } areanum = BotPointAreaNum( entinfo.origin ); if ( !trap_AAS_AreaTravelTimeToGoalArea( bs->areanum, bs->origin, areanum, bs->tfl ) ) { bs->ltgtype = 0; } return; } if ( bs->owndecision_time < FloatTime() ) { c = BotTeamCarrierVisible( bs ); if ( c >= 0 && ( bs->ltgtype != LTG_TEAMACCOMPANY || bs->teammate != c ) ) { BotRefuseOrder( bs ); bs->decisionmaker = bs->client; bs->ordered = qfalse; bs->teammate = c; bs->teammatevisible_time = FloatTime(); bs->teammessage_time = 0; bs->arrive_time = 1; bs->teamgoal_time = FloatTime() + 120; bs->ltgtype = LTG_TEAMACCOMPANY; bs->formation_dist = 70; BotSetTeamStatus( bs ); bs->owndecision_time = FloatTime() + 5; return; } } #if 0 if ( BotTeamLeader( bs ) ) { return; } if ( bs->lastgoal_ltgtype ) { bs->teamgoal_time += 60; } if ( !bs->ordered && bs->lastgoal_ltgtype ) { bs->ltgtype = 0; } if ( bs->ltgtype == LTG_TEAMHELP || bs->ltgtype == LTG_TEAMACCOMPANY || bs->ltgtype == LTG_DEFENDKEYAREA || bs->ltgtype == LTG_CAMPORDER || bs->ltgtype == LTG_PATROL || bs->ltgtype == LTG_GETITEM ) { return; } if ( BotSetLastOrderedTask( bs ) ) { return; } if ( bs->owndecision_time > FloatTime() ) { return; } if ( bs->ctfroam_time > FloatTime() ) { return; } if ( BotAggression( bs ) < 50 ) { return; } bs->teammessage_time = FloatTime() + 2 * random(); bs->ltgtype = 0; bs->ctfroam_time = FloatTime() + CTF_ROAM_TIME; BotSetTeamStatus( bs ); bs->owndecision_time = FloatTime() + 5; #endif }
/* ======================================================================================================================================= BotChat_HitNoDeath ======================================================================================================================================= */ int BotChat_HitNoDeath(bot_state_t *bs) { char name[32], *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 (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) { 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; } // don't chat in tournament mode if (gametype == GT_TOURNAMENT) { return qfalse; } if (random() > rnd * 0.5) { return qfalse; } if (!BotValidChatPosition(bs)) { return qfalse; } if (BotVisibleEnemies(bs)) { return qfalse; } if (bs->enemy >= MAX_CLIENTS) { return qfalse; } if (bs->enemy >= 0) { // get the entity information 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 = FloatTime(); bs->chatto = CHAT_ALL; return qtrue; }
/* ================== BotMatch_Camp ================== */ void BotMatch_Camp(bot_state_t *bs, bot_match_t *match) { int playernum, areanum; char netname[MAX_MESSAGE_SIZE]; char itemname[MAX_MESSAGE_SIZE]; aas_entityinfo_t entinfo; if (!TeamPlayIsOn()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; // BotMatchVariable(match, NETNAME, netname, sizeof(netname)); //asked for someone else playernum = FindPlayerByName(netname); //if there's no valid player with this name if (playernum < 0) { BotAI_BotInitialChat(bs, "whois", netname, NULL); BotEnterChat(bs->cs, bs->playernum, CHAT_TEAM); return; } //get the match variable BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname)); //in CTF it could be the base if (match->subtype & ST_THERE) { //camp at the spot the bot is currently standing bs->teamgoal.entitynum = bs->entitynum; bs->teamgoal.areanum = bs->areanum; VectorCopy(bs->origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); } else if (match->subtype & ST_HERE) { //if this is the bot self if (playernum == bs->playernum) return; // bs->teamgoal.entitynum = -1; BotEntityInfo(playernum, &entinfo); //if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum) {// && trap_AAS_AreaReachability(areanum)) { //NOTE: just assume the bot knows where the person is //if (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, playernum)) { bs->teamgoal.entitynum = playernum; bs->teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); //} } } //if the other is not visible if (bs->teamgoal.entitynum < 0) { BotAI_BotInitialChat(bs, "whereareyou", netname, NULL); playernum = PlayerFromName(netname); BotEnterChat(bs->cs, playernum, CHAT_TELL); return; } } else if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) { //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL); //playernum = PlayerFromName(netname); //BotEnterChat(bs->cs, playernum, CHAT_TELL); return; } // bs->decisionmaker = playernum; bs->ordered = qtrue; bs->order_time = FloatTime(); //set the time to send a message to the team mates bs->teammessage_time = FloatTime() + 2 * random(); //set the ltg type bs->ltgtype = LTG_CAMPORDER; //get the team goal time bs->teamgoal_time = BotGetTime(match); //set the team goal time if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_CAMP_TIME; //not arrived yet bs->arrive_time = 0; // BotSetTeamStatus(bs); // remember last ordered task BotRememberLastOrderedTask(bs); BotPrintTeamGoal(bs); }
/* ================== BotMatch_HelpAccompany ================== */ void BotMatch_HelpAccompany(bot_state_t *bs, bot_match_t *match) { int playernum, other, areanum; char teammate[MAX_MESSAGE_SIZE]; char netname[MAX_MESSAGE_SIZE]; char itemname[MAX_MESSAGE_SIZE]; bot_match_t teammatematch; aas_entityinfo_t entinfo; if (!TeamPlayIsOn()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; //get the team mate name BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate)); //get the player to help if (BotFindMatch(teammate, &teammatematch, MTCONTEXT_TEAMMATE) && //if someone asks for him or herself teammatematch.type == MSG_ME) { //get the netname BotMatchVariable(match, NETNAME, netname, sizeof(netname)); playernum = PlayerFromName(netname); other = qfalse; } else { //asked for someone else playernum = FindPlayerByName(teammate); //if this is the bot self if (playernum == bs->playernum) { other = qfalse; } else if (!BotSameTeam(bs, playernum)) { //FIXME: say "I don't help the enemy" return; } else { other = qtrue; } } //if the bot doesn't know who to help (FindPlayerByName returned -1) if (playernum < 0) { if (other) BotAI_BotInitialChat(bs, "whois", teammate, NULL); else BotAI_BotInitialChat(bs, "whois", netname, NULL); playernum = PlayerFromName(netname); BotEnterChat(bs->cs, playernum, CHAT_TELL); return; } //don't help or accompany yourself if (playernum == bs->playernum) { return; } // bs->teamgoal.entitynum = -1; BotEntityInfo(playernum, &entinfo); //if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum) {// && trap_AAS_AreaReachability(areanum)) { bs->teamgoal.entitynum = playernum; bs->teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); } } //if no teamgoal yet if (bs->teamgoal.entitynum < 0) { //if near an item if (match->subtype & ST_NEARITEM) { //get the match variable BotMatchVariable(match, ITEM, itemname, sizeof(itemname)); // if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) { //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL); //BotEnterChat(bs->cs, bs->playernum, CHAT_TEAM); return; } } } // if (bs->teamgoal.entitynum < 0) { if (other) BotAI_BotInitialChat(bs, "whereis", teammate, NULL); else BotAI_BotInitialChat(bs, "whereareyou", netname, NULL); playernum = PlayerFromName(netname); BotEnterChat(bs->cs, playernum, CHAT_TEAM); return; } //the team mate bs->teammate = playernum; // BotMatchVariable(match, NETNAME, netname, sizeof(netname)); // playernum = PlayerFromName(netname); //the team mate who ordered bs->decisionmaker = playernum; bs->ordered = qtrue; bs->order_time = FloatTime(); //last time the team mate was assumed visible bs->teammatevisible_time = FloatTime(); //set the time to send a message to the team mates bs->teammessage_time = FloatTime() + 2 * random(); //get the team goal time bs->teamgoal_time = BotGetTime(match); //set the ltg type if (match->type == MSG_HELP) { bs->ltgtype = LTG_TEAMHELP; if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_HELP_TIME; } else { bs->ltgtype = LTG_TEAMACCOMPANY; if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME; bs->formation_dist = 128; bs->arrive_time = 0; // BotSetTeamStatus(bs); // remember last ordered task BotRememberLastOrderedTask(bs); } BotPrintTeamGoal(bs); }
// cyr_drop{ void BotMatch_DropCart(bot_state_t *bs, bot_match_t *match) { int client, areanum; char netname[MAX_MESSAGE_SIZE]; aas_entityinfo_t entinfo; if (!TeamPlayIsOn()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; //get the netname trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname)); client = ClientFromName(netname); //if the bot doesn't know who to help (FindClientByName returned -1) if (client < 0) { BotAI_BotInitialChat(bs, "whois", netname, NULL); client = ClientFromName(netname); trap_BotEnterChat(bs->cs, client, CHAT_TELL); return; } //don't help or accompany yourself if (client == bs->client) { return; } // bs->teamgoal.entitynum = -1; BotEntityInfo(client, &entinfo); //if info is valid (in PVS) if (entinfo.valid) { areanum = BotPointAreaNum(entinfo.origin); if (areanum) {// && trap_AAS_AreaReachability(areanum)) { bs->teamgoal.entitynum = client; bs->teamgoal.areanum = areanum; VectorCopy(entinfo.origin, bs->teamgoal.origin); VectorSet(bs->teamgoal.mins, -8, -8, -8); VectorSet(bs->teamgoal.maxs, 8, 8, 8); } } if (bs->teamgoal.entitynum < 0) { BotAI_BotInitialChat(bs, "whereareyou", netname, NULL); client = ClientFromName(netname); trap_BotEnterChat(bs->cs, client, CHAT_TEAM); return; } //the team mate bs->teammate = client; // trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname)); // client = ClientFromName(netname); //the team mate who ordered bs->decisionmaker = client; // bs->ordered = qtrue; //bs->order_time = FloatTime(); //last time the team mate was assumed visible bs->teammatevisible_time = FloatTime(); //set the time to send a message to the team mates bs->teammessage_time = FloatTime() + 1 * random(); //set the ltg type bs->ltgtype = LTG_GIVECART; //G_Printf("^4giving cart! \n"); // cyr 20055 bs->teamgoal_time = FloatTime() + SYC_CART_EXCHANGE_TIME; }