/* ================== BotMatch_WhereAreYou ================== */ void BotMatch_WhereAreYou( bot_state_t *bs, bot_match_t *match ) { float dist, bestdist; int i, bestitem, redflagtt, blueflagtt, redtobluett; bot_goal_t goal; char *nearbyitems[] = { "Shotgun", "Grenade Launcher", "Rocket Launcher", "Plasmagun", "Railgun", "Lightning Gun", "BFG10K", "Quad Damage", "Regeneration", "Battle Suit", "Speed", "Invisibility", "Flight", "Armor", "Heavy Armor", "Red Flag", "Blue Flag", NULL }; // if ( !TeamPlayIsOn() ) { return; } //if not addressed to this bot if ( !BotAddressedToBot( bs, match ) ) { return; } bestitem = -1; bestdist = 999999; for ( i = 0; nearbyitems[i]; i++ ) { dist = BotNearestVisibleItem( bs, nearbyitems[i], &goal ); if ( dist < bestdist ) { bestdist = dist; bestitem = i; } } if ( bestitem != -1 ) { if ( gametype == GT_CTF ) { redflagtt = trap_AAS_AreaTravelTimeToGoalArea( bs->areanum, bs->origin, ctf_redflag.areanum, TFL_DEFAULT ); blueflagtt = trap_AAS_AreaTravelTimeToGoalArea( bs->areanum, bs->origin, ctf_blueflag.areanum, TFL_DEFAULT ); redtobluett = trap_AAS_AreaTravelTimeToGoalArea( ctf_redflag.areanum, ctf_redflag.origin, ctf_blueflag.areanum, TFL_DEFAULT ); if ( redflagtt < ( redflagtt + blueflagtt ) * 0.4 ) { BotAI_BotInitialChat( bs, "ctflocation", nearbyitems[bestitem], "red", NULL ); } else if ( blueflagtt < ( redflagtt + blueflagtt ) * 0.4 ) { BotAI_BotInitialChat( bs, "ctflocation", nearbyitems[bestitem], "blue", NULL ); } else { BotAI_BotInitialChat( bs, "location", nearbyitems[bestitem], NULL ); } } else { BotAI_BotInitialChat( bs, "location", nearbyitems[bestitem], NULL ); } trap_BotEnterChat( bs->cs, bs->client, CHAT_TEAM ); } }
/* ================== BotMatch_WhereAreYou ================== */ void BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) { float dist, bestdist; int i, bestitem, redtt, bluett, client; bot_goal_t goal; char netname[MAX_MESSAGE_SIZE]; char *nearbyitems[] = { "Shotgun", "Grenade Launcher", "Rocket Launcher", "Plasmagun", "Railgun", "Lightning Gun", "BFG10K", "Quad Damage", "Regeneration", "Battle Suit", "Speed", "Invisibility", "Flight", "Armor", "Heavy Armor", "Red Flag", "Blue Flag", #ifdef MISSIONPACK "Nailgun", "Prox Launcher", "Chaingun", "Scout", "Guard", "Doubler", "Ammo Regen", "Neutral Flag", "Red Obelisk", "Blue Obelisk", "Neutral Obelisk", #endif NULL }; // if (!TeamPlayIsOn()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; bestitem = -1; bestdist = 999999; for (i = 0; nearbyitems[i]; i++) { dist = BotNearestVisibleItem(bs, nearbyitems[i], &goal); if (dist < bestdist) { bestdist = dist; bestitem = i; } } if (bestitem != -1) { if (gametype == GT_CTF #ifdef MISSIONPACK || gametype == GT_1FCTF #endif ) { redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_redflag.areanum, TFL_DEFAULT); bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_blueflag.areanum, TFL_DEFAULT); if (redtt < (redtt + bluett) * 0.4) { BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "red", NULL); } else if (bluett < (redtt + bluett) * 0.4) { BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "blue", NULL); } else { BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL); } } #ifdef MISSIONPACK else if (gametype == GT_OBELISK || gametype == GT_HARVESTER) { redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, redobelisk.areanum, TFL_DEFAULT); bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, blueobelisk.areanum, TFL_DEFAULT); if (redtt < (redtt + bluett) * 0.4) { BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "red", NULL); } else if (bluett < (redtt + bluett) * 0.4) { BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "blue", NULL); } else { BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL); } } #endif else { BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL); } trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname)); client = ClientFromName(netname); trap_BotEnterChat(bs->cs, client, CHAT_TELL); } }
/* ================== BotMatch_WhereAreYou ================== */ void BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) { float dist, bestdist; int i, redtt, bluett, playernum; char *teamlocation; char *bestitemname; bot_goal_t goal; gitem_t *it; char netname[MAX_MESSAGE_SIZE]; char *nearbyitems[] = { #ifdef MISSIONPACK "Red Obelisk", "Blue Obelisk", "Neutral Obelisk", #endif NULL }; // if (!TeamPlayIsOn()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; bestitemname = NULL; bestdist = 999999; for (i = 1; i < BG_NumItems(); i++) { it = BG_ItemForItemNum( i ); if ( !it->classname || !*it->classname ) { continue; } //ignore health, ammo, holdables, small armor, and Red Cube and Blue Cube if ( it->giType == IT_HEALTH || it->giType == IT_AMMO || it->giType == IT_HOLDABLE || ( it->giType == IT_ARMOR && it->quantity < 50 ) #ifdef MISSIONPACK || ( it->giType == IT_TEAM && it->giTag == 0 ) #endif ) { continue; } dist = BotNearestVisibleItem(bs, it->pickup_name, &goal); if (dist < bestdist) { bestdist = dist; bestitemname = it->pickup_name; } } for (i = 0; nearbyitems[i]; i++) { dist = BotNearestVisibleItem(bs, nearbyitems[i], &goal); if (dist < bestdist) { bestdist = dist; bestitemname = nearbyitems[i]; } } if (bestitemname) { if (gametype == GT_CTF #ifdef MISSIONPACK || gametype == GT_1FCTF || gametype == GT_OBELISK || gametype == GT_HARVESTER #endif ) { #ifdef MISSIONPACK if (gametype == GT_OBELISK || gametype == GT_HARVESTER) { redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, redobelisk.areanum, TFL_DEFAULT); bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, blueobelisk.areanum, TFL_DEFAULT); } else #endif { redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_redflag.areanum, TFL_DEFAULT); bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_blueflag.areanum, TFL_DEFAULT); } // unpatched q3 used 'ctflocation', some games still use it if ( BotNumInitialChats( bs->cs, "teamlocation" ) ) { teamlocation = "teamlocation"; } else { teamlocation = "ctflocation"; } if (redtt < (redtt + bluett) * 0.4) { BotAI_BotInitialChat(bs, teamlocation, bestitemname, "red", NULL); } else if (bluett < (redtt + bluett) * 0.4) { BotAI_BotInitialChat(bs, teamlocation, bestitemname, "blue", NULL); } else { BotAI_BotInitialChat(bs, "location", bestitemname, NULL); } } else { BotAI_BotInitialChat(bs, "location", bestitemname, NULL); } BotMatchVariable(match, NETNAME, netname, sizeof(netname)); playernum = PlayerFromName(netname); BotEnterChat(bs->cs, playernum, CHAT_TELL); } }