Debian Codegraph @

code/game/ai_cmd.c

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23
24 /*****************************************************************************
25 * name: ai_cmd.c
26 *
27 * desc: Quake3 bot AI
28 *
29 * $Archive: /MissionPack/code/game/ai_cmd.c $
30 *
31 *****************************************************************************/
32
33 #include "g_local.h"
34 #include "../botlib/botlib.h"
35 #include "../botlib/be_aas.h"
36 #include "../botlib/be_ea.h"
37 #include "../botlib/be_ai_char.h"
38 #include "../botlib/be_ai_chat.h"
39 #include "../botlib/be_ai_gen.h"
40 #include "../botlib/be_ai_goal.h"
41 #include "../botlib/be_ai_move.h"
42 #include "../botlib/be_ai_weap.h"
43 //
44 #include "ai_main.h"
45 #include "ai_dmq3.h"
46 #include "ai_chat.h"
47 #include "ai_cmd.h"
48 #include "ai_dmnet.h"
49 #include "ai_team.h"
50 //
51 #include "chars.h" //characteristics
52 #include "inv.h" //indexes into the inventory
53 #include "syn.h" //synonyms
54 #include "match.h" //string matching types and vars
55
56 // for the voice chats
57 #include "../../ui/menudef.h"
58
59 int notleader[MAX_CLIENTS];
60
61 #ifdef DEBUG
62 /*
63 ==================
64 BotPrintTeamGoal
65 ==================
66 */
67 void BotPrintTeamGoal(bot_state_t *bs) {
68 char netname[MAX_NETNAME];
69 float t;
70
71 ClientName(bs->client, netname, sizeof(netname));
72 t = bs->teamgoal_time - FloatTime();
73 switch(bs->ltgtype) {
74 case LTG_TEAMHELP:
75 {
76 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna help a team mate for %1.0f secs\n", netname, t);
77 break;
78 }
79 case LTG_TEAMACCOMPANY:
80 {
81 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna accompany a team mate for %1.0f secs\n", netname, t);
82 break;
83 }
84 case LTG_GETFLAG:
85 {
86 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna get the flag for %1.0f secs\n", netname, t);
87 break;
88 }
89 case LTG_RUSHBASE:
90 {
91 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna rush to the base for %1.0f secs\n", netname, t);
92 break;
93 }
94 case LTG_RETURNFLAG:
95 {
96 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna try to return the flag for %1.0f secs\n", netname, t);
97 break;
98 }
99 case LTG_ATTACKENEMYBASE:
100 {
101 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna attack the enemy base for %1.0f secs\n", netname, t);
102 break;
103 }
104 case LTG_HARVEST:
105 {
106 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna harvest for %1.0f secs\n", netname, t);
107 break;
108 }
109 case LTG_DEFENDKEYAREA:
110 {
111 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna defend a key area for %1.0f secs\n", netname, t);
112 break;
113 }
114 case LTG_GETITEM:
115 {
116 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna get an item for %1.0f secs\n", netname, t);
117 break;
118 }
119 case LTG_KILL:
120 {
121 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna kill someone for %1.0f secs\n", netname, t);
122 break;
123 }
124 case LTG_CAMP:
125 case LTG_CAMPORDER:
126 {
127 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna camp for %1.0f secs\n", netname, t);
128 break;
129 }
130 case LTG_PATROL:
131 {
132 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna patrol for %1.0f secs\n", netname, t);
133 break;
134 }
135 case LTG_POINTA:
136 {
137 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna take care of point A for %1.0f secs\n", netname, t);
138 break;
139 }
140 case LTG_POINTB:
141 {
142 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna take care of point B for %1.0f secs\n", netname, t);
143 break;
144 }
145 default:
146 {
147 if (bs->ctfroam_time > FloatTime()) {
148 t = bs->ctfroam_time - FloatTime();
149 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna roam for %1.0f secs\n", netname, t);
150 }
151 else {
152 BotAI_Print(PRT_MESSAGE, "%s: I've got a regular goal\n", netname);
153 }
154 }
155 }
156 }
157 #endif //DEBUG
158
159 /*
160 ==================
161 BotGetItemTeamGoal
162
163 FIXME: add stuff like "upper rocket launcher"
164 "the rl near the railgun", "lower grenade launcher" etc.
165 ==================
166 */
167 int BotGetItemTeamGoal(char *goalname, bot_goal_t *goal) {
168 int i;
169
170 if (!strlen(goalname)) return qfalse;
171 i = -1;
172 do {
173 i = trap_BotGetLevelItemGoal(i, goalname, goal);
174 if (i > 0) {
175 //do NOT defend dropped items
176 if (goal->flags & GFL_DROPPED)
177 continue;
178 return qtrue;
179 }
180 } while(i > 0);
181 return qfalse;
182 }
183
184 /*
185 ==================
186 BotGetMessageTeamGoal
187 ==================
188 */
189 int BotGetMessageTeamGoal(bot_state_t *bs, char *goalname, bot_goal_t *goal) {
190 bot_waypoint_t *cp;
191
192 if (BotGetItemTeamGoal(goalname, goal)) return qtrue;
193
194 cp = BotFindWayPoint(bs->checkpoints, goalname);
195 if (cp) {
196 memcpy(goal, &cp->goal, sizeof(bot_goal_t));
197 return qtrue;
198 }
199 return qfalse;
200 }
201
202 /*
203 ==================
204 BotGetTime
205 ==================
206 */
207 float BotGetTime(bot_match_t *match) {
208 bot_match_t timematch;
209 char timestring[MAX_MESSAGE_SIZE];
210 float t;
211
212 //if the matched string has a time
213 if (match->subtype & ST_TIME) {
214 //get the time string
215 trap_BotMatchVariable(match, TIME, timestring, MAX_MESSAGE_SIZE);
216 //match it to find out if the time is in seconds or minutes
217 if (trap_BotFindMatch(timestring, &timematch, MTCONTEXT_TIME)) {
218 if (timematch.type == MSG_FOREVER) {
219 t = 99999999.0f;
220 }
221 else if (timematch.type == MSG_FORAWHILE) {
222 t = 10 * 60; // 10 minutes
223 }
224 else if (timematch.type == MSG_FORALONGTIME) {
225 t = 30 * 60; // 30 minutes
226 }
227 else {
228 trap_BotMatchVariable(&timematch, TIME, timestring, MAX_MESSAGE_SIZE);
229 if (timematch.type == MSG_MINUTES) t = atof(timestring) * 60;
230 else if (timematch.type == MSG_SECONDS) t = atof(timestring);
231 else t = 0;
232 }
233 //if there's a valid time
234 if (t > 0) return FloatTime() + t;
235 }
236 }
237 return 0;
238 }
239
240 /*
241 ==================
242 FindClientByName
243 ==================
244 */
245 int FindClientByName(char *name) {
246 int i;
247 char buf[MAX_INFO_STRING];
248 static int maxclients;
249
250 if (!maxclients)
251 maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
252 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
253 ClientName(i, buf, sizeof(buf));
254 if (!Q_stricmp(buf, name)) return i;
255 }
256 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
257 ClientName(i, buf, sizeof(buf));
258 if (stristr(buf, name)) return i;
259 }
260 return -1;
261 }
262
263 /*
264 ==================
265 FindEnemyByName
266 ==================
267 */
268 int FindEnemyByName(bot_state_t *bs, char *name) {
269 int i;
270 char buf[MAX_INFO_STRING];
271 static int maxclients;
272
273 if (!maxclients)
274 maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
275 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
276 if (BotSameTeam(bs, i)) continue;
277 ClientName(i, buf, sizeof(buf));
278 if (!Q_stricmp(buf, name)) return i;
279 }
280 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
281 if (BotSameTeam(bs, i)) continue;
282 ClientName(i, buf, sizeof(buf));
283 if (stristr(buf, name)) return i;
284 }
285 return -1;
286 }
287
288 /*
289 ==================
290 NumPlayersOnSameTeam
291 ==================
292 */
293 int NumPlayersOnSameTeam(bot_state_t *bs) {
294 int i, num;
295 char buf[MAX_INFO_STRING];
296 static int maxclients;
297
298 if (!maxclients)
299 maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
300
301 num = 0;
302 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
303 trap_GetConfigstring(CS_PLAYERS+i, buf, MAX_INFO_STRING);
304 if (strlen(buf)) {
305 if (BotSameTeam(bs, i+1)) num++;
306 }
307 }
308 return num;
309 }
310
311 /*
312 ==================
313 TeamPlayIsOn
314 ==================
315 */
316 int BotGetPatrolWaypoints(bot_state_t *bs, bot_match_t *match) {
317 char keyarea[MAX_MESSAGE_SIZE];
318 int patrolflags;
319 bot_waypoint_t *wp, *newwp, *newpatrolpoints;
320 bot_match_t keyareamatch;
321 bot_goal_t goal;
322
323 newpatrolpoints = NULL;
324 patrolflags = 0;
325 //
326 trap_BotMatchVariable(match, KEYAREA, keyarea, MAX_MESSAGE_SIZE);
327 //
328 while(1) {
329 if (!trap_BotFindMatch(keyarea, &keyareamatch, MTCONTEXT_PATROLKEYAREA)) {
330 trap_EA_SayTeam(bs->client, "what do you say?");
331 BotFreeWaypoints(newpatrolpoints);
332 bs->patrolpoints = NULL;
333 return qfalse;
334 }
335 trap_BotMatchVariable(&keyareamatch, KEYAREA, keyarea, MAX_MESSAGE_SIZE);
336 if (!BotGetMessageTeamGoal(bs, keyarea, &goal)) {
337 //BotAI_BotInitialChat(bs, "cannotfind", keyarea, NULL);
338 //trap_BotEnterChat(bs->cs, 0, CHAT_TEAM);
339 BotFreeWaypoints(newpatrolpoints);
340 bs->patrolpoints = NULL;
341 return qfalse;
342 }
343 //create a new waypoint
344 newwp = BotCreateWayPoint(keyarea, goal.origin, goal.areanum);
345 if (!newwp)
346 break;
347 //add the waypoint to the patrol points
348 newwp->next = NULL;
349 for (wp = newpatrolpoints; wp && wp->next; wp = wp->next);
350 if (!wp) {
351 newpatrolpoints = newwp;
352 newwp->prev = NULL;
353 }
354 else {
355 wp->next = newwp;
356 newwp->prev = wp;
357 }
358 //
359 if (keyareamatch.subtype & ST_BACK) {
360 patrolflags = PATROL_LOOP;
361 break;
362 }
363 else if (keyareamatch.subtype & ST_REVERSE) {
364 patrolflags = PATROL_REVERSE;
365 break;
366 }
367 else if (keyareamatch.subtype & ST_MORE) {
368 trap_BotMatchVariable(&keyareamatch, MORE, keyarea, MAX_MESSAGE_SIZE);
369 }
370 else {
371 break;
372 }
373 }
374 //
375 if (!newpatrolpoints || !newpatrolpoints->next) {
376 trap_EA_SayTeam(bs->client, "I need more key points to patrol\n");
377 BotFreeWaypoints(newpatrolpoints);
378 newpatrolpoints = NULL;
379 return qfalse;
380 }
381 //
382 BotFreeWaypoints(bs->patrolpoints);
383 bs->patrolpoints = newpatrolpoints;
384 //
385 bs->curpatrolpoint = bs->patrolpoints;
386 bs->patrolflags = patrolflags;
387 //
388 return qtrue;
389 }
390
391 /*
392 ==================
393 BotAddressedToBot
394 ==================
395 */
396 int BotAddressedToBot(bot_state_t *bs, bot_match_t *match) {
397 char addressedto[MAX_MESSAGE_SIZE];
398 char netname[MAX_MESSAGE_SIZE];
399 char name[MAX_MESSAGE_SIZE];
400 char botname[128];
401 int client;
402 bot_match_t addresseematch;
403
404 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
405 client = ClientOnSameTeamFromName(bs, netname);
406 if (client < 0) return qfalse;
407 //if the message is addressed to someone
408 if (match->subtype & ST_ADDRESSED) {
409 trap_BotMatchVariable(match, ADDRESSEE, addressedto, sizeof(addressedto));
410 //the name of this bot
411 ClientName(bs->client, botname, 128);
412 //
413 while(trap_BotFindMatch(addressedto, &addresseematch, MTCONTEXT_ADDRESSEE)) {
414 if (addresseematch.type == MSG_EVERYONE) {
415 return qtrue;
416 }
417 else if (addresseematch.type == MSG_MULTIPLENAMES) {
418 trap_BotMatchVariable(&addresseematch, TEAMMATE, name, sizeof(name));
419 if (strlen(name)) {
420 if (stristr(botname, name)) return qtrue;
421 if (stristr(bs->subteam, name)) return qtrue;
422 }
423 trap_BotMatchVariable(&addresseematch, MORE, addressedto, MAX_MESSAGE_SIZE);
424 }
425 else {
426 trap_BotMatchVariable(&addresseematch, TEAMMATE, name, MAX_MESSAGE_SIZE);
427 if (strlen(name)) {
428 if (stristr(botname, name)) return qtrue;
429 if (stristr(bs->subteam, name)) return qtrue;
430 }
431 break;
432 }
433 }
434 //Com_sprintf(buf, sizeof(buf), "not addressed to me but %s", addressedto);
435 //trap_EA_Say(bs->client, buf);
436 return qfalse;
437 }
438 else {
439 bot_match_t tellmatch;
440
441 tellmatch.type = 0;
442 //if this message wasn't directed solely to this bot
443 if (!trap_BotFindMatch(match->string, &tellmatch, MTCONTEXT_REPLYCHAT) ||
444 tellmatch.type != MSG_CHATTELL) {
445 //make sure not everyone reacts to this message
446 if (random() > (float ) 1.0 / (NumPlayersOnSameTeam(bs)-1)) return qfalse;
447 }
448 }
449 return qtrue;
450 }
451
452 /*
453 ==================
454 BotGPSToPosition
455 ==================
456 */
457 int BotGPSToPosition(char *buf, vec3_t position) {
458 int i, j = 0;
459 int num, sign;
460
461 for (i = 0; i < 3; i++) {
462 num = 0;
463 while(buf[j] == ' ') j++;
464 if (buf[j] == '-') {
465 j++;
466 sign = -1;
467 }
468 else {
469 sign = 1;
470 }
471 while (buf[j]) {
472 if (buf[j] >= '0' && buf[j] <= '9') {
473 num = num * 10 + buf[j] - '0';
474 j++;
475 }
476 else {
477 j++;
478 break;
479 }
480 }
481 BotAI_Print(PRT_MESSAGE, "%d\n", sign * num);
482 position[i] = (float) sign * num;
483 }
484 return qtrue;
485 }
486
487 /*
488 ==================
489 BotMatch_HelpAccompany
490 ==================
491 */
492 void BotMatch_HelpAccompany(bot_state_t *bs, bot_match_t *match) {
493 int client, other, areanum;
494 char teammate[MAX_MESSAGE_SIZE];
495 char netname[MAX_MESSAGE_SIZE];
496 char itemname[MAX_MESSAGE_SIZE];
497 bot_match_t teammatematch;
498 aas_entityinfo_t entinfo;
499
500 if (!TeamPlayIsOn()) return;
501 //if not addressed to this bot
502 if (!BotAddressedToBot(bs, match)) return;
503 //get the team mate name
504 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
505 //get the client to help
506 if (trap_BotFindMatch(teammate, &teammatematch, MTCONTEXT_TEAMMATE) &&
507 //if someone asks for him or herself
508 teammatematch.type == MSG_ME) {
509 //get the netname
510 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
511 client = ClientFromName(netname);
512 other = qfalse;
513 }
514 else {
515 //asked for someone else
516 client = FindClientByName(teammate);
517 //if this is the bot self
518 if (client == bs->client) {
519 other = qfalse;
520 }
521 else if (!BotSameTeam(bs, client)) {
522 //FIXME: say "I don't help the enemy"
523 return;
524 }
525 else {
526 other = qtrue;
527 }
528 }
529 //if the bot doesn't know who to help (FindClientByName returned -1)
530 if (client < 0) {
531 if (other) BotAI_BotInitialChat(bs, "whois", teammate, NULL);
532 else BotAI_BotInitialChat(bs, "whois", netname, NULL);
533 client = ClientFromName(netname);
534 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
535 return;
536 }
537 //don't help or accompany yourself
538 if (client == bs->client) {
539 return;
540 }
541 //
542 bs->teamgoal.entitynum = -1;
543 BotEntityInfo(client, &entinfo);
544 //if info is valid (in PVS)
545 if (entinfo.valid) {
546 areanum = BotPointAreaNum(entinfo.origin);
547 if (areanum) {// && trap_AAS_AreaReachability(areanum)) {
548 bs->teamgoal.entitynum = client;
549 bs->teamgoal.areanum = areanum;
550 VectorCopy(entinfo.origin, bs->teamgoal.origin);
551 VectorSet(bs->teamgoal.mins, -8, -8, -8);
552 VectorSet(bs->teamgoal.maxs, 8, 8, 8);
553 }
554 }
555 //if no teamgoal yet
556 if (bs->teamgoal.entitynum < 0) {
557 //if near an item
558 if (match->subtype & ST_NEARITEM) {
559 //get the match variable
560 trap_BotMatchVariable(match, ITEM, itemname, sizeof(itemname));
561 //
562 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
563 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
564 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
565 return;
566 }
567 }
568 }
569 //
570 if (bs->teamgoal.entitynum < 0) {
571 if (other) BotAI_BotInitialChat(bs, "whereis", teammate, NULL);
572 else BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);
573 client = ClientFromName(netname);
574 trap_BotEnterChat(bs->cs, client, CHAT_TEAM);
575 return;
576 }
577 //the team mate
578 bs->teammate = client;
579 //
580 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
581 //
582 client = ClientFromName(netname);
583 //the team mate who ordered
584 bs->decisionmaker = client;
585 bs->ordered = qtrue;
586 bs->order_time = FloatTime();
587 //last time the team mate was assumed visible
588 bs->teammatevisible_time = FloatTime();
589 //set the time to send a message to the team mates
590 bs->teammessage_time = FloatTime() + 2 * random();
591 //get the team goal time
592 bs->teamgoal_time = BotGetTime(match);
593 //set the ltg type
594 if (match->type == MSG_HELP) {
595 bs->ltgtype = LTG_TEAMHELP;
596 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_HELP_TIME;
597 }
598 else {
599 bs->ltgtype = LTG_TEAMACCOMPANY;
600 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;
601 bs->formation_dist = 3.5 * 32; //3.5 meter
602 bs->arrive_time = 0;
603 //
604 BotSetTeamStatus(bs);
605 // remember last ordered task
606 BotRememberLastOrderedTask(bs);
607 }
608 #ifdef DEBUG
609 BotPrintTeamGoal(bs);
610 #endif //DEBUG
611 }
612
613 /*
614 ==================
615 BotMatch_DefendKeyArea
616 ==================
617 */
618 void BotMatch_DefendKeyArea(bot_state_t *bs, bot_match_t *match) {
619 char itemname[MAX_MESSAGE_SIZE];
620 char netname[MAX_MESSAGE_SIZE];
621 int client;
622
623 if (!TeamPlayIsOn()) return;
624 //if not addressed to this bot
625 if (!BotAddressedToBot(bs, match)) return;
626 //get the match variable
627 trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
628 //
629 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
630 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
631 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
632 return;
633 }
634 //
635 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
636 //
637 client = ClientFromName(netname);
638 //the team mate who ordered
639 bs->decisionmaker = client;
640 bs->ordered = qtrue;
641 bs->order_time = FloatTime();
642 //set the time to send a message to the team mates
643 bs->teammessage_time = FloatTime() + 2 * random();
644 //set the ltg type
645 bs->ltgtype = LTG_DEFENDKEYAREA;
646 //get the team goal time
647 bs->teamgoal_time = BotGetTime(match);
648 //set the team goal time
649 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;
650 //away from defending
651 bs->defendaway_time = 0;
652 //
653 BotSetTeamStatus(bs);
654 // remember last ordered task
655 BotRememberLastOrderedTask(bs);
656 #ifdef DEBUG
657 BotPrintTeamGoal(bs);
658 #endif //DEBUG
659 }
660
661 /*
662 ==================
663 BotMatch_TakeA
664 For Double Domination
665 ==================
666 */
667 void BotMatch_TakeA(bot_state_t *bs, bot_match_t *match) {
668 // char itemname[MAX_MESSAGE_SIZE];
669 char netname[MAX_MESSAGE_SIZE];
670 int client;
671
672 if (!TeamPlayIsOn()) return;
673 //if not addressed to this bot
674 if (!BotAddressedToBot(bs, match)) return;
675 //get the match variable
676 /*trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
677 //
678 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
679 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
680 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
681 return;
682 }*/
683 //
684 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
685 //
686 client = ClientFromName(netname);
687 //the team mate who ordered
688 bs->decisionmaker = client;
689 bs->ordered = qtrue;
690 bs->order_time = FloatTime();
691 //set the time to send a message to the team mates
692 bs->teammessage_time = FloatTime() + 2 * random();
693 //set the ltg type
694 bs->ltgtype = LTG_POINTA;
695 //get the team goal time
696 bs->teamgoal_time = BotGetTime(match);
697 //set the team goal time
698 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + DD_POINTA;
699 //away from defending
700 bs->defendaway_time = 0;
701 //
702 BotSetTeamStatus(bs);
703 // remember last ordered task
704 BotRememberLastOrderedTask(bs);
705 #ifdef DEBUG
706 BotPrintTeamGoal(bs);
707 #endif //DEBUG
708 }
709
710 /*
711 ==================
712 BotMatch_TakeB
713 For Double Domination
714 ==================
715 */
716 void BotMatch_TakeB(bot_state_t *bs, bot_match_t *match) {
717 // char itemname[MAX_MESSAGE_SIZE];
718 char netname[MAX_MESSAGE_SIZE];
719 int client;
720
721 if (!TeamPlayIsOn()) return;
722 //if not addressed to this bot
723 if (!BotAddressedToBot(bs, match)) return;
724 //get the match variable
725 /*trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
726 //
727 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
728 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
729 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
730 //return;
731 }*/
732 //
733 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
734 //
735 client = ClientFromName(netname);
736 //the team mate who ordered
737 bs->decisionmaker = client;
738 bs->ordered = qtrue;
739 bs->order_time = FloatTime();
740 //set the time to send a message to the team mates
741 bs->teammessage_time = FloatTime() + 2 * random();
742 //set the ltg type
743 bs->ltgtype = LTG_POINTB;
744 //get the team goal time
745 bs->teamgoal_time = BotGetTime(match);
746 //set the team goal time
747 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + DD_POINTA;
748 //away from defending
749 bs->defendaway_time = 0;
750 //
751 BotSetTeamStatus(bs);
752 // remember last ordered task
753 BotRememberLastOrderedTask(bs);
754 #ifdef DEBUG
755 BotPrintTeamGoal(bs);
756 #endif //DEBUG
757 }
758
759 /*
760 ==================
761 BotMatch_GetItem
762 ==================
763 */
764 void BotMatch_GetItem(bot_state_t *bs, bot_match_t *match) {
765 char itemname[MAX_MESSAGE_SIZE];
766 char netname[MAX_MESSAGE_SIZE];
767 int client;
768
769 if (!TeamPlayIsOn()) return;
770 //if not addressed to this bot
771 if (!BotAddressedToBot(bs, match)) return;
772 //get the match variable
773 trap_BotMatchVariable(match, ITEM, itemname, sizeof(itemname));
774 //
775 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
776 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
777 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
778 return;
779 }
780 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
781 client = ClientOnSameTeamFromName(bs, netname);
782 //
783 bs->decisionmaker = client;
784 bs->ordered = qtrue;
785 bs->order_time = FloatTime();
786 //set the time to send a message to the team mates
787 bs->teammessage_time = FloatTime() + 2 * random();
788 //set the ltg type
789 bs->ltgtype = LTG_GETITEM;
790 //set the team goal time
791 bs->teamgoal_time = FloatTime() + TEAM_GETITEM_TIME;
792 //
793 BotSetTeamStatus(bs);
794 #ifdef DEBUG
795 BotPrintTeamGoal(bs);
796 #endif //DEBUG
797 }
798
799 /*
800 ==================
801 BotMatch_Camp
802 ==================
803 */
804 void BotMatch_Camp(bot_state_t *bs, bot_match_t *match) {
805 int client, areanum;
806 char netname[MAX_MESSAGE_SIZE];
807 char itemname[MAX_MESSAGE_SIZE];
808 aas_entityinfo_t entinfo;
809
810 if (!TeamPlayIsOn()) return;
811 //if not addressed to this bot
812 if (!BotAddressedToBot(bs, match)) return;
813 //
814 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
815 //asked for someone else
816 client = FindClientByName(netname);
817 //if there's no valid client with this name
818 if (client < 0) {
819 BotAI_BotInitialChat(bs, "whois", netname, NULL);
820 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
821 return;
822 }
823 //get the match variable
824 trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
825 //in CTF it could be the base
826 if (match->subtype & ST_THERE) {
827 //camp at the spot the bot is currently standing
828 bs->teamgoal.entitynum = bs->entitynum;
829 bs->teamgoal.areanum = bs->areanum;
830 VectorCopy(bs->origin, bs->teamgoal.origin);
831 VectorSet(bs->teamgoal.mins, -8, -8, -8);
832 VectorSet(bs->teamgoal.maxs, 8, 8, 8);
833 }
834 else if (match->subtype & ST_HERE) {
835 //if this is the bot self
836 if (client == bs->client) return;
837 //
838 bs->teamgoal.entitynum = -1;
839 BotEntityInfo(client, &entinfo);
840 //if info is valid (in PVS)
841 if (entinfo.valid) {
842 areanum = BotPointAreaNum(entinfo.origin);
843 if (areanum) {// && trap_AAS_AreaReachability(areanum)) {
844 //NOTE: just assume the bot knows where the person is
845 //if (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, client)) {
846 bs->teamgoal.entitynum = client;
847 bs->teamgoal.areanum = areanum;
848 VectorCopy(entinfo.origin, bs->teamgoal.origin);
849 VectorSet(bs->teamgoal.mins, -8, -8, -8);
850 VectorSet(bs->teamgoal.maxs, 8, 8, 8);
851 //}
852 }
853 }
854 //if the other is not visible
855 if (bs->teamgoal.entitynum < 0) {
856 BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);
857 client = ClientFromName(netname);
858 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
859 return;
860 }
861 }
862 else if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
863 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
864 //client = ClientFromName(netname);
865 //trap_BotEnterChat(bs->cs, client, CHAT_TELL);
866 return;
867 }
868 //
869 bs->decisionmaker = client;
870 bs->ordered = qtrue;
871 bs->order_time = FloatTime();
872 //set the time to send a message to the team mates
873 bs->teammessage_time = FloatTime() + 2 * random();
874 //set the ltg type
875 bs->ltgtype = LTG_CAMPORDER;
876 //get the team goal time
877 bs->teamgoal_time = BotGetTime(match);
878 //set the team goal time
879 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_CAMP_TIME;
880 //not arrived yet
881 bs->arrive_time = 0;
882 //
883 BotSetTeamStatus(bs);
884 // remember last ordered task
885 BotRememberLastOrderedTask(bs);
886 #ifdef DEBUG
887 BotPrintTeamGoal(bs);
888 #endif //DEBUG
889 }
890
891 /*
892 ==================
893 BotMatch_Patrol
894 ==================
895 */
896 void BotMatch_Patrol(bot_state_t *bs, bot_match_t *match) {
897 char netname[MAX_MESSAGE_SIZE];
898 int client;
899
900 if (!TeamPlayIsOn()) return;
901 //if not addressed to this bot
902 if (!BotAddressedToBot(bs, match)) return;
903 //get the patrol waypoints
904 if (!BotGetPatrolWaypoints(bs, match)) return;
905 //
906 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
907 //
908 client = FindClientByName(netname);
909 //
910 bs->decisionmaker = client;
911 bs->ordered = qtrue;
912 bs->order_time = FloatTime();
913 //set the time to send a message to the team mates
914 bs->teammessage_time = FloatTime() + 2 * random();
915 //set the ltg type
916 bs->ltgtype = LTG_PATROL;
917 //get the team goal time
918 bs->teamgoal_time = BotGetTime(match);
919 //set the team goal time if not set already
920 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_PATROL_TIME;
921 //
922 BotSetTeamStatus(bs);
923 // remember last ordered task
924 BotRememberLastOrderedTask(bs);
925 #ifdef DEBUG
926 BotPrintTeamGoal(bs);
927 #endif //DEBUG
928 }
929
930 /*
931 ==================
932 BotMatch_GetFlag
933 ==================
934 */
935 void BotMatch_GetFlag(bot_state_t *bs, bot_match_t *match) {
936 char netname[MAX_MESSAGE_SIZE];
937 int client;
938
939 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
940 if (!ctf_redflag.areanum || !ctf_blueflag.areanum)
941 return;
942 }
943 else if (gametype == GT_1FCTF) {
944 if (!ctf_neutralflag.areanum || !ctf_redflag.areanum || !ctf_blueflag.areanum)
945 return;
946 }
947 else {
948 return;
949 }
950 //if not addressed to this bot
951 if (!BotAddressedToBot(bs, match)) return;
952 //
953 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
954 //
955 client = FindClientByName(netname);
956 //
957 bs->decisionmaker = client;
958 bs->ordered = qtrue;
959 bs->order_time = FloatTime();
960 //set the time to send a message to the team mates
961 bs->teammessage_time = FloatTime() + 2 * random();
962 //set the ltg type
963 bs->ltgtype = LTG_GETFLAG;
964 //set the team goal time
965 bs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;
966 // get an alternate route in ctf
967 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
968 //get an alternative route goal towards the enemy base
969 BotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));
970 }
971 //
972 BotSetTeamStatus(bs);
973 // remember last ordered task
974 BotRememberLastOrderedTask(bs);
975 #ifdef DEBUG
976 BotPrintTeamGoal(bs);
977 #endif //DEBUG
978 }
979
980 /*
981 ==================
982 BotMatch_AttackEnemyBase
983 ==================
984 */
985 void BotMatch_AttackEnemyBase(bot_state_t *bs, bot_match_t *match) {
986 char netname[MAX_MESSAGE_SIZE];
987 int client;
988
989 if (gametype == GT_CTF|| gametype == GT_CTF_ELIMINATION) {
990 BotMatch_GetFlag(bs, match);
991 }
992 else if (gametype == GT_1FCTF || gametype == GT_OBELISK || gametype == GT_HARVESTER) {
993 if (!redobelisk.areanum || !blueobelisk.areanum)
994 return;
995 }
996 else {
997 return;
998 }
999 //if not addressed to this bot
1000 if (!BotAddressedToBot(bs, match)) return;
1001 //
1002 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1003 //
1004 client = FindClientByName(netname);
1005 //
1006 bs->decisionmaker = client;
1007 bs->ordered = qtrue;
1008 bs->order_time = FloatTime();
1009 //set the time to send a message to the team mates
1010 bs->teammessage_time = FloatTime() + 2 * random();
1011 //set the ltg type
1012 bs->ltgtype = LTG_ATTACKENEMYBASE;
1013 //set the team goal time
1014 bs->teamgoal_time = FloatTime() + TEAM_ATTACKENEMYBASE_TIME;
1015 bs->attackaway_time = 0;
1016 //
1017 BotSetTeamStatus(bs);
1018 // remember last ordered task
1019 BotRememberLastOrderedTask(bs);
1020 #ifdef DEBUG
1021 BotPrintTeamGoal(bs);
1022 #endif //DEBUG
1023 }
1024
1025 /*
1026 ==================
1027 BotMatch_Harvest
1028 ==================
1029 */
1030 void BotMatch_Harvest(bot_state_t *bs, bot_match_t *match) {
1031 char netname[MAX_MESSAGE_SIZE];
1032 int client;
1033
1034 if (gametype == GT_HARVESTER) {
1035 if (!neutralobelisk.areanum || !redobelisk.areanum || !blueobelisk.areanum)
1036 return;
1037 }
1038 else {
1039 return;
1040 }
1041 //if not addressed to this bot
1042 if (!BotAddressedToBot(bs, match)) return;
1043 //
1044 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1045 //
1046 client = FindClientByName(netname);
1047 //
1048 bs->decisionmaker = client;
1049 bs->ordered = qtrue;
1050 bs->order_time = FloatTime();
1051 //set the time to send a message to the team mates
1052 bs->teammessage_time = FloatTime() + 2 * random();
1053 //set the ltg type
1054 bs->ltgtype = LTG_HARVEST;
1055 //set the team goal time
1056 bs->teamgoal_time = FloatTime() + TEAM_HARVEST_TIME;
1057 bs->harvestaway_time = 0;
1058 //
1059 BotSetTeamStatus(bs);
1060 // remember last ordered task
1061 BotRememberLastOrderedTask(bs);
1062 #ifdef DEBUG
1063 BotPrintTeamGoal(bs);
1064 #endif //DEBUG
1065 }
1066
1067 /*
1068 ==================
1069 BotMatch_RushBase
1070 ==================
1071 */
1072 void BotMatch_RushBase(bot_state_t *bs, bot_match_t *match) {
1073 char netname[MAX_MESSAGE_SIZE];
1074 int client;
1075
1076 if (gametype == GT_CTF|| gametype == GT_CTF_ELIMINATION) {
1077 if (!ctf_redflag.areanum || !ctf_blueflag.areanum)
1078 return;
1079 }
1080 else if (gametype == GT_1FCTF || gametype == GT_HARVESTER) {
1081 if (!redobelisk.areanum || !blueobelisk.areanum)
1082 return;
1083 }
1084 else {
1085 return;
1086 }
1087 //if not addressed to this bot
1088 if (!BotAddressedToBot(bs, match)) return;
1089 //
1090 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1091 //
1092 client = FindClientByName(netname);
1093 //
1094 bs->decisionmaker = client;
1095 bs->ordered = qtrue;
1096 bs->order_time = FloatTime();
1097 //set the time to send a message to the team mates
1098 bs->teammessage_time = FloatTime() + 2 * random();
1099 //set the ltg type
1100 bs->ltgtype = LTG_RUSHBASE;
1101 //set the team goal time
1102 bs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;
1103 bs->rushbaseaway_time = 0;
1104 //
1105 BotSetTeamStatus(bs);
1106 #ifdef DEBUG
1107 BotPrintTeamGoal(bs);
1108 #endif //DEBUG
1109 }
1110
1111 /*
1112 ==================
1113 BotMatch_TaskPreference
1114 ==================
1115 */
1116 void BotMatch_TaskPreference(bot_state_t *bs, bot_match_t *match) {
1117 char netname[MAX_NETNAME];
1118 char teammatename[MAX_MESSAGE_SIZE];
1119 int teammate, preference;
1120
1121 ClientName(bs->client, netname, sizeof(netname));
1122 if (Q_stricmp(netname, bs->teamleader) != 0) return;
1123
1124 trap_BotMatchVariable(match, NETNAME, teammatename, sizeof(teammatename));
1125 teammate = ClientFromName(teammatename);
1126 if (teammate < 0) return;
1127
1128 preference = BotGetTeamMateTaskPreference(bs, teammate);
1129 switch(match->subtype)
1130 {
1131 case ST_DEFENDER:
1132 {
1133 preference &= ~TEAMTP_ATTACKER;
1134 preference |= TEAMTP_DEFENDER;
1135 break;
1136 }
1137 case ST_ATTACKER:
1138 {
1139 preference &= ~TEAMTP_DEFENDER;
1140 preference |= TEAMTP_ATTACKER;
1141 break;
1142 }
1143 case ST_ROAMER:
1144 {
1145 preference &= ~(TEAMTP_ATTACKER|TEAMTP_DEFENDER);
1146 break;
1147 }
1148 }
1149 BotSetTeamMateTaskPreference(bs, teammate, preference);
1150 //
1151 EasyClientName(teammate, teammatename, sizeof(teammatename));
1152 BotAI_BotInitialChat(bs, "keepinmind", teammatename, NULL);
1153 trap_BotEnterChat(bs->cs, teammate, CHAT_TELL);
1154 BotVoiceChatOnly(bs, teammate, VOICECHAT_YES);
1155 trap_EA_Action(bs->client, ACTION_AFFIRMATIVE);
1156 }
1157
1158 /*
1159 ==================
1160 BotMatch_ReturnFlag
1161 ==================
1162 */
1163 void BotMatch_ReturnFlag(bot_state_t *bs, bot_match_t *match) {
1164 char netname[MAX_MESSAGE_SIZE];
1165 int client;
1166
1167 //if not in CTF mode
1168 if (gametype != GT_CTF && gametype != GT_CTF_ELIMINATION && gametype != GT_1FCTF)
1169 return;
1170 //if not addressed to this bot
1171 if (!BotAddressedToBot(bs, match))
1172 return;
1173 //
1174 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1175 //
1176 client = FindClientByName(netname);
1177 //
1178 bs->decisionmaker = client;
1179 bs->ordered = qtrue;
1180 bs->order_time = FloatTime();
1181 //set the time to send a message to the team mates
1182 bs->teammessage_time = FloatTime() + 2 * random();
1183 //set the ltg type
1184 bs->ltgtype = LTG_RETURNFLAG;
1185 //set the team goal time
1186 bs->teamgoal_time = FloatTime() + CTF_RETURNFLAG_TIME;
1187 bs->rushbaseaway_time = 0;
1188 //
1189 BotSetTeamStatus(bs);
1190 #ifdef DEBUG
1191 BotPrintTeamGoal(bs);
1192 #endif //DEBUG
1193 }
1194
1195 /*
1196 ==================
1197 BotMatch_JoinSubteam
1198 ==================
1199 */
1200 void BotMatch_JoinSubteam(bot_state_t *bs, bot_match_t *match) {
1201 char teammate[MAX_MESSAGE_SIZE];
1202 char netname[MAX_MESSAGE_SIZE];
1203 int client;
1204
1205 if (!TeamPlayIsOn()) return;
1206 //if not addressed to this bot
1207 if (!BotAddressedToBot(bs, match)) return;
1208 //get the sub team name
1209 trap_BotMatchVariable(match, TEAMNAME, teammate, sizeof(teammate));
1210 //set the sub team name
1211 strncpy(bs->subteam, teammate, 32);
1212 bs->subteam[31] = '\0';
1213 //
1214 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1215 BotAI_BotInitialChat(bs, "joinedteam", teammate, NULL);
1216 client = ClientFromName(netname);
1217 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1218 }
1219
1220 /*
1221 ==================
1222 BotMatch_LeaveSubteam
1223 ==================
1224 */
1225 void BotMatch_LeaveSubteam(bot_state_t *bs, bot_match_t *match) {
1226 char netname[MAX_MESSAGE_SIZE];
1227 int client;
1228
1229 if (!TeamPlayIsOn()) return;
1230 //if not addressed to this bot
1231 if (!BotAddressedToBot(bs, match)) return;
1232 //
1233 if (strlen(bs->subteam))
1234 {
1235 BotAI_BotInitialChat(bs, "leftteam", bs->subteam, NULL);
1236 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1237 client = ClientFromName(netname);
1238 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1239 } //end if
1240 strcpy(bs->subteam, "");
1241 }
1242
1243 /*
1244 ==================
1245 BotMatch_LeaveSubteam
1246 ==================
1247 */
1248 void BotMatch_WhichTeam(bot_state_t *bs, bot_match_t *match) {
1249 if (!TeamPlayIsOn()) return;
1250 //if not addressed to this bot
1251 if (!BotAddressedToBot(bs, match)) return;
1252
1253 //
1254 if (strlen(bs->subteam)) {
1255 BotAI_BotInitialChat(bs, "inteam", bs->subteam, NULL);
1256 }
1257 else {
1258 BotAI_BotInitialChat(bs, "noteam", NULL);
1259 }
1260 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
1261 }
1262
1263 /*
1264 ==================
1265 BotMatch_CheckPoint
1266 ==================
1267 */
1268 void BotMatch_CheckPoint(bot_state_t *bs, bot_match_t *match) {
1269 int areanum, client;
1270 char buf[MAX_MESSAGE_SIZE];
1271 char netname[MAX_MESSAGE_SIZE];
1272 vec3_t position;
1273 bot_waypoint_t *cp;
1274
1275 if (!TeamPlayIsOn()) return;
1276 //
1277 trap_BotMatchVariable(match, POSITION, buf, MAX_MESSAGE_SIZE);
1278 VectorClear(position);
1279 //
1280 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1281 client = ClientFromName(netname);
1282 //BotGPSToPosition(buf, position);
1283 sscanf(buf, "%f %f %f", &position[0], &position[1], &position[2]);
1284 position[2] += 0.5;
1285 areanum = BotPointAreaNum(position);
1286 if (!areanum) {
1287 if (BotAddressedToBot(bs, match)) {
1288 BotAI_BotInitialChat(bs, "checkpoint_invalid", NULL);
1289 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1290 }
1291 return;
1292 }
1293 //
1294 trap_BotMatchVariable(match, NAME, buf, MAX_MESSAGE_SIZE);
1295 //check if there already exists a checkpoint with this name
1296 cp = BotFindWayPoint(bs->checkpoints, buf);
1297 if (cp) {
1298 if (cp->next) cp->next->prev = cp->prev;
1299 if (cp->prev) cp->prev->next = cp->next;
1300 else bs->checkpoints = cp->next;
1301 cp->inuse = qfalse;
1302 }
1303 //create a new check point
1304 cp = BotCreateWayPoint(buf, position, areanum);
1305 //add the check point to the bot's known chech points
1306 cp->next = bs->checkpoints;
1307 if (bs->checkpoints) bs->checkpoints->prev = cp;
1308 bs->checkpoints = cp;
1309 //
1310 if (BotAddressedToBot(bs, match)) {
1311 Com_sprintf(buf, sizeof(buf), "%1.0f %1.0f %1.0f", cp->goal.origin[0],
1312 cp->goal.origin[1],
1313 cp->goal.origin[2]);
1314
1315 BotAI_BotInitialChat(bs, "checkpoint_confirm", cp->name, buf, NULL);
1316 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1317 }
1318 }
1319
1320 /*
1321 ==================
1322 BotMatch_FormationSpace
1323 ==================
1324 */
1325 void BotMatch_FormationSpace(bot_state_t *bs, bot_match_t *match) {
1326 char buf[MAX_MESSAGE_SIZE];
1327 float space;
1328
1329 if (!TeamPlayIsOn()) return;
1330 //if not addressed to this bot
1331 if (!BotAddressedToBot(bs, match)) return;
1332 //
1333 trap_BotMatchVariable(match, NUMBER, buf, MAX_MESSAGE_SIZE);
1334 //if it's the distance in feet
1335 if (match->subtype & ST_FEET) space = 0.3048 * 32 * atof(buf);
1336 //else it's in meters
1337 else space = 32 * atof(buf);
1338 //check if the formation intervening space is valid
1339 if (space < 48 || space > 500) space = 100;
1340 bs->formation_dist = space;
1341 }
1342
1343 /*
1344 ==================
1345 BotMatch_Dismiss
1346 ==================
1347 */
1348 void BotMatch_Dismiss(bot_state_t *bs, bot_match_t *match) {
1349 char netname[MAX_MESSAGE_SIZE];
1350 int client;
1351
1352 if (!TeamPlayIsOn()) return;
1353 //if not addressed to this bot
1354 if (!BotAddressedToBot(bs, match)) return;
1355 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1356 client = ClientFromName(netname);
1357 //
1358 bs->decisionmaker = client;
1359 //
1360 bs->ltgtype = 0;
1361 bs->lead_time = 0;
1362 bs->lastgoal_ltgtype = 0;
1363 //
1364 BotAI_BotInitialChat(bs, "dismissed", NULL);
1365 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1366 }
1367
1368 /*
1369 ==================
1370 BotMatch_Suicide
1371 ==================
1372 */
1373 void BotMatch_Suicide(bot_state_t *bs, bot_match_t *match) {
1374 char netname[MAX_MESSAGE_SIZE];
1375 int client;
1376
1377 if (!TeamPlayIsOn()) return;
1378 //if not addressed to this bot
1379 if (!BotAddressedToBot(bs, match)) return;
1380 //
1381 trap_EA_Command(bs->client, "kill");
1382 //
1383 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1384 client = ClientFromName(netname);
1385 //
1386 BotVoiceChat(bs, client, VOICECHAT_TAUNT);
1387 trap_EA_Action(bs->client, ACTION_AFFIRMATIVE);
1388 }
1389
1390 /*
1391 ==================
1392 BotMatch_StartTeamLeaderShip
1393 ==================
1394 */
1395 void BotMatch_StartTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
1396 int client;
1397 char teammate[MAX_MESSAGE_SIZE];
1398
1399 if (!TeamPlayIsOn()) return;
1400 //if chats for him or herself
1401 if (match->subtype & ST_I) {
1402 //get the team mate that will be the team leader
1403 trap_BotMatchVariable(match, NETNAME, teammate, sizeof(teammate));
1404 strncpy(bs->teamleader, teammate, sizeof(bs->teamleader));
1405 bs->teamleader[sizeof(bs->teamleader)-1] = '\0';
1406 }
1407 //chats for someone else
1408 else {
1409 //get the team mate that will be the team leader
1410 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
1411 client = FindClientByName(teammate);
1412 if (client >= 0) ClientName(client, bs->teamleader, sizeof(bs->teamleader));
1413 }
1414 }
1415
1416 /*
1417 ==================
1418 BotMatch_StopTeamLeaderShip
1419 ==================
1420 */
1421 void BotMatch_StopTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
1422 int client;
1423 char teammate[MAX_MESSAGE_SIZE];
1424 char netname[MAX_MESSAGE_SIZE];
1425
1426 if (!TeamPlayIsOn()) return;
1427 //get the team mate that stops being the team leader
1428 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
1429 //if chats for him or herself
1430 if (match->subtype & ST_I) {
1431 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1432 client = FindClientByName(netname);
1433 }
1434 //chats for someone else
1435 else {
1436 client = FindClientByName(teammate);
1437 } //end else
1438 if (client >= 0) {
1439 if (!Q_stricmp(bs->teamleader, ClientName(client, netname, sizeof(netname)))) {
1440 bs->teamleader[0] = '\0';
1441 notleader[client] = qtrue;
1442 }
1443 }
1444 }
1445
1446 /*
1447 ==================
1448 BotMatch_WhoIsTeamLeader
1449 ==================
1450 */
1451 void BotMatch_WhoIsTeamLeader(bot_state_t *bs, bot_match_t *match) {
1452 char netname[MAX_MESSAGE_SIZE];
1453
1454 if (!TeamPlayIsOn()) return;
1455
1456 ClientName(bs->client, netname, sizeof(netname));
1457 //if this bot IS the team leader
1458 if (!Q_stricmp(netname, bs->teamleader)) {
1459 trap_EA_SayTeam(bs->client, "I'm the team leader\n");
1460 }
1461 }
1462
1463 /*
1464 ==================
1465 BotMatch_WhatAreYouDoing
1466 ==================
1467 */
1468 void BotMatch_WhatAreYouDoing(bot_state_t *bs, bot_match_t *match) {
1469 char netname[MAX_MESSAGE_SIZE];
1470 char goalname[MAX_MESSAGE_SIZE];
1471 int client;
1472
1473 //if not addressed to this bot
1474 if (!BotAddressedToBot(bs, match)) return;
1475 //
1476 switch(bs->ltgtype) {
1477 case LTG_TEAMHELP:
1478 {
1479 EasyClientName(bs->teammate, netname, sizeof(netname));
1480 BotAI_BotInitialChat(bs, "helping", netname, NULL);
1481 break;
1482 }
1483 case LTG_TEAMACCOMPANY:
1484 {
1485 EasyClientName(bs->teammate, netname, sizeof(netname));
1486 BotAI_BotInitialChat(bs, "accompanying", netname, NULL);
1487 break;
1488 }
1489 case LTG_DEFENDKEYAREA:
1490 {
1491 trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
1492 BotAI_BotInitialChat(bs, "defending", goalname, NULL);
1493 break;
1494 }
1495 case LTG_GETITEM:
1496 {
1497 trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
1498 BotAI_BotInitialChat(bs, "gettingitem", goalname, NULL);
1499 break;
1500 }
1501 case LTG_KILL:
1502 {
1503 ClientName(bs->teamgoal.entitynum, netname, sizeof(netname));
1504 BotAI_BotInitialChat(bs, "killing", netname, NULL);
1505 break;
1506 }
1507 case LTG_CAMP:
1508 case LTG_CAMPORDER:
1509 {
1510 BotAI_BotInitialChat(bs, "camping", NULL);
1511 break;
1512 }
1513 case LTG_PATROL:
1514 {
1515 BotAI_BotInitialChat(bs, "patrolling", NULL);
1516 break;
1517 }
1518 case LTG_GETFLAG:
1519 {
1520 BotAI_BotInitialChat(bs, "capturingflag", NULL);
1521 break;
1522 }
1523 case LTG_RUSHBASE:
1524 {
1525 BotAI_BotInitialChat(bs, "rushingbase", NULL);
1526 break;
1527 }
1528 case LTG_RETURNFLAG:
1529 {
1530 BotAI_BotInitialChat(bs, "returningflag", NULL);
1531 break;
1532 }
1533 case LTG_ATTACKENEMYBASE:
1534 {
1535 BotAI_BotInitialChat(bs, "attackingenemybase", NULL);
1536 break;
1537 }
1538 case LTG_HARVEST:
1539 {
1540 BotAI_BotInitialChat(bs, "harvesting", NULL);
1541 break;
1542 }
1543 //#endif
1544 case LTG_POINTA:
1545 {
1546 BotAI_BotInitialChat(bs, "dd_pointa", NULL);
1547 break;
1548 }
1549 case LTG_POINTB:
1550 {
1551 BotAI_BotInitialChat(bs, "dd_pointb", NULL);
1552 break;
1553 }
1554 default:
1555 {
1556 BotAI_BotInitialChat(bs, "roaming", NULL);
1557 break;
1558 }
1559 }
1560 //chat what the bot is doing
1561 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1562 client = ClientFromName(netname);
1563 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1564 }
1565
1566 /*
1567 ==================
1568 BotMatch_WhatIsMyCommand
1569 ==================
1570 */
1571 void BotMatch_WhatIsMyCommand(bot_state_t *bs, bot_match_t *match) {
1572 char netname[MAX_NETNAME];
1573
1574 ClientName(bs->client, netname, sizeof(netname));
1575 if (Q_stricmp(netname, bs->teamleader) != 0) return;
1576 bs->forceorders = qtrue;
1577 }
1578
1579 /*
1580 ==================
1581 BotNearestVisibleItem
1582 ==================
1583 */
1584 float BotNearestVisibleItem(bot_state_t *bs, char *itemname, bot_goal_t *goal) {
1585 int i;
1586 char name[64];
1587 bot_goal_t tmpgoal;
1588 float dist, bestdist;
1589 vec3_t dir;
1590 bsp_trace_t trace;
1591
1592 bestdist = 999999;
1593 i = -1;
1594 do {
1595 i = trap_BotGetLevelItemGoal(i, itemname, &tmpgoal);
1596 trap_BotGoalName(tmpgoal.number, name, sizeof(name));
1597 if (Q_stricmp(itemname, name) != 0)
1598 continue;
1599 VectorSubtract(tmpgoal.origin, bs->origin, dir);
1600 dist = VectorLength(dir);
1601 if (dist < bestdist) {
1602 //trace from start to end
1603 BotAI_Trace(&trace, bs->eye, NULL, NULL, tmpgoal.origin, bs->client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
1604 if (trace.fraction >= 1.0) {
1605 bestdist = dist;
1606 memcpy(goal, &tmpgoal, sizeof(bot_goal_t));
1607 }
1608 }
1609 } while(i > 0);
1610 return bestdist;
1611 }
1612
1613 /*
1614 ==================
1615 BotMatch_WhereAreYou
1616 ==================
1617 */
1618 void BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) {
1619 float dist, bestdist;
1620 int i, bestitem, redtt, bluett, client;
1621 bot_goal_t goal;
1622 char netname[MAX_MESSAGE_SIZE];
1623 char *nearbyitems[] = {
1624 "Shotgun",
1625 "Grenade Launcher",
1626 "Rocket Launcher",
1627 "Plasmagun",
1628 "Railgun",
1629 "Lightning Gun",
1630 "BFG10K",
1631 "Quad Damage",
1632 "Regeneration",
1633 "Battle Suit",
1634 "Speed",
1635 "Invisibility",
1636 "Flight",
1637 "Armor",
1638 "Heavy Armor",
1639 "Red Flag",
1640 "Blue Flag",
1641 "Nailgun",
1642 "Prox Launcher",
1643 "Chaingun",
1644 "Scout",
1645 "Guard",
1646 "Doubler",
1647 "Ammo Regen",
1648 "Neutral Flag",
1649 "Red Obelisk",
1650 "Blue Obelisk",
1651 "Neutral Obelisk",
1652 NULL
1653 };
1654 //
1655 if (!TeamPlayIsOn())
1656 return;
1657
1658 //if not addressed to this bot
1659 if (!BotAddressedToBot(bs, match))
1660 return;
1661
1662 bestitem = -1;
1663 bestdist = 999999;
1664 for (i = 0; nearbyitems[i]; i++) {
1665 dist = BotNearestVisibleItem(bs, nearbyitems[i], &goal);
1666 if (dist < bestdist) {
1667 bestdist = dist;
1668 bestitem = i;
1669 }
1670 }
1671 if (bestitem != -1) {
1672 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION
1673 || gametype == GT_1FCTF
1674 ) {
1675 redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_redflag.areanum, TFL_DEFAULT);
1676 bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_blueflag.areanum, TFL_DEFAULT);
1677 if (redtt < (redtt + bluett) * 0.4) {
1678 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "red", NULL);
1679 }
1680 else if (bluett < (redtt + bluett) * 0.4) {
1681 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "blue", NULL);
1682 }
1683 else {
1684 BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL);
1685 }
1686 }
1687 else if (gametype == GT_OBELISK || gametype == GT_HARVESTER) {
1688 redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, redobelisk.areanum, TFL_DEFAULT);
1689 bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, blueobelisk.areanum, TFL_DEFAULT);
1690 if (redtt < (redtt + bluett) * 0.4) {
1691 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "red", NULL);
1692 }
1693 else if (bluett < (redtt + bluett) * 0.4) {
1694 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "blue", NULL);
1695 }
1696 else {
1697 BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL);
1698 }
1699 }
1700 else {
1701 BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL);
1702 }
1703 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1704 client = ClientFromName(netname);
1705 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1706 }
1707 }
1708
1709 /*
1710 ==================
1711 BotMatch_LeadTheWay
1712 ==================
1713 */
1714 void BotMatch_LeadTheWay(bot_state_t *bs, bot_match_t *match) {
1715 aas_entityinfo_t entinfo;
1716 char netname[MAX_MESSAGE_SIZE], teammate[MAX_MESSAGE_SIZE];
1717 int client, areanum, other;
1718
1719 if (!TeamPlayIsOn()) return;
1720 //if not addressed to this bot
1721 if (!BotAddressedToBot(bs, match)) return;
1722 //if someone asks for someone else
1723 if (match->subtype & ST_SOMEONE) {
1724 //get the team mate name
1725 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
1726 client = FindClientByName(teammate);
1727 //if this is the bot self
1728 if (client == bs->client) {
1729 other = qfalse;
1730 }
1731 else if (!BotSameTeam(bs, client)) {
1732 //FIXME: say "I don't help the enemy"
1733 return;
1734 }
1735 else {
1736 other = qtrue;
1737 }
1738 }
1739 else {
1740 //get the netname
1741 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1742 client = ClientFromName(netname);
1743 other = qfalse;
1744 }
1745 //if the bot doesn't know who to help (FindClientByName returned -1)
1746 if (client < 0) {
1747 BotAI_BotInitialChat(bs, "whois", netname, NULL);
1748 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
1749 return;
1750 }
1751 //
1752 bs->lead_teamgoal.entitynum = -1;
1753 BotEntityInfo(client, &entinfo);
1754 //if info is valid (in PVS)
1755 if (entinfo.valid) {
1756 areanum = BotPointAreaNum(entinfo.origin);
1757 if (areanum) { // && trap_AAS_AreaReachability(areanum)) {
1758 bs->lead_teamgoal.entitynum = client;
1759 bs->lead_teamgoal.areanum = areanum;
1760 VectorCopy(entinfo.origin, bs->lead_teamgoal.origin);
1761 VectorSet(bs->lead_teamgoal.mins, -8, -8, -8);
1762 VectorSet(bs->lead_teamgoal.maxs, 8, 8, 8);
1763 }
1764 }
1765
1766 if (bs->teamgoal.entitynum < 0) {
1767 if (other) BotAI_BotInitialChat(bs, "whereis", teammate, NULL);
1768 else BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);
1769 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
1770 return;
1771 }
1772 bs->lead_teammate = client;
1773 bs->lead_time = FloatTime() + TEAM_LEAD_TIME;
1774 bs->leadvisible_time = 0;
1775 bs->leadmessage_time = -(FloatTime() + 2 * random());
1776 }
1777
1778 /*
1779 ==================
1780 BotMatch_Kill
1781 ==================
1782 */
1783 void BotMatch_Kill(bot_state_t *bs, bot_match_t *match) {
1784 char enemy[MAX_MESSAGE_SIZE];
1785 char netname[MAX_MESSAGE_SIZE];
1786 int client;
1787
1788 if (!TeamPlayIsOn()) return;
1789 //if not addressed to this bot
1790 if (!BotAddressedToBot(bs, match)) return;
1791
1792 trap_BotMatchVariable(match, ENEMY, enemy, sizeof(enemy));
1793 //
1794 client = FindEnemyByName(bs, enemy);
1795 if (client < 0) {
1796 BotAI_BotInitialChat(bs, "whois", enemy, NULL);
1797 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1798 client = ClientFromName(netname);
1799 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1800 return;
1801 }
1802 bs->teamgoal.entitynum = client;
1803 //set the time to send a message to the team mates
1804 bs->teammessage_time = FloatTime() + 2 * random();
1805 //set the ltg type
1806 bs->ltgtype = LTG_KILL;
1807 //set the team goal time
1808 bs->teamgoal_time = FloatTime() + TEAM_KILL_SOMEONE;
1809 //
1810 BotSetTeamStatus(bs);
1811 #ifdef DEBUG
1812 BotPrintTeamGoal(bs);
1813 #endif //DEBUG
1814 }
1815
1816 /*
1817 ==================
1818 BotMatch_CTF
1819 ==================
1820 */
1821 void BotMatch_CTF(bot_state_t *bs, bot_match_t *match) {
1822
1823 char flag[128], netname[MAX_NETNAME];
1824
1825 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
1826 trap_BotMatchVariable(match, FLAG, flag, sizeof(flag));
1827 if (match->subtype & ST_GOTFLAG) {
1828 if (!Q_stricmp(flag, "red")) {
1829 bs->redflagstatus = 1;
1830 if (BotTeam(bs) == TEAM_BLUE) {
1831 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1832 bs->flagcarrier = ClientFromName(netname);
1833 }
1834 }
1835 else {
1836 bs->blueflagstatus = 1;
1837 if (BotTeam(bs) == TEAM_RED) {
1838 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1839 bs->flagcarrier = ClientFromName(netname);
1840 }
1841 }
1842 bs->flagstatuschanged = 1;
1843 bs->lastflagcapture_time = FloatTime();
1844 }
1845 else if (match->subtype & ST_CAPTUREDFLAG) {
1846 bs->redflagstatus = 0;
1847 bs->blueflagstatus = 0;
1848 bs->flagcarrier = 0;
1849 bs->flagstatuschanged = 1;
1850 }
1851 else if (match->subtype & ST_RETURNEDFLAG) {
1852 if (!Q_stricmp(flag, "red")) bs->redflagstatus = 0;
1853 else bs->blueflagstatus = 0;
1854 bs->flagstatuschanged = 1;
1855 }
1856 }
1857 else if (gametype == GT_1FCTF) {
1858 if (match->subtype & ST_1FCTFGOTFLAG) {
1859 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1860 bs->flagcarrier = ClientFromName(netname);
1861 }
1862 }
1863 }
1864
1865 void BotMatch_EnterGame(bot_state_t *bs, bot_match_t *match) {
1866 int client;
1867 char netname[MAX_NETNAME];
1868
1869 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1870 client = FindClientByName(netname);
1871 if (client >= 0) {
1872 notleader[client] = qfalse;
1873 }
1874 //NOTE: eliza chats will catch this
1875 //Com_sprintf(buf, sizeof(buf), "heya %s", netname);
1876 //EA_Say(bs->client, buf);
1877 }
1878
1879 void BotMatch_NewLeader(bot_state_t *bs, bot_match_t *match) {
1880 int client;
1881 char netname[MAX_NETNAME];
1882
1883 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1884 client = FindClientByName(netname);
1885 if (!BotSameTeam(bs, client))
1886 return;
1887 Q_strncpyz(bs->teamleader, netname, sizeof(bs->teamleader));
1888 }
1889
1890 /*
1891 ==================
1892 BotMatchMessage
1893 ==================
1894 */
1895 int BotMatchMessage(bot_state_t *bs, char *message) {
1896 bot_match_t match;
1897
1898 match.type = 0;
1899 //if it is an unknown message
1900 if (!trap_BotFindMatch(message, &match, MTCONTEXT_MISC
1901 |MTCONTEXT_INITIALTEAMCHAT
1902 |MTCONTEXT_CTF
1903 |MTCONTEXT_DD)) {
1904 return qfalse;
1905 }
1906 //react to the found message
1907 switch(match.type)
1908 {
1909 case MSG_HELP: //someone calling for help
1910 case MSG_ACCOMPANY: //someone calling for company
1911 {
1912 BotMatch_HelpAccompany(bs, &match);
1913 break;
1914 }
1915 case MSG_DEFENDKEYAREA: //teamplay defend a key area
1916 {
1917 BotMatch_DefendKeyArea(bs, &match);
1918 break;
1919 }
1920 case MSG_CAMP: //camp somewhere
1921 {
1922 BotMatch_Camp(bs, &match);
1923 break;
1924 }
1925 case MSG_PATROL: //patrol between several key areas
1926 {
1927 BotMatch_Patrol(bs, &match);
1928 break;
1929 }
1930 //CTF & 1FCTF
1931 case MSG_GETFLAG: //ctf get the enemy flag
1932 {
1933 BotMatch_GetFlag(bs, &match);
1934 break;
1935 }
1936 //CTF & 1FCTF & Obelisk & Harvester
1937 case MSG_ATTACKENEMYBASE:
1938 {
1939 BotMatch_AttackEnemyBase(bs, &match);
1940 break;
1941 }
1942 //Harvester
1943 case MSG_HARVEST:
1944 {
1945 BotMatch_Harvest(bs, &match);
1946 break;
1947 }
1948 //CTF & 1FCTF & Harvester
1949 case MSG_RUSHBASE: //ctf rush to the base
1950 {
1951 BotMatch_RushBase(bs, &match);
1952 break;
1953 }
1954 //CTF & 1FCTF
1955 case MSG_RETURNFLAG:
1956 {
1957 BotMatch_ReturnFlag(bs, &match);
1958 break;
1959 }
1960 //CTF & 1FCTF & Obelisk & Harvester
1961 case MSG_TASKPREFERENCE:
1962 {
1963 BotMatch_TaskPreference(bs, &match);
1964 break;
1965 }
1966 //CTF & 1FCTF
1967 case MSG_CTF:
1968 {
1969 BotMatch_CTF(bs, &match);
1970 break;
1971 }
1972 case MSG_GETITEM:
1973 {
1974 BotMatch_GetItem(bs, &match);
1975 break;
1976 }
1977 case MSG_JOINSUBTEAM: //join a sub team
1978 {
1979 BotMatch_JoinSubteam(bs, &match);
1980 break;
1981 }
1982 case MSG_LEAVESUBTEAM: //leave a sub team
1983 {
1984 BotMatch_LeaveSubteam(bs, &match);
1985 break;
1986 }
1987 case MSG_WHICHTEAM:
1988 {
1989 BotMatch_WhichTeam(bs, &match);
1990 break;
1991 }
1992 case MSG_CHECKPOINT: //remember a check point
1993 {
1994 BotMatch_CheckPoint(bs, &match);
1995 break;
1996 }
1997 case MSG_CREATENEWFORMATION: //start the creation of a new formation
1998 {
1999 trap_EA_SayTeam(bs->client, "the part of my brain to create formations has been damaged");
2000 break;
2001 }
2002 case MSG_FORMATIONPOSITION: //tell someone his/her position in the formation
2003 {
2004 trap_EA_SayTeam(bs->client, "the part of my brain to create formations has been damaged");
2005 break;
2006 }
2007 case MSG_FORMATIONSPACE: //set the formation space
2008 {
2009 BotMatch_FormationSpace(bs, &match);
2010 break;
2011 }
2012 case MSG_DOFORMATION: //form a certain formation
2013 {
2014 break;
2015 }
2016 case MSG_DISMISS: //dismiss someone
2017 {
2018 BotMatch_Dismiss(bs, &match);
2019 break;
2020 }
2021 case MSG_STARTTEAMLEADERSHIP: //someone will become the team leader
2022 {
2023 BotMatch_StartTeamLeaderShip(bs, &match);
2024 break;
2025 }
2026 case MSG_STOPTEAMLEADERSHIP: //someone will stop being the team leader
2027 {
2028 BotMatch_StopTeamLeaderShip(bs, &match);
2029 break;
2030 }
2031 case MSG_WHOISTEAMLAEDER:
2032 {
2033 BotMatch_WhoIsTeamLeader(bs, &match);
2034 break;
2035 }
2036 case MSG_WHATAREYOUDOING: //ask a bot what he/she is doing
2037 {
2038 BotMatch_WhatAreYouDoing(bs, &match);
2039 break;
2040 }
2041 case MSG_WHATISMYCOMMAND:
2042 {
2043 BotMatch_WhatIsMyCommand(bs, &match);
2044 break;
2045 }
2046 case MSG_WHEREAREYOU:
2047 {
2048 BotMatch_WhereAreYou(bs, &match);
2049 break;
2050 }
2051 case MSG_LEADTHEWAY:
2052 {
2053 BotMatch_LeadTheWay(bs, &match);
2054 break;
2055 }
2056 case MSG_KILL:
2057 {
2058 BotMatch_Kill(bs, &match);
2059 break;
2060 }
2061 case MSG_ENTERGAME: //someone entered the game
2062 {
2063 BotMatch_EnterGame(bs, &match);
2064 break;
2065 }
2066 case MSG_NEWLEADER:
2067 {
2068 BotMatch_NewLeader(bs, &match);
2069 break;
2070 }
2071 case MSG_WAIT:
2072 {
2073 break;
2074 }
2075 case MSG_SUICIDE:
2076 {
2077 BotMatch_Suicide(bs, &match);
2078 break;
2079 }
2080 case MSG_TAKEA:
2081 {
2082 BotMatch_TakeA(bs, &match);
2083 break;
2084 }
2085 case MSG_TAKEB:
2086 {
2087 BotMatch_TakeB(bs, &match);
2088 break;
2089 }
2090 default:
2091 {
2092 BotAI_Print(PRT_MESSAGE, "unknown match type\n");
2093 break;
2094 }
2095 }
2096 return qtrue;
2097 }