📄 ai_team.c
字号:
}
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);
BotSayTeamOrder(bs, teammates[numteammates - i - 1]);
BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);
}
}
//
break;
}
}
}
else { //agressive
//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 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);
BotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWME);
}
else {
BotAI_BotInitialChat(bs, "cmd_accompany", name, carriername, NULL);
BotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWFLAGCARRIER);
}
BotSayTeamOrder(bs, other);
break;
}
default:
{
//20% will defend the base
defenders = (int) (float) numteammates * 0.2 + 0.5;
if (defenders > 2) defenders = 2;
//80% accompanies the flag carrier
attackers = (int) (float) numteammates * 0.8 + 0.5;
if (attackers > 8) attackers = 8;
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);
}
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]);
}
//
break;
}
}
}
}
/*
==================
Bot1FCTFOrders_EnemyHasFlag
X% defend the base, Y% towards neutral flag
==================
*/
void Bot1FCTFOrders_EnemyHasFlag(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:
{
//both 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);
//
ClientName(teammates[1], name, sizeof(name));
BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
BotSayTeamOrder(bs, teammates[1]);
BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);
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 also defend the base
ClientName(teammates[2], name, sizeof(name));
BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
BotSayTeamOrder(bs, teammates[2]);
BotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_DEFEND);
break;
}
default:
{
//80% will defend the base
defenders = (int) (float) numteammates * 0.8 + 0.5;
if (defenders > 8) defenders = 8;
//10% will try to return the flag
attackers = (int) (float) numteammates * 0.1 + 0.5;
if (attackers > 2) attackers = 2;
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_returnflag", name, NULL);
BotSayTeamOrder(bs, teammates[numteammates - i - 1]);
BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);
}
//
break;
}
}
}
else { //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_defendbase", name, NULL);
BotSayTeamOrder(bs, teammates[1]);
BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);
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_defendbase", name, NULL);
BotSayTeamOrder(bs, teammates[1]);
BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);
//
ClientName(teammates[2], name, sizeof(name));
BotAI_BotInitialChat(bs, "cmd_returnflag", name, NULL);
BotSayTeamOrder(bs, teammates[2]);
BotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);
break;
}
default:
{
//70% defend the base
defenders = (int) (float) numteammates * 0.7 + 0.5;
if (defenders > 8) defenders = 8;
//20% try to return the flag
attackers = (int) (float) numteammates * 0.2 + 0.5;
if (attackers > 2) attackers = 2;
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_returnflag", name, NULL);
BotSayTeamOrder(bs, teammates[numteammates - i - 1]);
BotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);
}
//
break;
}
}
}
}
/*
==================
Bot1FCTFOrders_EnemyDroppedFlag
X% defend the base, Y% get the flag
==================
*/
void Bot1FCTFOrders_EnemyDroppedFlag(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:
{
//50% defend the base
defenders = (int) (float) numteammates * 0.5 + 0.5;
if (defenders > 5) defenders = 5;
//40% get the flag
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 { //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 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:
{
//30% defend the base
defenders = (int) (float) numteammates * 0.3 + 0.5;
if (defenders > 3) defenders = 3;
//60% get the flag
attackers = (int) (float) numteammates * 0.6 + 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[numteammates - i - 1], VOICECHAT_DEFEND);
}
//
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -