182
182
==================
183
BotSortTeamMatesByReletiveTravelTime2ddA
184
For Double Domination
187
int BotSortTeamMatesByRelativeTravelTime2ddA(bot_state_t *bs, int *teammates, int maxteammates) {
188
int i, j, k, numteammates;
189
double traveltime, traveltime2b;
190
char buf[MAX_INFO_STRING];
191
static int maxclients;
192
double traveltimes[MAX_CLIENTS];
193
//int traveltimes2b[MAX_CLIENTS];
194
bot_goal_t *goalA = &ctf_redflag;
195
bot_goal_t *goalB = &ctf_blueflag;
198
maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
202
for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
203
trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
204
//if no config string or no name
205
if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
207
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
208
if (BotSameTeam(bs, i)) {
209
traveltime = (double)BotClientTravelTimeToGoal(i, goalA);
210
traveltime2b = (double)BotClientTravelTimeToGoal(i, goalB);
211
traveltime = traveltime/traveltime2b;
213
for (j = 0; j < numteammates; j++) {
214
if (traveltime < traveltimes[j]) {
215
for (k = numteammates; k > j; k--) {
216
traveltimes[k] = traveltimes[k-1];
217
teammates[k] = teammates[k-1];
222
traveltimes[j] = traveltime;
225
if (numteammates >= maxteammates) break;
183
234
BotSetTeamMateTaskPreference
184
235
==================
448
499
int numteammates, defenders, attackers, i;
449
500
int teammates[MAX_CLIENTS];
450
501
char name[MAX_NETNAME];
502
qboolean weAreAttacking;
452
504
numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
453
505
BotSortTeamMatesByTaskPreference(bs, teammates, numteammates);
507
weAreAttacking = qfalse;
509
//In oneway ctf we must all move out of the base (only one strategi, maybe we can also send some to the enemy base to meet the flag carier?)
510
//We must be defending
511
if(g_elimination_ctf_oneway.integer > 0) {
512
for (i = 0; i < numteammates; i++) {
514
ClientName(teammates[i], name, sizeof(name));
515
BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
516
BotSayTeamOrder(bs, teammates[i]);
517
BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_GETFLAG);
454
522
//passive strategy
455
523
if (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {
456
524
//different orders based on the number of team mates
759
void BotDDorders_Standard(bot_state_t *bs) {
761
int teammates[MAX_CLIENTS];
762
char name[MAX_NETNAME];
764
//sort team mates by travel time to base
765
numteammates = BotSortTeamMatesByRelativeTravelTime2ddA(bs, teammates, sizeof(teammates));
767
switch(numteammates) {
771
//the one closest to point A will take that
772
ClientName(teammates[0], name, sizeof(name));
773
BotAI_BotInitialChat(bs, "cmd_takea", name, NULL);
774
BotSayTeamOrder(bs, teammates[0]);
775
//BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_TAKEA);
776
//the other goes for point B
777
ClientName(teammates[1], name, sizeof(name));
778
BotAI_BotInitialChat(bs, "cmd_takeb", name, NULL);
779
BotSayTeamOrder(bs, teammates[1]);
780
//BotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_TAKEB);
785
for(i=0;i<numteammates/2;i++) { //Half take point A
786
ClientName(teammates[i], name, sizeof(name));
787
BotAI_BotInitialChat(bs, "cmd_takea", name, NULL);
788
BotSayTeamOrder(bs, teammates[i]);
789
//BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_TAKEA);
791
for(i=numteammates/2+1;i<numteammates;i++) { //Rest takes point B
792
ClientName(teammates[i], name, sizeof(name));
793
BotAI_BotInitialChat(bs, "cmd_takeb", name, NULL);
794
BotSayTeamOrder(bs, teammates[i]);
795
//BotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_TAKEB);
687
803
==================
692
808
int numteammates, defenders, attackers, i;
693
809
int teammates[MAX_CLIENTS];
694
810
char name[MAX_NETNAME];
811
qboolean weAreAttacking;
696
813
//sort team mates by travel time to base
697
814
numteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));
698
815
//sort team mates by CTF preference
699
816
BotSortTeamMatesByTaskPreference(bs, teammates, numteammates);
818
weAreAttacking = qfalse;
820
if(g_elimination_ctf_oneway.integer > 0) {
821
//See if we are attacking:
822
if( ( (level.eliminationSides+level.roundNumber)%2 == 0 ) && (BotTeam(bs) == TEAM_RED))
823
weAreAttacking = qtrue;
826
for (i = 0; i < numteammates; i++) {
828
ClientName(teammates[i], name, sizeof(name));
829
BotAI_BotInitialChat(bs, "cmd_getflag", name, NULL);
830
BotSayTeamOrder(bs, teammates[i]);
831
BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_GETFLAG);
834
for (i = 0; i < numteammates; i++) {
836
ClientName(teammates[i], name, sizeof(name));
837
BotAI_BotInitialChat(bs, "cmd_defendbase", name, NULL);
838
BotSayTeamOrder(bs, teammates[i]);
839
BotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);
842
return; //Sago: Or the leader will make a counter order.
700
845
//passive strategy
701
846
if (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {
702
847
//different orders based on the number of team mates
1932
2088
char netname[MAX_NETNAME];
1935
if ( gametype < GT_TEAM )
2091
if ( gametype < GT_TEAM || g_ffa_gt == 1 )
1937
2093
// make sure we've got a valid team leader
1938
2094
if (!BotValidTeamLeader(bs)) {
1960
2116
BotSayVoiceTeamOrder(bs, -1, VOICECHAT_STARTLEADER);
1961
2117
ClientName(bs->client, netname, sizeof(netname));
1962
2118
strncpy(bs->teamleader, netname, sizeof(bs->teamleader));
1963
bs->teamleader[sizeof(bs->teamleader)] = '\0';
2119
bs->teamleader[sizeof(bs->teamleader)-1] = '\0';
1964
2120
bs->becometeamleader_time = 0;
2151
case GT_CTF_ELIMINATION:
1996
2153
//if the number of team mates changed or the flag status changed
1997
2154
//or someone wants to know what to do
1998
if (bs->numteammates != numteammates || bs->flagstatuschanged || bs->forceorders) {
2155
if (bs->numteammates != numteammates || bs->flagstatuschanged || bs->forceorders || lastRoundNumber != level.roundNumber) {
1999
2156
bs->teamgiveorders_time = FloatTime();
2000
2157
bs->numteammates = numteammates;
2001
2158
bs->flagstatuschanged = qfalse;
2002
2159
bs->forceorders = qfalse;
2160
lastRoundNumber = level.roundNumber;
2004
2162
//if there were no flag captures the last 3 minutes
2005
2163
if (bs->lastflagcapture_time < FloatTime() - 240) {
2181
//if the number of team mates changed or the domination point status changed
2182
//or someone wants to know what to do
2183
if (bs->numteammates != numteammates || bs->flagstatuschanged || bs->forceorders) {
2184
bs->teamgiveorders_time = FloatTime();
2185
bs->numteammates = numteammates;
2186
bs->flagstatuschanged = qfalse;
2187
bs->forceorders = qfalse;
2189
//if it's time to give orders
2190
if (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 3) {
2193
bs->teamgiveorders_time = 0;
2021
2197
#ifdef MISSIONPACK